Author Topic: Servo Motors and PWM  (Read 1543 times)

0 Members and 1 Guest are viewing this topic.

Offline freddie00Topic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Servo Motors and PWM
« on: October 12, 2011, 12:15:26 AM »
So this is probably a really easy question for someone.

I am just starting to work with servo motors, so I am trying to work up to doing PWM on a PIC microcontroller.  I attached my servos, to a signal generator, where 1.5ms was suppose to correspond to the center position, then when I increasing the duty cycle the motor rotated clockwise, if I trying to reduce the duty cycle it would not move counter clockwise.  It would just move along clockwise direction as duty cycle varied, but never move back from the furthest point it had moved.

Is this because my frequency is out of wack or something else?

Thanks.

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Servo Motors and PWM
« Reply #1 on: October 12, 2011, 12:45:58 AM »
Well, frequency should be 50Hz however, it would not affect servo too much if it gone up or down a bit.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Servo Motors and PWM
« Reply #2 on: October 12, 2011, 08:05:58 AM »
Hi,

I am just starting to work with servo motors, so I am trying to work up to doing PWM on a PIC microcontroller.
Not that it matters for the function, but servo signals are not PWM but rather PDM (Pulse Duration Modulation).


I attached my servos, to a signal generator, where 1.5ms was suppose to correspond to the center position, then when I increasing the duty cycle the motor rotated clockwise, if I trying to reduce the duty cycle it would not move counter clockwise.  It would just move along clockwise direction as duty cycle varied, but never move back from the furthest point it had moved.

Is this because my frequency is out of wack or something else?
Hard to say from only a (loose) description.

Is it a modified servo?
The servo itself may be at fault - have you checked this with another servo?

The timing of the signals, which you probably know, are pulses of 1ms to 2ms with a repetition rate of 20ms.
As newInRobotics stated, the repetition rate can differ a bit without causing any problems, as long as it is stable.
The pulses on the other hand must follow the 1..2ms - do you have access to an oscilloscope to test the duration of the pulses?

If you have only one servo and no 'scope, consider building a simple servo tester with a 555.

If you have a crystal earphone, a crystal microphone capsule or a piezo disc, you can use that for listening to the signal out of the PIC and compare it with a signal generated on your PC (adjust until there's no beat note, like when tuning a guitar) this will tell you the pulse repetition rate.

Posting the bit of the code you use to generate the pulse timing may be an option as well.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline freddie00Topic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: Servo Motors and PWM
« Reply #3 on: October 12, 2011, 10:06:02 AM »
The servo is a futaba S3114 with torque: 21 oz-in (1.5 kg/cm)  and speed: 0.10 sec/60°. The servo is not modified.  I took the servo to a hobby shop and the guy tested it with his RC controller, so I know that it works fine.

The function generator has a very simple command to set the pulse length, which I set to 1.5 ms, at a frequency of 20Hz, then I just varied the duty cycle.  I did not observe on oscilloscope but I have access to one.  I'm sure I would see exactly a 1.5ms pulse if I observed with oscilloscope.

The pulse is generated from a function generator, no coding here, I just want to use this to understand what code I must write.  THe function generator allows you to enter, amplitute, length of pulse, frequency, duty cycle... I should be able to simulate everything with this?

THe part about the pulse repetition rate sounds interesting because I do know how to tune a guitar, but I still dont know how it applies to what I'm doing.  I'm not actually using the PIC to control the servo yet.  I am using a function generator to learn how PWM/PDM works.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,943
  • Helpful? 98
Re: Servo Motors and PWM
« Reply #4 on: October 12, 2011, 06:56:00 PM »
Just on the off chance:
Did you connect ground and +5 Volts to the servo?

Offline freddie00Topic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: Servo Motors and PWM
« Reply #5 on: October 13, 2011, 10:34:48 AM »
yes

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,943
  • Helpful? 98
Re: Servo Motors and PWM
« Reply #6 on: October 13, 2011, 07:46:33 PM »
Does the function generator output a 0 to 5V signal?
Is there a amplitude and offset adjustments correct?
Is the pulse (1.5msec) positive going?
Do use an O'scope to check the signal.

Offline freddie00Topic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: Servo Motors and PWM
« Reply #7 on: October 14, 2011, 03:09:55 AM »
The signal was 0 - 5V.  There is an amplitude adjustment.  What do you mean by offset adjustment, and what will be the outcome of adjusting it?  The pulse was 1.5ms, positive going.  Then I varied the duty cycle, simply by selecting the duty cycle adjustment knob, and increasing, then the servo would move clockwise, but whenever varying the duty cycle the opposite direction, the servo did not move counter clockwise?

I didnt use an oscilloscope, I trusted the function generator.  I can use one next time.
« Last Edit: October 14, 2011, 03:11:20 AM by freddie00 »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Servo Motors and PWM
« Reply #8 on: October 14, 2011, 05:07:34 PM »
Hi,

The function generator has a very simple command to set the pulse length, which I set to 1.5 ms, at a frequency of 20Hz,
It's supposed to be 20ms, not 20Hz
20ms equates to 50Hz


then I just varied the duty cycle.  I did not observe on oscilloscope but I have access to one.  I'm sure I would see exactly a 1.5ms pulse if I observed with oscilloscope.
I'm sure it would be at least somewhere near the 1.5ms when you set it (don't know the precision of what you used), but you "varied the duty cycle" '(a good reason why people should realize that PWM and PDM is different things).
If you wanna view the signal as if it was (a small part) a PWM signal, you need to realize that the allowable range of duty cycle is only 5% to 10% of the 20ms period (with 7.5% being the center setting), so you need to take that into account when setting it.
Better 'scope it though.

To set/check the repeat rate of the pulse, listen to it together with a 50Hz signal generated on your computer - listen for the beat note and adjust until zero (or at least very slow) beating - as said, like tuning a guitar (unless you use one of the guitar tuners that just show you which way to tune for any given string).

'If you haven't got the means to make a 50Hz signal for comparison, I can make you a wav-file.
A continuous tone compresses really well sound file - a 100MB file can be packed (zipped) to a little over 200kB).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 


Get Your Ad Here