How to control a small DC motor, both in speed and direction, from a PC


   DC motors are used in a wide variety of applications. They can be used in novelty items and toys such as train sets right through to more serious applications in industrial process control and automation. Whatever the application the role of the humble DC motor can be greatly enhanced by controlling Using a USB adaptor board to control a small DC motor from a PCit’s motion from a PC compatible computer. Having the “intelligence” of the PC available to dictate the operation of the motor allows elaborate control systems to be created with the flexibility of the PC control system. Whatever the DC motor is “hooked up” to the first step is to bring it under PC control both in speed and direction. For this purpose we will use a “MotorBee” USB adaptor board and a small 9v DC motor arranged in a worm drive to increase available torque.

Connecting the motor to MotorBee

    The DC motor has two connection points. One is invariably labelled ‘+’ and one ‘–‘. To a certain extent this is fairly meaningless, as the motor will operate with either polarity of supply. Reversing the supply simply makes the motor go in the opposite direction. Some applications only require the motor to go in one direction albeit at varying speeds and , for this purpose, the MotorBee has 4 independent motor control outputs. However, in our application, we require the motor to go in both directions so we will be using two of the MotorBee outputs for this one motor. We will use outputs 1 and 2 for this and the connection arrangement is shown below.

how to connect a 9v DC motor to a PC using a USB adaptor board

    Although the MotorBee gets it’s own power directly from it’s USB connection to the computer, the power to drive the motor is supplied separately. The 5v available on the USB cable to the MotorBee powers it’s on-board processor and it’s associated control circuitry. The external supply to power the motor in our case is a 9v battery. A photo of the connection arrangement is shown below for clarity...

The easy way to connect a small DC motor to a PC

    With these connections made then all we have to do now is connect the MotorBee to a free USB port of the PC using a standard cable and we are then ready to run the MotorBee software.

making a USB connection to the PC

     MotorBee is supplied with it’s own control software to allow beginners to quickly get up and running. The software is called MotorWay and installation from the supplied disk is straightforward. In the vast majority of cases all you need to do is click on the “Next” button on every screen to accept the default installation.
Once installed and running, MotorWay will present you with the following control screen

Software to allow a PC to control a DC electric motor both in speed and direction

    Although MotorWay offers a range of facilities for creating your own sequence control system we will focus on the manual controls needed to get our motor running under PC control. The drop down menu box on the left of the screen allows us to select “Manual” control.

manual control of a DC motor from a Windows XP PC computer

    In the top half of the screen you will see 5 vertical slider controls. The first four of these are used for DC motor control and the last one on the right for Servo control. The motor control sliders correspond, from left to right, to outputs 1 to 4.
Since we are using outputs 1 and 2 we are only concerned with the first two on the left. Between these two sliders there is a drop down selector box offering the choice of “single” or “twin”. This is to distinguish the use of outputs 1 and 2 being used for two un-directional motors or 1 bi-directional motor.

Motor speed control software using Windows XP

    You should select “Single”. When you do this you will see two new selection options appearing below it offering “Forward” or “Reverse”. Initially select “Forward”. This will cause the first slider to become active and the other to be “greyed out” inactive. Moving the slider up and down will now cause the attached motor to respond by varying it’s forward speed to match. Selecting the reverse direction switch the active slider to slider 2 and the motor will respond similarly to this control but in the reverse direction.


!!! You now have the motor under the control of the
PC in both speed and direction.   !!!


    Having reached this point you are well set up to explore the other facilities provided by MotorWay for creating sequences of motor speed changes etc.. or perhaps writing your own visual basic program using the supplied DLL. Please refer to the supplied manual or to other guides for these details.




.        .


© Copyright 2008