inc_pid_controller.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 __INC_PID_CONTROLLER_H__
  11. #define __INC_PID_CONTROLLER_H__
  12. #include <rtthread.h>
  13. #include "controller.h"
  14. typedef struct inc_pid_controller *inc_pid_controller_t;
  15. struct inc_pid_controller
  16. {
  17. struct controller controller;
  18. float kp;
  19. float ki;
  20. float kd;
  21. float minimum;
  22. float maximum;
  23. float p_error;
  24. float i_error;
  25. float d_error;
  26. float error;
  27. float error_l;
  28. float error_ll;
  29. float last_out;
  30. rt_tick_t last_time;
  31. };
  32. inc_pid_controller_t inc_pid_controller_create(float kp, float ki, float kd, rt_uint16_t sample_time);
  33. rt_err_t inc_pid_controller_set_kp(inc_pid_controller_t pid, float kp);
  34. rt_err_t inc_pid_controller_set_ki(inc_pid_controller_t pid, float ki);
  35. rt_err_t inc_pid_controller_set_kd(inc_pid_controller_t pid, float kd);
  36. #endif