Commit 0f82b26b authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Improve limit of i2t when some budget is already taken...

parent 348c480c
...@@ -67,7 +67,7 @@ static void i2t_calculate(struct controller_block *block) ...@@ -67,7 +67,7 @@ static void i2t_calculate(struct controller_block *block)
if (i2t >= peak2t) if (i2t >= peak2t)
priv->Ilim = priv->continuous; priv->Ilim = priv->continuous;
else else
priv->Ilim = priv->peaklim; priv->Ilim = sqrtf(peak2t - i2t + continuous2);
priv->i2t = i2t; priv->i2t = i2t;
} }
...@@ -75,10 +75,9 @@ static void i2t_calculate(struct controller_block *block) ...@@ -75,10 +75,9 @@ static void i2t_calculate(struct controller_block *block)
static void set_peak2t(struct controller_block *i2t) static void set_peak2t(struct controller_block *i2t)
{ {
struct controller_block_private *priv = i2t->private; struct controller_block_private *priv = i2t->private;
double tick = controller_time_period_get(i2t->time);
priv->peak2t = (priv->peak * priv->peak - priv->continuous2) * priv->duration / tick; priv->peak2t = (priv->peak * priv->peak - priv->continuous2) * priv->duration;
priv->peaklim = priv->peak / tick; priv->peaklim = priv->peak * priv->duration;
} }
static int param_set_peak(struct controller_block *i2t, char *param, int argc, static int param_set_peak(struct controller_block *i2t, char *param, int argc,
...@@ -96,8 +95,9 @@ static int param_set_duration(struct controller_block *i2t, char *param, int arg ...@@ -96,8 +95,9 @@ static int param_set_duration(struct controller_block *i2t, char *param, int arg
va_list val) va_list val)
{ {
struct controller_block_private *priv = i2t->private; struct controller_block_private *priv = i2t->private;
double tick = controller_time_period_get(i2t->time);
priv->duration = va_arg(val, double); priv->duration = va_arg(val, double) / tick;
set_peak2t(i2t); set_peak2t(i2t);
return 0; return 0;
......
...@@ -39,14 +39,14 @@ params { ...@@ -39,14 +39,14 @@ params {
} }
{ "test_1_Ilim", "value", 30, { "test_1_Ilim", "value", 30,
(float) { (float) {
30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 90.0, 90.0, 90.0, 90.0, 90.0, 90.0, 90.0, 90.0, 90.0, 90.0,
30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 10.0, 85.0, 81.0, 75.0, 70.0, 64.0, 57.0, 50.0, 41.0, 30.0, 10.0,
10.0, 10.0, 10.0, 10.0, 10.0, 30.0, 30.0, 30.0, 30.0, 30.0 10.0, 10.0, 10.0, 10.0, 10.0, 12.0, 13.0, 16.0, 19.0, 22.0
}, },
(float) { (float) {
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0
} }
} }
{ "test_10_I", "value", 30, (float) { { "test_10_I", "value", 30, (float) {
...@@ -56,14 +56,14 @@ params { ...@@ -56,14 +56,14 @@ params {
} }
{ "test_10_Ilim", "value", 30, { "test_10_Ilim", "value", 30,
(float) { (float) {
300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 283.0, 283.0, 283.0, 283.0, 283.0, 283.0, 283.0, 283.0, 283.0, 283.0,
300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 300.0, 281.0, 267.0, 252.0, 235.0, 217.0, 198.0, 177.0, 153.0, 124.0, 85.0,
10.0, 10.0, 10.0, 10.0, 10.0, 300.0, 300.0, 300.0, 300.0, 300.0 10.0, 10.0, 10.0, 10.0, 10.0, 12.0, 22.0, 30.0, 44.0, 54.0
}, },
(float) { (float) {
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0
} }
} }
} }
Supports Markdown
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