-
大小: 3KB文件類型: .c金幣: 1下載: 0 次發(fā)布日期: 2021-01-10
- 語言: 其他
- 標(biāo)簽:
資源簡(jiǎn)介
三路步進(jìn)電機(jī)驅(qū)動(dòng)程序--多軸聯(lián)動(dòng),使用了插值法,對(duì)步進(jìn)電機(jī)進(jìn)行驅(qū)動(dòng),可以實(shí)現(xiàn)多路步進(jìn)電機(jī)的聯(lián)動(dòng),快速反應(yīng),無延時(shí)
代碼片段和文件信息
void?pulse_out(int?motor_numunsigned?char?dir)?????//電機(jī)脈沖輸出函數(shù)(請(qǐng)自己添加對(duì)應(yīng)硬件函數(shù))
{
????if(dir==0)?????//收線
????????switch?(motor_num)
????????{
????????case?1?:motor_1(1);break;
????????case?2?:motor_2(1);break;
????????case?3?:motor_3(1);break;
????????}
????else??????????//放線
????{
????????switch?(motor_num)
????????{
????????case?1?:motor_1(-1);break;
????????case?2?:motor_2(-1);break;
????????case?3?:motor_3(-1);break;
????????}
????}
}
unsigned?int?int_abs(int?num)
{
????if(num<0)num=0-num;
????return?num;
}
void?Motor_linkage(int?Motor1_stepunsigned?char?Motor1_dirint?Motor2_stepunsigned?char?Motor2_dirint?Motor3_stepunsigned?char?Motor3_dir)
{
????int?max?=?0;??????????//通過冒泡排序,找出最大的脈沖數(shù)
????int?mid?=?0;
????int?min?=?0;
????int?max_pulse_num?=?0mid_puls
評(píng)論
共有 條評(píng)論