电机能运行的速度远远大于启动速度(即最大匀速速度),那么怎么平稳的运行到最大速度就是S型加减速曲线的作用
1、Qt
1.1、S加减速的计算
static float Freq[10][1000];
static unsigned int Period[10][1000];
/******************************************************************************
*
* Calculate the Period and Frequency 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 frequency value.
* parameter : *period - point to the array that keeps the period value.
* len : the procedure of accceleration 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 value.
* fre_min : minimum speed, frequency value.
* mind : 72 * 1000000 / 2^32 = 0.1, so fre_min can't less than 0.1.
* flexible : flexible value. adjust the S curves.
* Y = A + B / (1 + math.pow(exp, (-ax+b)))
* 其中的A分量在y方向进行平移, B分量在y方向进行拉伸,(ax+b)在x方向进行平移和拉伸.
* 加速过程 : 从fre_min Hz加速到fre_max Hz
* 采用1000个点进行加速处理。最终在加速过程中采用的曲线方程为:
* Fcurrent = Fmin + (Fmax - Fmin)/(1 + math.pow(exp, -Flexible * (i - num)/num
* 其中1000000为1MHz频率,此为定时器频率,由自己的设置和改变
* 最大的频率和最小的频率,最好是通过自己调试无杂音的频率
*******************************************************************************/
//S型加减速曲线的参数点的计算公式,
//0-999为加速的,999-0为减速的
void CalculateSModelLine(float *fre, unsi