Motor stepper simulation with L6219 controller

In the upperleft corner, you see the backside of the breadboard, connected with probes.
In the middle you see the stepper with a cut out cardboard disc, to visualize movement.
On top you see the picture of the oscilloscoop. Channel 1 is connected to Ph1 (current in coil 1) and the scoop triggered to it. This signal is clamped to the bottom of the scoop window. Channel 2 is connected to Ph2 (current in coil 2). The signal is clamped to the middle of the scoop window.

Test1

The first test sends the following PSDL to the stepper. Text in bold are PDSL-commands for the stepper. Emphesized text is output from the program.

By issueing a verbose level of 1 we can trace the stepper.
V1

We tell the motor to turn clockwise from now on.
CW

Set power to maximum (level 3) and gently rotate to 100 RPM. Maximum power is motor specific, but also speed dependant. In this case about 0.5A when stepping is initiated. Notice the 90 degrees phase shift of Phase 1 compaired to Phase 2.
P3 R100
Speeding motor clockwise from 0.0 to 100.0 RPM (power=3)

Set power to 2/3 maximum (level 2) and keep turning 8 full rounds. Notice the motor current is now 0.25A, about half the initial current, instead of 2/3. This is due to coil resistance for higher frequencies.
When motorspeeds are constant, fewer energy is needed to maintain rotation. This explains why we switch to lower current. Of course this also depends on the amount of torc the motor has to maintain.
P2 T8
Engine clockwise at 100.0 RPM for 8.0 turns (1600 steps,power=2)

Set power to maximum and gently advance to 300 RPM. Motor current rices to about 0.34A. Notice the clean signal timings, due to changing the Linux round ribbon scheduler to request minimal interrupts and demand complete attention to the stepper program.
P3 R300
Speeding motor clockwise from 100.0 to 300.0 RPM (power=3)

Set power to 2/3 maximum and keep turning 10 full rounds. Notice the current drops to about 0.15A!
P2 T10
Engine clockwise at 300.0 RPM for 10.0 turns (2000 steps,power=2)

Set power to maximum and slow gently down until it stand still. Motor current rises to about 0.52A.
P3 R0
Slowing motor clockwise from 300.0 to 0.0 RPM (power=3)

Shut power down (level 0) and end. Use W0 to really shut off motorpower. Phase 1 is on at the end, but the power set to 0 denies any currentflows.
P0 W0
Waiting 0.0 seconds (power=0)

Download a 15 second video from this test. Choose MPEG (1.3M) or Quicktime(176k).

Test2

The second example shows wat really happens when we issue clockwise and counter clockwise commands after one another. Please notice this can only be done with low rotation speeds.

V1 CW P3 R100
Speeding motor clockwise from 0.0 to 100.0 RPM (power=3)

T1.0
Engine clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)

Notice the 180 degrees phase shift of phase (coil) 2.
CCW T1.0 CW T1.0
Engine counter clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)
Engine clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)

CCW T1.0 CW T1.0
Engine counter clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)
Engine clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)

CCW T1.0 CW T1.0
Engine counter clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)
Engine clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)

CCW T1.0 CW T1.0
Engine counter clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)
Engine clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)

CCW T1.0
Engine counter clockwise at 100.0 RPM for 1.0 turns (200 steps,power=3)

R0
Slowing motor counter clockwise from 100.0 to 0.0 RPM (power=3)

P0 W0
Waiting 0.0 seconds (power=0)

Download a 15 second video from this test. Choose MPEG (1.3M) or Quicktime(176k).

Test3

The next example details verbose mode 3. Every step is shown which step is taken and how long it was taken (in seconds).

V3 CW

The total time measured just to speed up to 60 RPM is 2.89567 seconds. This transition time can be changed with the tau and transient_time constants in the source.
P3 R60
Speeding motor clockwise from 0.0 to 60.0 RPM (power=3)
step=1 d=0.302507
step=2 d=0.152514
step=3 d=0.102521
.
.
.
step=298 d=0.005035
step=299 d=0.005034
steps=299

P2 T1
Engine clockwise at 60.0 RPM for 1.0 turns (200 steps,power=2)
step=300 d=0.005000
step=301 d=0.005000
step=302 d=0.005000
.
.
.
step=498 d=0.005000
step=499 d=0.005000
steps=499

CCW
P2 T1
Engine counter clockwise at 60.0 RPM for 1.0 turns (200 steps,power=2)
step=498 d=0.005000
step=497 d=0.005000
step=496 d=0.005000
.
.
.
step=300 d=0.005000
step=299 d=0.005000
steps=299

P3 R0
Slowing motor counter clockwise from 60.0 to 0.0 RPM (power=3)
step=298 d=0.005034
step=297 d=0.005035
step=296 d=0.005036
.
.
.
step=1 d=0.152514
step=0 d=0.302507
steps=0

P0 W0
Waiting 0.0 seconds (power=0)

Download a 15 second video from this test. Choose MPEG (1.3M) or Quicktime(176k).

Test4

The next example just runs the motor to topspeed. Timing signals on the osciloscoop are 1ms/dev.

V1
CW
P3 R350
Speeding motor clockwise from 0.0 to 350.0 RPM (power=3)

P2 T25
Engine clockwise at 350.0 RPM for 25.0 turns (5000 steps,power=2)

P3 R0
Slowing motor clockwise from 350.0 to 0.0 RPM (power=3)

P0 W0
Waiting 0.0 seconds (power=0)

Download a 15 second video from this test. Choose MPEG (1.3M) or Quicktime(176k).

Test5

The last example demonstrates the jump directive. The motor is immediately instructed to spin at 60 RPM. This can only be done when jump speeds are low. Otherwise the motor just stands still and makes a buzzing noice :-) If you look at the direction of the drawn arrow on the cardboard disc, it returns to the same position :-)

V1
CW
P3 J60
Stepper ready for jumping clockwise to 60.0 RPM (power=3)

P2 T5
Engine clockwise at 60.0 RPM for 5.0 turns (1000 steps,power=2)

P1
W1.5
Waiting 1.5 seconds (power=1)

CCW
P3 J60
Stepper ready for jumping counter clockwise to 60.0 RPM (power=3)

P2 T5
Engine counter clockwise at 60.0 RPM for 5.0 turns (1000 steps,power=2)

P0 W0
Waiting 0.0 seconds (power=0)

Download a 15 second video from this test. Choose MPEG (1.3M) or Quicktime(176k).