Friday, December 21, 2012

12V-24V High-Current Motor Speed Controller Part-3

In first part we discussed about the detail of circuit, back EMF and Mosfet protection; and in second part we covered the display and menu, in this third and last part we will build and test our project. 

The DC Motor Speed Controller is built on two PC boards: a main board, and a display  board. These are joined together via a 12-way flat ribbon cable, which plugs into a pin header on the main board. 

The main board can be assembled first – see Fig.9. Start by checking the PC board for hairline cracks and for any visible shorts across the copper tracks, especially between the ground plane and any adjacent tracks. In addition, check the hole sizes for the larger hardware items by test fitting these parts into position.

Making a link
That done, begin by installing the 17 wire links. These must go in first, since some of them run underneath some components.

To straighten the link wire, first clamp one end in a vice, then stretch it slightly by pulling on the other end with a pair of pliers. It’s then just a matter of cutting the links to length and bending their leads down through 90° to match the holes in the PC board.

Note that resistor R1 should be 1kohm if the supply voltage will be higher than or equal to 16V. Alternatively, use a 100ohm resistor if the supply voltage is going to be less than 16V. The 22ohm 1W resistor (on the lefthand side of Fig.9) should be mounted 3mm to 4mm proud of the PC board to aid heat dissipation.

Once the resistors are in, install the diodes and the Zener diodes. Take care to ensure that these are all correctly oriented and note that diode D2 (near inductor L1) must be a 1N5819
Schottky type.

Take care also with the Zener diodes. ZD1 to ZD5 are all 16V 1W types, while ZD6 and ZD7 are 33V 5W types. The fast recovery diode (D3) can be left until later, as there are two
options for this.

The next thing to do is to solder in the four power MOSFETs (Q5 to Q8). These all come in a TO-220 package and sit horizontally on the PC board. Note that the source(s) lead of each device extends further than the other two. Before mounting each device, you will have to first position it on the PC board and bend its leads down through 90° so that they mate with the holes in the board. That done, fasten each device to the PC board using an M3 x 6mm screw and nut before soldering its leads.

Do not solder the leads before bolting the metal tab down. If you do, you risk stressing the soldered joints as the screw is tightened, and this could crack the copper or lift the pads.

The next thing to do is to solder in the two IC sockets. Make sure these are oriented correctly as per the component overlay. It is important that you use IC sockets because calibration of
the +5V rail is done with microcontroller IC1 out of circuit. This is described later during the setting-up stage.

Now the four bipolar transistors can be soldered in. There are three BC337 NPN types (Q2 to Q4) and one BC327 PNP type (Q1) – don’t get them mixed up. Their leads will only go in one way, and it’s just a matter of pushing them down onto the board as far as they will comfortably go before soldering the leads.

The single 3mm red LED can go in next, again taking care to orient it correctly. Its anode lead is the longer of the two; the cathode can also be identified by a ‘flat’ on the LED’s body.

Follow this with trimpot VR2 and the piezo buzzer. Note that the buzzer must be installed with its positive terminal towards the bottom edge of the board – see Fig.9.

Once these parts are in, you can solder the capacitors in place. The ceramic, monolithic and MKT polyester types can go in either way round, but be sure to orient the electrolytics
correctly. The large low-ESR 2200uF capacitor sits horizontally on the PC board, with its leads bent at 90° to go through the holes in the board.

The SPDT horizontal toggle switch (S1) can be soldered in next. Alternatively, this part can be mounted on a panel and connected back to the PC board via flying leads – it all depends
on how you intend mounting the board.

The 220uH toroid inductor (L1) sits vertically on the PC board – see photo. Be sure to strip the enamel from its leads and tin them with solder before attempting to solder it in position.

CON1, the 12-way header, is next on the list. This should be oriented as shown on Fig.9 and the photographs. That done, mount the two heavy-duty 3-way screw terminal blocks. Note that these are dovetailed together to make a 6-way block before mounting them on the board.

Potentiometer VR1 can now be installed. There are two possible locations on the board for this part. Mount it in the position that’s the most convenient for your application (but
don’t install a pot in both positions).

Alternatively, it can be mounted off the board and connected to its mounting pads via flying leads. Leave the two ICs out of their sockets for now. We’ll cover their installation later.

Fast recovery diode
Now for the fast recovery diode (D3). If you are using the 40EPF06PBF diode (rated at 40A), then this can be soldered straight in as shown in Fig.9 and the photo at left. Make sure that it goes in with its metal face towards the screw terminal block.

Alternatively, if you are using the two MBR20100CT 20A diodes, then these must be connected in parallel and installed as shown in Fig.10 and its accompanying photos. These particular diodes come in TO-220 packages and each package itself contains two 10A diodes, which are used in parallel.

The middle lead connects to the tab and is the cathode. This middle lead must be cut off using a small pair of sidecutters, as the tabs are used to make the cathode connections to the
board. The two outer leads of each device are the anode connections. The procedure for mounting these two diodes is as follows:
1) Drill the hole for the cathode connection on the PC board to 3mm.
2) Lightly tin the copper around the two mounting holes (this is necessary to ensure good contact with the screw heads).
3) Secure the metal tab of the first device to the PC board using an M3 × 12mm screw and nut, with the screw passing up from the underside of the board. Tighten the nut down firmly.
4) Install an M3 × 12mm screw through the hole at the anode end of the diodes, secure it with a nut, then fit a solder lug and secure it with a second nut. Again, make sure the nuts are done up tightly.
5) Solder the two outer leads of this first device to the solder lug, then fit another solder lug and nut.
6) Secure the tab of the second device in position and solder its outer leads to the top solder lug.

Building the display board
The display board is optional, but will be useful in many applications. If you decide not to build it, you will not be able to change the settings, and the default values will have to be used. You will also have no way of knowing what percentage of full speed the motor is running at.

As before, check the board for defects. In particular, check for shorts between copper tracks or between the ground plane and any adjacent tracks. Start the assembly by installing the
23 wire links. Some of these sit under the 7-segment LED displays, so make sure these links sit flat against the PC board. Don’t forget the short links immediately to the left of CON2 and at bottom right.

The resistors can go in next, followed by the 100nF capacitor and the four transistors (Q9 to Q12). If you are using an IC socket for IC3, then this can also now go in. Install it with its notched end positioned as indicated on the diagram, then install IC3 (74HC595).

Alternatively, IC3 can be directly soldered to the PC board. Be sure to install the IC with the correct orientation – ie, its notched end goes towards CON2.

Finally, complete the display board assembly by installing a 12-way pin header (this part is optional), the two pushbutton switches and the four 7-segment displays. Be sure to orient
the displays with the decimal points at bottom right.

Similarly, make sure that the push-button switches are correctly oriented. As shown in Fig.11, they must each be installed with the flat side towards the displays.

Connecting the boards
Once the board assemblies are complete, make up a 12-way ribbon cable to connect the two boards together. This should be terminated at either end to a 12-way header plug. Be sure to arrange this cable so that pin 1 of the header of the main board connects to pin 1 of the
header of the display board and so on. 

Once you have completed the construction, the next step is to go through the setting up procedure. You also need to adjust trimpot VR2 on the main board, so that the output from the MC30463 IC (IC2) sits at exactly +5V (this rail must be at exactly +5V to ensure that voltage measurements made by the microcontroller are accurate).

The set-up procedure is as follows:
1) Check that the two ICs on the main board are out of their sockets and that toggle switch S1 is in the OFF position (ie, the switch should be in the opposite position to that shown Fig.9).

2) Connect a 12V to 24V DC supply to the screw terminal blocks (check the supply voltage before you do this). Note that if you are connecting the supply leads directly to a battery,
there could be a spark when you first connect power due to the low-ESR 2200uF bypass capacitor across the supply. 

For this reason, connect the supply leads to the battery first, then to the terminal blocks, as it’s never a good idea to generate a spark near a battery.

As noted previously, resistor R1 should be 1kohm if you are using a supply greater than or equal to 16V. Alternatively, R1 should be 100ohm if you are using a supply less than 16V.

3) Apply power to the circuit by toggling S1 to ON.

4) Check the voltage on D1’s cathode. It should be about 0.6V less than the supply voltage.

5) Check the voltage on ZD1’s cathode. This should be very close to +16V if you are using a power supply that’s greater than 16V. Alternatively, it should sit between +12V and +16V if
you are using a 12-16V power supply. 

6) If these voltages are OK, switch off and install the MC34063 switchmode IC (IC2) into its socket. Make sure that the notch on the IC matches the notch on the socket – ie, the notch
must face towards inductor L1.

7) Apply power and check the voltage at pin 1 of the 12-way header on the main board. This is the +5V rail, but it may not yet be at exactly +5V (the exact voltage depends on the setting
of trimpot VR2).

8) Adjust VR2 until the voltage on pin 1 of the header is exactly +5V.

9) Assuming that the above voltage is now correctly set, switch off and insert microcontroller IC1 into its socket. Make sure that its notched end goes towards link LK11.

10) Plug the display board into the 12-way header and apply power. If everything is working correctly (and assuming a motor isn’t connected), the 4-digit display should immediately read ‘P00.0’, indicating the current speed.

11) If it all works correctly, skip the following troubleshooting section and go straight to the software initialisation procedure.

If you strike problems, the first thing to do is go back and check the board for any missed or bad solder joints. Check also that there are no shorts between tracks or between the ground plane and any adjacent tracks.

If these checks don’t reveal the problem, we suggest that you go through the following checklist:
1) Check that all 17 links are installed on the PC board. A missing link could mean that parts of the ground plane are floating and this will lead to improper operation!
2) Check that all polarised components, including the diodes, Zener diodes, electrolytic capacitors and ICs are correctly oriented as per the component overlay.
3) Check that you have used the correct value for R1, depending on your input supply voltage.
4) Make sure that the four transistors on the main board are the correct types. Q2 to Q4 are all BC337s but Q1 is a BC327 type.
5) Make sure that the input voltage connections to the 6-way terminal block are correct.

Software initialisation
If your boards are working, it is now time to initialise the software settings before connecting a motor. To do this, you must have the display board connected to the control board.

Note that more detailed user instructions for the DC Motor Speed Controller appeared in Part 1 and Part2. This section simply explains how to change the battery level alarm and the frequency of the PWM before you use the unit for the first time. These settings will be retained in non-volatile memory.

When the microcontroller begins executing the firmware (from a power-on reset) you should be taken straight to the main menu. This will indicate the percentage of full speed
that the motor is currently running at. Without a motor connected, it should read ‘P00.0’.

From here, press ‘short R’ twice (see Part 1) to arrive at the battery level alarm menu. This menu shows an ‘A’ followed by a 3-digit voltage value. which indicates the voltage level
below which the low battery alarm will sound.

In this menu, press ‘long L’ to set the level using potentiometer VR1. The ‘A’ should start flashing and you should then be able to vary the pot to change the level. Once you are happy
with the current level, press ‘short L’ to update the setting and return to the main menu.

Next, press ‘short R’ three times to arrive at the frequency menu. This will show an ‘F’ followed by a 3-digit frequency in kilohertz.

Once you are in this menu, press ‘long L’ and set the frequency of the PWM (pulse width modulation) using VR1. The ‘F’ should flash while you are setting the frequency. In practice, the frequency can be set to one of 256 values between 488Hz and 7812Hz.

Once you have set the desired frequency, press ‘short L’ to store the setting and return to the main menu. That’s it! For more detailed instructions on the other software modes, refer back to Part 1, and Part2.

Connecting the motor Once you have verified that the DC Motor Speed Controller is working
correctly, you can connect a motor. This should be connected with its positive terminal to the second terminal block from the top, while its negative terminal can go to either the
third or fourth terminal from the top.

Note that all supply and motor connections to the terminal block should be run using heavy-duty 56A wire.

The top terminal block is used to terminate the positive supply lead from the battery. This lead should connect via the 50A in-line fuse. Either of the bottom two terminals can be used for the negative battery lead (ie, one is left unused).

Your DC Motor Speed Controller is now ready for action. 


Downloads:Code n PCB Files


  1. Dear sir,
    thanks for the Article and also for the codes.

  2. Hi
    Will the motor run under the load correctly.

  3. Hi
    Will the motor run under the load correctly.

  4. Hi
    Will the motor run under the load correctly.

  5. Hi,
    What is the specification of toroid inductor.
    How much it shuold be the current resistive.
    What is the wattage of inductor (etc)...

  6. Did you know that you can create short urls with AdFly and get cash from every visitor to your short urls.

  7. Hi all,
    Where can I find code for micro controller?
    The link in the end of page is expired.