Shop OBEX P1 Docs P2 Docs Learn Events
Servo Woes — Parallax Forums

Servo Woes

djh82ukdjh82uk Posts: 193
edited 2008-02-12 19:49 in Propeller 1
Heya Guys

I picked up a servo to play with, got it wired up and it works, did not have any 4.7k resistors so used 2 x 2.2k and one 300R in series.

I cannot get the servo to do anything than jidder back and for (tiny movements)

this is the servo I have Linky

I am using this code
Somebody said...

CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 'Note Clock Speed for your setup!!
SpeedServo = 4
DirectionServo = 9


OBJ
SERVO : "Servo32"

PUB Servo32_DEMO | temp
'Preset Servo's you want to use to center position
SERVO.Set(SpeedServo,1500)
SERVO.Set(DirectionServo,1500)
'Note: Servo pins that will be used must be preset before running "SERVO.Start".
' This is because the I/O direction is set here and is only executed
' at the beginning of "SERVO.Start". Servo pins that aren't used will remain
' in their original direction state.
SERVO.Start 'Start Servo handler
repeat
SERVO.Set(SpeedServo,1500)
'SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq + cnt)

'SERVO.Set(SpeedServo,1000)
'SERVO.Set(DirectionServo,1000)
waitcnt(clkfreq + cnt)

SERVO.Set(SpeedServo,1500)
'SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq + cnt)

SERVO.Set(SpeedServo,1000)
'SERVO.Set(DirectionServo,2000)
waitcnt(clkfreq + cnt)

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-24 13:57
    1) How are you powering this setup? If there's not enough power for the servos and the Propeller runs off the same supply, you might be forcing the Propeller to reset as soon as it starts to move the servo.

    2) The WAITCNTs provide for a 1 second delay. That's not enough time for the servo to finish moving if it has far to go.

    3) You don't need precisely a 4.7K resistor. Anything in the range 470 ohm to 4.7K should work fine. You're trying to limit the "fault current" into the Propeller pin to something under 20ma if you accidentally connect the pin to a voltage over 3.3V or something other than what the Propeller is trying to output. This shouldn't happen with a servo since a servo has an input connection only, but accidents can happen.

    Post Edited (Mike Green) : 6/24/2007 2:05:04 PM GMT
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-24 14:40
    I jumpered the 5v so it is using the regulator, proto board being powered by a wall wart, server rated at 4.8v to 6.v, do not know what current it draws however.

    Do I need to find out the servo's operating range, if so how can I do that?

    I thought the waitcnt was effectivley the 1.5ms pause (neutral)?

    Im confused [noparse]:([/noparse]


    DJH
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-06-24 14:44
    waitcnt(clkfreq + cnt)

    Is a one second delay. This should be enough time for a fairly decent sized movement at least.

    Post your code as a file then the indentation etc can be seen.

    Graham
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-24 14:47
    Ok heres the code, ignore the 2nd servo as I am only using one. (pin 4)
  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-24 14:50
    A standard servo can draw over 1A under load. Look on the internet for the datasheet on the servos you're using for that information. The datasheet will give you the no-load current and the idle current.

    "waitcnt(clkfreq + cnt)" always causes a 1 second delay. "waitcnt(clkfreq/10 + cnt)" gives a 1/10 sec delay. "waitcnt(clkfreq*5 + cnt)" gives a 5 second delay.
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-24 14:55
    I will try and find a datasheet,

    I am not used to using waitcnt in that way, I always have to do waitcnt (clqfreq / 10000) to get a 1 second delays.

    DJH
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-24 14:58
    Cannot find a datasheet anywhere for a FTX3000

    this is all the info I have:



    Fastrax FTX3000 Universal Servo

    Standard fitting.

    For all steering etc.

    Compatible with Futaba etc.


    Inexpensive replacement servo ideally suited to aircraft or multi-channel cars where multiple servos are required, and you are looking for reasonable performance without paying the earth.

    Spec Check:

    * Speed: 0.20 sec/60°
    * Torque: 4.0kg/cm
    * Weight: 44.62g/15.74oz



    Part # Description Price (RRP)
    FTX3000 E-Std Servo £6.99
  • FranklinFranklin Posts: 4,747
    edited 2007-06-24 15:24
    Power the servo from a supply other than the onboard regulator get 4 1.5v batteries if you have nothing else. Servos draw a lot of power. show us how you are powering the servos I think that's where the problem is.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • El PaisaEl Paisa Posts: 375
    edited 2007-06-24 15:48
    I suspect you do not have enough power.

    The same happen to me until I used a 6 VDC wall brick from Lynxmotion.

    I am using the demo board and is not very easy to connect power to the servos.

    Including a setup I am using.
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-24 15:58
    well the wall wart is giving out 6V and 300ma, the servo gets it's power via the servo volateg reg on the protoboard, jumper is set to 5V (from reg).

    Now if I start the protoboard, sometimes the motor will rotate a good 90 degrees or so, then just start juddering..

    I have a 1A variable psu that I will try, which will be useful as it measure the current draw at the same, time.

    Thanks

    DJh
  • FranklinFranklin Posts: 4,747
    edited 2007-06-24 16:01
    Make sure you are not driving the servo against it's max travel stop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-24 16:09
    that is something I have considered and I have no way of knowing what it's range is, as in it's center posistion etc, or is it relative?

    when jiddering it does not seem to be at it's outer limit

    DJH
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-06-24 17:40
    djh82uk said...
    I will try and find a datasheet,

    I am not used to using waitcnt in that way, I always have to do waitcnt (clqfreq / 10000) to get a 1 second delays.

    DJH


    You are in your first post.

    Graham
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-24 18:04
    I grabbed the code from an example someone posted, just so I could test the servo, and by not understanding it, I could not see why it was not working.

    Thanks for your help

    DJH
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-25 00:49
    Your power supply is underrated for driving a servo, you should be using a supply capable of an amp, whats happening is that when the in-rush current of the servo happens, the voltage of your supply sags, and since it's only a few hundredths of a volt above the dropout of the regulator, it is shutting down and causes the Propeller to reset, this circular scenario is causing the stuttering you are seeing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • djh82ukdjh82uk Posts: 193
    edited 2007-06-25 00:57
    ah thats cool, will deffo try the 1 amp psu soon as I get my other problems sorted out (train speed detector thread)

    DJH
  • rokickirokicki Posts: 1,000
    edited 2007-06-25 01:49
    Hmm, but the prop reset delay is about one second. That is, the servo should *pause*, then do something,
    then *pause* again. This doesn't sound like juddering to me.

    Anyway, I'm now happily using 5 1.2V NiMH batteries with my Prop bot, and they do seem to last
    forever. And no unexpected resets.

    I'd add an LED and make your prop blink the LED at startup; this way you will *always* know when the
    prop resets.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-25 02:05
    Excellent point, the LED would definitely indicate if a reset is occuring.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • djh82ukdjh82uk Posts: 193
    edited 2008-02-12 16:20
    ok, im back to playing with servos, I have a 3.7g tiny little servo

    I can get it to rotate about 90 degrees

    is that about their limit?

    Also am I able to control speed?

    Does anyone have any spin code examples for controlling 1 servo, im currently using servo32 from the object exchange, but there is a lot to it and so is difficult to understand, (making it harder to figure out what bits to play with)

    DJH
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-12 16:28
    Most servos will rotate 180 degrees, but some are made for different ranges. Some will indeed rotate only 90 degrees while some will rotate 360 degrees or even 2 or 2 1/2 turns. You can't control speed directly. To do that, you have to slowly change the width of the control pulse making it wider or narrower a little bit each pulse.

    I think there's a 4 servo control object in the object exchange that's written in Spin. You can also look at BoeBotBasic which has a routine for controlling 3 servos that's written in Spin.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-12 19:49
    You can also look into my PWM Tutorial, which explaines tha basics behind PWM. There is a wiki entry as well...
Sign In or Register to comment.