The BS2 and the BS2sx with the V2X compass module from PNI...
deno
Posts: 242
Hello, again to fellow Stampers...
I have got an interesting problem, that has developed by switching a BS2 stamp for a BS2sx stamp to increase the programming speed of my satellite tracker.· I have been using the V2X compass module for years now with the BS2 with very good results.· However, I wanted to improve preformance with the SX.· In other words, faster azmuth correction speed of the dish as the boat drifts around on its anchor.
I have changed the BAUD to match the SX, and changed the timing issues associated with SHIFTIN command.· Now for the tricky part of explaning the problem.· The V2X outputs to the stamp a 16 bit word of which only 9 bits are used to give an azmuth reading of 0 degrees to 359 degrees.
With the SX stamp only, when the output (using· DEBUG and also·a LCD on the sat tracker) reaches 255 degrees, (which is 8 bits), the output from the SX jumps to 10 bits because the 10th bit is a 1, bypassing the 9th bit all together.· It only takes 9 bits of data to generate a number to 359. The other 7 bits of data of the 16 bit word are supposed to be 0. What this means is all readings above 255 degrees are 512 (degrees) to high.· So I had to program in an:··· IF rawHeading > 255 THEN
································································· ··rawHeading = rawHeading - 512
·································································ENDIF
This addition of code makes the sat tracker work just fine...
So the 64 dollar question is...why does the regular old BS2 work without the IF..THEN and the SX has to have the IF..THEN in place to output a azmuth heading from 0 degrees to 359 degrees.
Any thoughts on this..
Deno
I have got an interesting problem, that has developed by switching a BS2 stamp for a BS2sx stamp to increase the programming speed of my satellite tracker.· I have been using the V2X compass module for years now with the BS2 with very good results.· However, I wanted to improve preformance with the SX.· In other words, faster azmuth correction speed of the dish as the boat drifts around on its anchor.
I have changed the BAUD to match the SX, and changed the timing issues associated with SHIFTIN command.· Now for the tricky part of explaning the problem.· The V2X outputs to the stamp a 16 bit word of which only 9 bits are used to give an azmuth reading of 0 degrees to 359 degrees.
With the SX stamp only, when the output (using· DEBUG and also·a LCD on the sat tracker) reaches 255 degrees, (which is 8 bits), the output from the SX jumps to 10 bits because the 10th bit is a 1, bypassing the 9th bit all together.· It only takes 9 bits of data to generate a number to 359. The other 7 bits of data of the 16 bit word are supposed to be 0. What this means is all readings above 255 degrees are 512 (degrees) to high.· So I had to program in an:··· IF rawHeading > 255 THEN
································································· ··rawHeading = rawHeading - 512
·································································ENDIF
This addition of code makes the sat tracker work just fine...
So the 64 dollar question is...why does the regular old BS2 work without the IF..THEN and the SX has to have the IF..THEN in place to output a azmuth heading from 0 degrees to 359 degrees.
Any thoughts on this..
Deno
Comments
As we frequently suggest, posting your code (if possible) is always the best way to get help -- sometimes we're all too close to our own code to see problems that others might detect easily.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I slave mode, SCLK is an input, and data must be read from the V2X when SCLK is high (data is valid on the rising edge of SCLK). The maximum rate for clocking out data is 1 Mhz. There is no minimum time that the data is valid, so you can wait as long as you want before it is polled again (unless it is RESET before the next time it is polled again).
In slave mode, the V2X must receive 16 falling and 16 rising edges of the clock (to clock out the data before it is polled again (unless it is RESET before the next time it is polled again).
OK..now here is the code I have used successfully for a long time using the BS2. This is the SUB ROUTINE that I call for a compass heading:
'===V2X COMPASS ROUTINE__BS2_stamp=====================
V2Xcompass:
OUT8 = 1 'P/C...must be logic hi for V2X to start calculations
OUT10 = 1 'SS ...must be logic hi for V2x to start calculations
PULSOUT 8, 2000 'pulse P/C low for 4 msec...BS2
hold_1:
IF IN9 = 0 THEN hold_1 'EOC waits until calculation is finished
PAUSE 2 'wait 2 msec
OUT10 = 0 'SS
'starting the CLOCK pin(OUT14) high seems to produce the full 16 pulses that are required by the V2X...
OUT14 = 1 'added 15may04 'start clock pin at high level
PAUSE 2 'wait 2 msec
SHIFTIN 15, 14, MSBPRE, [noparse][[/noparse]rawHeading_1\16] 'msbpre
OUT10 = 1 'SS
RETURN
'I get a good heading every itineration with the above code.
'===V2X COMPASS ROUTINE__BS2SX=====================
V2Xcompass:
OUT8 = 1 'P/C...must be logic hi for V2X to start calculations
OUT10 = 1 'SS ...must be logic hi for V2x to start calculations
PULSOUT 8, 8000 'pulse P/C low for 6.4 msec...BS2sx
hold_1:
IF IN9 = 0 THEN hold_1 'EOC waits until calculation is finished
PAUSE 2 'wait 2 msec
OUT10 = 0 'SS
'starting the CLOCK PIN high OUT14) as above in the BS2 code...
OUT14 = 1 'added 15may04 'start clock pin at high level
PAUSE 2 'wait 2 msec
SHIFTIN 15, 14, MSBPRE, [noparse][[/noparse]rawHeading_1\17] 'msbpre
'now I have to change the number of bits to shift in to 17, 16 won't work.
OUT10 = 1 'SS
IF rawheading_1 > 255 THEN 'for some reason...Transistion form an 8 bit number (255)
rawheading_1 = rawHeading_1 - 512 '>to a 9 bit number (256 to 359) doesn't work with the
ENDIF '>BS2sx. The rawheading binary output jumps to a 10 bit
'>number (larger then 359). So a subtraction of 2^9 or
'> 512 is necessary to keep the compass heading between
'>0 degrees and 359 degrees. The bs2 doesn't do this.
RETURN
The more I play around with this, I think the BS2SX is just to fast for the V2X compass module. What do you think?
Deno
If you can point me to the data sheet I will write a subroutine for you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Deno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
http://www.robotics.com/arobot/vector.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I tried to get the complete web address for the the V2X compass module data sheet (small book), but my internet services provider seems to be playing around with my very slow dial up connection, anyway, the web site address is www.precisionnav.com and please don't confuse there new compass module (V2Xe) with the one I am using (V2X).
And, thanks for the tip on using the POST REPLY box instead of this QUICK REPLY box.
Deno
The V2X data sheet I have states that the minimum pulse width for the P/C low pulse should be 10 milliseconds (You have 4 ms on your BS2 and 6.4ms on your BS2sx). Also, the pause from EOC high to SS\ low should also be 10 milliseconds minimum (You have 2 ms). It may be that a 10ms pause is also required between SS\ low and the first clocking of the SHIFTOUT command. You have 2ms there. I don't know why the V2x needs those extra delays, or how making them longer could resolve the problem you have in going to the faster BS2sx.
The SHIFTIN command should only have to shift 16 bits, but your program is shifting 17. The data sheet is not too clear, but it looks like the V2x outputs its first data bit _after_ the first clock pulse, so the appropriate command would be,
SHIFTIN 15, 14, MSBPOST, [noparse][[/noparse]rawHeading_1\16] '
msbpost
The Stamp manual says the range of "bits" is o 1 to 16 and I'm not sure what happens when bits=17. The reason you had to go to 17 is because of setting the clock line high to begin with. As Jon explained, the first thing the SHIFTIN command does is to set that line low, and that should clock out the first data bit, the one you are picking up with msbpre.
The SHIFTOUT command in operation pulses the clock line high and then low, waits for a few microseconds, then reads the data line, then another clock pulse, read the data line, and so on. The clock is always low when it reads the state of the data line. The V2x moves from one bit to the next on the 1->0 transition of the clock line, so if the V2x is slow in outputting those bits, the Stamp might misread them. However, even the BS2sx SHIFTOUT command is working at less than 50 khertz, while the V2x claims that it can work at up to 1mhz. So a timing delay there seems unlikely. As Jon says, it is possible to bit bang the SHIFT and try it at a much lower speed.
P.S., here is a link to a data sheet from Jameco: www.jameco.com/wcsstore/Jameco/Products/ProdDS/126703.PDF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 5/28/2005 5:00:47 PM GMT
When I first started building this Sat Tracker with the V2X, I did try the SHIFTIN 15, 14, MSBPOST, [noparse][[/noparse]rawHeading_1\16] which resulted in every other itineration being %1111111111111111 from the V2X. By playing around, and starting the clock pulse high before the SHIFTIN, and then using 16 clock pulses, I was able to get every itineration of the V2Xcompass sub routine to output a valid azmuth heading, so I left it at that.
Now with the SX, I find by experimentation, that again I must start the clock pulse high and now use 17 clock pulses to output a valid azmuth angle every pass thru the sub routine. Otherwise with only 16 clock pulses every other pass is
%1111111111111111. The code above for the SX does work quite well, and response time for azmuth correction of the dish is faster, but again, I can't seem to figure out why the stamp, (if it is the SX) would jump over that 9th bit which is need to give an angle between 256 degrees and 359 degrees, and show the 10th bit as a 1?? It must be a timing issue.
Looping to bit bang would slow down the SX to a point where I should just stay with the BS2, don't you think??
Thanks to all who have read and contributed...
Deno
Thank again....Deno