Introduction: DIY Brushed Motor ESC Using Arduino and L298N H-Bridge
Arduino-compatible modules and remote control-compatible modules are quite differently made, especially in what communication protocols they use. An Arduino-compatible module such as L298N receives on and off signals and is really best controlled by programmatically sending these signals to its inputs. Meanwhile, the signals used for RC equipment, pulse position modulated (PPM) signals, are designed to control servo motors by sending numbers encoded in a serial fashion. The conversion between these are better done using a manufactured circuit called ESC (electrical speed controller); however, although ESCs for brushless motors are easy to find and cheap, it is apparently not the case for brushed motor. I could only find a single brushed ESC model that costed twice the cost of an average brushless ESC.
Fortunately, I had more toys to play with. The L298N module and the Arduino Pro Mini which I have a lot of experience with are both dirt cheap and not too complicated to assemble a circuit of this kind with. A had some code from the Destination Imagination challenge I participated in a couple of years ago and had these parts ready to waste, so I was happy to put this together for a good friend of mine. If that's enough rationale, we can begin.
- L298N H-bridge Breakout Board
- Arduino Pro Mini clone (or other Arduino Uno-compatible board)
- Another Arduino (preferably some junk Uno) to program the Pro Mini
- female-female and male-female breadboard jumper wire
- 9V battery socket (or other, according to your motor voltage needs)
Note that the circuit is designed having a FlySky IA6B radio receiver in mind. It should be a generic-enough receiver, but make sure if your receiver has specific requirements for connected devices. Comment below if you have questions.
Step 1: Prepare Your Boards
Solder pins on your Arduino Pro Mini. Soldering pins
- on either programming header or pins reset, 11, 12, 13 (to program the board)
- on pin 9
- on pin 13 :p
- on pin 2
- all VCC pins, including the ones in programming pins
- all GND pins, including the ones in programming pins
is enough; however, I recommend soldering on all pins so you can use the Arduino for other projects.
There is no preparation necessary for the L298N board. At least make sure the two-pin jumpers are still on there.
Step 2: Connect Everything
Make the following connections with female-female jumper cables.
- Pin 13 of Arduino goes to EN1 of L298N
- A GND pin of Arduino goes to IN1 of L298N
- Pin 9 of Arduino goes to IN2 of L298N
The following connections are a bit more involved.
- Cut one end of a jumper so you have a naked-female jumper wire. Remove the insulation from the naked end and twist around/solder with the battery socket's negative end. Put this joined end in the L298N's ground terminal. Connect the female end to one of the Arduino's remaining GND pins.
- Put the battery socket's positive end in L298N's 12V terminal.
- Put the male end of a male-female jumper in L298N's 5V terminal and connect the female end to one of Arduino's VCC pins.
- Separate a yellow-red-brown group of female-female jumper. This will connect to the receiver. Connect one brown end to the Arduino's free GND pin, one red end to the free VCC pin, and one yellow end to pin 2.
Before programming, disconnect the jumper cable coming from L298N's 5V!
Step 3: Program the Arduino
WARNING! Before programming, disconnect the jumper cable coming from L298N's 5V!
Also, I used this board core to enable programming the Pro Mini using the Arduino IDE.
Step 4: Connect Your ESC to Your Vehicle
Connect the motor to L298N's left hand side motor output terminal, when looking from the side of power terminals.
Connecting to the receiver might be troublesome. The ESC will connect like a servo, and will also power the receiver if you don't remove the jumpers. The red power cable will go to the middle pin, the yellow signal to the notched side pin, and the brown ground cable to the other pin. If you don't see a notch look for a label on the receiver packaging. If you don't see a label, well, good luck. :)
If you are using an airplane-oriented radio receiver, you will connect all receiver cables in the desired channel. If you have a quadcopter-oriented radio receiver, however, you might have a separate battery channel. If the latter is the case for you, connect the red and brown wires to that channel and the yellow cable to the desired channel.
(I guess you can power a quadcopter radio receiver from all channels, but I am not sure or can try right now.)