Files
2025-06-19 21:57:12 +08:00

22 lines
503 B
C
Raw Permalink 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 __PID_H__
#define __PID_H__
typedef struct
{
float kp;
float ki;
float kd;
float setpoint; // 目标值
float integral; // 积分项
float prev_error; // 上一次误差
float output; // 输出
unsigned long last_time; // 上次计算的时间戳单位ms
} PID_TypeDef;
void PID_Init(PID_TypeDef *pid, float kp,float ki, float ka);
float PID_Calculate(PID_TypeDef *pid,float measured,unsinged long now_time);
#endif // __PID_H__