From: (no author) <(no author)@38d2e660-2303-0410-9eaa-f027e97ec537> Date: Thu, 20 Aug 2009 14:47:36 +0000 (+0000) Subject: Use log and add pid configuration. X-Git-Tag: 2.2.0~192 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=8c4129cddaeb7181c0a0682a8490cb2a596064a1;p=bertos.git Use log and add pid configuration. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2776 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/algo/pid_control.c b/bertos/algo/pid_control.c index 90a368f2..df127e43 100644 --- a/bertos/algo/pid_control.c +++ b/bertos/algo/pid_control.c @@ -39,6 +39,13 @@ #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 +87,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; diff --git a/bertos/cfg/cfg_pid.h b/bertos/cfg/cfg_pid.h new file mode 100644 index 00000000..5a8375bb --- /dev/null +++ b/bertos/cfg/cfg_pid.h @@ -0,0 +1,57 @@ +/** + * \file + * + * + * \brief Configuration file for PWM module. + * + * \version $Id$ + * \author Daniele Basile + */ + +#ifndef CFG_PID_H +#define CFG_PID_H + +/** + * Module logging level. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_level" + */ +#define PID_LOG_LEVEL LOG_LVL_WARN + +/** + * Module logging format. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_format" + */ +#define PID_LOG_FORMAT LOG_FMT_VERBOSE + +#endif /* CFG_PID_H */