GitJer / Some_RPI-Pico_stuff

Some experiments I did with the Raspberry Pi Pico

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stops working at low frequencies

w9ran opened this issue · comments

commented

First, thanks very much for this nice PIO code, it does a very accurate job and is perfect for my application of measuring the frequency of audio tones, with one exception - it stops responding at 7 Hz and below. 8 Hz and up works fine.
I was expecting that the algorithm would fill the FIFO with zeros when the input signal stopped but that's not the case. I need a means of detecting when the applied PWM signal has stopped i.e. assumed a DC level. I may have to do this with a separate GPIO read but if there's a way that it can be done by modifying the PIO code that would be preferable. I understand the basic algorithm but am not skilled enough in the PIO to know if this is possible or how to do it. If you have time to respond I'm curious why the algorithm won't go below 8 Hz also.

I should add that the console does stop displaying measurements when the input stops, even though the actual value of pulse width (or period) never actually go to zero. So the console display stops because no more data is being sent through the FIFO, not because of the if statement. Thanks again!
Bob

Do you mean the PwmIn code? If so, for me it works fine at 7Hz (I've tested it down to 0.5 Hz).

You want to know when the PWM has stopped. Of course PWM can have an arbitrary low frequency. In the pio code, if the counter goes through 0 (at lines 28 and 34), that could somehow be used to signal that the PWM has stopped (currently it restarts the measurements at line 21).

commented

Thanks for taking the time to reply. My face is red - I was using a PC-based wave generator and in fact IT stops at 7 Hz, not the code, sorry! I've since written code that looks for pulses at the same pin and then use the PIO code for precise measurements, so I should be good to go. Bob

No problem, good to see that it works!