The circuit in the figure provides three levels of speed control for a dc motor, using a PC’s parallel port (LPT1). A C++ program performs the control functions by allowing the signals from the PC port to deliver three different voltages to the motor.
The system is an interface circuit that connects the motor to the PC using a 4-bit binary counter (a 74LS193), three current- limiting resistors, three npn transistors, three 5-V relays, and two supply resistors. Counter inputs A, B, and C receive the control signals from three of LPT1’s data pins, through a suitable cable. The counter acts as a buffer for the weak signals coming from the PC, so any other buffer IC, like a 74LS244, can be used.
Counter outputs QA, QB, and QC connect to the three transistors (2N2222s were used in this example) through the currentlimiting resistors. The transistors increase the current level of the PC signals in order to drive the relays. Depending on the control signals generated by the PC, the relays insert or take out the supply resistors. This action applies the desired voltage level from the 12-V supply to the motor to achieve the proper speed. The On/Off operation of the relays depends on the digital sequence generated by the computer program (see the table).
When the program is selected, a Start screen appears. Pressing any key brings up a screen containing a selection menu. From this menu, the user selects the desired motor speed or Exit. Once the motor is running—at any speed—the user can stop it by pressing any key, causing the selection menu to appear again.
The integer variable “choice” in the program listing stores the selection case of the user. Based on the value of this variable, the necessary digital sequence is stored at the integer variable “data.” The function “outportb()” places the suitable digital signal at the data lines of the PC’s parallel port, which is identified through its address. (The program is available at http://electronicdesign.com.)