FOSSASAT-1B
power_control.h File Reference
#include "FossaSat1B.h"
Include dependency graph for power_control.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  powerConfigBits_t
 Power configuration strutcture, each entry is one bit long. Total 1 byte, lowPowerModeActive is the least significant bit. More...
 
union  powerConfig_t
 Union to quickly access power configuration bits or the entire single-byte value. More...
 

Functions

void Power_Control_Load_Configuration ()
 Load the configuration bytes from the EEPROM into RAM. More...
 
void Power_Control_Save_Configuration ()
 Saves the configuration bytes from RAM into EEPROM. More...
 
void Power_Control_Charge (bool charge)
 This function ensures that the battery is charging. "set MPPT to input which enables battery charging, but only after checking keep alive and temperature limit". More...
 
uint32_t Power_Control_Get_Sleep_Interval ()
 Get the amount of seconds to sleep for given the battery voltage. More...
 
void Power_Control_Delay (uint32_t ms, bool sleep, bool sleepRadio=false)
 This function delays the program execution for the given number of milliseconds, while maintaining the watchdog signal to prevent it resetting. More...
 
void Power_Control_Setup_INA226 ()
 Initializes the INA226 current sensor. More...
 
bool Power_Control_INA226_Check ()
 Check that the INA2256 is valid. More...
 
float Power_Control_Get_Battery_Voltage ()
 Get the battery voltage by switching the MPPT off and then on again after reading is taken. More...
 
float Power_Control_Get_Charging_Voltage ()
 Gets the charging voltage (from the solar panels) by not switching the MPPT off and taking an INA226 reading. More...
 
float Power_Control_Get_Charging_Current ()
 Gets the amperage which is being provided to the battery. More...
 
bool Power_Control_Check_Battery_Limit ()
 Checks whether battery voltage is below low power limit. Will enable low power mode if that is the case. More...
 

Variables

powerConfig_t powerConfig
 The current power configuration settings.
 

Function Documentation

◆ Power_Control_Charge()

void Power_Control_Charge ( bool  charge)

This function ensures that the battery is charging. "set MPPT to input which enables battery charging, but only after checking keep alive and temperature limit".

Test:

(ID POWER_CONT_H_T3) (SEV 1) Make sure the battery charges when this function is called.

(ID POWER_CONT_H_T4) (SEV 1) When mppt keep alive is enabled, make sure that the battery charges.

(ID POWER_CONT_H_T5) (SEV 1) When mppt temperature switch is enabled, make sure the battery doesn't charge.

(ID POWER_CONT_H_T6) (SEV 1) When the charge boolean is TRUE, is allows the battery to charge.

(ID POWER_CONT_H_T14) (SEV 1) When the charge boolean is FALSe, is prevents the battery to charge.

Parameters
chargeThe option to charge the battery or turn off the MPPT.

Definition at line 23 of file power_control.cpp.

Here is the caller graph for this function:

◆ Power_Control_Check_Battery_Limit()

bool Power_Control_Check_Battery_Limit ( )

Checks whether battery voltage is below low power limit. Will enable low power mode if that is the case.

Returns
bool Whether battery check passed or not.

Definition at line 169 of file power_control.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Power_Control_Delay()

void Power_Control_Delay ( uint32_t  ms,
bool  sleep,
bool  sleepRadio = false 
)

This function delays the program execution for the given number of milliseconds, while maintaining the watchdog signal to prevent it resetting.

Test:
(ID POWER_CONT_H_T8) (SEV 1) Check that the satellite's program is delayed for the given number of seconds without restarting.
Parameters
msThe amount of time to delay the program for.
sleepWhether to use the LowPower libraries powerDown feature.
sleepRadioWhether to put the radio into sleep mode for the duration.

Definition at line 73 of file power_control.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Power_Control_Get_Battery_Voltage()

float Power_Control_Get_Battery_Voltage ( )

Get the battery voltage by switching the MPPT off and then on again after reading is taken.

Test:
(ID POWER_CONT_H_T11) (SEV 1) Check that this function returns the correct battery voltage.
Returns
float The voltage returned by the INA266 of the battery.

Definition at line 139 of file power_control.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Power_Control_Get_Charging_Current()

float Power_Control_Get_Charging_Current ( )

Gets the amperage which is being provided to the battery.

Test:
(ID POWER_CONT_H_T13) (SEV 1) Check the value returned by this function is the current charging solar panel Amperage.
Returns
float The shunt current value of the INA2256

Definition at line 162 of file power_control.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Power_Control_Get_Charging_Voltage()

float Power_Control_Get_Charging_Voltage ( )

Gets the charging voltage (from the solar panels) by not switching the MPPT off and taking an INA226 reading.

Test:
(ID POWER_CONT_H_T12) (SEV 1) Check that this function returns the correct solar panel charging voltage.
Returns
float The voltage provided by the solar panels.

Definition at line 155 of file power_control.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Power_Control_Get_Sleep_Interval()

uint32_t Power_Control_Get_Sleep_Interval ( )

Get the amount of seconds to sleep for given the battery voltage.

Todo:
Julian -> The sleep intervals should be updated to match the new CW-synced communications.
Test:
(ID POWER_CONT_H_T7) (SEV 1) Check what interval is returned at the designated voltages.
Returns
uint32_t The number of milliseconds to sleep for.

Definition at line 47 of file power_control.cpp.

Here is the call graph for this function:

◆ Power_Control_INA226_Check()

bool Power_Control_INA226_Check ( )

Check that the INA2256 is valid.

Test:
(ID POWER_CONT_H_T10) (SEV 1) Check that this function correctly returns the state of the INA226 component.
Returns
true The INA226 is working correctly.
false The INA226 is not working correctly.

Definition at line 114 of file power_control.cpp.

Here is the caller graph for this function:

◆ Power_Control_Load_Configuration()

void Power_Control_Load_Configuration ( )

Load the configuration bytes from the EEPROM into RAM.

Test:
(ID POWER_CONT_H_T0) (SEV 1) Make sure that the power configuration is loaded from EEPROM correctly.

Definition at line 15 of file power_control.cpp.

Here is the caller graph for this function:

◆ Power_Control_Save_Configuration()

void Power_Control_Save_Configuration ( )

Saves the configuration bytes from RAM into EEPROM.

Test:
(ID POWER_CONT_H_T1) (SEV 1) Make sure that the power configuration is wrote to the EEPROM correctly.

Definition at line 19 of file power_control.cpp.

Here is the caller graph for this function:

◆ Power_Control_Setup_INA226()

void Power_Control_Setup_INA226 ( )

Initializes the INA226 current sensor.

Test:
(ID POWER_CONT_H_T9) (SEV 1) Check that the INA226 is configured ok.

Definition at line 108 of file power_control.cpp.