## Saturday, January 8, 2011

### Weak current College】 【triple-phase stepping motor driver】.

Three-phase hybrid stepping motor three-phase six beats, just go winding power order: A, B, AB, BC, CA, C, A, reverse the order of power: A, AC, CB, C, B, BA, B, A.
Since stepping motor rotor has certain inertia and the inertia of the load, the stepper motor work process does not start and stop time, start to gradually accelerate to the target speed, stop before gradually slow down to a stop, otherwise, the result of step.
Stepping motor control problems can be summed up in two points:
1, produce work requires timing pulse;
2. control of stepper motor speed, so that it always followed accelerate, the law of uniform, deceleration.

System:

Interface:

Program:
#include<io8515v.h>
#include<macros.h>
constcharzhzhuan[7]={0x06,0x04,0x05,0x01,0x03,0x02,0x00};
constcharfanzhuan[7]={0x06,0x02,0x03,0x01,0x05,0x004,0x00};
Constinttime [5] = {4000, 2400, 1600, 3200, 800};/* pulse width: 0.05m, 0.04ms, 0.03ms, 0.02ms, 0.01ms */
Charnum;/* the number to be rotating step */
Chardirect;/* in the direction of rotation, flip, 1-0 to forward */
Charnum_run;/* number of steps have been rotating */

voidmain(void)
{
DDRA=0x07;
TCCR1A=0x00;
TCCR1B=0x09;
TIMSK=0x10;
SREG|=0x80;
while(1)
{
;
}
}

#pragmainterrupt_handlertime1coma:5
voidtime1coma(void)
{
chari,j;
if(num>9)
{
If (num_run < 5) OCR1A = time [num_run];/* speed */
Elseif (num_run > (num-5)) OCR1A = time [num-num_run];/* deceleration */
}
else
{
i=(num+1)/2;
If (num_run < (I)) OCR1A = time [num_run];/* speed */
ElseOCR1A = time [num-num_run];/* deceleration */
}
if(num_run<num)
{
j=num_run%6;
if(direct==1)PORTA=zhzhuan[j];
elsePORTA=fanzhuan[j];
num_run+=1;
}
else
{
OCR1A=0x0fa0;
}
}