打印
[multisim]

proteus步进电机仿真问题

[复制链接]
1994|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
步进电机为四相八拍模式,为什么要66拍才转了1圈,而不是64拍?
#include <reg52.h>
unsigned long beats=0;

void StartMotor(unsigned long angle);

void main()
{
        EA=1;
        TMOD=0x01;
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        ET0=1;
        TR0=1;
        StartMotor(360);
        while(1);
}

void StartMotor(unsigned long angle)
{
        EA=0;
        beats=(angle*66)/360;                                         //66拍
        EA=1;
}

void InterruptTimer0() interrupt 1
{
        static unsigned char index=0;
        unsigned char tmp;
        unsigned char code BeatChar[]={0x0e,0x0c,0x0d,0x09,0x0b,0x03,0x07,0x06};
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        if(beats!=0)
        {
                tmp=P1;
                tmp=tmp&0xf0;
                tmp=tmp|BeatChar[index];
                P1=tmp;
                index++;
                index=index&0x07;
                beats--;               
        }
        else
        {
                P1=P1|0x0f;
        }       
}


相关帖子

沙发
yangwenguan| | 2015-3-15 09:24 | 只看该作者
本帖最后由 yangwenguan 于 2015-3-15 09:33 编辑

4相的,拍数看你自己的设定了,可以设定成单4拍的,也可以设置成单双8拍的。
单4拍的就是A-B-C-D-A或者AB-BC-CD-DA-AB
单双8拍的就是:A-AB-B-BC-C-CD-D-DA-A

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

3

帖子

0

粉丝