Home About Technology Travel Pictures

I2C Servo Switch

On this page I want to describe the development of a servo controller. It is part of my Flobo project but will have a modular design to be used for other purposes too. But first I want to describe how servo control works in general.

To understand the funtionality of PPM decoding a RC receiver was opened.

Figure 1: Test setup

Here you can see the CMOS IC 4017 which seems to transform the PPM signal to several PWM signal lines to the serovs

Figure 2: Decoding circuit of the RC receiver

The 4017 is a Decade Counter that counts the input frequency and passes pulses on to its 10 output pins. The reset input is used to set the counter back to zero. After a reset or counter overflow the output pin 0 is accessed. An additional output divides the input frequency by 10. However it is not used in this context. Here the 4017 is used to split the signal pulses bundled with the PPM signal to the several servo outputs. The PPM signal is thereby connected to the input pin 14 (Clock Input).

Figure 3: PPM-Signal at pin 14

A reset signal - generated from the PPM by the receiver - is connected to pin 15. The reset is probably triggered after no High-to-Low edge occured within 4 milliseconds.

Figure 4: Correlation between Reset and servo pulse for channel 1

From Figure 4 you can read that the time of a complete PPM cycle is about 22 ms. The RC transmitter generates a total of 8 pulses which means that a maximum of 7 servos can be controlled because the last pulse is used for Reset. The servo position is encoded as the time distance between two Low-High edges. This distance has a minimun of 1 ms and maximum of 2 ms. In Figure 5 you can seed channel 6 and 7 in minimum and maximum position. The bigger gap between the edges is obvious.

Figure 5: Effect of different lever positions on the distance of PPM egdes

In the case of 7 channels to transmit a minimum of 7 ms and maximum of 14 ms is required for encoding of servo positions. In a cycle of 22 ms a remainder of 8 ms is left for reset and probably additional channels. See also the information on PPM-encoding by MFTech.

Figure 6: Effect of different lever positions to the servo pulse width

Figure 6 shows the correlation of the PPM and decoded servo signal. The servo signal is also called PWM signal (Pulse Width Modulation) because the servo position is defined by the width of the pulse (High). A Low-High edge starts the pulse and the next stops it. As figure 7 shows the end of servo 1 pulse is immediately followed by the start of servo 2 pulse.

Figure 7: Sequence of servo pulses for channel 1 and 2

Most RC receivers deliver the raw PPM signal at the third pin of their battery connector. In the Graupner receivers I tested the signal has a voltage of only 0.9 V and must therefore be amplified. The Op Amps LM324 or LM358 were used for this task. With the help of a test circuit I was able to measure the servo pulse width depending on the joystick position of the RC transmitter. The MC-15 by Graupner uses an absolute Range from -150% to +150% to display servo positions (on calibration). See the following table for results:

Joystick positionPulse width in ms

Accordingly one percent servo path is equivalent to 4 milliseconds.

This knowledge was useful for the generation of servo pulses by a microcontroller. A modul was developed that can convert the PPM signal into servo positions and transfer those position via I2C. Furthermore it can switch between different operation modes depending on the position of a determined RC channel and the awareness of I2C commands. One or more servo signals can be masked and replaced by synthesized signals as configured.

The following picture shows a schema and board layout of a suitable circuit. Most attention was payed for the layout to save space. The board has a dimension of 32 x 20 mm and can be mounted directly on a RC receiver. The I2C connector contains an additional pin for Vcc. This was necessary to drive a I2C level shifter which needs a reference voltage to convert the signals.


Board Layout

The next generation - version 5 - fixes some problems the earlier prototype showed. It uses the LM358 rather than the u741 which proved to be inappropriate for amplification. The current version can now successfully decode the PPM signal and drive the servos.

Figure 8: Servo controller mounted on a RC receiver

The software development has moved forward as well in the last months. It now has complete servo drive functionality, I2C slave receive and transmit mode and finally the PPM processing. The current firmware version 0.12 has the following features:

  • I2C slave address: 0x60
  • set servo position using byte sequence "AA nx xx" and "BA nx xx", where n is the servo number (4 Bit) and xxx the pulse width of the servo signal (12 Bit)
  • command "AA" sets servo postion immediately, "BA" uses the "Soft Drive" that slowly moves the servo to the target position
  • read out the current remote control settings via I2C
  • save the position of all servos into EEPROM when the push button is pressed
  • RC channel 7 is used to switch between RC mode and I2C control
  • LED displayes the current mode using different blink sequences
Download:Firmware and SourcecodeSource for I2C master

Meanwhile the circuit can be connected to the parallel developed Gumstix adapter board. Using a shell script I2C commands are send to two servos, as shown in this short video (1.2MB).

Based on the experience with the servo switch a new solution was developed end of 2009. The new PPM Switch is integrated closer to the R/C receiver and shall improve transmission range due to the use of opto couplers. Therefore further development of the servo switch was discontinued.

03.01.2010, Achim Walther, Mail