Skip to content

[TASK] Create a state_of_health Interface to Monitor Power Modes #159

@Mikefly123

Description

@Mikefly123

Story

  • As a circuitry_flight_software developer.
  • I want a simpler way to interact with the satellite's state_of_health.
  • So that we have a single source of truth of the current health of the satellite systems to determine which mode we should be in.

The state of health interface of the satellite should serve two roles, collecting metadata (like temperatures of key components and the voltage of the battery) and changing the current operational mode of the satellite as a result of what this meta data tells us. Implementing a mode_manager should probably be a separate task.

Data Points to Collect

All of these data points should be collected by the module and saved to a single data structure.

  • System Voltage
  • System Current
  • Solar Voltage
  • Solar Current
  • Radio Temperature
  • Microcontroller Temperature
  • Internal Temperature
  • Error Count

NOTE: If you are currently testing on a V4 flight controller board without a battery board there is no way to collect the voltage and current information. This might be a bit of a blocker if there is no easy way to just ignore the fact that those sensors are not connected.

Acceptance Criteria

  • Clean Out All of the Old State of Health Functions and Attributes
  • Consolidate state of health collection into a single interface module
  • Implement unit tests on the state of health system (example: checking that mode switching is done correctly)

Technical Details

A great place to start with this is in pysquared.py, where we have this function that sets the power_mode and manipulates some of the hardware as a result of the current mode:

    def powermode(self, mode: str) -> None:
        """
        Configure the hardware for minimum or normal power consumption
        Add custom modes for mission-specific control
        """
        try:
            if "crit" in mode:
                self.neopixel.brightness = 0
                self.enable_rf.value = False
                self.power_mode: str = "critical"

            elif "min" in mode:
                self.neopixel.brightness = 0
                self.enable_rf.value = False

                self.power_mode: str = "minimum"

            elif "norm" in mode:
                self.enable_rf.value = True
                self.power_mode: str = "normal"
                # don't forget to reconfigure radios, gps, etc...

            elif "max" in mode:
                self.enable_rf.value = True
                self.power_mode: str = "maximum"
        except Exception as e:
            self.logger.error(
                "There was an Error in changing operations of powermode",
                err=e,
                mode=mode,
            )

The power_mode attribute is then checked in main.py to determine what functional flow the satellite should take at any given time:

    ######################### MAIN LOOP ##############################
    try:
        while True:
            # L0 automatic tasks no matter the battery level
            c.check_reboot()

            if c.power_mode == "critical":
                c.RGB = (0, 0, 0)
                critical_power_operations()

            elif c.power_mode == "minimum":
                c.RGB = (255, 0, 0)
                minimum_power_operations()

            elif c.power_mode == "normal":
                c.RGB = (255, 255, 0)
                main()

            elif c.power_mode == "maximum":
                c.RGB = (0, 255, 0)
                main()

            else:
                f.listen()

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions