64 lines
1.6 KiB
C
64 lines
1.6 KiB
C
/*
|
|
* @Author: 张小明 zxm5337@163.com
|
|
* @Date: 2024-06-25 10:26:36
|
|
* @LastEditors: DaMingSY zxm5337@163.com
|
|
* @LastEditTime: 2024-09-03 09:19:23
|
|
* @FilePath: \controller-v2\User\lib\control\custom\cascade_pid_zh.h
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
*/
|
|
#ifndef __CASCADE_PID_ZH__
|
|
#define __CASCADE_PID_ZH__
|
|
|
|
#include "data_type_def.h"
|
|
|
|
typedef enum
|
|
{
|
|
TARGET_DIR_ADD,
|
|
TARGET_DIR_SUB,
|
|
} target_dir_e;
|
|
|
|
typedef struct
|
|
{
|
|
float kp;
|
|
float ki;
|
|
float kd;
|
|
|
|
float kup;
|
|
float kui;
|
|
float kud;
|
|
} fuzzy_pid_t;
|
|
|
|
typedef struct
|
|
{
|
|
BOOL iDetach, sm_open, fuzzy_open;
|
|
float feedBack;
|
|
float target, maxTarget;
|
|
float duty, kp, ki, kd;
|
|
float error, dError, lastError, errorDead;
|
|
float integral, iDetachCondation;
|
|
float output, maxOutput;
|
|
fuzzy_pid_t fuzzy_pid;
|
|
} smart_pid_t;
|
|
|
|
typedef struct
|
|
{
|
|
smart_pid_t inner;
|
|
smart_pid_t outer;
|
|
float output;
|
|
} cascade_pid_t;
|
|
|
|
typedef struct CascadePID
|
|
{
|
|
void (*smart_pid_init)(smart_pid_t *pid, float *duty, float *kp, float *ki, float *kd, float *errorDead, float *iDetachCondation, float *maxOut);
|
|
void (*cascade_pid_init)(cascade_pid_t *pid, smart_pid_t *pid_outer, smart_pid_t *pid_inner);
|
|
void (*smart_pid_calc)(smart_pid_t *pid, float *target, float *feedback);
|
|
void (*cascade_pid_calc)(struct CascadePID *pid, float *outerRef, float *outerFdb, float *innerFdb);
|
|
|
|
smart_pid_t smart_pid;
|
|
cascade_pid_t cascade_pid;
|
|
} pid_zh1_t; // PID_t;
|
|
|
|
extern void pid_zh_constructor1(struct CascadePID *pid);
|
|
|
|
#endif
|