PID制御計算用ライブラリ
Dependents: ROBOCON2017_archan ROBOCON2017_suchan
Revision 2:e340bdcb9bca, committed 2017-09-18
- Comitter:
- Akito914
- Date:
- Mon Sep 18 11:31:45 2017 +0000
- Parent:
- 1:f1f6c98a4b12
- Commit message:
- ??????????????????
Changed in this revision
cal_PID.cpp | Show annotated file Show diff for this revision Revisions of this file |
cal_PID.hpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f1f6c98a4b12 -r e340bdcb9bca cal_PID.cpp --- a/cal_PID.cpp Wed Sep 28 01:42:33 2016 +0000 +++ b/cal_PID.cpp Mon Sep 18 11:31:45 2017 +0000 @@ -32,8 +32,8 @@ past_error=0; integral_error=0; } -signed long cal_pid::get_pid(signed long position,signed long targ,int rd){ - error=targ-position; +signed long cal_pid::get_pid(signed long position,signed long targ, int out_dir){ + error = targ - position; integral_error+=error*control_period; differential_error=(error-past_error)/control_period; past_error=error; @@ -41,7 +41,7 @@ i_part=integral_error*i_gain; d_part=differential_error*d_gain; operate=p_part+i_part+d_part; - operate*=rd; + operate *= out_dir; if(operate<output_min)operate=output_min; else if(operate>output_max)operate=output_max;
diff -r f1f6c98a4b12 -r e340bdcb9bca cal_PID.hpp --- a/cal_PID.hpp Wed Sep 28 01:42:33 2016 +0000 +++ b/cal_PID.hpp Mon Sep 18 11:31:45 2017 +0000 @@ -12,7 +12,7 @@ void period(float _control_period); void output(signed long _min,signed long _max); void reset(); - signed long get_pid(signed long position,signed long targ,int rd=1); + signed long get_pid(signed long position,signed long targ, int out_dir = 1); private: signed long error; signed long past_error;