Hi Friend
For Stepper motor acceleration and deceleration, You must control timing between two pulses of motor.
This is done by this way.
Take one timer like timer0.
Make one data table for delay between two pulse
for ex.
const unsigned int CStepDelayTable[25] = { (0xB643),
(0xB8FB),
(0xBBA7),
(0xBE43),
(0xC0CF),
(0xC34F),
(0xC5BF),
(0xC81F),
(0xCA6F),
(0xCCB3),
(0xCEE7),
(0xD10B),
(0xD31F),
(0xD527),
(0xD71B),
(0xD903),
(0xDADB),
(0xDCA3),
(0xDE5F),
.............
.............
.............
............
}
Now timer0 load by CStepDelayTable[0]
and wait for timer0 over flow, when timer over flow, apply one pulse and timer 0 load by CStepDelayTable[1]
and wait for timer0 over flow, when timer over flow, apply second pulse and timer 0 load by CStepDelayTable[2]
and so on.
thats way motor running with acceleration.
For deceleration, apply this logic in reverse direction.
For ex.
timer0 load by CStepDelayTable[25]
and wait for timer0 over flow, when timer over flow, apply one pulse and timer 0 load by CStepDelayTable[24]
and wait for timer0 over flow, when timer over flow, apply second pulse and timer 0 load by CStepDelayTable[23]
and so on.
Shyam
INDIA