Problems with Boe-Bot
Link_Shinigami
Posts: 8
Hello everyone, I would like some help and would be greatful if anyone could provide even the slightest bit. And I apologize in advance if this has been answered before.
Last year another classmate and I were given a stamp and told to do some basic programming (Motor control, 7-segment LED display, LED Binary counter, etc). This year we (With our teacher) are working with the Boe-Bot.· We have been having slight problems and have not been able to solve problems or get around them.
I'll start with the problem (If our code is needed I can post it when I get into class).· We have been attempting to make the boe-bot do a simple line of movements, we try to make it (for example) go forward, reverse, turn left (90 degrees), turn left, go forward, turn right (90 degrees) then do a right forward arc.· We have tried using gosub but it does not work. It will execute the first routine but after that it seems to 'stutter' as it attempts to do the next routine (i.e. forward then turn right, the servo motors will -try- to do it but they seem to do it quickly then go right back to forward). We also attempted the same line of commands by (I believe the command is) 'data ("frllfr")' after giving them labels. As well, goto does the same as gosub.
Any help would be wonderful. All I remember is that we are using pins 12 and 13 and we·arn't using the boe-bot board, we are using a standard bread board my teacher had in class (Well, one of the several. It is a electronic engineering class, lol).
Thanks in advance! And if the code is needed, I can post it when I get into class (In about 4hours).
Last year another classmate and I were given a stamp and told to do some basic programming (Motor control, 7-segment LED display, LED Binary counter, etc). This year we (With our teacher) are working with the Boe-Bot.· We have been having slight problems and have not been able to solve problems or get around them.
I'll start with the problem (If our code is needed I can post it when I get into class).· We have been attempting to make the boe-bot do a simple line of movements, we try to make it (for example) go forward, reverse, turn left (90 degrees), turn left, go forward, turn right (90 degrees) then do a right forward arc.· We have tried using gosub but it does not work. It will execute the first routine but after that it seems to 'stutter' as it attempts to do the next routine (i.e. forward then turn right, the servo motors will -try- to do it but they seem to do it quickly then go right back to forward). We also attempted the same line of commands by (I believe the command is) 'data ("frllfr")' after giving them labels. As well, goto does the same as gosub.
Any help would be wonderful. All I remember is that we are using pins 12 and 13 and we·arn't using the boe-bot board, we are using a standard bread board my teacher had in class (Well, one of the several. It is a electronic engineering class, lol).
Thanks in advance! And if the code is needed, I can post it when I get into class (In about 4hours).
Comments
Posting the program code would be an excellent idea, since as you say there is more than one problem you're encountering.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
1. Missing ground wire between what's powering the servo's and what's powering the BS2 board.
2. Insufficient power to the servo and BS2 is causing BS2 reset.
3. Forgetting to 'refresh' the servo's every 20 mSec.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·' {$STAMP BS2sx}
' {$PBASIC 2.5}
DO UNTIL (instruction = "Q")
READ address, instruction
address = address +1
SELECT instruction
CASE "F": GOSUB forward
CASE "B": GOSUB backward
CASE "L": GOSUB left_turn
CASE "R": GOSUB right_turn
ENDSELECT
LOOP
END
DEBUG "Program Running"
Pulsecount VAR Word
address VAR Byte
instruction VAR Byte
DATA "flffrblbbq"
forward:
FOR pulsecount = 1 TO 64
PULSOUT 0,850
PULSOUT 1, 650
PAUSE 20
NEXT
RETURN
backward:
FOR pulsecount =· 1 TO 64
PULSOUT 0, 650
PULSOUT 1, 850
PAUSE 20
NEXT
RETURN
left_turn:
FOR pulsecount = 1 TO 24
PULSOUT 0, 650
PULSOUT 1, 650
PAUSE 20
NEXT
RETURN
right_turn:
FOR pulsecount = 1 TO 24
PULSOUT 0,850
PULSOUT 1,850
PAUSE 20
NEXT
RETURN
thanks a bunch (Slight problem. This is an older version of the current code due to save errors and such, I apologize for this)
Post Edited (Link_Shinigami) : 5/18/2006 4:20:30 PM GMT
It appeaars as though the first part of the program is missing, if that's supposed to represent the entire program.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Please see attached code:
You have your subroutines up in the body of your code. The return statements will not know where to 'return' to...
You have the pulsouts based on a BS2sx- in the code I attached I made the code BS2 - if you need BS2sx, you should alter your pulsout statements accordingly.
*edit* I responded based on the code you had originally posted - I'll have to check again...
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Post Edited (Ryan Clarke (Parallax)) : 5/18/2006 5:25:08 PM GMT
* You are using a BS2sx? Change your pulseout values accordingly
* You have your servos on Pins 0 and 1 ? (Just verifying this)
* Changed your pulsecount variable to a byte (no need for a word, your value never goes above 64)
* Restructured the code (moved variable declarations to the top, etc)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Post Edited (Ryan Clarke (Parallax)) : 5/18/2006 5:26:07 PM GMT
The PULSOUT instruction-
Syntax: PULSOUT Pin, Duration
The units in Duration are as follows:
BS1: 10 µs
BS2, BS2e, and BS2pe: 2 µs
BS2sx, BS2p, and BS2px: 0.8 µs
So a pulsout statement on the BS2 such as:
PULSOUT 1, 650
Sends a pulse of (650 * 2 µs) = 1.3 mS
to get the same value on a BS2sx:
PULSOUT 1, 1625
because (1625 * 0.8 µs) = 1.3 mS
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Please verify your power source. (Check your batteries with a meter, not just the LED on the BOE)...
The code I changed moved things - you have versions (depending on when you look at the message)- where things will never get executed because of how the code was organized.
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Post Edited (Ryan Clarke (Parallax)) : 5/18/2006 5:06:48 PM GMT
Did you center your servos?
Also, check the case of the letters in your DATA vs. your case statement.
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
We changed the case statement and the servos are something we havn't tried. We'll have to try that tomorow since class is over (lol). Thanks everyone for your· help, I just hope the end result isn't us getting taken off this project (He said it today but there is a good chance he just said that to see our responses...).· THanks again everyone, your help has been greatly appreciated.
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Thanks again for everyones help!
DO
· PULSOUT 13, 750
· PULSOUT 12, 750
· PAUSE 20
LOOP
However, your BS2sx runs 2.5 times faster than a BS2. This means you will have to modify some of the command arguments to get the timing to be the same as it would have been with a BASIC Stamp 2. The rule of thumb is multiply all duration arguments by 2.5, and divide all frequency arguments by 2.5. The exception here is the PAUSE command, whose duration argument stays the same.
So your program must use PULSOUT commands with these modified Duration arguments (1875 instead of 750):
DO
· PULSOUT 13, 1875
· PULSOUT 12, 1875
· PAUSE 20
LOOP
With FREQOUT commands, you are dealing with both a duration and a frequency.
For example, FREQOUT 4, 2000, 3000 will have to be changed to FREQOUT 4, 5000, 1200.
You will have to make these updates to the frequency and duration arguments in every program in the book before you run it, otherwise they won't work right.
Post Edited (Andy Lindsay (Parallax)) : 5/19/2006 1:33:36 AM GMT