datasheets.com EBN.com EDN.com EETimes.com Embedded.com PlanetAnalog.com TechOnline.com   UBM Tech
UBM Tech

Control a dc motor with your PC

Firas M Ali Al-Raie, Polytechnic Higher Institute of Yefren, Yefren, Libya; Edited by Martin Rowe and Fran Granville - August 26, 2010

 View as PDF


The circuit in this Design Idea controls the speed of a 5V permanent-magnet dc motor through the PC’s parallel port (Figure 1). You use the C++ computer program 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 PC’s parallel port with an interface circuit. The design comprises IC1, 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.

Control a dc motor with your PC table 1The 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.1×RB, reducing the on time of the pulse signal and, 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.

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 PC’s parallel port using the outportb function. The program uses the kbhit function to stop the motor when you hit any key on the keyboard.

Loading comments...

Share your thoughts.

To comment please Log In.

EDN.com Analog Design Channel Video Player

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
KNOWLEDGE CENTER