pez-globo / pufferfish-software

All software for the Pufferfish ventilator.
Apache License 2.0
0 stars 1 forks source link

Power management low-level driver #22

Open ethanjli opened 4 years ago

ethanjli commented 4 years ago

We would like to write a lower-level driver for the power management system. This will just be a thin layer which abstracts away the details of GPIO read/write calls and exposes an interface for higher layers operating at the level of measurements and signals. This lower-level driver will need to provide a somewhat abstracted interface for all microcontroller pins assigned to power management functionalities. This abstracted interface will be used by a higher-level power management driver (which will be written after this low-level driver is written) for telemetry, monitoring, and control of the power management electronics. Some examples of what the interface of this lower-level will need to provide:

The implementation of this driver should mostly just be making calls using classes from firmware/ventilator-controller-stm32/Core/Inc/Pufferfish/HAL/STM32/DigitalInput.h and firmware/ventilator-controller-stm32/Core/Inc/Pufferfish/HAL/STM32/DigitalOutput.h, and, once #21 is completed, firmware/ventilator-controller-stm32/Core/Inc/Pufferfish/HAL/STM32/AnalogInput.h. I would suggest implementing this lower-level driver as one or more classes, each corresponding to some aspect of the power management electronics.

This lower-level driver can be prototyped before @RLaxmanrao and @deepakkrishnamurthy have finished putting together a set of design specifications for the firmware's complete power management functionality from the regulatory requirements for the power management subsystems. We can have someone start prototyping immediately based on the above list of examples and some additional documentation - @deepakkrishnamurthy, could you please post links to the various pieces of documentation on this thread?

The first step will be for someone to review our meeting notes and the documentation which @deepakkrishnamurthy will post; then ask questions for clarification about the task described here and about the documentation; and then make a pull request with a proposed interface and implementation for this lower-level driver.

RLaxmanrao commented 4 years ago

@ethanjli Created following methods for Power module, Power module consist of two classes one is LTC4421 for power path control and Battery class related to charge control. In LTC4421 class contains LTC4421::readPwrSource method to read active power source in ventilator which will report external or internal or no power source. LTC4421::fault method will report related to power. In Battery Battery::readVoltage method to read Battery voltage by converting ADC samples to Battery voltage. BatteryVoltage = 4.2(TBD) 3.3 inputvoltage / 65536. Here 4.2 is offset value which will give battery voltage rage 0V to 13.8V. Battery::enBatteryCharge method for enabling and disabling Battery charger.

Regarding battery charge levels are depending on the soc pct, so it's better will send below structure to the UART for UI. struct Profile { float batteryVoltage; float batteryTemperature; float soc_pct; bool socMaximum; bool socMedium; bool socLow; bool socCritical; };

ethanjli commented 4 years ago

This seems like a reasonable interface to start out with. Does "soc pct" mean "state of charge percentage"? Also, would it make sense to define a chargeLevel class enum with values maximum, medium, low, and critical, instead of having 4 bool flags? (I ask because I am not entirely sure what those flags are intended to represent)

deepakkrishnamurthy commented 4 years ago

@ethanjli @RLaxmanrao We have made a change on hardware side for the production power-board which should hopefully significantly simplify firmware development. The new chip LTC 4015 incorporates multiple functions including Power Path management, Battery charging, Battery fuel-gauge and buck-boost converter. The chip exposes an i2c interface for both reading and writing parameters. Therefore the low-level driver would expose an interface to higher-level firmware, a means to read and write to these i2c registers.

I am adding datasheets as well as SDK resources here for the Avin team. The firmware development can begin immediately using the SDK and initial testing can be done once the eval-board reaches Avin.

PowerManagementSystem_DesignSchematic_v2 0 (1) BatteryManagementIC_4015fb.pdf LTC4015_DEMO_DC2039A.pdf

deepakkrishnamurthy commented 4 years ago

SDK resources for LTC 4015 LTC4015_SDK.zip

ethanjli commented 3 years ago

We are no longer using the LTC 4015.

ethanjli commented 3 years ago

Oops, we are still using the LTC4015 - LTC4421 is the one we're no longer using.