Shop OBEX P1 Docs P2 Docs Learn Events
Help with Servo32v7 - Stop/Pause Servo — Parallax Forums

Help with Servo32v7 - Stop/Pause Servo

ckbw33ckbw33 Posts: 5
edited 2012-05-18 08:42 in Propeller 1
I hope this is a quick/easy question!

I'm using Servo32v7, and I'd like to let the servo "relax". I don't care about it's subsequent position, I'd just like to cut the power to the servo after I've finished actuating it.

I could not find a "stop" function in the object, but this seems like a straighforward task (i.e. stop pulses on that pin). The assembly portion is a little hairy for my Propeller knowlege depth, so can anyone suggest code for a "stop" PUB?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-18 08:21
    You turn off a servo by using an invalid servo pulse width. The valid range is 500 (0.5ms) to 2500 (2.5ms), so anything less than 500 or greater than 2500 will work. The I/O pin will be set to input mode. The servo will shut itself off after 20-30ms typically. There are comments in the SetRamp and Set routines that discuss this.
  • ckbw33ckbw33 Posts: 5
    edited 2012-05-18 08:26
    Fantastic! I will give that a shot. Thanks for the quick response. I could gather the pin was switched to an input when it was out of range, but I'm still mystified by the globalness of variables when ASM and SPIN are in the same object. Thanks!!!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-18 08:42
    The Start method doesn't return anything.

    It seems like it would be a good idea if it at least returned the cog number so the parent object could stop the cog if needed.

    I suppose anyone wanting to top and retart a cog would probably know how to do this themseleves, but it just seems odd there isn't any information returned from the Start method.

    Changing:
    PUB Start
        RampFlag := 0 
        ZoneClocks := (clkfreq / _1uS * ZonePeriod)                                 'calculate # of clocks per ZonePeriod
        NoGlitch   := $FFFF_FFFF-(clkfreq / _1uS * NoGlitchWindow)                  'calculate # of clocks for GlitchFree servos. Problem occurs when 'cnt' value rollover is less than the servo's pulse width.                                                                                                                                                                                                                         
        cognew(@ServoStart,@ZoneClocks)
    

    To:
    PUB Start
        RampFlag := 0 
        ZoneClocks := (clkfreq / _1uS * ZonePeriod)                                 'calculate # of clocks per ZonePeriod
        NoGlitch   := $FFFF_FFFF-(clkfreq / _1uS * NoGlitchWindow)                  'calculate # of clocks for GlitchFree servos. Problem occurs when 'cnt' value rollover is less than the servo's pulse width.                                                                                                                                                                                                                         
       [B]result := [/B]cognew(@ServoStart,@ZoneClocks)
    

    The added "result :=" doesn't even increase the program size (which I think is kind of strange).
Sign In or Register to comment.