A to D measurements with Boron

Hello,

My company produces a control box for our customer which then supplies these to end users at locations all over the US. In the control box, the device uses the Boron module and is monitoring some different items.
The control box can monitor the current of pumps attached to the system by means of measuring the analog output of a current sense IC.
In normal operation, if a pump was in water and pumping water, the current sense component would measure a value between 350 and 400.
In normal operation, if a pump was out of water, the current sense values measured were usually measured around 100 to 130.
A middle of the road value was chosen of 225 as the threshold.
If the current sense is above 225, the pump would stay on.
If the current sense is 225 or less, the pump would shut off. If the pump successfully measured current above 225, (water present), the circuit would need to measure a value below the threshold for 60 continuous seconds to be able to shut down.
I have the ability to request the current sense value from units in the field. I can also change the threshold in the field. For example, I can change the pump 1 threshold to 275.

The issue that we are seeing is that a handful of units that have the pumps stay on even though they should shut down. In these cases, the current sense values seen on these units needs to be increased to about 270 from a value of 225. On these units, the current sense values for the pumps exceed the 225 value and will not turn off the pump. As stated earlier, the normal value seen when a pump is out of water is a value between 100 and 130.

For the A to D functionality, I am using the code found at

I then have my own code that takes the A to D measurements and uses a moving average to provide a more steady analog reading.

We had shipped devices that were running DeviceOS 4.0.2. We then made other functional changes (unrelated to the current sense code) and updated the DeviceOS to 6.1.0. And additional updates to DeviceOS 6.2.1.

When I have monitored a unit that has a larger current sense value, all of the other A to D readings seem to be correct (the device is monitoring A to D readings on different pins as well). It does not appear that all of the readings are corrupt.

Just curious if anyone else has seen any strange behavior with A to D readings in the field with Boron units.

Thanks.

Those symptoms are unexpected. The nRF52840 really just has one SAADC, with an analog MUX before it, so a measurement failure should exist across all channels.

Borons other than the BRN404X use 3V3 as the ADC reference, and this can cause issues if the voltage varies. The BRN404X uses an internal voltage reference, which is generally more accurate. Other devices can switch to using internal reference if desired. However this would affect all channels, not just one.

Though you mention using other ADC not using ADCDMAGen3_RK. The library is not intended to work that way; I'm surprised it worked at all. Since there is only one ADC peripheral you'd have to synchronize the manual and DMA retrieval, and the code does not do that. I'm not sure it's even possible. If you are monitoring multiple channels with DMA and just ignoring the samples you don't need at a high rate, that should work fine.

1 Like

So my thought was the same, that if there was some measurement failure, I would see it across multiple readings.

I had posted years ago when I was trying to use the ADC using DMA.

Short story version, I found the measurements were getting out of order. I modified the code so that it does use DMA to take a bunch of readings but it will only operate on one pin for a period of time, and then switch to a measurement on a different pin. Overall, the method seems to work. I am just unsure what could be the cause and how to track down a solution. I was hoping someone else may have some ideas. If I figure anything out, I will try to share my findings.

OK, that should work then.

Just in case it is the voltage reference, you could try using the withReferenceGain() method in ADCDMAGen3_RK with NRF_SAADC_REFERENCE_INTERNAL and NRF_SAADC_GAIN1_6. The caveat is that you must also scale each sample, because now 0 = 0V and 4095 = 3.6V, not 3.3V.

The code in Device OS for analogRead() looks like this:

// With the internal reference (0.6V) and GAIN1_6, the 12bit ADC range is 0~4095 -> 0V~3.6V, need a conversion
adcValue = (int16_t)(adcValue * 3600 / 3300);