Home » Arduino » How to generate a PPM signal with Arduino to control a servo?

Login with your Social Account

How to generate a PPM signal with Arduino to control a servo?

  •  
  •  
  •  
  •  
  •  
  •  

Learn to control a servo with Arduino to position an axis of rotation (or control the speed of a wheel with a continuous rotation servo). Examples of connection and programming (both graphic and textual) are included.

A servo is an engine of direct current (DC) that has the electronics necessary to position the axis of rotation through the generation of a signal of pulse position modulation (PPM). The vast majority of servos use a standard in which the signal period is 20ms and can be moved from its position minimum with a pulse width (typically 0.5ms) to its maximum position (typically 2.5ms), passing by its intermediate position (normally are 1.50).

servo_pulse_width

Specification of the PPM to generate control signal comes from the scope of the radio control (RC), for this reason, controllers for brushless motors (electronic speed control or ESC) typically used in the drones are also controlled by signals PPM as the servos. In reality the PPM signal, is a PWM signal (pulse-modulated) with a frequency of 50 Hz for position control. Normally, the actuator allows you to control the position of an axis since it has an internal potentiometer that allows feedback on that position. Occasionally, and for simplicity, to control the speed of an axis of rotation, also can be used (continuous rotation) servomotors control is usually easier than the use of specific electronics based on bridges in H and PWM signals. Like position servos, continuous rotation servos supported a PPM signal with the same standard, normally having a trimming potentiometer to set zero speed with a 1.50 pulse width.

Types of servos:

The servo or servo motors are widely used in robotics and servo of many types and sizes can be found:

  • Submicroservos (0 – 5g): they offer pairs below the 1 Kg and power ranges tend to be between the 4.8V-6V.
  • Microservos (5g – 10g): they offer pairs below 2 Kg and power ranges tend to be between the 4.8V-6V.
  • Miniservos (11g – 20g): they offer pairs below the 4 Kg and power ranges tend to be between the 4.8V-6V.
  • Parkservo (21g – 30g): they offer pairs below the 7 Kg and power ranges tend to be between the 4.8V-6V.
  • Standard servo (31-49 g): they offer pairs below 15 Kg (normally) and the ranges of power tend to be between 4.8V-6V or 6V-7.4V.
  • Extralarge servo (50 g +): they offer pairs below 30 Kg (normally) and the ranges of power tend to be between 4.8V-6V or 6V-7.4V.

The angles of rotation of the servos depend on the model of engine and manufacturer, with what is suggested to access the features of each actuator leaves.

How to connect a servo?

Servos typically use a 3 pin connector and depending on the manufacturer, there are different variations on the connector and the colours used (the vast majority are compatible between them):

  • Futaba “J”: uses white-red colors – black.

J_connector_2

  • JR: uses colors orange – brown.

JR_connector_2

  • HITEC “s”, Airtronics z, Airtronics ‘t ‘: used yellow-red colors – black.
  • To avoid a possible incorrect connection, signal power is always on the pin in the middle.

To connect a servo to the Arduino, must take into consideration that the current required by the servo motor should not provide it Arduino 5V regulator, since this is designed for small currents (not supported beyond the 200mA) and thus most applications require a regulated external power. There are devices for this purpose which can obtain the necessary voltages for the servos in the field of the RC (5V or 6V, normally) capable of providing much higher currents (e.g.: 3A). These regulators are known by the acronym BEC (battery eliminator circuit) also known by UBEC (ultimate BEC) or SBEC (smart BEC). Only in the case that we want to control a submicroservo or microservo, I would recommend the use of the engine directly to Arduino.

On the other hand, we must bear in mind that Arduino has certain specific PIN to generate signal PWM (default), while properly managing the timers available, you could use any of the IO pins. In the case of the Arduino Nano v3.0, has 6 PWMs in the pin 3,5,6,9,10,11 with 8-bit resolution. The analogWrite() function allows to generate PWM signals, but to comply with the standards of the PPM signals, we should use the Arduino Servo library.

Below an example of a servo connection shown to Arduino Nano v3.0 using the IO expansion card:

servo_power_nano_io_bb

A cable (or jumper) can be used in and 3-pin (cables to extend the servo connectors) for the purpose of providing the 5V power through the UBEC. Ideally, feeds the UBEC 5V and the Arduino 5V (pin in the middle of the expansion card) should not mix, although it is not an additional problem. If the servo control does not consume much power we could dispense with the UBEC.

How to control the position of the servo?

The following file contains sample code for controlling the position of the servo using the Arduino IDE:

To control the position of the servo using Ardublock we use the block “Servo” in the menu “pins”, specifying the pin that we want to control and the angle of the servo (between 0 and 180). The specified angles do not have why be real angles, since in reality refer to minimum and maximum position. Each servo model can have a few different angles at its minimum and maximum position. If you want to specify the actual angles, you can use the “map” bloc within “utilities” (the example assumes an angle.

servo_ardublock

Download the program here:

In the case of continuous rotation servos (typically used to control the speed of rotation of a wheel), you can use the following sample program in Arduino IDE:

The equivalent code in Ardublock is:

servo_rotacion_ardublock

You can download here:

Where to buy?

Servos

Arduino

Jumpers

%d bloggers like this: