6

I have been controlling my servomotors for a while now only using pin 0. After some research, it has became apparent to me that the ports with ~ are the PWM pins.

I thought that all pins sent out PWM signals, therefore the motor was able to move back and forth. Now I'm really confused as to how the motor was able to turn without using a ~ pin like pin 5.

Can someone explain why I should or should not use PWM signal when controlling a motor?

1 Answer 1

3

Servos does not use PWM, it uses PPM:

  • PWM = Pulse width modulation, The pulse start at 0ms, and is high for the percentage of the time compared to the percentage of the voltage you want, 5v signal, if you want 1v, the pulse is 20ms High and 80ms Low.
  • PPM = Pulse position modulation, The pulse length is always 5ms High and 95ms low, but the interesting part is if high starts after 5ms or 50ms (or any other).

So PWM is to lower voltage, PPM is a signal pulse.

This means that no matter what port you are using on the arduino you are able to control a servo since you only need High or Low, and not a lower voltage.

What you need to be aware of in this case is on the arduino is a PPM signal is using up a timer. The arduino has 3 timers where of 2 is available, one is used internally. Though there is code where you can attach up to 3 servos on the same internal timer.

6
  • Just 2 links describing this better than i did: - endurance-rc.com/ppmtut.php - forum.arduino.cc/index.php/topic,14146.0.html Commented Sep 2, 2014 at 5:56
  • 2
    PWM doesn't change voltage. It just changes the duty cycle. If you setup the timer correctly you might be able to have it do PPM (pulse position modulation). But you would only be able to control one serve per timer.
    – Gerben
    Commented Sep 2, 2014 at 18:04
  • @Gerben sure PWM does not change voltage, but the effect of a 50% duty cycle of a 5v battery is roughly the same as just attaching a 2.5 volt battery, and to be exact you want to add a filter behind it to get the lowered voltage. But since i don't know my target audience i try to make it as basic as possible. Commented Sep 3, 2014 at 8:30
  • @Gerben Also edited wrong term, thanks for the correction. Commented Sep 4, 2014 at 9:23
  • 2
    -1. Your description of PWM vs PPM is correct, but you're wrong when you say servo control is PPM. It's PWM. Typically you'd vary the pulse width between 1ms and 2ms to control between fully left and fully right. See for instance this image. Commented May 9, 2015 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.