PER Firmware
Loading...
Searching...
No Matches
bangbang.h File Reference

Generic bang-bang controller with hysteresis and minimum switch interval. More...

#include <stdint.h>

Go to the source code of this file.

Classes

struct  bangbang_t
 

Macros

#define INIT_BANG_BANG(name, upper, lower, on_callback, off_callback, min_interval)
 

Functions

void bangbang_update (bangbang_t *controller, float value, uint32_t current_time)
 Update the state of the bang-bang controller based on the input value and current time. It calls the appropriate on/off functions if the state changes.
 

Detailed Description

Generic bang-bang controller with hysteresis and minimum switch interval.

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Macro Definition Documentation

◆ INIT_BANG_BANG

#define INIT_BANG_BANG ( name,
upper,
lower,
on_callback,
off_callback,
min_interval )
Value:
bangbang_t name = { \
.upper_bound = upper, \
.lower_bound = lower, \
.on_func = on_callback, \
.off_func = off_callback, \
.min_switch_interval = min_interval, \
.last_switch_ms = 0, \
.is_on = false \
}; \
static_assert(upper > lower, "Upper bound must be greater than lower bound for bang-bang controller");
Definition bangbang.h:13

Function Documentation

◆ bangbang_update()

void bangbang_update ( bangbang_t * controller,
float value,
uint32_t current_time )

Update the state of the bang-bang controller based on the input value and current time. It calls the appropriate on/off functions if the state changes.

Parameters
controllerPointer to the bang-bang controller.
valueThe current input value.
current_timeThe current time in milliseconds.