Main Menu

LPF Error?

Started by Olaf, August 03, 2019, 02:47:15 PM

Olaf

I'm happy with the Current Ranger but noticed an inconsistency in measurements:

When measuring the current of a device in sleep mode the OLED display shows 6.4mA - inline with the 6.4mV I measure on the Out ports. The small ADC raw data on the top left of the display shows 8.
When I switch on the LPF mode I notice that the display changes to 4.0mA (ADC raw shows 5) - while the Out ports still measure 6.4mV.

As the LPF always switches on (I think) when in Auto mode, I currently can't use the Auto mode.

Any suggestions on what the issue could be?
Thanks

Felix

You can use LPF either way. You can turn it on manually via combination of touch pads as described in the guide - nA+mA.

The output can be slightly off from the raw output in the lower ends of each range, because of non-linearities in the ADC. It could be improved by using different ADC references to increase resolution but if you're looking for the most accurate measurement, directly from the opamps, then use a DMM from the output terminals (instant reading) or a scope which can catch fast current transients.

Also note that for ADC measurements - if LPF is off, and you're in a range that picks up noise from the environment or through cables attached to the device, then the readings can be off. So that is where LPF can be helpful because visual (ie instant) readings from the OLED or attached DMM are not going to need the ultra fast readings you can get on a scope. So it just makes sense to use it.

Olaf

Thanks for the reply Felix,

I have further reduced the length of the cables (in case of interference) but the issue is the same.

In the described example can I assume that
- the 6.4mA measured with the LPF off is correct - as the DMM shows 6.4mV ?
- the 4.0mA measured with the LPF on is incorrect - as the DMM still shows 6.4mV?

Thanks

Felix

If the load is the same, then I can expect a difference in the OLED reading, it is not unusual.
There is just more noise with LPF off.
That is why this can happen, especially at the lower range.

Olaf

Yes, the load is the same. You keep mentioning that there is more noise without the LPF, but it looks like in my case it is actually the LPF that creates an error of 38%! This error is not there with the LPF off.
Is it possible that my device is defective or is  such a big measurement error normal?

Felix

The LPF will reduce the output noise (visible on a SCOPE only, so you can better mesure less than ultrafast signals).

But don't expect miracles from the humble ADC + OLED combination in the lower ends, regardless of how the CR is setup. I am not 100% sure why your particular setup gives a higher reading without LPF. However a single 1 difference in the ADC translates to  0.8ma on the OLED. So there is around 2 least significant bits of difference in your setup with+without LPF.

For super high accuracy we need to implement complex offset and gain correction that correct those using value tables according to the ADC nonlinearity. That is way complicated and for simplicity the implemented ones are basic hardware offset and gain correction.

Overall the ADC/OLED readings can be pretty useful, that's why that feature is present.
But it is expected that you're not going to get the accuracy of DMM from the averaged 12bit readings.

The OLED display is meant to be a complement to a DMM.
If you're looking for best accuracy, use the DMM to take a true RMS reading.

I guess that's what is more important to understand here.

Olaf

Thanks for the explanation Felix.
I now understand that the OLED readings are not accurate enough for measurements of a few mAs but that the DMM readings should be more accurate.
As you made the CR code available on your website I will modify it to improve the OLED readings in the low end.
Thanks again
/Olaf

Felix

You can increase the number of samples and that will actually give a more accurate reading:
#define ADCREADINGS            1   //do averaging in hardware rather than software


You may also balance that with less hardware averaging if you need to keep the range switching speed, specifically these lines:
int adcRead(byte ADCpin)
{
...
  //ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1 | ADC_AVGCTRL_ADJRES(0x00ul);  // take 1 sample, adjusting result by 0
  //ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_16 | ADC_AVGCTRL_ADJRES(0x4ul); //take 16 samples adjust by 4
  //ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_512 | ADC_AVGCTRL_ADJRES(0x4ul); //take 1024 samples adjust by 4
  ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1024 | ADC_AVGCTRL_ADJRES(0x4ul); //take 1024 samples adjust by 4


Finally, any ADC has some offset that is typically not linear.
While a more difficult task, you may want to measure your offsets at different points in a range, and add/subtract them based on the measurement.