mirror of
https://gitee.com/dlmu-cone/tronone-h7-scaffold
synced 2026-07-24 19:37:45 +08:00
add ffc controller
This commit is contained in:
@@ -44,7 +44,7 @@ float FFC_FeedForwardCalc(FFC_Handle_t *handle, float target) {
|
|||||||
handle->result = abs_clip(handle->result, handle->configs.MaxOutput);
|
handle->result = abs_clip(handle->result, handle->configs.MaxOutput);
|
||||||
|
|
||||||
// 更新历史状态
|
// 更新历史状态
|
||||||
// 注意:原 C++ 代码中先更新 LAST 再更新 LLAST,这会导致移位寄存器逻辑变为 LLAST = (新的)LAST。
|
// 注意:原代码中先更新 LAST 再更新 LLAST,这会导致移位寄存器逻辑变为 LLAST = (新的)LAST。
|
||||||
// 为了保持转换的一致性,这里保留原代码的顺序。
|
// 为了保持转换的一致性,这里保留原代码的顺序。
|
||||||
handle->set[FFC_LAST] = handle->set[FFC_NOW];
|
handle->set[FFC_LAST] = handle->set[FFC_NOW];
|
||||||
handle->set[FFC_LLAST] = handle->set[FFC_LAST];
|
handle->set[FFC_LLAST] = handle->set[FFC_LAST];
|
||||||
@@ -70,7 +70,6 @@ void FFC_CheckPointer(FFC_Handle_t *handle, float *get) {
|
|||||||
void FFC_Init(FFC_Handle_t *handle, FFC_Init_Config_s config, float *get) {
|
void FFC_Init(FFC_Handle_t *handle, FFC_Init_Config_s config, float *get) {
|
||||||
if (handle == NULL) return;
|
if (handle == NULL) return;
|
||||||
|
|
||||||
// 对应 C++: FFCSetConfig(config, get)
|
|
||||||
FFC_SetConfig(handle, config);
|
FFC_SetConfig(handle, config);
|
||||||
if (get != NULL) {
|
if (get != NULL) {
|
||||||
FFC_CheckPointer(handle, get);
|
FFC_CheckPointer(handle, get);
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
* @file controller.c
|
* @file controller.c
|
||||||
* @author wanghongxi
|
* @author wanghongxi
|
||||||
* @author modified by TuxMonkey
|
* @author modified by TuxMonkey
|
||||||
* @brief PID控制器定义
|
* @brief PID控制器及前馈控制器
|
||||||
* @version beta
|
* @version beta
|
||||||
* @date 2026-02-12
|
* @date 2026-02-12
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2025 DLMU.CONE EC all rights reserved
|
* @copyright Copyright (c) 2025 DLMU.CONE EC all rights reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pid.h"
|
#include "pid.h"
|
||||||
|
#include "ffc.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
/* ----------------------------下面是pid优化环节的实现---------------------------- */
|
/* ----------------------------下面是pid优化环节的实现---------------------------- */
|
||||||
@@ -80,7 +82,8 @@ static void f_Output_Filter(PIDInstance *pid)
|
|||||||
pid->Last_Output * pid->Output_LPF_RC / (pid->Output_LPF_RC + pid->dt);
|
pid->Last_Output * pid->Output_LPF_RC / (pid->Output_LPF_RC + pid->dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 前馈控制计算
|
// 前馈控制计算(后续考虑写成电流/速度前馈)
|
||||||
|
|
||||||
static void f_FeedForward_Control(PIDInstance *pid)
|
static void f_FeedForward_Control(PIDInstance *pid)
|
||||||
{
|
{
|
||||||
// 更新设定值历史
|
// 更新设定值历史
|
||||||
|
|||||||
Reference in New Issue
Block a user