63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
#pragma once
|
|
|
|
#include <sys/errno.h>
|
|
|
|
typedef union {
|
|
fp4816_t values[10];
|
|
struct {
|
|
fp4816_t kp,
|
|
ki,
|
|
kd;
|
|
|
|
fp4816_t integral,
|
|
last_value,
|
|
out;
|
|
|
|
fp4816_t lim_omin, // Lower Limit: Output
|
|
lim_omax, // Upper Limit: Output
|
|
lim_imin, // Lower Limit: Integral
|
|
lim_imax; // Upper Limit: Integral
|
|
};
|
|
} fp4816_pid_t;
|
|
|
|
|
|
fp4816_pid_t* pid4816_create (void);
|
|
int pid4816_set (fp4816_pid_t *pid,fp4816_t Kp,fp4816_t Ki,fp4816_t Kd);
|
|
|
|
int pid4816_set_kp (fp4816_pid_t *pid,fp4816_t Kp);
|
|
int pid4816_set_ki (fp4816_pid_t *pid,fp4816_t Ki);
|
|
int pid4816_set_kd (fp4816_pid_t *pid,fp4816_t Kd);
|
|
|
|
int pid4816_get_kp (fp4816_pid_t *pid,fp4816_t *Kp);
|
|
int pid4816_get_ki (fp4816_pid_t *pid,fp4816_t *Ki);
|
|
int pid4816_get_kd (fp4816_pid_t *pid,fp4816_t *Kd);
|
|
|
|
int pid4816_set_limits
|
|
(fp4816_pid_t *pid,fp4816_t *omin,fp4816_t *omax,fp4816_t *imin,fp4816_t *imax);
|
|
int pid4816_get_limits
|
|
(fp4816_pid_t *pid,fp4816_t *omin,fp4816_t *omax,fp4816_t *imin,fp4816_t *imax);
|
|
|
|
static inline int pid4816_clear (fp4816_pid_t *pid){
|
|
if (!pid)
|
|
return -ENULLPTR;
|
|
|
|
pid->integral = 0;
|
|
pid->last_value = 0;
|
|
pid->out = 0;
|
|
|
|
return ESUCCESS;
|
|
};
|
|
|
|
|
|
int pid4816_cycle (fp4816_pid_t *pid,fp4816_t value);
|
|
|
|
static inline int pid4816_get_value(fp4816_pid_t *pid,fp4816_t *value){
|
|
if (pid){
|
|
*value = pid->out;
|
|
return ESUCCESS;
|
|
};
|
|
return -ENULLPTR;
|
|
};
|
|
|
|
|