Shop OBEX P1 Docs P2 Docs Learn Events
rc serco motor control — Parallax Forums

rc serco motor control

ChcKsssChcKsss Posts: 10
edited 2006-08-15 16:07 in BASIC Stamp
Just a quick question,
Is it possible to control a standard rc servo (e.g. Futaba micro mini) in forward and backward mode?
I have a loop that moves the servo 120 degree forward. I thought I just can count backwards and then it will move backwards the same distance. But this doesn't work. The servo is moving on its own back and not with the stepsize that I want.
The motor control looks like that in the moment:
MAIN: FOR i=334 TO 1166 STEP 10
GOSUB MOVE
NEXT

MOVE: LOW 15
PULSEOUT 15, i
PAUSE 20
RETURN
The same would be for the backward movement, just with negative counting in the FOR LOOP.

ChcKsss

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-15 15:26
    The command LOW 15 should be toward the beginning of your code (preferably in the initialization routine) and not executed each pass through the subroutine.· Also, the code will fall right through into the subroutine when it passes through the first loop because you have no END or STOP statement.· i would need to declared as a WORD variable.· I don't know what you mean about just counting backward.· Your FOR...NEXT loop values would simply need to be reversed.· I hope this helps.

    FOR i=1166 TO·334 STEP 10

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ChcKsssChcKsss Posts: 10
    edited 2006-08-15 15:34
    Thank you Chris for the hint with the LOW 15.
    With the backward counting I meant the FOR Loop, like you defined it. But with this the motor is not moving backwards :-(
    ChcKsss
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-15 15:46
    Please post complete code...As an attachment, since pasting it is losing the formatting.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-15 15:52
    ChcKsss -

    There may be a slight conceptual problem here, at least from my point of view. Ordinary R/C servos only operate in one direction. There really is no forwards or backwards per se, only forwards.

    However, that is not to say that you can't move forward in successively larger or smaller steps or that you can't move radially fewer and fewer degress with each succesive 20 mS pass. The latter case would "simulate" (if you will) moving backwards.

    Just to reinforce what Chris said, the variable "i" MUST be a WORD sized variable:

    i var WORD

    Once you change that, I suspect the situation will change in your favor.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • ChcKsssChcKsss Posts: 10
    edited 2006-08-15 16:07
    Bruce,
    The servo that I use can move backwards and can also move just a maximum angle of 120 degree. (But I also wasn't sure at first if this is possible or not...)

    Chris,
    I just forgot the whole time to reset the Stamp... Sorry. It is working that way now.
    Thank you for the help from both of you.
    Have a nice day
    ChcKsss
Sign In or Register to comment.