The PIC18F458 reads the battery voltage and NOT the avionics system bus voltage, which switches between the battery and shore power. It reads an onboard 10bit ADC which is connected to the battery via a resistive voltage divider, which in turn is turned on by a ZXMN2A01F N-channel MOSFET. The divider is R1 = 115K, R2 = 20K which gives a theoretical divide by factor of 0.14815. Thus Vb should be 5/1024/0.14815*(raw ADC). Since the resistors are only 1%, and the MOSFET adds it's own resistance, we'll simply modify the voltage divider constant (0.14815).
So, Keith wrote a Nickle script to take the CAN message from the APS (APS_REPORT_VOLTAGE) and display it on the screen in a nice format (a voltage value). We also connected a Fluke 84 DMM (in high accuracy mode) to the battery directly at the pack via some clip leads.
- Fluke says a very steady 16.5535 V
- APS says 495/494 raw data which is 16.28/16.31 V. keith says 494.7 given eyeball integration.
This gives a new constant of 0.14592. Trying again:
- Fluke: 16.552 V
- APS: 16.530 - 16.563 V
A bit low... whooops! went the wrong way, should be more like 484.3 not 484.7. Keith added some exponential filtering to the raw data: exp(-1/30).
- Fluke: 16.549 V
- Filtered APS: 494.2 = 16.537 V
This gives a new constant of 0.14581.
- Fluke: 16.548 V
- Filtered APS: 494.2 = 16.55 V
I'll take it! Now we'll try and charge the voltage the voltage and see what happens.
- Fluke: 16.709 V
- Filtered APS: 500.0 = 16.75 V
One LSB of the 10bit ADC is 5/1024/0.14581 = 33.5 mV... so the 40mV difference between the Fluke and APS is ~ 1 LSB
- Fluke: 16.628 V
- Filtered APS: 496.6 = 16.63 V
And that's well within error of 1 LSB... ship it!
|APS Battery Voltage Constant||
From the LTC4150 datasheet:
one interrupt = 1/(Gvf*Rsense) Coulombs = 1/(32.55 Hz/V * 10 mOhm) Coulombs = 3.072197 Coulombs
Amps = dC/dT = 3.072197/T where T is the period between interrupts.
If we divide the period T into ticks of 4ms (250 Hz) as it is in the APS, then we get:
Amps = 3.072197/(ticks*4ms) = 768.049155/ticks
|5.0 A||614 ms||154|
|2.5 A||1.229 s||307|
|1.0 A||3.072 s||768|
|0.5 A||6.144 s||1536|
|0.1 A||30.722 s||7681|
|0.03 A||102.407 s||25602|
Measurements with a Fluke 88 DMM on mA mode, with the battery charging
- Fluke: +2.540 A
- APS: 296 = 1.184 s = 2.595 A
- New calibration factor: 751.840
Now we'll try it with outgoing current (FC on, CAN bus on):
- Fluke: -524.4 mA
- APS: 1433 = 5.732 s = 2.595 A
- New calibration factor: 751.465
Now we'll do it at close to zero current:
- Fluke: -20.0 mA +/- 0.5 mA (depends on blinking APS LED)
- APS: 38003,37905,38125 = 152.012 s = 2.595 A
- New calibration factor: 762.5,758.1,762.5
The battery charge is given in an accumulation of ticks from the LTC4150. Each tick equals = 3.072197 Coulombs. We arbitrarily cut off the maximum and minimum of the charge - since we obviously can't go beyond the capacity of the battery.