The mikroC Pro for the PIC program listing is given in
Figure 7.164 (MIKROC-USTP1.C). The motor is operated in one-phase full-step sequencing mode. At the beginning of the program, the required number of revolutions and the moor step size are defined. Inside the main program array Step stores the sequence of pulses to be sent to the motor in each cycle. PORTB is configured as a digital output. Then, the cycle count is calculated and pulses are sent to the motor inside two
for loops. The motor rotates 100 revolutions where 2000 pulses are sent to the motor. A 3-ms delay is inserted between each pulse. Therefore, the motor operates for 6
s. The speed of the motor can be calculated to be 1000
revolutions per minute (rpm).