Putting robotics at your service™

Free shipping on orders over $200

New bot.

Print view Share :
Previous topicNext topic

Page 1 of 1 [ 3 posts ]

New ( offline )
Posts: 8
Posted: 2009-03-04 11:09 
 Post subject: New bot.
Greetings!
I am working on a bot with a parallax bs2 homework board, a sabertooth 2x5, and a tritrack chassis. The problem that I am having, is that when I send a pulsout command of 750 to my controller for each motor it does not stop. I have my dip switches set for a micro according to the printout. It will turn just fine using pivot steering, but when I need the bot to stop to take some measurements, it does not.

Here is the code for reference.

'{$stamp BS2}
'{$Pbasic 2.5}
'Lynxmotion Bot
'Written by Jason Smith 25Feb09
'
'
'------Variables----------------------------------------------------------------------------------------------------------

Right PIN 14 'Variable for right motor controller
Left PIN 15 'Variable for left motor controller
Hturret PIN 01 'Variable for Horizontle Turret movement
Vturret PIN 12 'Variable for verticle turret movement
Ping PIN 00 'Variable for Ping sensor
counter VAR Byte 'Variable for counter
Time VAR Word 'Variable for time
Time1 VAR Byte 'Variable for time1
Time2 VAR Byte 'Variable for time2
'------Initialize---------------------------------------------------------------------------------------------------------

PAUSE 5000 'Wait 5 sec before starting

'------Main Program-------------------------------------------------------------------------------------------------------

Main:
GOSUB radar 'check distance
IF time > 1000 THEN GOSUB Forward 'if distance is clear go Foward
IF time <= 1000 THEN GOSUB turret_scan 'if object is detected then scan for clear path
IF time1 > time2 THEN GOSUB turn_left 'if time1 is greater than time2 then turn left
IF time2 > time1 THEN GOSUB turn_right 'if time2 is greater than time1 then turn right
GOTO Main


'------Sub-Routines-------------------------------------------------------------------------------------------------------
Forward:
DO WHILE Time > 1000 'keep moving until Ping senses something in the way
GOSUB radar 'run radar subroutine
IF Time <= 1000 THEN GOTO Main 'keep checking distance while moving foward
PULSOUT right, 400
PULSOUT left, 400 'Go forward
LOOP

Back_Up:
FOR counter = 1 TO 20
GOSUB radar
IF time > 700 THEN GOTO Main 'return to main if time is right
PULSOUT right, 800
PULSOUT left, 500 'Back up
PAUSE 18
NEXT
RETURN

Turn_Right:
DO UNTIL time > 1000 'keep moving for 130 pulses
GOSUB radar
IF Time > 1000 THEN GOTO Main 'keep checking distance while turning
PULSOUT right, 740
PULSOUT left, 800 'Turn right
PAUSE 18
LOOP
RETURN

Turn_Left:
FOR counter = 1 TO 130 'keep moving for 130 pulses
GOSUB radar
IF Time > 1000 THEN GOTO Main 'keep checking distance while turning
PULSOUT right, 800
PULSOUT left, 740 'Turn left
PAUSE 18
NEXT
RETURN

Turret_Scan:
PULSOUT right, 750
PULSOUT left, 750
FOR counter = 1 TO 120
PULSOUT hturret, 800
NEXT
GOSUB time_1
PAUSE 1500
FOR counter = 1 TO 230
PULSOUT hturret, 450
NEXT
GOSUB time_2
PAUSE 1500
FOR counter = 1 TO 51
PULSOUT hturret, 825
NEXT
RETURN

Radar:
PULSOUT ping, 5
PULSIN ping, 1, time
RETURN

Time_1:
PULSOUT ping, 5
PULSIN ping, 1, time1
RETURN

Time_2:
PULSOUT ping, 5
PULSIN ping, 1, time2
RETURN [/list]


User avatar
Guru ( offline )
Posts: 9256
Posted: 2009-03-04 11:24 
 Post subject: Re: New bot.
totcohand wrote:
Greetings!
I am working on a bot with a parallax bs2 homework board, a sabertooth 2x5, and a tritrack chassis. The problem that I am having, is that when I send a pulsout command of 750 to my controller for each motor it does not stop. I have my dip switches set for a micro according to the printout. It will turn just fine using pivot steering, but when I need the bot to stop to take some measurements, it does not.


This is an easy fix. The accuracy of the Sabertooth clock is not as good as the Microcontroller generating the pulses. So stopped may not be exactly 1500uS. It may be 1520, or 1480, or 1475, etc... The good news is after you find the exact value to stop the motors it will remain accurate. The full speed in both directions will be an equal delta from the stopped value. So if you find 1520 is the real stopped value 1020 and 2020 should provide full speed in the two directions. Easy right?

_________________
Jim Frye, the Robot Guy
http://www.lynxmotion.com
I've always tried to do my best...


New ( offline )
Posts: 8
Posted: 2009-03-07 11:50 
 Post subject: Re: New bot.
Thanks for the help! Too easy!


 

All times are UTC - 5 hours [ DST ]. It is currently 2014-12-21 20:36
Feedback Form
Feedback Form