Sunteți pe pagina 1din 2

designideas

EditEd By Martin rowE and Fran GranvillE

readerS SOLVe deSIGN PrOBLeMS

Control a dc motor with your PC


Firas M Ali Al-Raie, Polytechnic Higher Institute of Yefren, Yefren, Libya

DIs Inside
42 Look-up table eliminates the need for an IC 44 Operate circuits from voltages as high as 540V ac 46 Microcontroller supervises 0- to 20-mA protection circuit 47 LED indicates power source
to see all of EDNs design ideas, visit www.edn.com/designideas.

The circuit in this Design Idea controls the speed of a 5V permanent-magnet dc motor through the PCs parallel port (Figure 1). You use the C++ computer program, available at www. edn.com/100826dia, to run the motor at three speeds. The circuit uses PWM (pulse-width modulation) to change the average value of the voltage to the dc motor. You connect the motor to the PCs parallel port with an interface circuit. The design comprises IC 1, a 74LS244 buffer; IC2, a ULN2003 driver; relay switches S1, S2, and S3; IC3, a 555 astable multivibrator circuit; and Q1, a 2N2222 driving transistor. The 555 timer

operates as a variable-pulse-width generator. You change the pulse width by using relays to insert or split resistors in the 555 circuit. The computer program controls these resistors. When S1 is on and both S2 and S3 are off, the timer output is set to logic one, thereby driving the motor with its maximum speed. When S1 and S2 are on, the 555 timer generates a pulse signal with a 50% duty cycle. In this case, the charging resistor, RA1, is equal to the discharging resistor, RB. In the third case, S1 and S3 are on, and the charging resistor is RA2,where RA2=0.1RB, reducing the on time of the pulse signal and,
5V

consequently, the speed of the motor to the lower limit. Table 1 summarizes the on/off-operation conditions of the relays and the corresponding dc-motor speeds.

S3 PC PARALLEL PORT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 D0 D1 D2 2 4 6 5V 5V 20 18 16 14 IC1 74LS244 1 2 3 5V 9 14 15 16 IC2 ULN2003 8 IN4148 RB 47k C1 10 nF

S2

5V RA2 4.7k IN4148

5V

IN4148

RA1 47k

4 7

10 1 19

IC3 NE555 3 6 2 1 5

R1 1k 5V C2 0.1 F

+ M

5V DC MOTOR

Q1 2N2222

S1

Figure 1 This circuit controls the speed of a 5V permanent-magnet motor through the PCs parallel port.

August 26, 2010 | EDN 41

designideas
The code prompts you to select a certain speed, stores your selection as an integer variable choice, generates the proper digital sequence, and stores it at another integer variable. You place the value of the integer variable data at a PCs parallel port using the outportb function. The program uses the kbhit function to stop the motor when you hit any key on the keyboard.EDN

TAbLE 1 Switch StateS and generated Pc SequenceS


S3 Off Off Off On S2 Off Off On Off S1 Off On On On Equivalent digital sequence 000 001 011 101 Motor speed Stop Maximum Medium Minimum

Look-up table eliminates the need for an IC


Abel Raynus, Armatron International, Malden, MA

When you need to connect a microcontroller to a seven-seg5V 5V

ment LED display, you can use a BCD (binary-coded-decimal)-to-seven-seg-

COMMON CATHODE a a b c d e f g a b c d e f g

ment decoder. Figure 1 shows a typical circuit that uses a CD4511 to translate a 4-bit code into BCD. Unfortunately, a limited size and budget may force you to omit components whenever possible. This requirement is especially critical with consumer products. Simple firmware allows you to overcome this limitation by directly connecting the display to a microcontroller (Figure 2). A recent project used the 8-bit Freescale (www.freescale.com) MC68HC-

pB0 MC68HC908QY4 pB1 pB2 pB3

A B C D

CD4511

g e c

Figure 1 A CD4511 converts bCD codes to seven-segment-displays.

a NuMerIc dISPLay NeedS a SPecIaL SeVeN-SeGMeNt cOde, the VaLue Of whIch dePeNdS ON the cOMMON POINt Of the dISPLay Leds.
908QY4 microcontroller. When you write code for a microcontroller, you often represent data in decimal, hexadecimal, or BCD formats. A numeric display needs a special seven-segment code, the value of which depends on the common point of the display LEDs common cathode or common anode and on microcontroller outputs you choose for display. Tables 1 and 2 show how to obtain seven-segment code values for common-cathode and commonanode displays, respectively. No mathematical connection exists between seven-segment code and any of these formats. Thus, you must use a table that a previous Design Idea

5V

COMMON CATHODE a pB0 pB1 pB2 MC68HC908QY4 pB3 pB4 pB5 pB6 a b c d e f g a b c d e f g

g e c

Figure 2 The look-up table lets the microcontroller produce a seven-segment output.

42 EDN | August 26, 2010

S-ar putea să vă placă și