Loop Timing Witness
Native controller and runtime interfaces; hardware qualification pending
Loading...
Searching...
No Matches
witness_controller.h File Reference
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  witness_coefficients
struct  witness_pid_state
struct  witness_command

Functions

bool witness_coefficients_valid (const witness_coefficients *coefficients)
void witness_pid_reset (witness_pid_state *state)
bool witness_pid_step (const witness_coefficients *coefficients, witness_pid_state *state, uint32_t cycle, int32_t reference, int32_t position, witness_command *command)
bool witness_lqr_step (const witness_coefficients *coefficients, uint32_t cycle, int32_t reference, int32_t position, int32_t velocity, witness_command *command)

Detailed Description

Function Documentation

◆ witness_coefficients_valid()

bool witness_coefficients_valid ( const witness_coefficients * coefficients)

Refuse reversed bounds, bounds excluding zero, negative PID gains or decay outside [0,1].

◆ witness_lqr_step()

bool witness_lqr_step ( const witness_coefficients * coefficients,
uint32_t cycle,
int32_t reference,
int32_t position,
int32_t velocity,
witness_command * command )

Compute u=floor((reference_gain*r-position_gain*y-velocity_gain*v)/2^24) followed by configured output saturation. Gains are supplied from a discrete Riccati design; this kernel does not solve or certify the Riccati equation. Invalid coefficients leave the command unchanged.

◆ witness_pid_reset()

void witness_pid_reset ( witness_pid_state * state)

Reset all PID state, including derivative-on-measurement initialization.

◆ witness_pid_step()

bool witness_pid_step ( const witness_coefficients * coefficients,
witness_pid_state * state,
uint32_t cycle,
int32_t reference,
int32_t position,
witness_command * command )

Compute conditional-integration PID; return false without mutation for invalid coefficients. Error and measurement differences retain their signed 33-bit range. Products accumulate before floor division by 2^24. Output saturation with the prior integral freezes integration if the error would worsen it. Otherwise accept the bounded integral proposal before computing output. The first sample has zero derivative; subsequent samples use a filtered derivative on measurement. No setpoint derivative kick is introduced.