MP28GA步進(jìn)電機(jī)C語言測試程序
步進(jìn)電機(jī)測試程序
步進(jìn)電機(jī)型號:MP28GA步進(jìn)電機(jī)
驅(qū)動(dòng)芯片:ULN2003
連接方式:P10~P13分別接ABCD
Author:Kevin Chin
Date:2010/07/17
Email:kevinchin@qq.com
************/
#include
#defineMotorPort P1
//unsigned char FMove[4] = {0xf1, 0xf2, 0xf4, 0xf8};//單四拍節(jié) A、B、C、D驅(qū)動(dòng)
//unsigned char FMove[4] = {0xf3, 0xf6, 0xfc, 0xf9};//雙四拍節(jié) AB、BC、CD、DA驅(qū)動(dòng)
//單雙8拍節(jié) A、AB、B、BC、C、CD、D、DA驅(qū)動(dòng)
unsignedcharFMove[8]={0xf1,0xf3,0xf2,0xf6,0xf4,0xf9,0xf8};
voidmDelay(unsignedinti)//延時(shí)約0.5ms
{
for(;i>0;i--)
{
unsignedcharj=244;
while(--j);
}
}
voidmain(void)
{
char*p,i,count;
p=FMove;
count=sizeof(FMove);
while(1)
{
for(i=0;i
MotorPort=*(p+i);
mDelay(5);
}
}
}
評論