Using UWP and Raspberry Pi, how can I measure the frequency of an input signal that fluctuates around 1000 Hz (1 millisecond)?

I am converting some code from the .NET Micro Framework that I was running on Netduino. The code measures the frequency of a rectangular oscillator with a maximum frequency of about 1000 Hz or a period of about 1 millisecond. The application is a rain detector that changes its capacity depending on how wet it is. The capacity increases with humidity, which reduces the frequency of the generator.

In Netduino, I used InterruptPin. This is not a true interrupt, but a .NET event scheduling, but it EventArgscontains a timestamp when the pin value has changed. On Netduino, I could also configure whether it would be a rising or falling edge that would trigger the event. I managed to get this job pretty well, and 1 kHz was approaching the maximum bandwidth that Netduino could reliably measure.

On a raspberry pi, things are not going so well. It runs on Windows 10 IoT Core, which is certainly a great environment for Netduino. I have an event ValueChangedthat I can connect to, but there is no timestamp, and it occurs twice as fast because it is triggered by both halves of the waveform. I was hoping that with its faster quad-core Raspberry Pi processor would be able to handle this, but in fact the best bandwidth I can get is in the order of 1 event every 30 milliseconds - an order of magnitude worse than that, at least I got on Netduino, which means I'm lagging behind in time at a 1 kHz square wave.

So I'm looking for ideas. I was thinking about slowing the oscillator. The original circuit worked at a frequency of about 1 MHz, and I added a lot of resistors to increase the time constant, bringing it to 1 KHz. I could add resistors, but there comes a time when it starts to get dumb and I'm worried about component tolerance, which makes this problem difficult to calibrate.

It would be convenient for the Raspberry Pi to detect some counter / timer functions, but none of these manufacturer's tips does this for some incomprehensible reason.

One approach might be to use the A-to-D converter to somehow get a direct read, but the electronics are a little taller than me (hey, I'm a development guy!).

" " , ! - GPIO?

+4

Source: https://habr.com/ru/post/1615999/


All Articles