pos_pid_controller.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-08-26 sogwms The first version
  9. */
  10. #ifndef __POS_PID_CONTROLLER_H__
  11. #define __POS_PID_CONTROLLER_H__
  12. #include <rtthread.h>
  13. #include "controller.h"
  14. typedef struct pos_pid_controller *pos_pid_controller_t;
  15. struct pos_pid_controller
  16. {
  17. struct controller controller;
  18. float kp;
  19. float ki;
  20. float kd;
  21. float minimum;
  22. float maximum;
  23. float anti_windup_value;
  24. float p_error;
  25. float i_error;
  26. float d_error;
  27. float integral;
  28. float error;
  29. float error_l;
  30. float last_out;
  31. rt_tick_t last_time;
  32. };
  33. pos_pid_controller_t pos_pid_controller_create(float kp, float ki, float kd, rt_uint16_t sample_time);
  34. rt_err_t pos_pid_controller_set_kp(pos_pid_controller_t pid, float kp);
  35. rt_err_t pos_pid_controller_set_ki(pos_pid_controller_t pid, float ki);
  36. rt_err_t pos_pid_controller_set_kd(pos_pid_controller_t pid, float kd);
  37. #endif // __POS_PID_CONTROLLER_H__