9#include <flexptp_options.h>
14#define K_P (0.5 * 0.476)
50#error "No CMD_FUNCTION macro has been defined, cannot register CLI functions!"
53static CMD_FUNCTION(CB_params) {
61 MSG(
"> PTP params: K_p = %.3f, K_i = %.3f, K_d = %.3f\n",
Kp,
Ki,
Kd);
66static CMD_FUNCTION(CB_logInternals) {
68 int en =
ONOFF(ppArgs[0]);
71 MSG(
"\nSyncIntv. [ns] | dt [ns] | gamma [ppb]\n\n");
89static void pid_ctrl_register_cli_commands() {
90 sCliCmdIdx.params =
CLI_REG_CMD(
"ptp servo params [Kp Ki Kd] \t\t\tSet or query Kp, Ki, and Kd servo parameters", 3, 0, CB_params);
91 sCliCmdIdx.internals =
CLI_REG_CMD(
"ptp servo log internals {on|off} \t\t\tEnable or disable logging of servo internals", 4, 1, CB_logInternals);
96static void pid_ctrl_remove_cli_commands() {
97 CLI_REMOVE_CMD(sCliCmdIdx.params);
98 CLI_REMOVE_CMD(sCliCmdIdx.internals);
108 pid_ctrl_register_cli_commands();
114 pid_ctrl_remove_cli_commands();
#define CLI_REG_CMD(cmd_hintline, n_cmd, n_min_arg, cb)
static float Kp
Proportional factor.
#define K_D
Default Kd parameter value.
static double rd_prev_ppb
relative frequency error measured in previous iteration
static bool logInternals
Decides if servo's internal operation shoud be reported or not.
static float Ki
Integrating factor.
#define K_I
Default Ki parameters value.
static bool firstRun
Indicates if first run did not occur yet.
static double integrator_value
value stored in the integrator
static float Kd
Differentiating factor.
float pid_ctrl_run(int32_t dt, PtpServoAuxInput *pAux)
#define K_P
Default Kp parameter value.