PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.17k stars 13.36k forks source link

[Bug] "system power unavailable" using ADS1115/ADC and 6X #22474

Open Drime1337 opened 9 months ago

Drime1337 commented 9 months ago

Describe the bug

As discussed with @dagar and @dk7xe in the developer call, the issue regarding the ADS1115 with 6x: While using the HolyBro 6x with an ADS1115 ADC we do run into a critical error "System Power Unavailable". We're using a 12s setup with version 1.14 on a Holybro 6x standard board. The voltage- and current readings are valid. Parameters for the ADS1115 are Set and the readings do work. The board_adc driver is not running.

To Reproduce

Holybro 6x standard board setup. Connect External ADC (ADS1115) to i2c ports on power1/2 Power Setup: Bat1 -> Power Module Set up parameters: ADC_ADS1115_EN = enable BAT1_I_CHANNEL = 1 BAT1_V_CHANNEL = 0

boot the FC check logs or QGC messages for critical error messages

Expected behavior

No Error on booting

Screenshot / Media

67592ce7f791e4f96c56b15bfb143dadf004b3e5

Flight Log

Mavlink console outputs:

nsh: sysinit: fopen failed: No such file or directory

NuttShell (NSH) NuttX-11.0.0
nsh> ads1115 status
INFO  [SPI_I2C] Running on I2C Bus 1, Address 0x48
ads1115: single-sample: 2441 events, 4201938us elapsed, 1721.40us avg, min 1703us max 1852us 1664.237us rms
INFO  [SPI_I2C] Running on I2C Bus 2, Address 0x48
ads1115: single-sample: 2442 events, 4154714us elapsed, 1701.36us avg, min 1682us max 1819us 1659.885us rms
nsh> listener adc_report

TOPIC: adc_report
 adc_report
    timestamp: 49304100 (0.019352 seconds ago)
    device_id: 9455625 (Type: 0x90, I2C:1 (0x48))
    raw_data: [16437, 3462, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    resolution: 32768
    v_ref: 6.14400
    channel_id: [0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1]

nsh> listener adc_report

TOPIC: adc_report
 adc_report
    timestamp: 50585217 (0.003269 seconds ago)
    device_id: 9455633 (Type: 0x90, I2C:2 (0x48))
    raw_data: [16434, 3463, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    resolution: 32768
    v_ref: 6.14400
    channel_id: [0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1]

nsh>

console output:

HW arch: PX4_FMU_V6X
HW type: V6X000003
HW version: 0x000
HW revision: 0x003
PX4 git-hash: b8c541dd7277ed735139d7d1bfb829d61fbe29fb
PX4 version: Release 1.14.0 (17694975)
OS: NuttX
OS version: Release 11.0.0 (184549631)
OS git-hash: de41e7feaeffaec3ce65327e9569e8fdb553ca3d
Build datetime: Oct 19 2023 16:24:32
Build uri: localhost
Build variant: default
Toolchain: GNU GCC, 9.3.1 20200408 (release)
PX4GUID: 000600000000363339383137511300090017
MCU: STM32H7[4|5]xxx, rev. Y
INFO  [param] selected parameter default file /fs/mtd_params
INFO  [param] importing from '/fs/mtd_params'
INFO  [parameters] BSON document size 4559 bytes, decoded 4559 bytes (INT32:90, FLOAT:130)
INFO  [param] selected parameter backup file /fs/microsd/parameters_backup.bson
Board architecture defaults: /etc/init.d/rc.board_arch_defaults
Board defaults: /etc/init.d/rc.board_defaults
Loading airframe: /etc/init.d/airframes/12001_octo_cox
INFO  [dataman] data manager file '/fs/microsd/dataman' size is 62560 bytes
rgbled_ncp5623c #0 on I2C bus 1 (external) address 0x39
INFO  [px4io] IO FW CRC match
Board sensors: /etc/init.d/rc.board_sensors
ads1115 #0 on I2C bus 1 (external) address 0x48
bmi088_accel #0 on SPI bus 3 rotation 4
bmi088_gyro #0 on SPI bus 3 rotation 4
INFO  [ads1115] ADS1115: reported ready
icm42688p #0 on SPI bus 2 rotation 6
ERROR [ads1115] ADS1115: not ready. Device lost?
icm42670p #0 on SPI bus 1 rotation 10
INFO  [ads1115] ADS1115: reported ready
bmm150 #0 on I2C bus 4 (external) address 0x10
ERROR [ads1115] ADS1115: not ready. Device lost?
ist8310 #0 on I2C bus 1 (external) address 0xE rotation 10
INFO  [ads1115] ADS1115: reported ready
bmp388 #0 on I2C bus 4 (external) address 0x77
ERROR [ads1115] ADS1115: not ready. Device lost?
INFO  [ads1115] ADS1115: reported ready
bmp388 #1 on I2C bus 2 (external) address 0x76
ERROR [ads1115] ADS1115: not ready. Device lost?
INFO  [ads1115] ADS1115: reported ready
ERROR [ads1115] ADS1115: not ready. Device lost?
WARN  [SPI_I2C] ms5611: no instance started (no device on bus?)
INFO  [ads1115] ADS1115: reported ready
ERROR [ads1115] ADS1115: not ready. Device lost?
WARN  [SPI_I2C] Already running on bus 1
INFO  [ads1115] ADS1115: reported ready
ekf2 [782:237]
Starting MAVLink on /dev/ttyS6
INFO  [mavlink] mode: Normal, data rate: 1200 B/s on /dev/ttyS6 @ 57600B
Starting MAVLink on /dev/ttyS1
INFO  [mavlink] mode: Normal, data rate: 100000 B/s on /dev/ttyS1 @ 57600B
INFO  [rc_input] valid device required
ERROR [rc_input] Task start failed (-1)
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [uavcan] Node ID 1, bitrate 1000000

NuttShell (NSH) NuttX-11.0.0
nsh> e[KWARN  [health_and_arming_checks] Preflight Fail: system power unavailable
INFO  [logger] [logger] /fs/microsd/log/sess104/log100.ulg  
INFO  [logger] Opened full log file: /fs/microsd/log/sess104/log100.ulg
INFO  [vehicle_magnetometer] MAG switch from #0 -> #1

Software Version

1.14 stable

Flight controller

Holybro 6X standard set

Vehicle type

Multicopter

How are the different components wired up (including port information)

ADC/ADS1115 to Power1 ADC/ADS1115 to Power2

Additional context

The magnetometer output is correct, it's 90° tilted and can be ignored.

niklaut commented 9 months ago

The board_adc driver is not running.

Is there a specific reason why not? The board_adc driver is publishing the system_power uORB message that is required for the system power check to pass. (You can disable the system power check via the CBRK_SUPPLY_CHK parameter).

dk7xe commented 9 months ago

@Drime1337 ?

Drime1337 commented 8 months ago

@niklaut As far as I know it's disabled the moment you enable the ads1115 parameter. If I recall correctly @dagar was suggesting something in that direction as well. I don't know why it's disabled as a default while the ads1115 is active though.

niklaut commented 8 months ago

Ah, indeed. It's coded like that in the rc.board_sensors, apparently it was added by https://github.com/PX4/PX4-Autopilot/pull/19549/files#diff-70d0f8c00e5bed2400f3d0f0e59f82806a8097b42766d3511d28918e71b90fc8R11

if param compare -s ADC_ADS1115_EN 1
then
    ads1115 start -X
else
    board_adc start
fi

@davids5 why is the board_adc disabled here?

davids5 commented 8 months ago

@niklaut

Have a look at https://github.com/PX4/PX4-Autopilot/pull/19145 and https://github.com/PX4/PX4-Autopilot/commit/28c27f1b9af7fd4904330aff61ee014069d28eb6

niklaut commented 8 months ago

Hm, it seems like it tries to avoid board_adc from also publishing to the adc_report topic. I think starting the board_adc with the -n flag like so should fix this issue. Can you try this @Drime1337?

if param compare -s ADC_ADS1115_EN 1
then
    ads1115 start -X
    board_adc start -n
else
    board_adc start
fi
Drime1337 commented 8 months ago

Quick update so you guys are not in the dark - I do not have access to another 6X / ADS1115 combo at the moment, but will most likely have one in 1-2 Weeks. I'll let you know once i have it.

jwwaite commented 6 months ago

I encountered this same issue with an ADS1115 measuring battery voltage and current, and a Pixhawk 6X-RT. The fix to rc.board_sensors as proposed above by @niklaut works.