Arduino Mega 2560 Servo Jamming to Endpoint

Hello, this is my first post here, so I’ll try to follow the guidelines as much as I can.

I’ve been trying to use my Arduino Mega 2560 to control a servo. I’ve found that the analogWrite is for PWM, not PPM, which is what the servos use(?)
I’ve tried it with both a continuous rotation Futaba S3003 and an unmodified Spektrum Z270. The Z270 goes to it’s left endpoint, while the S3003 just turns at full speed clockwise. The servos are powered with a 4.5VDC wall plug, with a signal wire to the headers. I’ve tried different ports (PWM and non-PWM), and they all yield the same results. The servos aren’t faulty, since I can control them with a FlySky radio.
I’m powering the Arduino itself off of the supplied USB connector, although I’ve tried with a 9.7VDC input from a power supply.
I also haven’t been able to find anybody else with this problem on Google.

The program I’m using is the unmodified Sweep example, except for the pin changes.
Any help is appreciated, thanks in advance.

Xenoth

You only use the Servo command for servo's. PWM is not compatible.

Use the Servo library example that comes default with the arduino compiler. If memory recalls you just enter a value from 0-180.

Use a 5V source that does not come from a USB power, USB does not have the current for anything but perhaps 1-2 very low power servo's.

Connect the ground of your alternate power supply with the ground of the arduino.

I'm not sure about the mega but servo commands on the more common models (uno, leonardo) can be done from any pin.

Thanks! Looks like the servo just needed to be grounded (I modified the setup to run my Arduino on a 9VDC input and just used the 5VDC out from the board..)

Xenoth

Servo's do use exactly PWM, the width of the pulses, not their position, is what determines the servo position. However they normally expect around 50 pulses a second of duration 0.85 to 2ms.

To generate this kind of signal the Servo library uses the 16 bit timer1 and time-shares it amongst upto 12 pins.

You could drive a servo from timer1 directly, but not from timer0 or timer2 which are only 8 bit and too coarse a granularity.

Servo's do use exactly PWM, the width of the pulses, not their position, is what determines the servo position. However they normally expect around 50 pulses a second of duration 0.85 to 2ms.

AKA, don't put a PWM signal on a servo. Although ppm is a modified version of pwm, they are light years apart in real world compatibility.

If you don't know what you are talking about, please don't post to the forum as if you do.

Standard hobby servos use pulse width modulation, not pulse position modulation.

MarkT:
Standard hobby servos use pulse width modulation, not pulse position modulation.

One common application with these channel characteristics, first used in the early 1960s, is the radio control of model aircraft, boats and cars. PPM is employed in these systems, with the position of each pulse representing the angular position of an analogue control on the transmitter, or possible states of a binary switch. The number of pulses per frame gives the number of controllable channels available. The advantage of using PPM for this type of application is that the electronics required to decode the signal are extremely simple, which leads to small, light-weight receiver/decoder units. (Model aircraft require parts that are as lightweight as possible).

Servos made for model radio control include some of the electronics required to convert the pulse to the motor position – the receiver is merely required to demultiplex the separate channels and feed the pulses to each servo.

I think what is usually missed is that PPM is probably used between an RC transmitter and RC receiver only. The servo PWM is used between the RC receiver and the servo. The chip in the servo then produces a different motor control PWM to control the H-bridge in the servo.

zoomkat: I think what is usually missed is that PPM is probably used between an RC transmitter and RC receiver only. The servo PWM is used between the RC receiver and the servo.

Yes. Personally, I would prefer to refer to the receiver -> servo connection as PPM to distinguish it from generic PWM, due to the specific frequency and duty cycle used. But perhaps this would more properly be called de-multiplexed PPM.

You could in theory control a servo with pure PWM, but you'd need a lot of resolution to deal with the large dead time required between 50Hz pulses.

Servo's do NOT USE PPM. They use PWM. The clue is in the words "position" and "width".

However due to the precision needed (duty cycle ranges from 4.25% to 12% at a 50 pps rate), a 16 bit PWM timer is required - only two pins on the Uno support this resolution via timer1. Thus the Servo library which utilises the timer1 and interrupts to drive up to 12 pins with appropriate pulse widths at a 1us granularity.

The standard PWM setup at boot on the Uno is 8 bit resolution on all pins at 1kHz or 500Hz or so depending on timer, which indeed is not Servo-compatible, but that doesn't mean Servo's aren't PWM.

MarkT: Servo's do NOT USE PPM. They use PWM. The clue is in the words "position" and "width".

I agree that servos use PWM.

But it is rather unfortunate that the same term is used for the output from analogWrite() which is normally used in a fundamentally different way. The output from analogWrite() represents the power (to be made) available to an LED or a DC motor whereas the servo signal conveys position information to the servo controller.

Perhaps PWP - Pulse Width Positioning would be more appropriate for describing servo signals - but I have no expectation that the world will adopt my suggestion.

And personally I don't think PPM is a good way to describe the multiplexed servo signals from an R/C transmitter - although I recognize that it is often used for that purpose.

...R