Shop OBEX P1 Docs P2 Docs Learn Events
gosub — Parallax Forums

gosub

HenrymouHenrymou Posts: 128
edited 2007-08-21 00:26 in Robotics
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000

servopulse var byte

PROGRAM Main

Main:
Do
gosub backward
pause 2000
gosub forward
Loop

forward:
Pulsout RB.7, 100
Pulsout RC.7, 200
return

backward:
Pulsout RB.7, 200
Pulsout RC.7, 100
return

ok this code should make the servos on my SX boe bot go backward, then forward, it just sits there and doesn't move though
why is this?
-Henry

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-08-20 19:24
    Because the "control signal" for a servo is to give it a positive going pulse of 1 mSec to 2 mSec duration (depending on the desired shaft position) and REPEATING that signal every 20 mSec.

    Sending one pulse doesn't do very much.
  • D FaustD Faust Posts: 608
    edited 2007-08-21 00:26
    The pause should probably be in the subroutines. The is almost no pauses between the forward and backward commands. Otherwise, allanlane5 is right.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum
    LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum
    ON subnum GOTO Hope_this_helps, Thanks!, WOW!!
    END 
    
Sign In or Register to comment.