|
前一段日子同事(差不多是老板,呵呵)叫我帮他做一个小项目,所以一直在忙这个事情,项目接近尾声,终于可以喘口气了。
透露一下这个项目的有关硬件:ATmega16 主控芯片,主要是温度的采集 用DS18B20,还有语音芯片ISD2500系列的,还有红外遥控的单片机解码,这些都很快搞定了,后来由于开环控制直流电机,有点棘手,弄了好几天,后来发现是电机正反转速度不一样。
转到正题:
步进电机的细分驱动远没有我想的那样简单,所以很多人多步进电机的细分驱动问题摸不着头脑。我也在细分驱动设计中失败了好多次。原本以为成功的,现在用示波器测试了驱动器中的波形,发现电机的电流没有达到预想的那样的 正弦余弦的波形。
所以说对步进电机的细分驱动还有很多没有搞清出的地方,今天重新打开一些PDF格式的datasheet在看。一篇文章中看到这样的描述:
We now come to one of the most advanced topics in all of Stepper motor theory - Current Recirculation. This subject separates the men from the boys when it comes to manufacturers of Microstepping circuitry. Some choose to ignore it completely, some give you complete control. Personally, I consider Allegro's understanding and handling of this topic to be top-notch. But first, what is Current Decay? (Note: this topic also has relevance in non-Microstepping Controllers but will not be discussed here.)
大致的翻译是这样的:
(电流续流)Current Recirculation是步进电机驱动最重要的问题。细分驱动的高手往往对电流续流问题研究的非常的透彻。作者认为Allegro的驱动芯片处理此类问题做的最好了。
在 Allegro的驱动芯片资料中,有三个关键词:我觉得非常的重要:slow decay fast decay mixed decay 。也就是处理(电流续流)Current Recirculation的方法。
还有一个问题我一直没有想明白就是使用L6506的事情:上次用L6506设计的驱动器有问题。一直对L6506很有疑惑,因为L6506的datasheet实在是不怎么详细。看L6506的内部结构和通常的斩波驱动的结构有点差异,就是20k的信号脚是接在D锁存器的CLK还是S脚。L6506是接在了S脚,datasheet中没有说明里面的锁存器的时序是和7474的时序是一样的。这一点我很气愤的。但是在实际的测试中我得出结论是一样的。
当L6506的内部的S脚是0(20K斩波的低电平),R端是0(比较器输出是0)那么输出的还是Q端还是1
所以当SENSE的电压即使高于REF的电压,Q端输出的波形和20K斩波的波形是一样的。
L6506和L6203 或者L298的电路很容易得到,但是软件的实现可能有点麻烦,至今我还没有搞明白
看了 Rundstedt 的代码很不理解。
还有用示波器测试步进电机产品的波形是这样的:这个就更不明白了
![](http://cache.amobbs.com/bbs_upload782111/files_2/armok0154145.jpg)
![](http://cache.amobbs.com/bbs_upload782111/files_2/armok0154146.jpg)
![](http://cache.amobbs.com/bbs_upload782111/files_2/armok0154147.jpg)
Rundstedt 的代码:
#include <reg51.h>
unsigned char code mstep[64]=
{0xf4,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
0xf1,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,
0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xfd,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc};
unsigned char code dacb[32]={200,199,196,191,184,176,166,154,
141,126,111, 94, 76, 58, 39, 19,
0, 19, 39, 58, 76, 94,111,126,
141,154,166,176,184,191,196,199};
unsigned char code daca[32]={ 0, 19, 39, 58, 76, 94,111,126,
141,154,166,176,184,191,196,199,
199,199,196,191,184,176,166,154,
141,126,111, 94, 76, 58, 39, 19};
unsigned char tmp,cnt;
unsigned char dac_a,dac_b;
sbit sel=P1^4;
sbit wr=P1^5;
void incr (void) interrupt 0 //***********0
{
P2=mstep[cnt];
P0=dac_b;
wr=0;
wr=1; // write data to DACB
P0=dac_a;
sel=0;
wr=0;
wr=1; // write data to DACA
P1=-1;
tmp=P1&0x3;
switch(tmp){
case 0:
++cnt;
break;
case 1:
cnt=(cnt&0x3e)+2;
break;
case 2:
cnt=(cnt&0x3c)+4;
break;
default:
cnt=(cnt&0x38)+8;
break;
}
cnt&=0x3f;
dac_b=dacb[cnt&0x1f];
dac_a=daca[cnt&0x1f];
}
main(){
IT0=1; // edge trigger
EX0=1; // external interrupt 0 : CLK
EA=1;
while(1){
}
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|