Skip to content
Snippets Groups Projects
Commit ddbc6a79 authored by ucart's avatar ucart
Browse files
parents 3992a71e e711eb3f
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ static void pid_computation(void *state, const double* params, const double *inp ...@@ -48,7 +48,7 @@ static void pid_computation(void *state, const double* params, const double *inp
if (fabs(params[PID_KI]) <= FLT_EPSILON) { if (fabs(params[PID_KI]) <= FLT_EPSILON) {
pid_state->acc_error = 0; pid_state->acc_error = 0;
} else { } else {
pid_state->acc_error += error; pid_state->acc_error += (error * inputs[PID_DT]);
} }
if (pid_state->just_reset) { if (pid_state->just_reset) {
...@@ -60,7 +60,7 @@ static void pid_computation(void *state, const double* params, const double *inp ...@@ -60,7 +60,7 @@ static void pid_computation(void *state, const double* params, const double *inp
// Compute each term's contribution // Compute each term's contribution
P = params[PID_KP] * error; P = params[PID_KP] * error;
I = params[PID_KI] * pid_state->acc_error * inputs[PID_DT]; I = params[PID_KI] * pid_state->acc_error;
// Low-pass filter on derivative // Low-pass filter on derivative
double change_in_value = inputs[PID_CUR_POINT] - pid_state->prev_val; double change_in_value = inputs[PID_CUR_POINT] - pid_state->prev_val;
double term1 = params[PID_ALPHA] * pid_state->last_filtered; double term1 = params[PID_ALPHA] * pid_state->last_filtered;
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
* NOTE: * NOTE:
* If you wound up here after following some IDE function declaration trail, * If you wound up here after following some IDE function declaration trail,
* you've hit the end of the application layer. Go to the location of the * you've hit the end of the application layer. Go to the location of the
* hardware layer appropriate for your circumstance:p * hardware layer appropriate for your circumstance:
* ../../xsdk_worksapce/modular_quad_pid -> running quad_app on the Zybo * ../../xsdk_worksapce/real_quad -> running quad_app on the Zybo
* ../virt_quad -> running quad_app in a Unix environment * ../virt_quad -> running quad_app in a Unix environment
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment