Modifying PWM signal for a servo

First and foremost, hello!

First post here and a great community from what I've been reading!

Now somewhat of a quandary I have...

I have a servo (actually 2) which I want to take the existing PWM signal and modify it by a predetermined factor, for example, 2, and have the servo move twice as far (no movement limitations on the motor).

In essence I'd like to use the board as an inline signal modifier for 2 individual servos that need to be moved that each have their own independent signal and modifying factor.

As I'm in the beginning stages of programming Arduino (small background in writing C) I'd like to be able to get a grasp on what would be necessary to make this project work and where abouts I should start looking.

Breakdown:

Input from original signal-> modify to desired signal-> output to servo with new positions based on new signal.

Any input is greatly appreciated!

Thanks in advance,

-J

So, this "original" PWM comes from somewhere else, and that's all you have? You can't get to the raw data creating the PWM? That signal is PWM and not a servo control pulse, right?

You can filter PWM to varying-DC with a low-pass filter. For servo speeds, a simple [u]RC Filter[/u] should do the job.

Run that DC into an analog input (I'm assuming 5V PWM?) and convert the A/D reading to an angle for the servo library. The map() function is one way to do that.

I'd probably start with porgramming & testingt the servos under software control, then work on converting the PWM to an angle, then combine everything.

you could measure the incoming PWM width with pulseIn() function. that gives the pulse width in microseconds.

The signal IN is a PWM too as well so I figure might as well just work from the most simple (going straight to the servo) rather than trying to figure out the original programming and whatever modifiers they have. However, I will be attempting to do that later on I just would like to get something to test for now so I can dummy fit everything. And yes, it is PWM =)

I have the two servos and I'll be testing them as I come up with coding because the servos moving is an important part but I'll also be adding a couple of other features (lighting to match the sweep of the servo) that I'll need to tie in together at some point.

I'll look into all the suggestions y'all have given me!

Thanks a bunch!

-J

and have the servo move twice as far (no movement limitations on the motor).

Or you could just put a 1:2 ratio gear/pulley pair on the output shaft.

Or, if the signal ultimately comes from an RC transmitter, you could get a transmitter with adjustable sensitivity and centering trims.

I wonder if jargon is getting in the way here?

PWM describes a regular square wave signal in which the width of the "on" part of the wave varies (perhaps from 0 - 100%) and it is usually used to drive a small electric motor as an alternative to providing a varying analogue voltage. Within reasonable limits the frequency of the square wave isn't very important.

It's confusing to describe a servo signal as PWM even if it may be technically correct. Servos are indeed controlled by a signal that has a varying pulse width, but it's a specialized signal with a single square wave pulse about once every 20milliseconds. In effect the width of the pulse tells the electronics inside the servo what position the servo arm should move to. Roughly speaking the pulse width varies between 1 and 2 ms with 1.5ms representing the centre position. But there will be some variation between individual servos. I have also seen servo signals described as PPM (pulse position modulation) but that doesn't really capture the idea either.

If you have something producing a servo signal that moves a servo arm to (say) 60degrees and you would prefer it to move to 120degrees then it will be necessary to capture the first pulse, measure its width and then output a longer pulse - and do it every 20ms. This should be well within the capabilities of an Arduino.

...R

Input from original signal-> modify to desired signal-> output to servo with new positions based on new signal.

Any input is greatly appreciated!

Pretty simple.

  1. Measure the pulse width of the incoming PWM signal using the arduino pulseIn(pin, value) function.
  2. Calculate the duty cycle value of the PWM pulse compared to it's possible input range.
  3. Modify this value according to your requirements.
  4. Map this value into the output range of the servo.write range of your servo using the arduino
    servo library.

Lefty

It's confusing to describe a servo signal as PWM

Displacement is proportional to pulse width.
What's confusing about that?

I have also seen servo signals described as PPM (pulse position modulation) but that doesn't really capture the idea either.

When they're in a multiplexed stream between transmitter and receiver, then those same PWM pulses are indeed PPM.