Driving a Stepper Motor in a Single Direction

In order to drive the motor, the waveforms described in the Figure 2 must be generated. The period of each signal that drives the motor is divided into six sequences, defined as partial steps.

To create each sequence of the step, a periodic signal is needed with a frequency six times greater than the signal that drives a contact. To generate this signal, an NCO peripheral is used.

The signal that drives Contact 1 of the motor is obtained by dividing the NCO_out frequency by six. To obtain this, the NCO_out frequency is divided by three, using Timer2, and then divided by two, using CLC1.

The CLC1 is configured as a D-type Flip Flop (D-FF), with its output inverted and connected to the Data (D) port with the NCO_out connected to the Clock (CLK) port. Using CLC1 in this configuration will divide the frequency of the output from Timer2 (TMR2_out) by two.

At this point, the output from the CLC1 (CLC1_out) is the signal capable to drive Contact 1.

Figure 1. NCO_out and CLC1_out Signals

In Figure 2, it can be observed that the signal which drives Contact 4 of the motor can be derived from the CLC1_out by applying a delay of one partial step and an inversion.

The delay is obtained by configuring the CLC4 as a D-FF, with CLC1_out connected to the Data (D) port and with NCO_out connected to the Clock (CLK) port. The inversion is created by negating its output.

At this point, the output from the CLC4 (CLC4_out) is the signal capable to drive Contact 4.

Figure 2. NCO_out, CLC1_out, and CLC4_out Signals

The following step is to create the signal that drives Contact 2 and Contact 3. This is done by applying the same operations used to obtain the signal that drives Contact 4, but applied on the CLC4_out instead of the CLC1_out.

The delay is obtained by configuring CLC2 as a D-FF, with the CLC4_out connected to the Data (D) port and with the NCO_out connected to the Clock (CLK) port. The inversion is created by negating its output.

At this point, the output from the CLC2 (CLC2_out) is the signal capable to drive Contact 2 and Contact 3.

Figure 3. NCO_out, CLC1_out, CLC4_out, and CLC2_out Signals

The following figure offers a better visualization and understanding of the peripheral connections and how the signals are obtained.

Figure 4. Peripherals Used for Driving the Stepper Motor in a Single Direction