optical/NxFuncs/motions/curves.h
2025-09-04 09:45:08 +08:00

94 lines
2.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __CURVES_H__
#define __CURVES_H__
#include "config.h"
//--------------------------------------------------
// 梯形加减速曲线
typedef struct
{
// 输入参数
u32 movement; // 本段位移量
float begPPS; // 本段初始速度
float endPPS; // 本段结束速度
float runPPS; // 本段运行速度
float maxPPSS; // 最大的加速度
// 计算中间变量和结果
u32 mvmtseg[3]; // 三段位移, 分段的位移量 (如果位移量不为零, 说明存在这个段)
float newRunPPS; // 新的运行速度
float newAddPPSS; // 新的加速度
}TTypeCtrl;
//--------------------------------------------------
// 计算位移量
u32 TTypeCalcDisplacement(float pps1, float pps2, float ppss);
// 计算加速度
float TTypeCalcAddPPSS(u32 disp, float pps1, float pps2);
// 计算运动结束的速度
float TTypeCalcEndSpd(u32 disp, float pps1, float ppss);
// 计算运动的时间
float TTypeCalcRunTime(u32 disp, u32 startpps, u32 stoppps, u32 runpps, u32 addppss);
// 计算运动相关参数
int TTypeCalcRunParas(TTypeCtrl * pTTypeCtrl);
// 计算生成分频系数表
int TTypeCalcDivTab(u32 fin, TTypeCtrl * pTTypeCtrl, u32 * pFidvTab, u32 * pTablen);
//--------------------------------------------------
// 7段S型加减速曲线
typedef struct
{
// 输入参数
u32 movement; // 本段位移量
float begPPS; // 本段初始速度
float endPPS; // 本段结束速度
float runPPS; // 本段运行速度v
float maxPPSS; // 最大的加速度a
float maxPPSSS; // 最大的加加速度j
// 计算中间变量和结果
u32 timeseg[7]; // 七段时间长度, 单位为1个时间片
u32 mvmtseg[7]; // 七段位移, 分段的位移量 (如果位移量不为零, 说明存在这个段)
float newRunPPS; // 新的运行速度
}STypeCtrl;
// 计算位移量
u32 STypeCalcDisplacement(float pps1, float pps2, float ppss);
// 计算加速度
float STypeCalcAddPPSS(u32 disp, float pps1, float pps2);
// 计算运动结束的速度
float STypeCalcEndSpd(u32 disp, float pps1, float ppss);
// 计算运动的时间
float STypeCalcRunTime(u32 disp, u32 startpps, u32 stoppps, u32 runpps, u32 addppss);
// 计算运动相关参数
int STypeCalcRunParas(STypeCtrl * pSTypeCtrl);
// 计算生成分频系数表
int STypeCalcDivTab(u32 fin, STypeCtrl * pSTypeCtrl, u32 * pFidvTab, u32 * pTablen);
//--------------------------------------------------
#endif