Reference no: EM132391443
EE344 Solid-State Power Electronics Assignment - United States Naval Academy, USA
Prepare the C program for Stepper Motor.
Description: A 4-pole stepper motor has 4 inputs and can rotate clockwise and counterclockwise in either 90 degrees (full step mode) or 45 degrees (half step mode) per step. The diagram of a 4-pole stepper motor is shown in Figure 10.8. As long the user applies the sequence given in Table 10.1, the stepper motor will rotate a cycle in full-step mode. If the user applies the sequence given in Table i0.2, the stepper motor will rotate a cycle in half-step mode.
![457_figure.png](https://secure.expertsmind.com/CMSImages/457_figure.png)
Table 10.1 Full-step sequence for clockwise rotation
Step
|
Q4 PA3
|
Q3 PA2
|
Q2 PA1
|
Q1 PA0
|
Value
|
1
|
on
|
on
|
off
|
off
|
1100
|
2
|
off
|
on
|
on
|
off
|
0110
|
3
|
off
|
off
|
on
|
on
|
0011
|
4
|
on
|
off
|
off
|
on
|
1001
|
Table 10.2 Half-step sequence for clockwise rotation
Step
|
Q4 PA3
|
Q3 PA2
|
Q2 PA1
|
Q1 PA0
|
Value
|
1
|
on
|
off
|
off
|
off
|
1000
|
2
|
on
|
on
|
off
|
off
|
1100
|
3
|
off
|
on
|
off
|
off
|
0100
|
4
|
off
|
on
|
on
|
off
|
0110
|
5
|
off
|
off
|
on
|
off
|
0010
|
6
|
off
|
off
|
on
|
on
|
0011
|
7
|
off
|
off
|
off
|
on
|
0001
|
8
|
on
|
off
|
off
|
on
|
1001
|
A button is connected to the PC13 pin in your demo kit. This button allows you to generate an interrupt to the microcontroller. The user press this button to start the rotation in the following manner forever:
When the user presses the button for the first time, the stepper motor rotates in the following manner:
1.1 The motor rotates clockwise in full-step mode for 5 seconds.
1.2 The motor rotator counterclockwise in full-step mode for 5 seconds.
1.3 The motor rotator clockwise in half-step mode for 5 seconds.
1.4 The motor rotator counterclockwise in half-step mode for 5 seconds.
When the user presses the button for the second time, the stepper motor rotates in the following manner:
2.1 The motor rotates counterclockwise in half-step mode for 5 seconds.
2.2 The motor rotates clockwise in half-step mode for 5 seconds.
2.3 The motor rotates counterclockwise in full-step mode for 5 seconds.
2.4 The motor rotates clockwise in full-step mode for 5 seconds.