5 Replies - 542 Views - Last Post: 26 October 2013 - 03:05 PM Rate Topic: -----

#1 jberte11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-October 13

Robot will not go forward

Posted 26 October 2013 - 01:07 PM

hey guys I am new to programming and it is required for my engineering class and we are currently working with paralax boe bots.

The code we are using is supposed to make the bot go forward until it detects an edge and if it does then to back up or turn depending on which IR LED detects the edge.

i have the program written but i cannot determine why when i run it my bot just backs up while pivoting to the right all the time, it never goes forward. i have already tested both IR's to determine if they are working and have also ran different programs to verify that both servos are working correctly but it is still not going forward when i run this program, any help as to determining the cause of this would be greatly appreciated.

' {$STAMP BS2}
' {$PBASIC 2.5}
irdetectleft VAR Bit

irdetectright VAR Bit

pulseleft VAR Bit

pulseright VAR Bit

loopcount VAR Bit

pulsecount VAR Bit

FREQOUT 4, 2000, 3000

DO

FREQOUT 8, 1, 38500
irdetectleft = IN9
FREQOUT 2, 1, 38500
irdetectright = IN0

IF (irdetectleft = 0) AND (irdetectright = 0) THEN
  pulsecount = 1
  pulseleft = 809
  pulseright = 650

ELSEIF (irdetectleft = 1) AND (irdetectright = 1) THEN
  pulsecount = 15
  pulseleft = 686
  pulseright = 850

ELSEIF (irdetectright = 1) THEN
  pulsecount = 10
  pulseleft = 650
  pulseright = 650

ELSEIF (irdetectleft = 1) THEN
  pulsecount = 10
  pulseleft = 850
  pulseright= 850

ENDIF

FOR loopcount = 1 TO pulsecount
  PULSOUT 13, pulseleft
  PULSOUT 12, pulseright
  PAUSE 20

NEXT

LOOP

This post has been edited by Salem_c: 26 October 2013 - 01:11 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Robot will not go forward

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 4278
  • View blog
  • Posts: 13,439
  • Joined: 25-December 09

Re: Robot will not go forward

Posted 26 October 2013 - 02:03 PM

This is not a C/C++ question and you may be better off finding a forum that deals with your processor and the language being used, PBasic.

What do all those "magic numbers" represent. For example:
IF (irdetectleft = 0) AND (irdetectright = 0) THEN
  pulsecount = 1
  pulseleft = 809  // What does 809 do?
  pulseright = 650 // What does 650 do?



Have you verified that you can get the robot to go forward, reverse, circle forward left, circle forward right, stop, etc. without any of your logic?

Jim
Was This Post Helpful? 0
  • +
  • -

#3 jberte11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-October 13

Re: Robot will not go forward

Posted 26 October 2013 - 02:20 PM

As i said I am new to programming so I did not know what C/C++ is and those numbers correspond to the direction and speed with which the servos turn.
ex. pulsout 12: 750 pulsout 13: 750 is both servos stoppped
pulsout 12: 850 pulsout 13: 650 is left servo clockwise right servo counterclockwise so it goes forward

And yes I have verified that the robot moves in all directions correctly with other programs, it is just this one that it gets stuck on.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is offline

  • member icon


Reputation: 4278
  • View blog
  • Posts: 13,439
  • Joined: 25-December 09

Re: Robot will not go forward

Posted 26 October 2013 - 02:41 PM

Quote

And yes I have verified that the robot moves in all directions correctly with other programs, it is just this one that it gets stuck on.


Your numbers don't make much sense to me, so I recommend you verify that the numbers you're using actually drive the bot in the direction you suspect. And for now verify that the bot moves at the same speed going forward/reverse and right/left. Until you get the basic logic working I'd also stay with the same "pulsecount"

You should also verify the "polarity" of your edge detectors.


Also lines 19 to 22 probably don't need to be in your loop, they should probably be before the "DO".

Jim
Was This Post Helpful? 1
  • +
  • -

#5 jberte11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-October 13

Re: Robot will not go forward

Posted 26 October 2013 - 02:59 PM

alright thank you for your help, I did discover what was confusing my bot.
Was This Post Helpful? 0
  • +
  • -

#6 jberte11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-October 13

Re: Robot will not go forward

Posted 26 October 2013 - 03:05 PM

I just had too many VAR Bit for it to handle, I had to change two of them to VAR Byte and another two to VAR Word. After that it worked perfect
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1