Step 6I never half-step, because I'm not a half-stepper...
Half-stepping in a nutshell: Instead of Blue, Black, Red, Yellow, you drive the motor with Blue, Blue+Black, Black, Black+Red, Red, Red+Yellow, Yellow, Yellow+Blue. The upshot is that for half the time you're engaging both magnets at once.
And during the times that both sets are engaged, the motor points halfway between the two, shrinking the angle between "steps" and making the motor turn more smoothly. Can you tell from the video? I'm not sure...
Now the part of the code that does the half-stepping looks like this:
void halfStepping(uint16_t delay, uint8_t direction[]){ uint8_t i; for ( i=0; i<=3; i++ ){ PORTB = direction[i]; /* single-coil part */ _delay_ms(delay); PORTB |= direction[i+1]; /* add in half-step */ _delay_ms(delay); }}
The first PORTB command sets a single pole to positive and all the rest to negative. Then it waits. Then the second PORTB command sets a second pole (on the other winding) to positive, engaging both windings for 1.4x the torque (and 2x the current).
A full program listing is attached below. Two arrays are now defined (clockwise, counterclockwise) and both have 5 elements each to allow for the i+1 entry in the halfStepping function.
| « Previous Step | Download PDFView All Steps | Next Step » |
3
comments
|
Add Comment
|
![]() |
Add Comment
|












































