ME 507 Romi++
Cylindrical Differential Drive Robot created for ME 507 at Cal Poly in Spring 2025
|
A finite state machine for monitoring battery voltage. More...
#include <battery_check.h>
Public Types | |
enum | state { S0_INIT , S1_CHECK_ADC , S2_BATTERY_LOW } |
typedef enum BATTERY_CHECK::state | state_t |
Public Member Functions | |
BATTERY_CHECK () | |
Constructor for the BATTERY_CHECK class. | |
void | run (void) |
Executes one iteration of the battery check FSM. |
A finite state machine for monitoring battery voltage.
Uses ADC readings to determine if battery voltage is too low and triggers an indicator if necessary.
enum BATTERY_CHECK::state |
BATTERY_CHECK::BATTERY_CHECK | ( | ) |
Constructor for the BATTERY_CHECK class.
Initializes the FSM to the S0_INIT state.
void BATTERY_CHECK::run | ( | void | ) |
Executes one iteration of the battery check FSM.
Reads ADC value and determines if battery is low.
Uses ADC readings to determine battery voltage level. If voltage falls below a threshold (~10.05V), an indicator LED is turned on. When the voltage rises above a recovery threshold (~10.20V), the LED is turned off. This ensures that the LED won't be constantly switching back and forth when the battery voltage decreases.