Shop OBEX P1 Docs P2 Docs Learn Events
Simple Boe-Bot program not working — Parallax Forums

Simple Boe-Bot program not working

kickflipper11kickflipper11 Posts: 4
edited 2011-03-06 19:14 in Robotics
Hello

I am new to programming and I have been working on a really simple program for the Boe-Bot. I currently have a program that drives the boebot when a button is pressed. It uses the feelers to navigate, so it's in the format of

do

If (IN5 = 0) then
backup, turn
elseif(IN7 = 0) then
backup, turn
else
drive

loop

I didn't wanna post the actual code so its not confusing, but I can if it would help. Currently, it works fine, when the program is uploaded, the robot does not move until the button is pressed. However, I want to make it so that when the button is pressed again the boebot stops. I added another elseif stating that when the button is pressed (IN12 = 0), the whole program is called again with GOTO programname. However, just adding this new elseif ruins the drive program, and it won't go at all. Ive tried so many different variations, but nothing seems to work and I'm getting pretty frustrated, since it makes perfect sense in my head.

Am I going about this wrong? Are there any problems you could see with this approach? Thank you very much for any help you can offer, this is driving me crazy haha =/

Comments

  • FranklinFranklin Posts: 4,747
    edited 2011-02-20 13:14
    Your code is not valid bs2 code. Please do attach your program you are trying to run. Also if you could tell us how you have things connected and what errors you get that qualifies as "not working"
  • Mark KiblerMark Kibler Posts: 546
    edited 2011-02-20 15:59
    Yes, posting the entire program code would be helpful. The code you posted doesn't seem complete. We ran a similar program earlier today and there's more to it.

    Mark
  • kickflipper11kickflipper11 Posts: 4
    edited 2011-02-21 18:39
    button program.txt

    Ok, there is the program (in a .txt file), I hope it works. Anyway, I have a button set up on the bread board of the BASIC stamp. I have tested it with the DEBUG command in a test program: when it's pressed, it returns 0, and when it isn't, it returns 1. I simply want the button to be used as a start/stop for a drive program.

    When I had just used the button as a way to start the program, it worked fine. I turned on the BoeBot, waited however long I wanted, then pressed it and it ran fine. With the new program I uploaded (the one that is supposed to start and stop the boebot), I turn on the Boebot and press the button and it twitches a little bit and then stops.

    The worst I expected was for the button to only function as a starter, just not stop it. Now, it won't do either. Thanks a lot for the replies, I really appreciate it.
  • kickflipper11kickflipper11 Posts: 4
    edited 2011-03-06 11:40
    Anybody? I have a week off from school I was hoping to make progress this week
  • Martin_HMartin_H Posts: 4,051
    edited 2011-03-06 16:12
    Two things I'll suggest. First I would add DEBUG statements to your program to help you determine flow control. Second, indenting code two spaces inside each block (loop or if) really aids in readability.
  • Tony B.Tony B. Posts: 356
    edited 2011-03-06 17:37
    ELSE
            PULSOUT 12, 850    ‘Drives forward
            PULSOUT 13, 650
            PAUSE 20
    

    It seems to me that you need to adust the PAUSE time in this section. I believe your code is taking to long to get back to the PULSOUT parts running through all the IF statements. Remember a servo needs to recieve pulses every 20-40 ms to work properly. First, I would try commenting PAUSE out and see what happens. If that doesn't work maybe try PAUSE 5 and then PAUSE 10.

    Tony
  • kickflipper11kickflipper11 Posts: 4
    edited 2011-03-06 18:15
    Ok, thanks for the suggestions, I will try those and post the results in a bit
  • P!-RoP!-Ro Posts: 1,189
    edited 2011-03-06 19:14
    If the pause time is longer than 20 ms it will still work alright, but the servo will have less power, which means less speed.

    On the Basic Stamp it seems I've never had good luck with many if statements, it just causes problems. I haven't worked with the Stamp enough recently to know for sure but I think the select case command will suit you just fine. Normally one would use a single variable for it, but I'm sure you could ask some of the pro's here if you could select a case based on the button inputs. If you don't know about the case command I advise you look it up in the Stamp manual, I haven't used it myself enough to teach you.

    Hope this helped,
    Derrick
Sign In or Register to comment.