Measuring relative timing/phase of fast analog signals

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
pythoncoder
Posts: 3666
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Measuring relative timing/phase of fast analog signals

Post by pythoncoder » Sat Mar 31, 2018 3:29 pm

I've raised a PR which adds this capability to the firmware, and also written a guide to how to install and use the patch (follow the link in the README). A phase sensitive detector is described with a guide to the theory of operation and a code sample.

I am intrigued by the application possibilities of this. I'm already using it in my electrical network analyser to measure the relative phase of sinewaves up to 36KHz. This can be done with about 10° accuracy at that frequency. Other applications that have struck me as interesting are ultrasonic range finders and sonars, but I'm sure there are numerous other uses.
Peter Hinch

User avatar
pythoncoder
Posts: 3666
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Firmware V1.9.4 includes this patch.

Post by pythoncoder » Sun May 13, 2018 6:05 am

The ADC now supports read_timed_multi enabling multiple ADC instances to be read on each timer tick almost simultaneously (the gap between readings is about 1.8μs).

With compensation for this gap, accurate (on the order of +-5°) phase measurements can now be performed on signals up to 50KHz. See this guide to quadrature phase detection.
Peter Hinch

User avatar
Kip
Posts: 21
Joined: Sat Dec 26, 2015 7:23 am

Re: Measuring relative timing/phase of fast analog signals

Post by Kip » Mon Nov 19, 2018 6:40 am

Hi,

I'm a little lost on how to install the patch so I can use read_timed_multi() on pyboard v 1.1. I clicked the link to the guide and couldn't find it. Could you please point me in the right direction?

Thanks,

Kip

User avatar
pythoncoder
Posts: 3666
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Measuring relative timing/phase of fast analog signals

Post by pythoncoder » Mon Nov 19, 2018 6:45 am

This was incorporated into mainline some while ago: I suggest you flash the current firmware build.

Code: Select all

MicroPython v1.9.4-479-g828f771 on 2018-08-20; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> from pyb import ADC
>>> a = ADC(1)
>>> dir(a)
['__class__', 'read', 'read_timed', 'read_timed_multi']
>>> 
Peter Hinch

User avatar
Kip
Posts: 21
Joined: Sat Dec 26, 2015 7:23 am

Re: Measuring relative timing/phase of fast analog signals

Post by Kip » Mon Nov 19, 2018 7:16 am

Ah, great. Updating the firmware was very easy!

https://github.com/micropython/micropyt ... are-Update

Thanks!

Post Reply