在脈沖模式下,步進(jìn)電機(jī)啟動(dòng)器的脈沖頻率與速度成正比,函數(shù)void CalculateSModelLine(float fre[], unsigned short period[], float len, float fre_max, float fre_min, float flexible)主要目的就是生成每一個(gè)細(xì)分步加速的速度。芯片用的是stm32f103c8t6,驅(qū)動(dòng)器用的是2DM420。
程序流程如下:
- STM32硬件基本初始化,主要是針對(duì)定時(shí)器
- 調(diào)用函數(shù)CalculateSModelLine()生 成每一個(gè)細(xì)分步定時(shí)器的自動(dòng)重裝載值(實(shí)際就是改變脈沖的周期)
- 打開定時(shí)器
- 更新中斷發(fā)生,將數(shù)組中的數(shù)據(jù)賦值給定時(shí)器的自動(dòng)重裝載寄存器
- 跳出中斷后脈沖頻頻率就變化了
- 下一次更新中斷產(chǎn)生
對(duì)應(yīng)的計(jì)算接口code:
/* calculate the Period and Freq array value, fill the Period value into the Period register during the timer interrupt.
*calculate the acceleration procedure , a totally 1000 elements array.
* parameter fre[]: point to the array that keeps the freq value.
* period[]: point to the array that keeps the timer period value.
* len: the procedure of acceleration length.it is best thing to set the float number, some compile software maybe transfer error if set it as a int
* fre_max: maximum speed, frequency vale.
* fre_min: start minimum speed, frequency vale. mind : 10000000/65535 = 152, so fre_min can't less than 152.
* flexible: flexible value. adjust the S curves
*/
void CalculateSModelLine(float fre[], unsigned short period[], float len, float fre_max, float fre_min, float flexible)
{
int i=0;
float deno ;
float melo ;
float delt = fre_max-fre_min;
for(; i;>
{
melo = flexible * (i-len/2) / (len/2);
deno = 1.0 / (1 + expf(-melo)); //expf is a library function of exponential(e)
fre[i] = delt * deno + fre_min;
period[i] = (unsigned short)(10000000.0 / fre[i]); // 10000000 is the timer driver frequency
}
return ;
}
文章整合自:CSDN
編輯:ymf
-
驅(qū)動(dòng)
+關(guān)注
關(guān)注
12文章
1927瀏覽量
88170 -
STM32
+關(guān)注
關(guān)注
2305文章
11118瀏覽量
370956 -
步進(jìn)電機(jī)
+關(guān)注
關(guān)注
152文章
3215瀏覽量
151516
發(fā)布評(píng)論請(qǐng)先 登錄
基于UART通訊控制TMC2208/2209模塊驅(qū)動(dòng)兩相四線步進(jìn)電機(jī)
?DRV8818步進(jìn)電機(jī)控制器IC技術(shù)文檔總結(jié)
EVL6470步進(jìn)電機(jī)驅(qū)動(dòng)評(píng)估板技術(shù)解析與應(yīng)用指南
?DRV8434步進(jìn)電機(jī)驅(qū)動(dòng)器技術(shù)文檔總結(jié)
關(guān)于TMC2208與TMC2209的區(qū)別及基于STM32F103控制TMC2209模塊驅(qū)動(dòng)2相4線步進(jìn)電機(jī)
DRV8461步進(jìn)電機(jī)驅(qū)動(dòng)器技術(shù)解析與應(yīng)用指南
6軸步進(jìn)電機(jī)驅(qū)動(dòng)+STM32F767+485+CAN+網(wǎng)口+12輸入輸出原理圖
Analog Devices / Maxim Integrated MAX22204步進(jìn)電機(jī)驅(qū)動(dòng)器數(shù)據(jù)手冊(cè)
TMCM-3216步進(jìn)電機(jī)控制器/驅(qū)動(dòng)器模塊
Analog Devices / Maxim Integrated MAX22210步進(jìn)電機(jī)驅(qū)動(dòng)器數(shù)據(jù)手冊(cè)
ADI Trinamic TMC5272步進(jìn)電機(jī)控制器數(shù)據(jù)手冊(cè)
ADI Trinamic TMC5271步進(jìn)電機(jī)控制器數(shù)據(jù)手冊(cè)
HJ4205步進(jìn)電機(jī)驅(qū)動(dòng)電路詳解
想讓步進(jìn)電機(jī)控制更順滑?微步控制優(yōu)勢(shì)與挑戰(zhàn)全揭秘!
基于STM32F405RGT6的TMC2660步進(jìn)電機(jī)驅(qū)動(dòng)器,附帶原理圖+PCB

STM32步進(jìn)電機(jī)驅(qū)動(dòng)的算法
評(píng)論