三相步进电机驱动
2012-09-22

三相步进电机的三相六拍工作方式,正转的绕组通电顺序:A、AB、B、BC、C、CA、A,反转的通电顺序:A、AC、C、CB、B、BA、B、A。

由于步进电机转子有一定的惯性以及所带负载的惯性,故步进电机的工作过程中不能及时的启动和停止,在启动时应慢慢的加速到预定速度,在停止前应逐渐减速到停止,否则,将产生失步现象。

步进电机的控制问题可总结为两点:

1、产生工作方式需要的时序脉冲;

2、控制步进电机的速度,使它始终遵循加速、匀速、减速的规律工作。

系统:

接口:

程序:

#include<io8515v.h>
#include<macros.h>
const char zhzhuan[7] = {0x06, 0x04, 0x05, 0x01, 0x03, 0x02, 0x00};
const char fanzhuan[7] = {0x06, 0x02, 0x03, 0x01, 0x05, 0x004, 0x00};
const int time[5] = {4000, 3200, 2400, 1600, 800}; /*脉冲宽度:0.05m,0.04ms,0.03ms,0.02ms,0.01ms*/
char num;/*将要转动的步数*/
char direct;/*转动方向,0为反转,1为正转*/
char num_run; /*已经转动的步数*/
void main(void)
{
      DDRA = 0x07;
      TCCR1A = 0x00;
      TCCR1B = 0x09;
      TIMSK = 0x10;
      SREG |= 0x80;
      while (1)
          {
            ;
    }
     
}
#pragma interrupt_handler time1coma:5
void time1coma(void)
{
       char i, j;
       if (num > 9)                        {
        if (num_run < 5)
        {
            OCR1A = time[num_run];
        }
                         /*增速*/
            else if (num_run > (num - 5))
        {
            OCR1A = time[num - num_run];    /*减速*/
        }
          
    }
    else  {
                i = (num + 1) / 2;
            if (num_run < (i)) {
        OCR1A = time[num_run];
        }
                 /*增速*/
            else {
            OCR1A = time[num - num_run];
        }
                        /*减速*/
      
    }
       if (num_run < num)
           {
            j = num_run % 6;
            if (direct == 1)
        {
            PORTA = zhzhuan[j];
        }
                   
            else
        {
            PORTA = fanzhuan[j];
        }
            num_run += 1;
          
    }
       else
           {
                OCR1A = 0x0fa0;
              
        }
         
    }



可能会用到的工具/仪表
本站简介 | 意见建议 | 免责声明 | 版权声明 | 联系我们
CopyRight@2024-2039 嵌入式资源网
蜀ICP备2021025729号