專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

單片機(jī)驅(qū)動(dòng)4相步進(jìn)電機(jī)proteus仿真

作者:huqin   來(lái)源:本站原創(chuàng)   點(diǎn)擊數(shù):  更新時(shí)間:2014年04月13日   【字體:

單片機(jī)IO驅(qū)動(dòng)能力不夠,因此使用ULN2003驅(qū)動(dòng)。

采用4相8拍驅(qū)動(dòng)方式,步進(jìn)電機(jī)在proteus里是motor-stepper,接法:中間引出接電源,其他腳順時(shí)針或逆時(shí)針接即可。




程序如下:

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
void delay(uint a);
const uchar step_table[]={0x04,0x0c,0x08,0x18,0x10,0x30,0x20,0x24};//4相8拍方式
void main()
{
    uint i,j;
    j=300;
    while(j--)
    {
        for(i=0;i<8;i++)
        {
            P0=step_table[i];
            delay(1);
        }
    }
    while(1);
}
void delay(uint a)
{
    uint i,j;
    for(i=a;i>0;i--)
        for(j=122;j>0;j--);
}

關(guān)閉窗口

相關(guān)文章