Let's learn how to read PWM signals from an RC receiver!
The first step in creating a combat bot is to get something driving! Without the ability to move, you can’t compete. Even with just a couple of gearmotors, wheels and a receiver, you can create a simple rammer or wedge bot capable of pushing opponents into hazards. On this episode of “Adventures in Science,” we look at reading signals from an RC transmitter and receiver set.
Most RC controllers, like the one shown in the video, send out wireless signals to a receiver. When you buy a transmitter/receiver set, the receiver can be used with a whole host of applications and is often used to control servos and motors. You really only need two channels (forward/backward and left/right) to make a drivable robot, but if you’re looking to control a weapon on your bot, getting something with a third channel is advisable.
Specialized modules, called Electronic Speed Control (ESC) units, can be purchased that accept the Pulse-Width Modulated (PWM) signals from a variety of RC receivers. However, we can measure these pulse widths using the
pulseIn() function in Arduino and use it to control motors.
In the video, we read the pulse width from one channel, which can range from 1000 μs to 2000 μs and set the speed and direction of the motor accordingly. Note that we’re using a control stick that returns to center, so full back is supposed to be 1000 μs, center is 1500 μs, and full forward is 2000 μs. In reality, back is around 1100 μs, center is close to 1500 μs, and forward is near 1800 μs. We use a bit of math to convert that number to a PWM signal intended for motors (0 to 255).
We demonstrate this technique using one channel, so you can only drive back and forth. Not really useful for a combat bot, but it’s a start. Next time, we’ll look at mixing in a second channel for steering!
The demo code in the video can be found here.
What other tips can you offer for wiring up a receiver in a combat bot? I know, leaving everything on a breadboard isn’t ideal.