#Getting battery voltage and current sensing to work on the H725/H735

1 messages · Page 1 of 1 (latest)

potent coral
#

I'm trying to get the ADC to return somewhat plausible values, but they don't change at all. I've attached the current config.

VBat is on PC5, IBat is on PA5. I can use either ADC1 or ADC2 for those.

Symptom: Both values are stuck at unreasonable values, BF configurator shows 13.2 V and 24.8 A when powered from USB. VBat doesn't change when I short the battery pads (should report close to zero) or when I apply 5 V to the positive battery pad.

#

my DMA OPT might be wrong, trying with 9

#

nope, something else might be missing

velvet hinge
#

Can you post the output of dma show and a full CLI dump?

potent coral
#

@velvet hinge sorry for the delay. I don't know why.

# dma show

Currently active DMA:
--------------------
DMA1 Stream 0: DSHOT_BITBANG 3
DMA1 Stream 1: SPI_SDO 3
DMA1 Stream 2: SPI_SDI 3
DMA1 Stream 3: SPI_SDO 4
DMA1 Stream 4: SPI_SDI 4
DMA1 Stream 5: FREE
DMA1 Stream 6: FREE
DMA1 Stream 7: FREE
DMA2 Stream 0: FREE
DMA2 Stream 1: FREE
DMA2 Stream 2: FREE
DMA2 Stream 3: FREE
DMA2 Stream 4: FREE
DMA2 Stream 5: FREE
DMA2 Stream 6: FREE
DMA2 Stream 7: FREE
dry rover
velvet hinge
#

Yeah, ADC DMA isn't being assigned

potent coral
velvet hinge
potent coral
#

Currently active DMA:
--------------------
DMA1 Stream 0: DSHOT_BITBANG 3
DMA1 Stream 1: SPI_SDO 3
DMA1 Stream 2: SPI_SDI 3
DMA1 Stream 3: SPI_SDO 4
DMA1 Stream 4: SPI_SDI 4
DMA1 Stream 5: FREE
DMA1 Stream 6: FREE
DMA1 Stream 7: FREE
DMA2 Stream 0: FREE
DMA2 Stream 1: FREE
DMA2 Stream 2: FREE
DMA2 Stream 3: FREE
DMA2 Stream 4: FREE
DMA2 Stream 5: FREE
DMA2 Stream 6: FREE
DMA2 Stream 7: FREE```
velvet hinge
potent coral
#

of course not

velvet hinge
#

😅

potent coral
#

Currently active DMA:
--------------------
DMA1 Stream 0: ADC 1
DMA1 Stream 1: DSHOT_BITBANG 3
DMA1 Stream 2: SPI_SDO 3
DMA1 Stream 3: SPI_SDI 3
DMA1 Stream 4: SPI_SDO 4
DMA1 Stream 5: SPI_SDI 4
DMA1 Stream 6: FREE
DMA1 Stream 7: FREE
DMA2 Stream 0: FREE
DMA2 Stream 1: FREE
DMA2 Stream 2: FREE
DMA2 Stream 3: FREE
DMA2 Stream 4: FREE
DMA2 Stream 5: FREE
DMA2 Stream 6: FREE
DMA2 Stream 7: FREE
#

shorting the battery pads still doesn't pull the indicated voltage towards zero. it's stuck at 27.01 V

velvet hinge
#

What voltage do you measure on pins A05 and C05?

potent coral
#

I can't do that right now - but if it's electrically ok then those should measure 0V. I'll give you those values as soon as i can

#

or at least the value in BF should change a bit when I apply a small voltage to the battery input pad

velvet hinge
#

Is the current sense pad broken out, or is this an AIO?

potent coral
#

the Yolo is an AIO

#

that's why I sent out chonkers (dev FCs without anything really fixed), the guys can do everything with those

velvet hinge
#

For the heck of it, can you enter this in the CLI also:

dma ADC 3 8
set adc_device = 3
save```
#

It looks like the H7 has some internal sensors (temp, Vref) that use ADCs also but I haven't looked deeper

#

The above is just assigning DMA to all of the ADC channels, and moving the curr and vbat adcs to channel 3

#

Just cribbing from hydra's H7RF target

potent coral
#

cool, larger numbers!

#

no change when I short the bat pads

velvet hinge
#

If you apply voltage does it go up?

potent coral
#

I think I should set that up properly before I do something really bad

#

but I saw the indicated value change when I reset the MCU

#

so something is happening indeed

velvet hinge
#

If you change the resource mappings for resource ADC_BATT 1 and resource ADC_CURR 1 to different pins how much do the values change? Do they change on reboot? ie I'm wondering if the pins are NC/floating

potent coral
#

I set the pin for ADC_BATT to the USB voltage sensing pin. after reboot, I see the indicated voltage rise to a final value of 61.91 V

#

the scaling is wrong for that, of course

#

I need to sleep, fighting a light pneumonia. only took my doctor 1.5 weeks to figure that out...

velvet hinge
#

Get some sleep

#

Hopefully you're on some antibiotics

potent coral
#

I am

#

good night! I'll attach some more stuff tomorrow so that we have a better chance at debugging VBat

potent coral
#

There we go

#

@velvet hinge @dry rover
supplied by a bench PSU, set to 7 V with a 0,2 A current limit. current drawn: 100 mA (a bit much!?)

the voltage I can measure at the voltage divider is 0.63 V (1/11th of the supply voltage, consistent with a 10k/1k divider)

reported voltage is wrong and does not change when I set the PSU to, say, 10 V

I also notice an inconsistency between the number of cells reported in the configurator's top bar and in the "Power & Battery" tab

#

what I also find surprising is that "mAh used" doesn't increase from zero despite the rather high calculated current of almost 328 A

#

it should be through the roof already

#

reported voltage doesn't change after switching off the bench PSU

#

sidenote: I can't measure the voltage directly at the MCU (smaller circle, top right), because it's a BGA. I measured at the divider/filter cap (bottom)

potent coral
#

Has anyone tried anything with their chonker?

potent coral
#

@round spade this is the forum thread

round spade
#

Yo!

#

In particular, see section 28.4.16

#

Highlights: To setup, Enable the RCC periph clock, enable advregen, perform a calibration per the RM (This is a little involved), and set the appropriate config settings like differential if applicable, continuous mode etc, eg in the CFGR register

#

Set up the SEQR register as required for multi-channel sequences

#

To do a one-shot reading, set up the sequence, then set the ADSTART bit in the CR register. Wait until EOS is clear. Then read the DR register for the result

#

See the RM for details on timer triggers and DMA

#

I would start with a simple program that sets up the ADC in one-shot mode, and takes a single channel reading, and see if it makes sense adn matches a voltmeter

#

Then start DMA, sequences etc

potent coral
#

I think this should all be done in BF already because the H735 shares a RM with the 730 (which seems to work)

round spade
#

Concur

potent coral
# round spade Concur

So I think it's a problem with my BF configuration rather than something low level. The discussion isn't that long, if you want to catch up