PowerPort
class provides features of an electrical power connection.- Users can use the class to control the electrical power switching of components and calculate the component's consumed electrical current.
- Main files:
power_port.cpp, .hpp
- Referenced files:
component.cpp, .hpp
andpower_control_unit.cpp, .hpp
- Example: The
sample_components.hpp
in thes2e-core/simulation_sample/spacecraft/
is helpful to know how to use the feature. - Make a component class that inherits the
Component
class.- The
Component
class has thePowerPort
class as a member and controls the component's action according to the electrical power switches.
- The
- Make an instance of
PowerControlUnit
and connect the power port.- The
PowerControlUnit
base class has a member of themap
of thePowerPort
class and manages the port id and connection of thePowerPort
. - Users can make their PCU by inheriting the
PowerControlUnit
base class and can control the power switching in theMainRoutine
function.
pcu_ = new PowerControlUnit(clock_gen); pcu_->ConnectPort(0, 0.5, 3.3, 0.3);
- The
- Make an instance of the components with the connected
PowerPort
.obc_ = new OnBoardComputer(1, clock_gen, pcu_->GetPowerPort(0));
- Control the power switches by using the
PowerControlUnit
.- The default setting of the power switch is
off
, so users need to power on the port to execute theMainRoutine
of the components.
pcu_->GetPowerPort(0)->SetVoltage(3.3);
- The default setting of the power switch is
- Note: The virtual power port is created when users make an instance of the
Component
class and its subclasses without thePowerPort
information. The virtual port has a minus value port ID, and the switch state is originallyON
, but the consumed power is zero.
- This function is a setter function of the supply voltage to the power port.
- Users can control the power switch by using this function.
- input: supply voltage to the port
- output: switch state of the port
- After the voltage is set, the
Update
function is called to check that the supply voltage is enough to turn on the component.
- This is an update function of the switch state and the consumed current.
- This function also has an over-current protection feature.
- input: N/A (members of the class)
- output: switch state of the port
- When the supply voltage is larger than the
kMinimumVoltage
of the component, the switch state becomestrue
, and the consumed current is calculated as the following equation.
- The
P
is theassumed_power_consumption
, and users can set the value with theSetAssumedPowerConsumption
function. - If the calculated current consumption is larger than the
kCurrentLimit
, the over-current protection feature is executed and turning the switch off.
N/A
N/A