ADC function precision

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
schvic
Posts: 15
Joined: Wed Jul 09, 2014 2:45 pm

ADC function precision

Post by schvic » Sat Jul 04, 2015 2:00 pm

Hello micropython board users,

I would like to know if anyone has evaluated the precision of the funciton "adc.read_timed(buf, freq)" as for how precise the timing of the acquisition is. Any additional information is welcomed. And what is the maximum frequency programmable for this function?

Thank you and best regards,

V.S

manitou
Posts: 73
Joined: Wed Feb 25, 2015 12:15 am

Re: ADC function precision

Post by manitou » Sun Jul 05, 2015 4:41 pm

The adc.read_timed() is clocked by timer 6 and can run up to 84MHz. The accuracy of the timer is dictated by the MCU's crystal spec of 30 ppm. I measured the crystal frequency accuracy on my pyboard at 33 ppm. Ultimately, your adc_read_time() frequency shouldn't exceed the time for the ADC to collect a 12-bit sample. The datasheet wasn't real clear on ADC speed (0.5 to 16 us), so I measured the ADC speed in the firmware's adc.c with the processors cycle counter (SysTick->VAL). My testing showed the ADC was taking about 152 ticks, so @ 168 mhz that's less than a microsecond! So conceivably you could run the read_timed() at 1 MHz. The precision of setting the timer 6 frequency is related to the prescaler divisors of 84mhz and the period -- see firmware timer_tim6_init() in stmhal/timer.c

schvic
Posts: 15
Joined: Wed Jul 09, 2014 2:45 pm

Re: ADC function precision

Post by schvic » Thu Jul 09, 2015 6:37 pm

Thank you very much for your answer :)
Concerning the MCU's crystal accuracy, one question raised, if it has 30 ppm accuracy, the RTC of the pyboard could deviate of 78 seconds (2600000 (secs) * 0,999970) per month ? I am working on a standalone project (trancking weather events), so time accuracy is important, even more if the module will stay few months outside. I will perform some testing.

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: ADC function precision

Post by blmorris » Thu Jul 09, 2015 8:14 pm

MCU's crystal accuracy, one question raised, if it has 30 ppm accuracy, the RTC of the pyboard could deviate of 78 seconds
Not exactly - the RTC is driven by a separate crystal from the rest of the MCU; the RTC has a low-power 32.768 KHz crystal versus the 8 MHz crystal which drives the rest of the processor. The RTC peripheral can continue to operate when power is removed from the rest of the pyboard; it can be powered by a small watch battery connected to the VBAT pin.
There have been numerous reports that the accuracy of the RTC crystal is less than satisfactory (search for 'RTC' related discussions on the forum) but we have recently added support for RTC calibration, which can nominally improve accuracy to < 1 ppm. I don't know if anyone have been that successful yet.

See http://docs.micropython.org/en/latest/l ... alibration

-Bryan

Post Reply