BS2 to BS2sx program compatability
petep
Posts: 5
First off, I'm new to robotics and programming...
So I've been using a BS2 chip with a boe bot for a couple months. I started running out of code space, so I decided to purchase the BS2sx chip.
The first thing I noticed when I plugged in the BS2sx chip was that the drive servos needed to be recentered.
To recenter them I used:
pulsout 750
pause 20
Then I started playing around and tried to load all my old BS2 programs onto the·BS2sx·chip. The boe bot stutters and barely moves.
The batteries are brand new.
Is this happening because of the different processor speed? What do I need to change in my BS2 code to use it on the BS2sx?· If the two chips work significantly differently, where could I get a guide book for the BS2sx? I looked through the Parallax store and there were only BS2 books.
Thanks!
·
So I've been using a BS2 chip with a boe bot for a couple months. I started running out of code space, so I decided to purchase the BS2sx chip.
The first thing I noticed when I plugged in the BS2sx chip was that the drive servos needed to be recentered.
To recenter them I used:
pulsout 750
pause 20
Then I started playing around and tried to load all my old BS2 programs onto the·BS2sx·chip. The boe bot stutters and barely moves.
The batteries are brand new.
Is this happening because of the different processor speed? What do I need to change in my BS2 code to use it on the BS2sx?· If the two chips work significantly differently, where could I get a guide book for the BS2sx? I looked through the Parallax store and there were only BS2 books.
Thanks!
·
Comments
Two things will probably need to be changed. One is the duration in the PULSOUT command, and the second is how·the PAUSE commands are set up. The former is a definite, but the latter is a maybe.
The BS-2 and BS-2sx have different values for "timer units" (TU's) and thus the program must be modified according to the table in the description of the PULSOUT command in the PBASIC Help file, or PBASIC Reference Manual. Here is a copy:
Stamp Model·········· BS1········ BS2, BS2e, and BS2pe······· BS2sx, BS2p, and BS2px
Units in Duration···· 10 µs·············· 2 µs····························· ···· 0.8 µs
Solving this formula will give you your new durations:
Old duration···· X New duration
=
··· 2 µs··············· 0.8 µs
The business with the PAUSE statements just ensures that the servos are refreshed every 20 ms. Servos will not maintain position on their own without this refresh. If the PAUSEs were adequate before, they probably will be now too. If however they were marginal before, they may need to be increased, as almost all instructions execute faster on a BS-2sx.
Hope that gets you going.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
Post Edited (Bruce Bates) : 10/15/2008 7:17:32 AM GMT
In regards to the pause. The way I understand it, if I was relying on a program execution time of 20ms to give me a pause, the execution time would now be faster than 20ms. So I would need to add a Pause to make up the time.
The way I have it set up, uses a PAUSE 20 after a pulsout. So since I am not using the program execution time to give me a pause, I don't need to worry about pauses.
For my PULSOUT command,
Right now PULSOUT 750 gives me a stop on the servo motors. With the SX chip I should use:
750 * 2us = X * 0.8us
X = (750 * 2 us) / 0.8us
X = 1875
So I should use PULSOUT 1875 for a stop on the servo motors.
I'll try this tonight, when I get home. But let me know if I'm on the wrong track!
Now, not wanting to rewrite my code incase I go back to using the BS2 chip. I think I'm going to add this code:
'
INITALIZE
#SELECT $STAMP
#CASE BS2, BS2E
Scale CON 65535
#CASE BS2SX, BS2P, BS2PX
Scale CON·26214 ' (2us/.8us = 2.5) or we could divide by 0.4 (0.4 * 65536 = 26214)
#ENDSELECT
'----IN MY MOTOR SUBROUTINE
forward_pulse
PULSOUT 13, 850 / (1** Scale)
PULSOUT 12, 650 / (1** Scale)
PAUSE 20
RETURN
Am I on the right track with that piece of code?
Thanks, Pete
Post Edited (petep) : 10/15/2008 8:55:53 PM GMT
Perhaps I'm missing something. Where did the 65536 come from? Other than that, your technique seems okay.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
"An interesting application of the ** operator is to multiply by a known fractional value less than one. The fraction value is expressed in units of 1/65536. To find the fractional ** parameter, multiply the fraction part by 65536."
So I could divide·by 26214/65536 which is (0.4) but not 0.4 itself.
Oops, sorry about that. Don't know how I overlooked that.
Looks fine then.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
Is there a way to generate or substitute a PAUSE command that will hold for 0.4ms.
The min time for the command is 1ms and I need to pause for 0.4ms only.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."