Analog Input Accuracy

I have a few questions about the accuracy and precision of the imp’s Analog Inputs/ Sampler class. I would like to take synchronized Analog Input samples from four pins on an imp-002 module. The signals are generated by a SPI DAC (so actually if the imp can work as a SPI Slave you can ignore all of the questions =) ) and are 0-2V. I’d like to sample each pin at 1kHz and be accurate to 5mV.

  1. What is the accuracy of the Analog inputs? I found reference to the imp’s ADC’s being 12-bit. That should give me a theoretical accuracy of 3.3/(2^12) = 0.81mV. Has anyone done any tests to verify the precision of the imp ADC’s?

  2. The imp-002 has an ADC reference voltage input. If I referenced it to 2V instead of 3.3V that would give an accuracy of 0.49mV. Does the imp have a way to measure this V_DDA voltage (referenced to ground) directly? I would like to take the (ADC_value/65536.0)*V_DDA so I can measure true voltage on the analog inputs (Otherwise I guess I will simply assume a known value of V_DDA).

  3. I know the multi-channel sampler is on the todo list… Any ideas as to how far down the list it is? I’ve done some tests and with 4 Analog Inputs it looks like I can sample around 8kHz. These won’t be completely synchronized but since I only need to sample at 1kHz I’m unsure if that’s going to work well for this application until I get a little further along…

  1. I haven’t seen any direct tests of the ADC accuracy on IMP-002, though it should be better in the next firmware release than in the current one.

  2. V_DDA is the voltage measured by hardware.voltage() – but it’s required to be the same value as V_DD (see STM32 datasheet table 12).

  3. Multi-channel sampling is done and will be in the next release. (SPI slave isn’t and won’t – though for low enough clock frequencies, you might be able to “bit-unbang” SPI slave using the Sampler.)

Peter

The Module specification makes it appear (to me at least) that V_DD and V_DDA could be two separate voltages… I take it from your comment that is a pretty bad idea? Should pins 18,33,and 34 all be tied together?

How many channels does the multi-channel sampler support? Are the readings synchronized or will there be some (minimal) time differences between them?

(edited when I came to my senses)

The VDDA pin on imp002 is actually the CPU’s VREF+ line. We named it VDDA because it can draw power, and VREF+ was confusing people because they thought it was an output. The CPU package we use has no separate VDDA pin - it’s internally shorted to VDD.

They are separate pins to allow for cleaning up the rail for the analog supply (eg, an RC filter or LDO). For example, the Lala reference design runs the VDDA pin at 2.8v whilst the imp runs at 3.3v.

There is only one ADC in the CPU so they are not concurrent readings (Peter can probably give chapter and verse on the separation, but the idea is that the inter-sample rate is the same for each channel).

OK, that’s a bit confusing. Couldn’t we have chosen a name that wasn’t also the name of a different STM32 signal? V_FRED isn’t taken yet, nor V_BOB :expressionless:

So armed with the new information I looked into it again: yes, the VDDA pin on the IMP-002 can be lower than V_DD (it can’t be higher). And hardware.voltage() does measure the VDDA pin – though running it at below V_DD may lead to slight oddities in the firmware, which in places uses hardware.voltage() assuming that it measures the V_DD pin. Those oddities, if any, are bugs though and we’ll fix them. (Anyone with a Lala is invited to check what hardware.voltage() returns, but I think it’s VDDA.)

Note that hardware.voltage() is measured relative to the STM32 internal voltage reference, 1.21+/-0.03V. That reference may well be less accurate than the regulation of your VDDA supply.

As for the multi-sampler, it can sample up to all six pins at once on IMP-001, and up to all eight analog-capable pins at once on IMP-002. The samples aren’t taken precisely simultaneously, but 0.5us apart. But as Hugo says, they’re always sampled in the same order (the ordering is specified when configuring the sampler), so the sample rate on each channel is always the value asked for.

Peter

What is the accuracy for imp-001 module?

Also another thread mentioned possible issues with the April board due to the socket?

Lastly, when I switch from usb to battery power through 5V boost converter to April board the readings get noisy. Is this due to alkaline batteries that ive heard are bad to use or something else? IVe tried averaging 5 consecutive readings but still noisy

Depends on how noisy your boost converter is, then. The april board has a DCDC on it already (buck) so it’s not just that you’re using a DCDC.

If it’s still noisy when you’re going battery -> 5v boost -> april’s 3.3v buck then check your physical layout and look to see if your boost converter is magnetically coupling onto any of the wires you’re sampling.

What voltage is the battery, and what boost are you using?

Battery is above 4.5V. Boost is a step up/down converter from Pololu. Sadly no schematic from them.

I did notice that if I read the analog voltage before wifi is on the reading is more accurate, stable and consistent. Not sure if this points to the battery or the boost. Im on breadboard so theres lots of space between components. It also might be the sensor electronics itself-the circuit draws 2 mA , runs on 5V and i switch it off to save power. I do have a warm up delay time after i power it back on though. (i also have resistor divider on the output)

Great job on the customer service and responsiveness btw. You have monster stamina and patience. =D>

If you have a 4.5v battery, is there any reason you don’t just connect it directly to the april? The April board will from from ~3.5v-17v and still maintain 3.3v regulation.

If you want to determine whether the noise is coming from the sensor or the imp, try making a voltage divider between 3.3v and 0v with two 10k resistors, hook the imp ADC to the middle, and look at the readings you get.

How big are the resistors in your output divider?

Im using 3 AAs so if they drop to 1.1V each when low, that wont be enough to power the regulator right? Although i just realized I can use 4 AAs instead and not have to worry about that and have the boost power only my sensor.

Im using 2 10kohm to divide the sensor output. Will try the divider between 3.3V.

setup:
adc read tests of 3.3v through divide by 2 resistor network with 2 10kohm
adc reads are 5 averaged samples
adc and dmm readings are done after voltages have stabilized
using sparkfun april breakout board
Fluke 115 dmm
3.3V is 3.288V in deep sleep

results:
usb power:
adc with wifi off: 8mV difference
adc with wifi on: 10mV difference
3.3V with wifi off: 3.285 (3mV diff)
3.3V with wifi on: 3.282V (6mV diff)

battery->boost->april:
adc with wifi off: 8mV difference
adc with wifi on: 50mV difference
3.3V with wifi off: 3.297 (9mV diff)
3.3V with wifi on: 3.33V (42mV diff)

battery->april:
adc with wifi off: 2mV difference
adc with wifi on: 21mV difference
3.3V with wifi off: 3.291 (3mV diff)
3.3V with wifi on: 3.307V (19mV diff)

conclusion:
USB power maintains accuracy. Having wifi on is affecting the adc accuracy when powered by battery, but worse with the boost converter in the middle. Most likely due to 3.3V stability, which points to the power source. Guess its time to try NiMH batteries.

interestingly the accuracy was better with batteries and wifi off vs usb.

note: adc comparisons were done with respect to signal input to pin, not input to voltage divider.