Path: EDN Asia >> Design Ideas >> Computing/Peripherals >> How to control a dc motor using your PC
Computing/Peripherals Share print

How to control a dc motor using your PC

23 Apr 2015  | Firas M Ali Al-Raie

Share this page with your friends

The circuit in this design idea controls the speed of a 5V permanent-magnet dc motor through the PC's parallel port (figure). You use the C++ computer program to run the motor at three speeds. The circuit uses pulse-width modulation (PWM) 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 multi-vibrator 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.


Figure: This circuit controls the speed of a 5V permanent-magnet motor through the PC’s parallel port.


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.1×RB, reducing the on time of the pulse signal and, consequently, the speed of the motor to the lower limit. The table summarises the on/off-operation conditions of the relays and the corresponding dc-motor speeds.


Table: Switch states and generated PC sequences.


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.


About the author
Firas M Ali Al-Raie of Polytechnic Higher Institute of Yefren in Yefren, Libya.


This article is a Design Idea selected for re-publication by the editors. It was first published on August 26, 2010 in EDN.com.




Want to more of this to be delivered to you for FREE?

Subscribe to EDN Asia alerts and receive the latest design ideas and product news in your inbox.

Got to make sure you're not a robot. Please enter the code displayed on the right.

Time to activate your subscription - it's easy!

We have sent an activate request to your registerd e-email. Simply click on the link to activate your subscription.

We're doing this to protect your privacy and ensure you successfully receive your e-mail alerts.


Add New Comment
Visitor (To avoid code verification, simply login or register with us. It is fast and free!)
*Verify code:
Tech Impact

Regional Roundup
Control this smart glass with the blink of an eye
K-Glass 2 detects users' eye movements to point the cursor to recognise computer icons or objects in the Internet, and uses winks for commands. The researchers call this interface the "i-Mouse."

GlobalFoundries extends grants to Singapore students
ARM, Tencent Games team up to improve mobile gaming


News | Products | Design Features | Regional Roundup | Tech Impact