Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5801

MicroPython • Setting a timer to start at a specific time

$
0
0
I have some poor 433MHz transmitter/receivers. I acknowledge these are hopeless but the following is more for a learning purpose rather than practical application (and it has thrown up some interesting problem areas). I also know that I should use C++ for this because of extra features and speed but I prefer the interpreted nature of Python to avoid time on recompilation.

The fastest timer on a Pico has a period of 1ms and I am using this to time a '1kHz' transmission. As there is no receiver->transmitter feedback, there is no automatic synchronisation of clock timing. What I want to do is sample the received signal around the middle of the clock cycle as it is probably at its most stable then.

What I am currently doing to synchronise the receiver:
a) Detect pulse rise time using rising edge interrupt
b) Wait until time of middle of pulse with a timer loop
c) Initialise a new 1ms clock for use with sample synchronisation (i.e. timer = Timer(mode=Timer.PERIODIC, period=1, callback=rx_timing) )

Now I accept there will be variable latency associated with the various operations but accuracy to 0.1ms would be perfectly acceptable.

Unfortunately the timer created in step c) does not seem to have a defined start time (as shown with an oscilloscope output) and cannot be varied by adjusting step b). Any suggestions?

Statistics: Posted by rallan — Thu Apr 04, 2024 9:27 am



Viewing all articles
Browse latest Browse all 5801

Trending Articles