Help with Ramping Code for Boe-Bot
Hi, I'm new to the Parallaxe message boards and I've recently just gotten my Boe-Bot robot kit last month.· I've done most of the activities in the activity book that came with the kit.· Chapter 4 has a really short section on ramping up / down for the servos on the Boe-Bot...· I was wondering if there was a way to incorporate that code into the other example programs in the book.· One being the one for Roaming with Whiskers or Roaming with irDetection.· Here is the code that I'm tryin to modify..
' Robotics with the Boe-Bot - RoamingWithIrDetectionAndRamping.bs2
' Boe-Bot uses·irDetection to detect objects, and navigates around them.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program running"
irDetectLeft·· VAR····· Bit
irDetectRight· VAR····· Bit
pulseCount···· VAR····· Byte
FREQOUT 4, 2000, 3000
DO
· FREQOUT 8, 1, 38500
· irDetectLeft = IN9
· FREQOUT 2, 1, 38500
· irDetectRight = IN0
· IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
··· HIGH 10
··· HIGH 1
··· GOSUB Ramp_down
··· GOSUB Back_Up
··· GOSUB Turn_Left
··· GOSUB Turn_Left
· ELSEIF (irDetectLeft = 0) THEN
··· HIGH 10
··· GOSUB Ramp_Down
··· GOSUB Back_Up
··· GOSUB Turn_Right
· ELSEIF (irDetectRight = 0) THEN
··· HIGH 1
··· GOSUB Ramp_down
··· GOSUB Back_Up
··· GOSUB Turn_Left
· ELSE
··· LOW 10
··· LOW 1
··· GOSUB Ramp_Up
··· GOSUB Forward_Pulse
· ENDIF
LOOP
Ramp_Up:
· FOR pulseCount = 0 TO 60
··· PULSOUT 13, 750 + pulseCount
··· PULSOUT 12, 750 - pulseCount
··· PAUSE 20
· next
· RETURN
Forward_Pulse:
· PULSOUT 13, 850
· PULSOUT 12, 650
· PAUSE 20
· RETURN
Turn_Left:
· FOR pulseCount = 0 TO 45
··· PULSOUT 13, 750 - pulseCount
··· PULSOUT 12, 750 - pulseCount
··· PAUSE 20
· NEXT
· RETURN
Turn_Right:
· FOR pulseCount = 0 TO 45
··· PULSOUT 13, 750 + pulseCount
··· PULSOUT 12, 750 + pulseCount
··· PAUSE 20
· NEXT
· RETURN
Ramp_Down:
····FOR pulseCount = 0 TO 60
····· PULSOUT 13, 750 - pulseCount
····· PULSOUT 12, 750 + pulseCount
····· PAUSE 20
··· NEXT
··· RETURN
Back_Up:
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
When I try to run this program - My Boe-Bot seems to get stuck on this bit of code ( Ramp_Up ), and it repeats that over and over.· Is there a way to program the servos to gradually accelerate without having to go in a set/determined programmed length of area?· I want my Boe-Bot to move more fluidly around instead of having the jerks whenever it changes into a new direction.·
Thanks.
' Robotics with the Boe-Bot - RoamingWithIrDetectionAndRamping.bs2
' Boe-Bot uses·irDetection to detect objects, and navigates around them.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program running"
irDetectLeft·· VAR····· Bit
irDetectRight· VAR····· Bit
pulseCount···· VAR····· Byte
FREQOUT 4, 2000, 3000
DO
· FREQOUT 8, 1, 38500
· irDetectLeft = IN9
· FREQOUT 2, 1, 38500
· irDetectRight = IN0
· IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
··· HIGH 10
··· HIGH 1
··· GOSUB Ramp_down
··· GOSUB Back_Up
··· GOSUB Turn_Left
··· GOSUB Turn_Left
· ELSEIF (irDetectLeft = 0) THEN
··· HIGH 10
··· GOSUB Ramp_Down
··· GOSUB Back_Up
··· GOSUB Turn_Right
· ELSEIF (irDetectRight = 0) THEN
··· HIGH 1
··· GOSUB Ramp_down
··· GOSUB Back_Up
··· GOSUB Turn_Left
· ELSE
··· LOW 10
··· LOW 1
··· GOSUB Ramp_Up
··· GOSUB Forward_Pulse
· ENDIF
LOOP
Ramp_Up:
· FOR pulseCount = 0 TO 60
··· PULSOUT 13, 750 + pulseCount
··· PULSOUT 12, 750 - pulseCount
··· PAUSE 20
· next
· RETURN
Forward_Pulse:
· PULSOUT 13, 850
· PULSOUT 12, 650
· PAUSE 20
· RETURN
Turn_Left:
· FOR pulseCount = 0 TO 45
··· PULSOUT 13, 750 - pulseCount
··· PULSOUT 12, 750 - pulseCount
··· PAUSE 20
· NEXT
· RETURN
Turn_Right:
· FOR pulseCount = 0 TO 45
··· PULSOUT 13, 750 + pulseCount
··· PULSOUT 12, 750 + pulseCount
··· PAUSE 20
· NEXT
· RETURN
Ramp_Down:
····FOR pulseCount = 0 TO 60
····· PULSOUT 13, 750 - pulseCount
····· PULSOUT 12, 750 + pulseCount
····· PAUSE 20
··· NEXT
··· RETURN
Back_Up:
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
When I try to run this program - My Boe-Bot seems to get stuck on this bit of code ( Ramp_Up ), and it repeats that over and over.· Is there a way to program the servos to gradually accelerate without having to go in a set/determined programmed length of area?· I want my Boe-Bot to move more fluidly around instead of having the jerks whenever it changes into a new direction.·
Thanks.
Comments
The only trap here is if you are doing any kind of subsumption based program (like many of the examples for the Boe floating around the forum). Many of those routines effectively "destroy" the previously sent motor speed, so you need to either preserve the last "sent" speed, or you need to code your subsumption state machines so they do not destroy the previous motor speed if they are not actually subsuming.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
One other question.. Why is there not a Sticky Boe-Bot thread? Like for the ones Penguin robot and Squibbler Robot?
The basic idea is that you have a subroutine, or a single place in your code, where the motor speeds are actually "dumped" and output to the servos. That way you can have your main loop keep tweaking and changing the motor speeds, and when the loop is done, THEN the final "set" speeds are actually sent. This might show it better. I'm using Words for servo speeds for simplicity, but words are a real waste of var space for these speeds (if your servo speed range is 650-850 that's a range of only 200, far less than a byte):
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php