Simple DC motor driver board

I needed to make a board to drive 6 DC motors (windshield wiper motors). In my opinion, the only interesting parts of this simple project are few tricks that I used to save microcontroller pins. Therefore I am not describing all the details here.

The board needs to drive up to 6 DC motors, forward and reverse. My windshield wiper motors consume about 2A of current at 12V. I designed my board for up to 3.5A continuous current or up to 5.5A for few seconds (for motor start). I was lucky with the motors because I could easily rewire them to isolate motor chassis (in a car windshield wiper motor the minus pole is connected to the motor chassis). On the other hand, brushes are not symmetrically mounted so I expect higher than normal wear of brushes when the motor runs in reverse.

The board is not designed for PWM regulation of motor speed, but a rudimentary (slow) PWM can be simulated by software if needed. Also, for my project I did not need more than one motor to run at the same time, so the power supply part was dimensioned to drive only one motor.

In addition to 6 bidirectional motor outputs, the board accepts 6 analog inputs – these are connected to multi-turn potentiometers used for motor position feedback (a rudimentary servo system). Also, a 4-digit 7-segment display is connected to the board. There is also a keyboard with 8 keys…. This requires a large number of input/output pins on a microcontroller.

But I prefer to use the tiny ATMega8 that only has 22 IO pins available (+reset pin).

Motor drivers

I used one output pin per motor. When this pin is in high-impedance state the motor is not powered; when it is high (5V) the motor is supplied with +12V; when it is low (0V) the motor gets -12V. I used symmetrical power supply (+12 and -12V) provided by a transformer that has two separate windings because it seemed simpler than to drive motors by H bridges.

I actually did not use two resistors (100ohm and 150ohm) because my +2.5V power supply had high internal resistance (I just divided the 5V power supply by two 50ohm resistors) and because I don’t have to drive two or more motors simultaneously. However if you opt for a ‘hard’ +2.5V supply, you need these two resistors to limit currents through small transistors. BTW, these two transistors are near their limit of 100mA and you might consider some more capable transistors for higher robustness.

The two diodes are for high-voltage protection generated when the motor (an inductive load) is turned off. For faster turn-off times, you should add resistors (say 3.3kohm) in parallel to these diodes, but I intentionally wanted slow turn-off time to decrease the voltage spike. I therefore used 1N4007 diodes. (Your power supply should have means to deal with over-voltages generated by the load).


I made s simple circuit to control up to 9 keys with only 3 microcontroller pins. The limitation is that it is not possible to hold down two keys simultaneously - the microcontroller might misinterpret the input.

In the above circuit the three 220 ohm resistors are not actually needed, but I used them to protect my microcontroller from any programming error. The three 68kohm resistors are internal in the microcontroller (pull-up resistors). I used tiny 1N4148 diodes.

The keyboard scanning schema is simple:
- configure one pin as output (drive it low) and two other pins as input (pull-up enabled)
- check the state of the two input pins and remember them
- do the same for every of the three pins
- deduce what key is pressed by looking at a logic-state table

For example if the ‘A’ key is held down then:
- when pin1 is driven low: pin2 will read low and pin3 will read high
- when pin2 is driven low: pin1 will read low and pin3 will read high
- when pin3 is driven low: pin1 will read high and pin2 will read high

In my case it was highly possible that the user will press keys D and E simultaneously which would read as if the F key is pressed. As a result, my keyboard only had 8 keys (no ‘F’ key) so that such misinterpretation was not possible.

The three microcontroller pins used to scan the keyboard are, in my case, MISO, MOSI and SCK pins that are used to program the chip. Therefore when I disconnect the keyboard, I can use the same connector to program the chip (the microcontroller reset signal is also provided on the connector).

7-segment display and analog inputs

I use 11 pins to drive the 4-digit, 7-segment display - this is a very standard solution. Four pins are used to select the digit, and 7 pins are used to drive LED segments. I intentionally wanted to use 7-segment display instead of some LCD display because of better visibility. However, I suspect that an LCD display with serial communication would use much smaller number of microcontroller pins.

I needed one decimal point at fixed position so I hardwired this LED. Whenever the corresponding digit is selected, its decimal point LED lights on. The only way I can turn off the decimal point LED is by not selecting that digit.

Because I am selecting digits in round-robin fashion, I decided to use the same four microcontroller outputs, that I use to select a digit, also to drive my analog input multiplexer. Therefore, analog readings are synchronized with the display refresh.

Only two analog input channels are used (two pins on the microcontroller). As there are four selection lines for the multiplexer, I can read up to eight analog signals.

As it can be seen, the analog input multiplexer is somewhat costly in term of components used. BC550 transistors are used to ground those analog signals that are not selected for reading by MUX lines. Only non-grounded analog signals are propagated toward the ‘analog bus’. Unfortunately, diodes (1N4148) generate about 0.6V voltage drop, making the usable analog input signal range to shift into 0.6-5.6V region (instead of 0-5V).

If you have any question or suggestion, just e-mail me... And recall that whenever you work on your projects you can benefit by using Math-o-mir, math notepad software.

Danijel Gorupec, 2015