tldr; Stepper motors are AC motors that should be driven with sine waves for satisfactory operation using two-phase inverter. Today, market is full of integrated drivers. Forget about "sequences", they are fundamentally flawed and tend to go wrong.
I'm about to start a project that uses stepper motors, and I came upon this ancient thread. I have a lot of experience with motor control, but not with steppers. I agree that sine wave drive is probably the way to go when driving steppers, but there's one thing I'm missing here... When driving a stepper in the conventional way, it's easy to control the angle of the motor just by sending it the appropriate number of steps since each step corresponds to 1.8 degrees, or whatever the step size of the motor is. How is this done when driving a stepper with sine waves?
I still stand behind my words from 7 years ago.
Let's assume 1.8deg/step motor.
With full-stepping, you are just forced to use 1.8 deg resolution.
With half-stepping, you have 0.9 deg resolution.
With microstepping/sine wave drive, you just choose any arbitrary step size! The smaller, the better.
Then, you just index the sine/cosine tables with the step index you have chosen, and set the PWM values accordingly. The motor holds there, at any arbitrary position.
Let's say I want to move the rotor 45 degrees, which corresponds to 25 1.8 degree steps when driving it the conventional way, how is that done?
The key is to understand electrical rotation vs. physical rotation. The problem is, these motors
are synchronous AC motors, but unlike other motor types which are specified by
number of poles (2 poles: electrical rotation equals physical rotation. 20 poles: electrical rotation = 1/10th physical rotation i.e. 36 degrees), stepper motor manufacturers just do not specify this. So you need to back-calculate this by referring to those ancient "full steps". Since the "full stepping" pattern repeats every 4 cycles, this means, 1.8deg per step is 4*1.8 = 7.2deg per electrical revolution.
So you want to rotate it by 45 deg? It's going to be 45deg/7.2deg = 6.25 electrical revolutions. Meaning, for your 256 entry look up table, you just loop it, increasing the index one by one, finally reaching 6.25*256 = 1600 counts. (Do utilize the natural wrap-around of unsigned integers if writing in C. 256- or 65536-entry tables wrap around with no overhead at all; arbitrary 2^n size requires masking high bits when accessing the table, usually perfectly acceptable.)
In any case, the math is easy to verify in practice (we are prone to errors, anyway). Write the 256 elements long sin/cos tables, and test iterating over it by 1600 steps, see if you got 45 degrees, or if I did some error in the calculation.
If memory is limited, first optimization is to only use sine table and get cosine by accessing the table 64 elements off. I usually won't bother going further, but of course you can then only store half of the table, and get the other half by negating the value. You can again halve that by utilizing the symmetry, sin[62] == sin[64], sin[61] == sin[65] and so on.