controller help
science_geek
Posts: 247
im working on using an atari controller to control a boe bot, but when ever i push a button it does what i want until i let go then i jitters and moves backwards, heres my code
·········· ' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "test", CR,
····· "on ",CR
DO
IF (IN0 = 1 ) THEN
PULSOUT 12, 650
PULSOUT 13,850
PAUSE 50
ELSEIF (IN1 = 1) THEN
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 50
ELSEIF (IN2 = 1) THEN
PULSOUT 12, 650
PAUSE 50
ELSEIF ( IN0 = 0 AND IN1 = 0 AND IN2 = 0 AND IN3 = 0 AND IN4 = 0) THEN
PAUSE 100
ENDIF
LOOP
·········· ' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "test", CR,
····· "on ",CR
DO
IF (IN0 = 1 ) THEN
PULSOUT 12, 650
PULSOUT 13,850
PAUSE 50
ELSEIF (IN1 = 1) THEN
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 50
ELSEIF (IN2 = 1) THEN
PULSOUT 12, 650
PAUSE 50
ELSEIF ( IN0 = 0 AND IN1 = 0 AND IN2 = 0 AND IN3 = 0 AND IN4 = 0) THEN
PAUSE 100
ENDIF
LOOP
Comments
pulsout 12,750
pulsout 13,750
endif
pause 20
loop
you need to keep refreshing the servo, when you release the button there is no refresh the way it is. You also need to command them to the neutral position (750).
Jeff T.
Edit sorry I should say your refresh rate is too long you need around 20 - 30 mS
' {$STAMP BS2sx}
' {$PBASIC 2.5}
Main:
IF (IN0 = 1 ) THEN GOSUB forward
IF (IN1 = 1 ) THEN GOSUB Backwards
IF (IN2 = 1 ) THEN GOSUB Left
IF (IN3 = 1 ) THEN GOSUB Right
GOSUB Halt
GOTO Main
Forward:
PULSOUT 12, 650
PULSOUT 13,850
PAUSE 50
RETURN
Backwards:
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 50
RETURN
Left:
PULSOUT 12, 650
PAUSE 50
RETURN
Right:
PULSOUT 13, 650
PAUSE 50
RETURN
Halt:
LOW 12
LOW 13
RETURN
You'll have to modify the code slightly, I'm not sure if I have the left and right mixed up or not. Rather than sending out a neutral freq. to the servos I'd set there lines low stopping the servo completely.
----EDIT
it might be better to set 12 and 13 to inputs rather than low. just in case.
Halt:
INPUT 12
INPUT 13
pause 20
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A complex design is the sign of an inferior designer. - Jamie Hyneman
Post Edited (Dgswaner) : 5/20/2007 4:34:29 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
HTH
Duncan
·
· vdd
· ······!
······· !
O/ O
······················· ······················· ··········· ····························· ·!
······················· ······················· ··········· ····························· ·!
······················· ······················· ········································ ·pin 0············
i cant seem to upload the picture but heres a crude example wher i have vdd going threw a switch and into pin 0 i did try putting resistors in and it didnt completely cure it it still would shake and sometimes take off backwards but it did seem to help, i tried putting bigger and smaller resistors but the smaller would make it shake more, and the bigger would make it not shake as much but it would do really weird stuff that i cant explain
lots of good advice here.· I just wanted to add the results of my experience with the boe bot and the servos.
First, using the debug statements are an excelent way of troubleshooting.· It sounds that you do have a problem with the joystick interface to the boe bot. Take a look at page 168 in the "Robotics with the Boe-bot" manual.· It gives an example of interfacing a simple switch.· If I remember correctly the joystick uses a common wire to all switches.· you will have to take that into consideration.
Second, even if the pauses were too long the servos should still operate, they would just pulse on and off.· Even though the pauses may need to be shortened, keep in mind you can also cause problems by sending the pulsout commands too often.· Also the servos will still operate correctly with a pause longer than 20, depending on your code.
Third, I don't think you need to send a command to neutral position.· when the servo no longer recieves a pulse it will coast to a stop.· Now if you want it to brake instead of coasting the neutral position command is an excellent way of doing that.· Keep in mind sudden changes in speed are hard on the servos.
agfa
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support