X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Falgo%2Fpid_control.c;h=73e7ffdf7badb0503507020eb7385800f8f618ba;hb=7a613efa9f80222fa9642bfb6a249972c7ae6c6e;hp=90a368f2da95d269610a0a6393c877b3389da564;hpb=1a045725086dd85d06d93650a8906ccd66330e34;p=bertos.git diff --git a/bertos/algo/pid_control.c b/bertos/algo/pid_control.c index 90a368f2..73e7ffdf 100644 --- a/bertos/algo/pid_control.c +++ b/bertos/algo/pid_control.c @@ -32,13 +32,19 @@ * * \brief Proportional, integral, derivative controller (PID controller) (implementation) * - * \version $Id$ * * \author Daniele Basile */ #include "pid_control.h" +#include "cfg/cfg_pid.h" + +// Define logging setting (for cfg/log.h module). +#define LOG_LEVEL PID_LOG_LEVEL +#define LOG_VERBOSITY PID_LOG_FORMAT + +#include #include /** @@ -80,14 +86,14 @@ piddata_t pid_control_update(PidContext *pid_ctx, piddata_t target, piddata_t cu D = (err - pid_ctx->prev_err) * pid_ctx->cfg->kd / ((piddata_t)pid_ctx->cfg->sample_period / 1000); -// TRACEMSG("curr_pos[%lf],tgt[%lf],err[%f],P[%f],I[%f],D[%f]", curr_pos, target, err, P, I, D); + LOG_INFO("curr_pos[%lf],tgt[%lf],err[%f],P[%f],I[%f],D[%f]", curr_pos, target, err, P, I, D); //Store the last error value pid_ctx->prev_err = err; piddata_t pid = MINMAX(pid_ctx->cfg->out_min, (P + I + D), pid_ctx->cfg->out_max); -// TRACEMSG("pid[%lf]",pid); + LOG_INFO("pid[%lf]",pid); //Clamp out between out_min and out_max return pid;