Avalon Firmware
 
Loading...
Searching...
No Matches
supercap_controllers.hpp File Reference

Core control logic for the supercapacitor power manager. More...

#include "adc_utils.hpp"
#include "hrtim.h"

Go to the source code of this file.

Data Structures

class  supercap_control_manager
 Main control class for managing the supercapacitor charge/discharge behavior. More...
 

Macros

#define HRTIM_PERIOD   34000
 Defines the full period (and half-period) for HRTIM PWM in timer ticks. Used to calculate duty cycle offset during PWM generation.
 
#define HRTIM_HALF_PERIOD   17000
 

Enumerations

enum  Safety_DetectItemTypedef { voltageErr , currentErr }
 Enumerates the various error detection sources used for safety monitoring. More...
 
enum  safetyLevelDef {
  safe , warning , wtf , runAway ,
  itsJoever
}
 Safety level definitions for runtime system checks. More...
 
enum  Mode_ModeTypedef { idle , normal }
 Modes for the supercap control loop. More...
 

Functions

void softwareReset ()
 Software-triggered MCU reset function (called on fatal error or remote command).
 

Variables

uint8_t safetyItemLevel [8]
 Global safety flags indexed by Safety_DetectItemTypedef.
 
float chassis_voltage
 Extern global values for chassis voltage and battery current (used across control loops and diagnostics).
 
float battery_current
 

Detailed Description

Core control logic for the supercapacitor power manager.

This header defines the controller class and enums responsible for managing the supercapacitor charge/discharge behavior, error safety levels, and PID loops.

Created on: Jul 6, 2024 Author: Yassine Bakkali

Macro Definition Documentation

◆ HRTIM_HALF_PERIOD

#define HRTIM_HALF_PERIOD   17000

◆ HRTIM_PERIOD

#define HRTIM_PERIOD   34000

Defines the full period (and half-period) for HRTIM PWM in timer ticks. Used to calculate duty cycle offset during PWM generation.

Enumeration Type Documentation

◆ Mode_ModeTypedef

Modes for the supercap control loop.

Enumerator
idle 

Supercap system inactive.

normal 

Supercap active and managing power.

◆ Safety_DetectItemTypedef

Enumerates the various error detection sources used for safety monitoring.

Enumerator
voltageErr 

Detected unsafe or unstable voltage conditions.

currentErr 

Detected unsafe current draw or injection.

◆ safetyLevelDef

Safety level definitions for runtime system checks.

These are used internally to determine how critical a condition is and what kind of reaction the controller should take.

Enumerator
safe 

Normal operation.

warning 

Mild error, could recover automatically.

wtf 

Dangerous state; enters idle.

runAway 

Reserved for runaway behavior.

itsJoever 

Catastrophic failure (system shutdown trigger)

Function Documentation

◆ softwareReset()

void softwareReset ( )

Software-triggered MCU reset function (called on fatal error or remote command).

Software-triggered MCU reset function (called on fatal error or remote command).

Used during critical fault recovery to completely reboot the board. Disables interrupts and enters an infinite loop until the system reset is triggered via NVIC.

Variable Documentation

◆ battery_current

float battery_current
extern

◆ chassis_voltage

float chassis_voltage
extern

Extern global values for chassis voltage and battery current (used across control loops and diagnostics).

◆ safetyItemLevel

uint8_t safetyItemLevel[8]
extern

Global safety flags indexed by Safety_DetectItemTypedef.

Global safety flags indexed by Safety_DetectItemTypedef.