Controlling Servos With RC Controller

From AutonomousPrime Senior Design
Jump to: navigation, search

In order to control the vehicle we needed to be able to interpret a PPM Signal from either the RC Controller itself, or the onboard computer that is running the neural network.

Capturing PPM Signal

Implementing reading of PPM (Pulse Position Modulation) on the on-board Arduino was a simple task. Using this tutorial (PPM Signal Capture), you can plug any PPM receiver with up to 16 channels into the Arduino and it will print out the channel values to the serial output without any modifications to the file.

Controlling Servos

To control the servos for our RC car, steering and throttle, with the Arduino, we needed to take the incoming PPM signals from channels 1 and 2, and send their values to the servos. Arduino provides a very helpful Servo library just for this type of control. Unfortunately, due to the setup of our PPM capturing software using Timer1 to capture the signals, we cannot use this library. To properly implement the servos, we had to download and utilize the ServoTimer2 library located here. This library utilizes Arduino's Timer2 instead of Timer1, allowing us to control the servos while using Timer1 for the PPM capture. ServoTimer2 has most of the same functions as Servo, but the functions are listed here for reference.

ServoTimer2 Compilation Issues

Unfortunately, according to many internet forums on this topic, due to updates to Arduino's IDE (currently version 1.8.2) there are various compilation issues with the ServoTimer2 library. The solutions to these compilation issues are located at these places.

The updated versions of the library files we ended up using are posted here for convenience. Place these files in a folder entitled ServoTimer2 in your Arduino/Libraries directory.

Final Arduino Code

The Arduino code will be modified more as we refine the PPM capture and servo controls, but as of 04/01/2017, this is our Arduino code.

DO NOT CONNECT AN ELECTRONIC SPEED CONTROLLER (ESC) TO 5V POWER SOURCE ON ARDUINO IF YOUR ARDUINO IS CONNECTED TO A COMPUTER VIA USB

THIS HAS THE POSSIBILITY OF BURNING OUT YOUR USB PORT AS WELL AS YOUR COMPUTER




Return to Main Page