Shop OBEX P1 Docs P2 Docs Learn Events
using a gyroscope with a BS2 — Parallax Forums

using a gyroscope with a BS2

atstew01atstew01 Posts: 6
edited 2009-04-13 14:36 in Accessories
I am trying to synchronize a Melexis MLX90609 gyroscope with a BS2. I found code in the forums that claim to have made this product work. I implemented this code this code exactly and it did not work despite all attempts by me and my professors. I contacted the manufacturer and they said that the data exchange between the stamp and the gyro, had to occur in parallel and that using the SHIFTIN and SHIFTOUT commands did this data exchange in series. They suggested that using some of the very basic commands in PBASIC, directly controlling the ports, I may be able to accomplish this parallel communication. I was wondering if anyone had any ideas to do this or knew of any other commands i could use to accomplish this.

Thanks for your help!



this is the code that I am currently using and does not work:

' {$STAMP BS2}
' {$PBASIC 2.5}

'this is a program designed to test the gyroscope and display its output

'---pin layout----
'pin 5 is orange is MOSI
'pin 6 is blue is MISO
'pin 7 is green is SS
'pin 8 is yellow is SCLK

'---Constants---
MOSI CON 5
MISO CON 6
SS CON 7
SCLK CON 8

'---Variables----
answer VAR Word

'----Program----

DO

HIGH SS
LOW SS
SHIFTOUT MOSI,SCLK,MSBFIRST,[noparse][[/noparse]%10010100\8] 'start ADC and set channel to 0 (GYRO CHANNEL)
HIGH SS
LOW SS
SHIFTOUT MOSI,SCLK,MSBFIRST,[noparse][[/noparse]%10000000\8] 'poll for reading
SHIFTIN MISO,SCLK,MSBPRE,[noparse][[/noparse]answer\16] 'save the answer in a variable
HIGH SS
answer=answer & %0000111111111110 'mask answer to extract data from ADC, we don't need the first 4 digits or the last onr (from left to right)
answer=answer >> 1 'shift the answer so that we dont display the LSB which is not part of the answer
DEBUG HOME,"Omega = ",DEC answer,11 'Display answer

LOOP
Sign In or Register to comment.