Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f96677b
create Ina219 manager and driver components (not impl)
asiemsen Nov 1, 2025
14819e2
Add Ina219 Driver to CMAKE
nateinaction Nov 1, 2025
700544e
fixing power monitor generations
asiemsen Nov 1, 2025
2fa08f7
Merge branch 'power-monitor' of https://github.com/Open-Source-Space-…
asiemsen Nov 1, 2025
56fdece
Impl PowerMonitor
nateinaction Nov 1, 2025
0c5314b
implemented ina219 manager cpp
asiemsen Nov 1, 2025
313debc
add run handler function
asiemsen Nov 3, 2025
31ab047
Add comments
nateinaction Nov 3, 2025
bd118fd
add powermonitorManager and inu219Manager to topology
asiemsen Nov 3, 2025
3d00b38
fix typo
asiemsen Nov 3, 2025
84d8e66
Override min number of rate group ports
nateinaction Nov 3, 2025
bdb101e
add helper function for power monitor device configure and add solar …
asiemsen Nov 3, 2025
6413cd8
fixed instances
asiemsen Nov 3, 2025
bc2a83e
change member variable naming
asiemsen Nov 3, 2025
816d1e3
fix build errors
asiemsen Nov 3, 2025
1a81717
fixing build errors
asiemsen Nov 3, 2025
1e51e8c
Update Device Tree
Mikefly123 Nov 3, 2025
8df88e4
Fixed Pin Names
Mikefly123 Nov 3, 2025
51a9a31
Added Bus Voltage Range
Mikefly123 Nov 3, 2025
cad87d7
Fixed Telem Writes
Mikefly123 Nov 3, 2025
2fe4c95
Feedback
nateinaction Nov 3, 2025
fe27a58
Unify power monitor
nateinaction Nov 3, 2025
7121696
Fill out power monitor sdd
nateinaction Nov 3, 2025
cc753a4
Initial power monitor test
nateinaction Nov 4, 2025
98dc73c
Test passing
nateinaction Nov 4, 2025
7252219
More Device Tree Tweaks!
Mikefly123 Nov 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Include project-wide components here

add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/AntennaDeployer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ComDelay/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FsSpace/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NullPrmDb/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PowerMonitor/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/AntennaDeployer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FsSpace/")
1 change: 1 addition & 0 deletions FprimeZephyrReference/Components/Drv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Helpers/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ina219Manager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RtcManager")
Expand Down
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/Drv/Ina219Manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# F Prime CMakeLists.txt:
#
# SOURCES: list of source files (to be compiled)
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
# DEPENDS: list of libraries that this module depends on
#
# More information in the F´ CMake API documentation:
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Ina219ManagerTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Ina219ManagerTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of a big nit pick, but we should probably just name this component INA219 or INA219PowerMonitor or something to maintain the Application / Manager / Driver design pattern separation between things.

A higher level PowerMonitorManager component might group together all of the individual power monitor components into a single interface with a little bit of logic that can be used to manipulate them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the lack of consistency around component naming is maddening. This specific plan where we create specific device "managers" in the Drv dir was discussed with @LeStarch but as long as we are consistent it doesn't matter. In this case this device manager is consistent with the Lis2mdl and Lsm6dso managers. I vote to keep the names as-is so we don't spend time futzing with the small potatoes stuff before launch. Some time post launch let's find agreement on a component naming scheme.

Also, as you said the power monitor component will likely change before launch similar to the imu component shifting to a detumble component so there will likely be a chance to change that higher level component this month.

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// ======================================================================
// \title Ina219Manager.cpp
// \brief cpp file for Ina219Manager component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219Manager.hpp"
#include <Fw/Types/Assert.hpp>

namespace Drv {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

Ina219Manager ::Ina219Manager(const char* const compName) : Ina219ManagerComponentBase(compName) {}

Ina219Manager ::~Ina219Manager() {}

// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------

void Ina219Manager::configure(const struct device* dev) {
this->m_dev = dev;
}

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

F64 Ina219Manager ::currentGet_handler(FwIndexType portNum) {
if (!device_is_ready(this->m_dev)) {
this->log_WARNING_HI_DeviceNotReady();
return 0;
}
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();

struct sensor_value current;

sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_CURRENT);

sensor_channel_get(this->m_dev, SENSOR_CHAN_CURRENT, &current);

this->tlmWrite_Current(sensor_value_to_double(&current));

return sensor_value_to_double(&current);
}

F64 Ina219Manager ::powerGet_handler(FwIndexType portNum) {
if (!device_is_ready(this->m_dev)) {
this->log_WARNING_HI_DeviceNotReady();
return 0;
}
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();

struct sensor_value power;

sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_POWER);

sensor_channel_get(this->m_dev, SENSOR_CHAN_POWER, &power);

this->tlmWrite_Power(sensor_value_to_double(&power));

return sensor_value_to_double(&power);
}

F64 Ina219Manager ::voltageGet_handler(FwIndexType portNum) {
if (!device_is_ready(this->m_dev)) {
this->log_WARNING_HI_DeviceNotReady();
return 0;
}
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();

struct sensor_value voltage;

sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_VOLTAGE);

sensor_channel_get(this->m_dev, SENSOR_CHAN_VOLTAGE, &voltage);

this->tlmWrite_Voltage(sensor_value_to_double(&voltage));

return sensor_value_to_double(&voltage);
}

} // namespace Drv
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module Drv {
port VoltageGet -> F64
port CurrentGet -> F64
port PowerGet -> F64
}

module Drv {
@ Manager for Ina219 device
passive component Ina219Manager {
# Ports
@ Port to read the voltage in volts
sync input port voltageGet: VoltageGet

@ Port to read the current in amps
sync input port currentGet: CurrentGet

@ Port to read the power in watts
sync input port powerGet: PowerGet

# Telemetry channels

@ Telemetry channel for voltage in volts
telemetry Voltage: F64

@ Telemetry channel for current in amps
telemetry Current: F64

@ Telemetry channel for power in watts
telemetry Power: F64

@ Event for reporting INA219 not ready error
event DeviceNotReady() severity warning high format "INA219 device not ready" throttle 5

###############################################################################
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
###############################################################################
@ Port for requesting the current time
time get port timeCaller

@ Port for sending textual representation of events
text event port logTextOut

@ Port for sending events to downlink
event port logOut

@ Port for sending telemetry channels to downlink
telemetry port tlmOut

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// ======================================================================
// \title Ina219Manager.hpp
// \brief hpp file for Ina219Manager component implementation class
// ======================================================================

#ifndef Drv_Ina219Manager_HPP
#define Drv_Ina219Manager_HPP

#include "FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219ManagerComponentAc.hpp"

#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/kernel.h>
namespace Drv {

class Ina219Manager final : public Ina219ManagerComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

//! Construct Ina219Manager object
Ina219Manager(const char* const compName //!< The component name
);

//! Destroy Ina219Manager object
~Ina219Manager();

public:
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------

//! Configure the INA219 device
void configure(const struct device* dev);

private:
// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for currentGet
//!
//! Port to read the current in amps
F64 currentGet_handler(FwIndexType portNum //!< The port number
) override;

//! Handler implementation for powerGet
//!
//! Port to read the power in watts
F64 powerGet_handler(FwIndexType portNum //!< The port number
) override;

//! Handler implementation for voltageGet
//!
//! Port to read the voltage in volts
F64 voltageGet_handler(FwIndexType portNum //!< The port number
) override;

// ----------------------------------------------------------------------
// Member variables
// ----------------------------------------------------------------------

//! Zephyr device stores the initialized LIS2MDL sensor
const struct device* m_dev;
};

} // namespace Drv

#endif
111 changes: 111 additions & 0 deletions FprimeZephyrReference/Components/Drv/Ina219Manager/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Drv::Ina219Manager

The INA219 Manager component interfaces with the INA219 current/power monitor to provide voltage, current, and power measurements.

## Usage Examples

The INA219 Manager component is designed to be called periodically to collect and return sensor data. It operates as a passive component that responds to manager calls.

### Typical Usage

1. The component is instantiated and initialized during system startup
2. A manager calls any of the input ports: `VoltageGet`, `CurrentGet`, or `PowerGet`
3. On each call, the component:
- Fetches fresh sensor samples from the sensor
- Converts sensor data to double precision floating point
- Writes telemetry data
- Returns data in SI units

## Class Diagram

```mermaid
classDiagram
namespace Drv {
class Ina219ManagerComponentBase {
<<Auto-generated>>
}
class Ina219Manager {
- m_dev: const struct device*
+ Ina219Manager(const char* compName)
+ ~Ina219Manager()
+ configure(const struct device* dev)
- voltageGet_handler(const FwIndexType portNum): F64
- currentGet_handler(const FwIndexType portNum): F64
- powerGet_handler(const FwIndexType portNum): F64
}
}
Ina219ManagerComponentBase <|-- Ina219Manager : inherits
```

## Port Descriptions
| Name | Type | Description |
|---|---|---|
| VoltageGet | sync input | Triggers voltage data collection and returns voltage in volts |
| CurrentGet | sync input | Triggers current data collection and returns current in amps |
| PowerGet | sync input | Triggers power data collection and returns power in watts |

## Sequence Diagrams

### VoltageGet
```mermaid
sequenceDiagram
participant Manager
participant INA219 Manager
participant Zephyr Sensor API
participant INA219 Sensor

Manager-->>INA219 Manager: Call VoltageGet synchronous input port
INA219 Manager->>Zephyr Sensor API: Fetch sensor data
Zephyr Sensor API->>INA219 Sensor: Read sensor
INA219 Sensor->>Zephyr Sensor API: Return sensor data
Zephyr Sensor API->>INA219 Manager: Return voltage sensor_value struct
INA219 Manager->>INA219 Manager: Write telemetry
INA219 Manager-->>Manager: Return F64 voltage in volts
```

### CurrentGet
```mermaid
sequenceDiagram
participant Manager
participant INA219 Manager
participant Zephyr Sensor API
participant INA219 Sensor

Manager-->>INA219 Manager: Call CurrentGet synchronous input port
INA219 Manager->>Zephyr Sensor API: Fetch sensor data
Zephyr Sensor API->>INA219 Sensor: Read sensor
INA219 Sensor->>Zephyr Sensor API: Return sensor data
Zephyr Sensor API->>INA219 Manager: Return current sensor_value struct
INA219 Manager->>INA219 Manager: Write telemetry
INA219 Manager-->>Manager: Return F64 current in amps
```

### PowerGet
```mermaid
sequenceDiagram
participant Manager
participant INA219 Manager
participant Zephyr Sensor API
participant INA219 Sensor

Manager-->>INA219 Manager: Call PowerGet synchronous input port
INA219 Manager->>Zephyr Sensor API: Fetch sensor data
Zephyr Sensor API->>INA219 Sensor: Read sensor
INA219 Sensor->>Zephyr Sensor API: Return sensor data
Zephyr Sensor API->>INA219 Manager: Return power sensor_value struct
INA219 Manager->>INA219 Manager: Write telemetry
INA219 Manager-->>Manager: Return F64 power in watts
```

## Requirements
| Name | Description | Validation |
|---|---|---|
| VoltageGet Port | The component shall provide access to voltage sensor data and return in volts | Integration test |
| CurrentGet Port | The component shall provide access to current sensor data and return in amps | Integration test |
| PowerGet Port | The component shall provide access to power sensor data and return in watts | Integration test |
| DeviceNotReady Event | The component shall emit a throttled warning event when the device is not ready | Verify event is emitted and throttled to 5 occurrences |

## Change Log
| Date | Description |
|---|---|
| 2025-11-03 | Initial INA219 Manager component |
Loading
Loading