LPC812 MAX Experiment: Stepping Motor
Experiment: Stepping Motor
In this experiment you will learn how to control a http:en.wikipedia.org/wiki/Stepper_motor.
Hardware
In this lab you will need:
- 1x breadboard
- 1x 330 ohm resistor
- 1x trimming potentiometer
- 1x step motor
- 1x L293D step motor driver
- cables
Mount the components on the breadboard and connect the breadboard to the LPC812 as show in the image below.
Information
The stepper motor in the experiment kit does not look exactly like the stepper motor in the image above. The connector will differ but the important thing is that the order of the cables from the breadboard to the motor is either 1-2-3-4 or 4-3-2-1.
The pin(s) are specified in the mbed library with the actual pin names as well as some useful aliases:
Schematic Name | mbed Pin Name | Arduino Shield Alias | Description |
---|---|---|---|
AIN0_XPIO0 (SJ5 in 1-2 pos) | N/A | A0 | Trimming Potentiometer |
PIO0_13 | P0_13 | D10 | Step Motor Driver pin 1A |
PIO0_14 | P0_14 | D11 | Step Motor Driver pin 2A |
PIO0_15 | P0_15 | D12 | Step Motor Driver pin 3A |
PIO0_12 | P0_12 | D13 | Step Motor Driver pin 4A |
1) Description
The stepper motor has four control signals (1A and 3A) and the inverse of those (2A and 4A) so to move it one step clockwise you have to control the outputs in this sequence:
1A | 2A | 3A | 4A |
---|---|---|---|
1 | 0 | 1 | 0 |
1 | 0 | 0 | 1 |
0 | 1 | 1 | 0 |
0 | 1 | 0 | 1 |
To get it one step anti-clockwise the sequence is the reverse so:
1A | 2A | 3A | 4A |
---|---|---|---|
0 | 1 | 0 | 1 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 |
1 | 0 | 1 | 0 |
The step motor in the experiment kit is specified to have a step angle of 18o or 20 steps per revolution.
Use the following program as a starting point:
main.cpp
#include "mbed.h" DigitalOut ph1(D10); DigitalOut ph2(D11); DigitalOut ph3(D12); DigitalOut ph4(D13); int main() { // Delay between steps float number = 0.5; // Initialize outputs ph1=1; ph2=1; ph3=1; ph4=1; while(1) { ph1 = 1; ph2 = 0; ph3 = 1; ph4 = 0; wait(number); ph1 = 1; ph2 = 0; ph3 = 0; ph4 = 1; wait(number); ph1 = 0; ph2 = 1; ph3 = 0; ph4 = 1; wait(number); ph1 = 0; ph2 = 1; ph3 = 1; ph4 = 0; wait(number); } }
Experiment with different values of the delay (not recommended to go below 0.05) to see how it affects the speed.
Change the direction of the rotation by reversing the different steps.
2) Description
In the previous step the delay was fixed, it is now time to control it with the trimming potentiometer. Use the PCF8591 class from the Analog Input experiment to read the value of the trimming potentiometer and convert it into a reasonable delay.
An alternative is to use the trimming potentiometer for both direction and speed. If the value is above 128 it turns one way and if it is below it turns the other way. The 0 and 255 are maximum speeds in the respective directions.
3) Description
This experiment the goal is to use absolute positioning of the stepper motor. Each step is 18o so the input will not be more accurate than that. Use the trimming potentiometer to give the position.
Solution(s)
Import programlpc812_exp_solution_stepper-motor
Solutions for the Stepper Motor experiments for LPC812 MAX
1 comment on LPC812 MAX Experiment: Stepping Motor:
Please log in to post comments.
There is an inconsistency in the tables for clockwise/anti-clockwise rotation. Steps 3 and 4 seem to be switched. The program works for me correct.