PC Based Stepper Motor Controller

By Ashutosh M. Bhatt

17491
 

62E_table-1

Number of rotations

The step resolution of 18°/pulse means if you apply only one pulse, the motor will rotate by 18°. If you apply 10 pulses sequentially, the motor will rotate 180° (half of a revolution). So if you limit the number of pulses applied to the motor, you can stop it at any angular position (multiple of 18°) after completing the desired number of full revolutions. Thus if you apply only 25 pulses, the motor will complete one full revolution and rotate further by 90º (¼ revolution) and stop.

H-bridge

The transistors in the circuit act as switches. When high logic (3.49V) is applied to any data pin of the port, the transistor connected to it conducts and acts as a closed switch, allowing the current to pass through it. When low logic (0.09V) is applied, the transistor stops conducting and acts as an open switch, so the current cannot pass through it.

The pulse sequences to be given to switch the transistors are shown in tables. The current will flow into/out of the coils through the four terminals of the motor (red, orange, green and yellow).

Clockwise rotation

In the first phase, orange and green terminals should be high and red and yellow terminals should be low. To achieve this, out of the eight transistors, four transistors (T2, T3, T6 and T7) should conduct. For this, you have to output hex data word ‘CC’ (1100 1100) from the LPT port.

In the second phase, red and yellow terminals should be high, while orange and green terminals should be low. To achieve this, only transistors T2, T3, T5 and T8 should conduct. For this, you have to output hex data word ‘3C’ (0011 1100) from the LPT port.

In the next phase, red and green terminals should be high, while orange and yellow terminals should be low. To achieve this, transistors T1, T4, T5 and T8 should conduct. For this, hex data word will be ‘33’ (0011 0011).

In the next phase, red and yellow terminals should be low, while orange and green terminals should be high. To achieve this, transistors T1, T4, T6 and T7 should conduct. For the purpose, hex data word ‘C3’ (1100 0011) has to be output from the LPT port.

Thus the data sequence to be fed to the port for clockwise rotation of the motor is CC-3C-33-C3.

Anticlockwise rotation

To rotate the motor in anti-clockwise direction, the sequence of hex data to be output from the LPT port will be CC-C3-33-3C.

Fig. 4: Screenshot of the program output
Fig. 4: Screenshot of the program output

Software

All the controlling actions are performed by the software program. The program is written in ‘C++’ language and compiled in Turbo C++ Version 3. The complete software program (STEPCNT.CPP) is given at the end of this article along with necessary comments. You require the egavga.bgi graphic file to be in the same directory as the application program to run the program. The output of the program is shown in Fig. 4.

The main functions of the software are:

  1. Change the direction of rotation of the stepper motor by switching the eight transistors in proper manner.
  2. Vary the RPM of the stepper motor accurately.
  3. Stop the motor at a given angular position after the desired number of complete rotations

The software is divided into three parts: graphics, stepper motor control and mouse interfacing.

Graphics

The graphics part generates complete view of the control panel. It draws buttons like clockwise, anti-clockwise and RPM increase/decrease, displays instructions, draws borderline, writes text like ‘RPM,’ ‘rotations,’ ‘number of rotations,’ etc. Graphic functions are used to make the program output screen visually appealing.

Stepper motor control

To change the direction of rotation of the motor, the program generates the desired pulse sequence, either CC-3C-33-C3 (to rotate the motor in clockwise direction) or CC-C3-33-3C (to rotate the motor in anticlockwise direction), on the parallel port with appropriate delay. The delay adjustment is done depending upon the RPM.

To vary the RPM, the program varies the PRF. First, the current RPM (S) is converted into RPS (S1) by dividing it by ‘60’ as follows:

63Z_text-1

Now for one complete revolution, you have to apply 20 pulses. So the RPS factor (S1) multiplied by ‘20’ will give you the desired PRF.

The delay (d) between the pulse sequences is given by:

CF5_text-2

When RPM is greater than ‘10,’ you can increase or decrease the RPM by a factor of ±10. For RPM less than ‘10,’ you can increase or decrease it by ±1 only. There is no limit on the maximum RPM but the minimum limit is 1 RPM.

As stated earlier, 20 sequential pulses are required for a complete revolution of the stepper motor. Since a sequence of four pulses is repeated (for clockwise or anticlockwise movement), we may say that a revolution of the stepper motor involves five identical sequences of four pulses. You can increase or decrease the number of rotations linearly by ±1. For ‘N’ below ‘1,’ you can decrease or increase ‘N’ by a factor of ‘0.5.’ The minimum limit is 0.25 (quarter revolution), but there is no maximum limit.

SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here