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.
Measuring relative timing/phase of fast analog signals
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Measuring relative timing/phase of fast analog signals
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Firmware V1.9.4 includes this patch.
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.
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
Index to my micropython libraries.
Index to my micropython libraries.
Re: Measuring relative timing/phase of fast analog signals
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
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
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Measuring relative timing/phase of fast analog signals
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
Index to my micropython libraries.
Index to my micropython libraries.
Re: Measuring relative timing/phase of fast analog signals
Ah, great. Updating the firmware was very easy!
https://github.com/micropython/micropyt ... are-Update
Thanks!
https://github.com/micropython/micropyt ... are-Update
Thanks!