Pulse Width Modulation motor control
By Michael Adler and Fred Culpepper

Continued from issue 6

In the previous issue of Electronics in Meccano I outlined the principles of Pulse Width Modulation (PWM).

The PWM circuit in figure 1 uses two NE555 ICs and is actually a combination of two circuits. The first is a free running astable multivibrator with a frequency of about 1.2kHz. The output of this circuit then triggers a pulse shaping (monostable) circuit which adjusts the width of the pulse. The circuit produces a duty cycle of approximately 3% to 97%.

The NE555 astable and monostable circuits are discussed in issue 3 and issue 4 respectively.

Click here to read this datasheet in Adobe Acrobat format 555 Timer Datasheet
141Kb

The speed of the motor is controlled with a single potentiometer speed control. It is possible to run an M5 motor to test the circuit. This can run from dead still to full speed using the potentiometer speed control and a 6v battery as the sole power source.

A BFY51 transistor is shown connected to the output of the second NE555 IC so that motors with a higher current consumption can be driven.

Contrast with: Simple motor control , Rotary switch motor control

Figure 1: Circuit diagram of the NE555 pulse width modulation unit

Goto top of page


Digital electronics: Logic IC reduction

Looking at the logic gate ICs available, you will see that many of them have more than one gate in their package. For example, there are six NOT gates in the 4069 package. Therefore it would be an advantage if the circuit that one wishes to build could be made entirely from one type of gate, thus using all the gates available on each IC, and possibly reducing the number of ICs required.

Every type of logic gate can be built from combinations of NAND gates. The equivalent circuits of the NOT, AND and OR gates are shown in figure 2, and it is a simple matter of substituting these for other gates as appropriate in your circuits.

Figure 2: How the NOT, AND and OR gates can be made from NAND gates

An example circuit is shown in figure 3a. Figure 3b shows the same circuit using only NAND gates.  Notice that in replacing gates with their NAND gate equivalents, there are now some duplicated ‘NOT’ gates (marked with an X) which can be removed to leave the final circuit looking like the one in figure 3c.  The original circuit used 3 ICs (1 x NOT, 1 x AND, 1 x OR), but the final one uses 1 IC (2 x NAND).

Note that combinations of NOR gates can also be used as substitutes for other logic gates, but that the circuits will be different.

See also: Digital electronics: Logic gates

Figure 3: The conversion of a logic circuit to NAND gates only

Goto top of page


Digital electronics: Counters

A counter IC counts the number of pulses that enter its Clock (CK) input and provides outputs that indicate the value of the count.

Number systems

Digital counter ICs do not normally count using the decimal (base 10) number system. Instead they use the binary (base 2) number system which has only two digits: 0 and 1. Another numbering system used in digital electronics, especially in computing applications, is hexadecimal (base 16). This has 16 digits: 0 to 9 and then A to F. A table showing all three systems for decimal values 0 to 15 is shown on the right. To avoid confusion I will always put ‘d’, ‘b’ or ‘h’ in subscript after numbers in this article.

In digital electronics we say that one binary digit is called a ‘bit’. The name comes from the words ‘BInary digiT’. From the table you can see that to represent the value 15 d, four binary bits, 1111 b, are needed. This is known as a 4-bit number. An 8-bit binary number can represent decimal values up to 255 d and is called a ‘byte’. This name is thought to be a contraction of the words ‘by eight’. The left-most bit of a binary number is called the Most Significant Bit (MSB) and the right-most bit is called the Least Significant Bit (LSB).

To convert a binary number into a decimal number, look at the decimal numbers printed above each bit in the conversion table. Start with a total of zero, and work along the columns of the binary number from left to right (MSB to LSB). Wherever you see a 1 b , add the number at the top of the column to your total. Ignore the 0’s.

For example, the number 1010 b is 8 d + 0 d + 2 d + 0 d = 10d. You can work backwards to convert a decimal number into a binary number.

Decimal

Hexadecimal

Binary

 

 

8

4

2

1

0

0

0

0

0

0

1

1

0

0

0

1

2

2

0

0

1

0

3

3

0

0

1

1

4

4

0

1

0

0

5

5

0

1

0

1

6

6

0

1

1

0

7

7

0

1

1

1

8

8

1

0

0

0

9

9

1

0

0

1

10

A

1

0

1

0

11

B

1

0

1

1

12

C

1

1

0

0

13

D

1

1

0

1

14

E

1

1

1

0

15

F

1

1

1

1

Figure 5: Pinout of the 4520 counter ICCounting, counting, 1, 2, 3...

Even though the binary number system only uses two digits, it still obeys the rules of mathematics. If a 2-bit counter starts at 00 b and the CK input is pulsed, the counter will count to 01 b. After the next CK pulse the counter will count to 10b – there is a carry into the second column, in the same way that adding 1 d to 9 d in decimal gives 10 d. The next CK pulse gives 11 b and the next gives 00 b, because this is only a 2-bit counter and it therefore resets to zero.

The 4520 counter IC

The 4520 shown in figure 5 contains two identical and independent 4-bit binary counters. For each one there is a Clock (CK) input, a Reset (R) input, an Enable (EN) input, and four counter outputs (QA to QD). The output QA is the LSB and the output QD is the MSB.

In order for the counter to operate, the EN input must be taken high to +Vs and the R input must be taken low to 0V.
If the EN input is taken low, then the counter will not respond to pulses on the CK input. If the R input is taken high, then the counter resets to 0000 b.

Click here to read this datasheet in Adobe Acrobat format 4520 2x Counter Datasheet
323Kb

Building a counter circuit

When you try building the circuit in figure 6 to test out the counter, you will probably encounter a problem called ‘contact bounce‘. The circuit uses a simple push button to act as the CK input. When you push the button down, the counter will probably count more than once due to the contacts of the button ‘bouncing’ before they settle. Even though the contacts settle very rapidly, the bounce is enough to clock the counter. This is where the NE555 circuits from the previous issues of Electronics in Meccano become useful. By connecting the output of a monostable circuit (issue 4) to the CK input, you can ‘de-bounce’ the push button so that the counter only receives one clock pulse each time the button is pushed. The time period of the monostable circuit needs to be just long enough for the switch contacts to settle; try 220ms by using 10mF for C and 22kW for R.

If you would like the counter to count automatically, clock it from the output of an NE555 astable circuit (issue 3), setting the frequency as desired.

Remember that the NE555, 4520 and all other logic ICs (such as logic gates) will work together so long as they are all using the same power supply – you could clock the counter from the output of a logic gate, for example.

Figure 6: A test circuit for the 4520 counter IC

Figure 4: Resetting a counter on 12dI want to count to 10…

If you want a counter that will count from 0 d to 9d, you could use a Binary Coded Decimal (BCD) counter IC such as the 4518. A BCD counter counts from 0000 b to 1001 b and then resets – the other values from 1010 b to 1111 b will not appear on the counter output. You will also find ICs that can operate in either binary or BCD mode depending on the state of one of their pins – an example is the 4029.

If you would like to be able to have any number of states in your counter, such as 4d or 12d, you can use logic gates to reset the counter. For example, to make a counter have twelve states (0d to 11d), you need to reset the counter to zero when it is clocked to 12d. Since 12d in binary is 1100 b, connect the inputs of an AND gate to QC and QD of the counter and the output of the AND gate to the R input of the counter. This is shown in figure 4.

To reset on 4d is even easier and does not even require a logic gate – just connect QC to R.

Click here to read this datasheet in Adobe Acrobat format 4518 Counter Datasheet
323Kb

Other features of counter ICs

Some counters, such as the 4029, have an UP/DOWN input. When this is taken high, the counter will count upwards when clocked, when it is taken low, the counter will count downwards when clocked.

The 4029 also allows its output to be preset to any value.  Set the inputs A, B, C and D as required and take the Program Enable (PE) input high to preset the counter.

Yet another feature of the 4029 and some other counter ICs is ‘daisy chaining’. The 4029 has a Carry Out (COUT) output which can be connected to the EN input of another 4029 IC to create an 8-bit counter. You could add a third IC to get a 12-bit counter – to count up to 4096d! The clock pulse is input to the CK inputs of all the 4029 ICs.

Click here to read this datasheet in Adobe Acrobat format 4029 Counter Datasheet
296Kb

Ripple and synchronous counters

Some counter ICs have simple ‘ripple’ circuits where the outputs of the IC do not all change at the same time in response to a clock pulse. In these ICs, QA changes first, then QB, then QC, and then QD. Each change takes a small amount of time, so there will be periods where the value of the count is invalid. As this could be a problem in some circuits, ‘synchronous’ counter ICs are available which avoid this problem using a ‘look-ahead’ circuit.
The 4029 counter is a ‘synchronous’ counter – all of its outputs change state at exactly the same time.

Goto top of page


Rotary switch motor controllers
By John Hewes

Described below are two motor controllers that can be built using the simplest of components – a rotary switch, diodes and resistors. The diodes and resistors can be soldered directly onto the tags of the rotary switch, avoiding the use of breadboard or stripboard.

Controller 1: Forward/Reverse at 2 speeds with centre-off

This controller, shown in figure 7, is powered from an AC supply and uses six diodes in an arrangement that allows the motor to rotate at half or full speed, in either the forward or reverse direction.

The rotary switch used is a 6-way type with two poles, but only five positions are needed for this controller. To set the number of position, prise off the metal ring on the top of the switch with a screwdriver. You will see a legend from ‘2’ to ‘5’, so move the ring to the ’5’ position. Note that to get 6 positions, you would leave the ring off permanently.

Controller 2: Forward/Reverse at 4 speeds with centre-off

The controller in figure 8 is similar to the one described above, except that it uses resistors as well as diodes to provide extra speed settings. It also requires a ‘wafer’ switch to be used, so is slightly more complicated to assemble.

Resistors R1 and R2 must be chosen to suit the requirements of the motor to be controlled. The value of R1 should probably be the same as the value of R2, and for typical Meccano motors would be between 5W and 25W.  The resistors will need to be wire-wound and rated for high power – at least 3W and certainly more for medium sized motors.

Lamps such as torch bulbs (3.5V, 0.2A rating) could be used instead of the resistors – they have the advantage of a lower resistance when first switched on, giving the motor an initial surge of power to overcome inertia in the mechanism.  This would be especially useful at the low speed settings
(+1 and –1) where the motor may be reluctant to start despite running quite happily once it has started!

Wafer switches

As mentioned previously, this controller requires a two pole wafer switch. Wafer switches, such as the MakaSwitch range from Maplin Electronics, consist of several parts:

The top half of figure 8 shows the first of the wafers in the four-speed motor controller. One lead from the motor is connected to the common of this wafer, the other lead is connected to the common of the second wafer.  Other connections to the second wafer are between it and the first wafer – connect a wire from contact +1 of the first wafer to contact –1 of the second wafer, a wire from contact +2 of the first wafer to contact –2 of the second wafer, etc. This is shown in the bottom half of figure 8.

Six diodes are required for each controller, although in fact one of these diodes could be omitted, but I think it is better left in to keep the design symmetric, reducing the chance of an error occurring – diodes are cheap after all! Use a 1N4001 diode for currents up to 1A, or a 1N5400 for currents up to 3A.

Pictures of the MakaSwitch wafer and shaft assembly

In issue 8 we will look at a circuit which uses a pair of transistors to provide a variable speed motor control with negative feedback.

See also: Simple motor control , Motor control with a Darlington Pair

Goto top of page


Title: Shopping ListThe following lists the electrical parts that are discussed in the articles. Prices and order codes given are taken from the current Maplin catalogue, which is the probably best source of electronic components for the hobbyist in the UK.

If you have access to a company account with Rapid Electronics or RS Electronics you may find these companies are cheaper.

Pulse Width Modulation motor control
 
Parts needed for the PWM controller in Figure 1 to be constructed on stripboard
Maplin Order Code Price Page
2 x NE555 Timer IC QH66W 29p 292
2 x 8-pin IC holder BL17T 14p 304
1 x 560pF Capacitor WX65V 13p 89
1 x 0.1mF Capacitor BX76H 15p 91
3 x 0.01mF Capacitor BX70M 15p 91
1 x 82kW Resistor M82K 7p 221
1 x 8.2kW Resistor M8K2 7p 221
1 x 1MW Linear variable resistor FW28F 89p 226
1 x BFY51 Transistor QF28F 49p 247
1 x 1N4148 Signal diode QL80B 8p 246
Stripboard (about 24 holes x 12 rows) JP47B £1.79 204
Digital electronics: Logic IC reduction
Maplin Order Code Price Page
4011 NAND gate IC (4 in package) QX05F 39p 250
Digital electronics: Counters
 
Parts needed for the counter test circuit in Figure 6 to be constructed on stripboard.  The push button is used to clock the counter.  An alternative may be to use a regular pulse from the NE555 Astable circuit in issue 3.
Maplin Order Code Price Page
1 x 4520 Counter IC QX33L 99p 250
1 x 16-pin IC holder BL19V 19p 304
1 x 1kW Resistor M1K 7p 221
4 x 220W Resistor M220R 7p 221
4 x 5mm Red LED WL27E 9p 181
1 x Push button FH59P 59p 314
Also mentioned in the article:
4029 Counter IC QW20W 99p 250
Rotary switch motor controllers
Maplin Order Code Price Page
2-pole 6-way rotary switch FF74R £1.19 310
MakaSwitch shaft assembly FH46A £3.69 310
MakaSwitch 1-pole 12-way wafer FH47B £2.49 310
1N4001 (1A) Rectifier diode QL73Q 5p 246
1N5400 (3A) Rectifier diode QL81C 11p 246

Maplin charge £2.50 for delivery on orders under £30.00 inc. VAT.
Prices are taken from the September 2000 - August 2001 Maplin catalogue, and include VAT at 17.5%

Contact their order line on 0870 264 6000 or visit one of their shops.
Their customer service line is 0870 264 6002 and they have a website at www.maplin.co.uk where on-line ordering is available.

Goto top of page


EiM Logo

www.eleinmec.freeserve.co.uk

Electronics in Meccano April 2000 -- Issue 7

Edited by Tim Surtell
E-mail: timsurtell@eleinmec.freeserve.co.uk


| Home | Contents of Issues | Index | About | Letters | Printed Edition | Circuits Shop | Wizards | SELMEC | Links |