Battery Sensor Current Reading Error

Hi all,
Im currently trying to configure the Pixhawk 2.1 to read the current from 2 power pins. It appears to be the BATT2_CURR_PIN changes the current sensing ADC pin for both the power brick input and BATT_CURR_PIN doesn’t change anything.

The current configuration is set up using plane 3.8(Beta).

Any one have any idea why this is not working?

Cheers :slight_smile:

Hi Alex,

Please share what values do you have in those parameters.

H Francisco

I have attached the current parameters sets, one detailing what we belive to be the correct config, one detailing what was done to make a single input read (working_batt_config.param (14.0 KB)) and one detailing what is belive to be the correct Pixhawk2 configuration ( correct_config.param (14.0 KB)
).

It was noticed that when you set the BATT2_CURR_PIN to the Pixhawk 2 pin, you get a completely random input to current (I think it is whatever is floating on that pin).

If it gets set to the Pixhawk 1 configuration it gets set correctly, however both of the inputs are identical.

When we swapped the pins over , power cant read at all, even in the correct pin configuration.
Any ideas?

Two experiments you can try to debug where the problem is:

  • connect to the first power input and set BATT_CURR_PIN to 3, try both power modules, do they both work?
  • connect to the second power input and set BATT_CURR_PIN to 12, try both power modules, do they both work?

To test this we disabled BATT2 power module.

For BATT_CURR_PIN => 3, everything works fine

Setting BATT_CURR_PIN => 12, voltage measurements are fine, current measurements dont work, appears to give a random number.

Weirdly when enbaling BATT2, the BATT2_CURR_PIN controls where the current reading are from.

When enabling and disabling BATT2 changes only took effect after turning the system on and off.

Let’s leave BATT2 out of equation now, otherwise it gets harder to debug - but it is expected that you need to reboot when you change the type of a battery monitor.

Can you try BATT_CURR_PIN set to 14 with the second power input?

Hi Francisco

I’m working with Alex on this.

I’ve just tested this. With BATT_CURR_PIN set to 14 current is read correctly

From the hardware… AUX battery…

PC4 is Current
PC3 is Voltage

how that relates to these “pin” numbers, I’m not sure…

Thank you for the information. I’ve corrected the information on our parameter documentation.

So just the inability to read both current sensors at the same time to solve. Any ideas?

Setting BATT_CURR_PIN to 3 and BATT2_CURR_PIN to 14 doesn’t work? It should - don’t forget to reboot.

With BATT_CURR_PIN set to 3 and BATT2_CURR_PIN set to 14 BATTERY.current_battery and BATTERY2.current_battery both read an identical current value from power2 input.

With BATT_CURR_PIN set to 14 and BATT2_CURR_PIN set to 3 BATTERY.current_battery and BATTERY2.current_battery both read an identical current value current value from power1 input.

Voltages are both read correctly.

Seems that BATT2_CURR_PIN overrides the BATT_CUR_PIN or that BATT2_CURR_PIN reading is transmitted to on both the BATTERY2 and BATTERY mavlink messages.

1 Like

I’ve check the code and I can’t see where that would happen. Do you have a dataflash log we can look at?

1 01-01-2000 00-33-26.bin (685.1 KB)
1 01-01-2000 00-33-26.bin.log (1.3 MB)
Hi Francisco,

Ive downloaded the logs and had a look and it appears to show the values as expected.

Interestingly whilst testing this we used a different version of mission planner and this was reporting the values back correctly, so I think it may be a problem with that rather than the code.
It doenst appear to work on version 1.3.48 but appears correct on 1.3.46.

(P.S sorry about the incomplete post, internet is being a bit dodgey today so I dont think it saved properly…)

@Neoxas Your post looks incomplete. If the logs are OK, we need to look at the MAVLink side. What GCS are you using?

@OXINARF, please see the edited post above.

It was appear to report correctly on mission planner version 1.3.46, however both values are matching on version 1.3.48.

Can you please try the Mission Planner beta?

Tried it with the Beta version, still has the same issue.
Current display is mirrored whilst the log shows a distinct difference between them.

Please see the logs attached.
1 01-01-2000 02-05-46.bin (965.8 KB)
1 01-01-2000 02-05-46.bin.log (1.8 MB)

Can you get the tlog from MP?

Here you go, copy of both Tlogs and pixhawk logs
Batt 2 is a backup battery battery and so should draw no current, but there is obviously some noise on the ADC.
Batt 1 is the motor and so should have large current draw.

2017-05-29 11-42-15.tlog (229.3 KB)
2017-05-29 11-43-40.bin (728.8 KB)
2017-05-29 11-43-40.log (1.5 MB)