PDA

View Full Version : Boe-Bot: ramping to go smoothly forward and back while turning



ddg1100
11-28-2009, 12:04 AM
Sorry for this long e-mail but it will take a bit to outline what my problem is.

I am working through the Boe-Bot book and I am up to Ch 4 where you are fine tuning the maneuvers.
I am trying to write a program that will ramp the Boe-Bot forward and backwards smothly in a stright line.
I have some code that seems to work just fine. I can ramp the "PulseOut" commands smoothly, and with a "Wheel Bias" term, ·I·am able to·adjust the ramp of one wheel·so that the Boe-Bot goes stright ahead and stight back.

But I wanted to see what·would happen if I put in a "Wheel Bias" value that was extream.··So I used 50 which should have slowed one wheel down by 50 percent. I expected to see the Boe-Bot, from a stop, accelerate up to speed and then back down to a stop while turning smoothly clockwise. It then should have done the same thing in reverse backing up to its starting point. But turning counter clockwise while backing up.

This expirement was in preperation for writing code that would give me smooth 90 deg and 180 degree turns while ramping the wheel speeds. These turns were to be smooth true arcs of a circle. (arcs with a fixed radious)

It, more or less, dose do this but not exactly!!

With my Bias = 50 (one·wheel should be·running at 50% of the other wheel)
· (1) It starts out by accelerating from a stop and also starting to turn CW (this is what I·expected).
· (2) But it then strightens out and no longer turns CW while it is still accelerating (I did NOT expect this).
··· ·· It is now going forward at it's fastest, stright ahead.
· (3) It now decelerates stright ahead but, as it gets close to stopping, it starts to turn CW again.
· (4) When it backs up, it is a mirror image of what it does going forward. It starts out turning CCW and
······· acceleratring while going backwards. As it reaches its top speed it·strightens out. It continues stright back
······· as it slows down and then as it gets close·to a stop, it·resumes turning CCW.
I don't have true arcs of a circle that I expected. (arcs with a fixd radious).
I have done a bunch of "tweeking" in the code but I can't seem to make the Boe-Bot turn in a smooth arc while ramping the wheel speeds up and down.




My·code·looks like this:

' {$STAMP BS2}
' {$PBASIC 2.5}
'out and back with ramp and bias
'11/27/2009
value12·· VAR Word
value13·· VAR Word
Counter01 VAR Word
count001· VAR Word
bias····· VAR Word· ' wheel bias
N12······ VAR Word
N13······ VAR Word
VALUE12·· = 750· 'Right wheel at 0 rpm
VALUE13·· = 750· 'Left· wheel at 0 rpm
Counter01 =·· 0· 'loop (expletive)er
' wheel bias
' Bias =· 20; turns it CW going forward, CCW going backwards
' Bias =· 50; is not working like I expected
' Bias =· 90; is stright ahead and stright back
' Bias = 100; is "no Bias" so it curves just a
'······· little bit because the two servos don't
'······· act exactly the same.
' Bias > 100; does not work vary well because it makes the wheel
'········ pulses go above 850 and/or below 650.
bias····· =· 50· 'wheel bias
count001· = 100· 'LOOP counter limit
FREQOUT 4, 500, 4000
'DO
· N12 =· value12
· N13 =· value13
· DEBUG DEC N12,CR '750, 0 wheel rpm
· DEBUG DEC N13,CR '750, 0 wheel rpm
FOR Counter01 = 0 TO count001
'forward accelerate
· N12 =· value12 - (counter01*bias/100)
· N13 =· value13 + counter01
· PULSOUT 12, N12
· PULSOUT 13, N13
· PAUSE 20
NEXT
· DEBUG DEC N12,CR '660, with bias = 90
· DEBUG DEC N13,CR '850
FOR Counter01 = count001 TO 0
'forward decelerate
· N12 =· value12 - (counter01*bias/100)
· N13 =· value13 + counter01
· PULSOUT 12, N12
· PULSOUT 13, N13
· PAUSE 20
NEXT
· DEBUG DEC N12,CR '750, 0 wheel rpm
· DEBUG DEC N13,CR '750, 0 wheel rpm
FOR Counter01 = 0 TO count001
'backward accelerate
· N12 =· value12 + (counter01*bias/100)
· N13 =· value13 - counter01
· PULSOUT 12, N12
· PULSOUT 13, N13
· PAUSE 20
NEXT
· DEBUG DEC N12,CR '840, with bias = 90
· DEBUG DEC N13,CR '650
FOR Counter01 = count001 TO 0
'backward decelerate
· N12 =· value12 + (counter01*bias/100)
· N13 =· value13 - counter01
· PULSOUT 12, N12
· PULSOUT 13, N13
· PAUSE 20
NEXT
· DEBUG DEC N12,CR '750, 0 wheel rpm
· DEBUG DEC N13,CR '750, 0 wheel rpm
'LOOP