psas / stm32

PSAS STM32F4xx firmware development.
30 stars 20 forks source link

Aquire battery information from the BQ3060 #24

Closed ThirteenFish closed 10 years ago

ThirteenFish commented 10 years ago

It generates lots of cool information about the batteries like voltage and temperature and stuff. We need to determine exactly what we want, create the code to get it, and then have this information sent to the FC over the RocketNet.

Additionally it has a bunch of safety features. We should see if we can read the status of them or get notifications of when they change, and then send this to the FC over the error channel.

ThirteenFish commented 10 years ago

The BQ3060 updates values once every second. These are the registers we are interested in.

DavidRamage commented 10 years ago

State of Charge

MaxError 0x0c

Relative State of Charge 0x0d -read only -percentage of charge remaining

Remaining Capacity - 0x0f

Full Charge Capacity - 0x10

Run Time To Empty - 0x11 -read -predicted battery life 0-65534 minutes

Average Time to Empty - 0x12

Average Time To Full - 0x13 -read

CapM

AverageCurrent - 0x0b

AtRate - 0x04

AtRateTimeToFull - 0x05

AtRateTimeToEmpty - 0x06

AtRateOk - 0x07

SafetyAlert - 0x50

SafetyStatus - 0x51 -read

PFAlert - 0x52

PFStatus - 0x53

DavidRamage commented 10 years ago

The registers SafetyAlert, PFAlert, and PFStatus respectively contain values for items which are nearing alert thresholds, pending safety issues which have not yet yet caused a failure, and permanent failures.

A possible way to handle these situations is to:

  1. Have the read thread in BQ3060.c read each of these registers as it spins.
  2. In the case of a nonzero read from any of them, an event for that particular register will fire. The event handler will take a particular action based on the nature of the alert or failure. It may be desirable to have specific events for specific alerts or failures to reduce the number of register reads.
DavidRamage commented 10 years ago

I talked with Andrew tonight. He said that in situations where there is anything wrong with the battery, it should prevent the rocket from arming if it isn´t already armed. If it is, it should just send the error state down the wire. I have created a branch called rnh_safety_events which polls all three of the safety registers. If any of them read nonzero an event is triggered. Right now this event just sends the contents of all three registers onto the wire. A todo item is to go over the arming code and add in the ability to prevent arming should the need arise.

DavidRamage commented 10 years ago

This is apparently fixed in commit 4990e651fec6e387d908d2d482c8872c81dfac1a