Commit 9634b339 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Add multifrequency support

The frequency keyword has been removed.
The blocks keyword now needs two arguments: frequency (Hz) and delay (seconds)
parent 303f8814
......@@ -18,8 +18,8 @@ help:
echo " release Build both controller and console release"; \
echo " clean Clean for both controller and console"; \
echo ""; \
echo " HOST=<prefix> Cross compile for <prefix>.";\
echo " e.g.: HOST=arm-linux-gnueabihf"; \
echo " HOSTSYS=<prefix> Cross compile for <prefix>.";\
echo " e.g.: HOSTSYS=arm-linux-gnueabihf"; \
echo ""; \
echo "Building a release"; \
echo "------------------"; \
......
......@@ -17,11 +17,11 @@ else
FLEX=/usr/local/bin/flex
endif
ifdef HOST
CC=${HOST}-gcc
LIBTOOL=${HOST}-libtool
CONF_HOST=--host=${HOST}
HW=$(HOST)
ifdef HOSTSYS
CC=${HOSTSYS}-gcc
LIBTOOL=${HOSTSYS}-libtool
CONF_HOST=--host=${HOSTSYS}
HW=$(HOSTSYS)
endif
......
......@@ -20,6 +20,8 @@
#ifndef _INCLUDE_LOG_H_
#define _INCLUDE_LOG_H_
#include <stdlib.h>
enum log_type {
LOG_T_ERROR,
LOG_T_WARNING,
......
frequency 10
trigger {
{ "immediate" }
}
blocks {
blocks (10.0, 0.0) {
{ "command_bool", "command_bool" }
{ "test_output_bool", "value" }
......
frequency 250
trigger {
{ "immediate" }
}
blocks {
blocks (250.0, 0.0) {
{ "random", "noise" }
{ "filter_iir", "iir" }
{ "filter_iir", "iir2" }
......
......@@ -22,7 +22,7 @@
#include <string.h>
#include <controller/controller_block.h>
#include <controller/controller_sample.h>
#include <controller/controller_time.h>
/*
inputs outputs
......@@ -58,10 +58,12 @@ static void filter_lp_calculate(struct controller_block *lp)
static int param_set(struct controller_block *lp, va_list val)
{
double period = controller_time_period_get(lp->time);
lp->private->tau = va_arg(val, double);
lp->private->alpha =
controller_sample_period() / (controller_sample_period() + lp->private->tau);
lp->private->alpha = period / (period + lp->private->tau);
return 0;
}
......
frequency 100
trigger {
{ "immediate" }
}
blocks {
blocks (100.0, 0.0) {
{ "gain", "gain" }
{ "test_input_float", "test_input" }
......
frequency 10
trigger {
{ "immediate" }
}
blocks {
blocks (10.0, 0.0) {
{ "limit", "limit" }
{ "test_input_float", "in" }
......
......@@ -23,7 +23,7 @@
#include <math.h>
#include <controller/controller_block.h>
#include <controller/controller_sample.h>
#include <controller/controller_time.h>
/*
inputs outputs
......@@ -119,10 +119,12 @@ static void limit_2nd_calculate(struct controller_block *limit)
static void param_prep(struct controller_block *limit)
{
double period = controller_time_period_get(limit->time);
limit->private->min = limit->private->mint
* controller_sample_period() * controller_sample_period();
* period * period;
limit->private->max = limit->private->maxt
* controller_sample_period() * controller_sample_period();
* period * period;
limit->private->imin = 1.0 / limit->private->min;
limit->private->imax = 1.0 / limit->private->max;
}
......
frequency 10
trigger {
{ "immediate" }
}
blocks {
blocks (10.0, 0.0) {
{ "matrix_2x2", "matrix" }
{ "test_input_float", "in0" }
......
frequency 100
trigger {
{ "immediate" }
}
blocks {
blocks (100.0, 0.0) {
{ "not", "not" }
{ "test_input_bool", "test_input" }
......
......@@ -22,7 +22,7 @@
#include <string.h>
#include <controller/controller_block.h>
#include <controller/controller_sample.h>
#include <controller/controller_time.h>
/*
inputs outputs
......@@ -106,10 +106,10 @@ static void param_prep(struct controller_block *pid)
{
pid->private->ci =
pid->private->ki *
controller_sample_period();
controller_time_period_get(pid->time);
pid->private->cd =
pid->private->kd /
controller_sample_period();
controller_time_period_get(pid->time);
}
static int param_set_kp(struct controller_block *pid, va_list val)
......
......@@ -22,7 +22,7 @@
#include <string.h>
#include <controller/controller_block.h>
#include <controller/controller_sample.h>
#include <controller/controller_time.h>
/*
inputs outputs
......@@ -113,8 +113,8 @@ static void pid_aw_calculate(struct controller_block *pid)
static void param_prep(struct controller_block *pid)
{
pid->private->ci = pid->private->ki * controller_sample_period();
pid->private->cd = pid->private->kd / controller_sample_period();
pid->private->ci = pid->private->ki * controller_time_period_get(pid->time);
pid->private->cd = pid->private->kd / controller_time_period_get(pid->time);
}
static int param_set_kp(struct controller_block *pid, va_list val)
......
frequency 100
trigger {
{ "immediate" }
}
blocks {
blocks (100.0, 0.0) {
{ "pid_aw", "pid" }
{ "test_input_float", "in" }
......
frequency 10
trigger {
{ "immediate" }
}
blocks {
blocks (10.0, 0.0) {
{ "quantize", "quantize" }
{ "test_input_float", "in" }
......
frequency 10
trigger {
{ "immediate" }
}
blocks {
blocks (10.0, 0.0) {
{ "rangecheck", "rangecheck" }
{ "test_input_float", "in" }
......
......@@ -24,7 +24,7 @@
#include <log/log.h>
#include <controller/controller_block.h>
#include <controller/controller_sample.h>
#include <controller/controller_time.h>
#include <controller/controller_command.h>
/*
......@@ -142,7 +142,7 @@ static void servo_state_calculate(struct controller_block *servo_state)
float out_x = priv->out_x;
float out_v = priv->out_v;
float out_a = 0.0;
float t = controller_sample_period();
float t = controller_time_period_get(servo_state->time);
if (out_v > 0.0) {
out_a = -priv->max_a;
......
frequency 10
trigger {
{ "immediate" }
}
blocks {
blocks (10.0, 0.0) {
{ "servo_state", "servo_state" }
{ "test_input_float", "spg_x" }
......
......@@ -26,7 +26,7 @@
#include <controller/controller_block.h>
#include <controller/controller_command.h>
#include <controller/controller_sample.h>
#include <controller/controller_time.h>
#include <log/log.h>
/*
......@@ -184,7 +184,7 @@ static void setpoint_generator_1d_calculate(struct controller_block *spg)
}
if (priv->cur_command.type == COMMAND_PTYPE_SPEED) {
cur_v = priv->cmd_v * controller_sample_period();
cur_v = priv->cmd_v * controller_time_period_get(spg->time);
priv->cmd_x = cur_x + cur_v;
if (priv->cmd_x > priv->max_x)
priv->cmd_x = priv->max_x;
......@@ -253,10 +253,10 @@ static int block_setpoint_generator_command_filter(struct controller_command *co
static void scale(struct controller_block *spg)
{
/* Scale all settings to sample time unit */
spg->private->max_v = spg->private->max_v_sec * controller_sample_period();
spg->private->max_v = spg->private->max_v_sec * controller_time_period_get(spg->time);
spg->private->freq = 1.0 / controller_sample_period();
spg->private->period_nsec = controller_sample_period() * 1000000000;
spg->private->freq = 1.0 / controller_time_period_get(spg->time);
spg->private->period_nsec = controller_time_period_get(spg->time) * 1000000000;
}
static int param_set_setpoint(struct controller_block *spg, va_list val)
......
frequency 10
trigger {
{ "immediate" }
}
blocks {
blocks (10.0, 0.0) {
{ "setpoint_generator_1d", "spg", "spg", "na" }
{ "test_input_bool", "reset" }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment