Shop OBEX P1 Docs P2 Docs Learn Events
Hobby Servos — Parallax Forums

Hobby Servos

sicoloco55sicoloco55 Posts: 6
edited 2011-04-25 21:25 in Propeller 1
Hi:

My question is about hobby servos and the servo32v7.spin object found in the OBEX.
The instructions say that to center a servo the pulse width that is used is 1500, so y think this was for standard restringed servos not for the hobby servos.

An example:

In BS2 I use PULSOUT Pin, 550
to center de servo... I have to use the same width in the propeller with the Serv.Set method??

I have a Prop USB Board
And here is the code I wrote
CON

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

VAR

  long stack[20]
  long puls
OBJ

  Serv1 : "Servo32v7.spin"
PUB Start | Pin
 repeat while true
  Pin := 5
  Serv1.Start
  Serv1.Set(Pin, 1000)
  waitcnt(5_000_000 + cnt)

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-04-25 20:23
    What is your question? The command to center a servo using servo32v7.spin?
    SERVO.Set(ServoCh1, 1500)
    
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-04-25 21:20
    sicoloco55,

    The Servo32v7.spin is designed to set and forget, meaning you don't need to keep making updates. Also, you don't need to keep launching the driver. In your repeat loop you keep starting. So the Servo commands should happen outside of the repeat loop, and the waitcnt can be removed from the repeat loop.

    The DEMO associated with the OBEX file should be explanatory and provide adequate information to set this up. Let me know if you have any further problems and I'll see what we can do..
  • W9GFOW9GFO Posts: 4,010
    edited 2011-04-25 21:25
    For the BS2, each unit of pulse width is equal to 2 microseconds (.002 milliseconds). So PULSOUT 550 is actually a pulse width of 1.100 mS or 1100 microsceonds. When using the Servo32v7 object you enter in the actual pulse width that you want in one microsecond increments. So that PULSOUT 550 is the same pulse width as Serv1.Set(Pin, 1100).

    Rich H
Sign In or Register to comment.