Unit C · Telling a machine what you want
What we are making: a motor that turns exactly once round, then exactly once back. Not roughly — exactly.
You have met two already. A plain DC motor spins while you give it power. A servo goes to an angle between 0 and 180 and stops there. A stepper is the third kind, and it does something neither of the others can: it turns in tiny fixed increments, and it can keep going round forever while still knowing exactly how far it has gone.
This one takes 2048 steps to complete a full turn. Ask for 1024 and you get exactly half a turn. Ask for 4096 and you get exactly two. That precision is why steppers are in printers, in scanners, and in every 3D printer — including the one you will use in Unit E.
Stepper line: 8, 10, 9, 11. That is not a typo and it is not a mistake. The library expects the coils in a different order from the way the pins are numbered on the driver. Put them in numerical order and the motor will buzz and shudder instead of turning. This catches nearly everybody.step(stepsPerTurn) to step(512). How far does it go?| What you see | Why | What to do |
|---|---|---|
| It buzzes and shudders but does not turn | The coil order is wrong. | The Stepper line must read 8, 10, 9, 11. Not numerical order. |
| It turns very slowly whatever I do | 2048 steps is a lot of steps. | Normal for this motor. Raise the speed a little, but see the next row. |
| It stalls when I speed it up | Steppers lose torque as they go faster. | A real limit. Find the speed where yours stops coping and stay below it. |
| Only two of the four lights come on | A wire is loose. | Check all four IN wires, and push the white plug fully home. |
In this session