BS2 servos do not turn the opposite way
trelozakinthinos
Posts: 13
in BASIC Stamp
Hello,
First post here!
I am from Greece and I have collected DeAgostini's robot which has Parallax'es BS2. I am trying to rotate the robot where the light is. This is accomplished with 2 photoresistor one for left and one for right in combination with resistor and capacitor.
This is my programm
There is a problem with the turn_left command. It just turns so slow that is like shaking.
I tried in a new program to try it and it worked perfectly.
Any ideas? Thank you for your time!
First post here!
I am from Greece and I have collected DeAgostini's robot which has Parallax'es BS2. I am trying to rotate the robot where the light is. This is accomplished with 2 photoresistor one for left and one for right in combination with resistor and capacitor.
This is my programm
' {$STAMP BS2} ' {$PBASIC 2.0} '----------variables------------------ photo_right VAR Word photo_left VAR Word pbin VAR IN2 '------constants--------------- threshold CON 20 left_in CON 10 right_in CON 9 left_servo CON 12 right_servo CON 13 '---------------activation------------------- LOW right_servo LOW left_servo start: IF pbin = 1 THEN start '---------main-------------- main: HIGH right_in PAUSE 3 RCTIME right_in, 1, photo_right HIGH left_in PAUSE 3 RCTIME left_in, 1, photo_left IF ABS(photo_right-photo_left) < threshold THEN main IF photo_left > photo_right THEN turn_right IF photo_left < photo_right THEN turn_left turn_left: PULSOUT right_servo,500 PULSOUT left_servo,500 PAUSE 20 turn_right: PULSOUT right_servo,1000 PULSOUT left_servo,1000 PAUSE 20 GOTO main
There is a problem with the turn_left command. It just turns so slow that is like shaking.
I tried in a new program to try it and it worked perfectly.
' {$STAMP BS2} ' {$PBASIC 2.0} lowtime VAR Word lowtime=20 LOW 12 LOW 13 loop: PULSOUT 12,500 PULSOUT 13,500 PAUSE lowtime GOTO loop
Any ideas? Thank you for your time!
Comments
I forgot the GOTO main under the turn_left!
(for instance if photo_left = photo_right)
Yes you are right! Thank you.
Even the possibilities to be equal are very low it is more safe to add it!