Crude low frequency counters with Raspberry Pi Pico
Crude low frequency counter Used two state machines to generate two square waves as signal sources. Frequency counter measured these two frequencies. Frequency counter input Pico pin 20 (GPIO-15) 40 Hz sq.wave signal source on Pico pin 21 (GPIO-16) 25 kHz sq.wave signal source on Pico pin 22 (GPIO-17) 25 kHz was maximum frequency that could be measured. With 25 kHz input, reading varied from 25000 Hz to 25004 Hz Number of interrupts in one second were counted to get frequency. MicroPython code: ##################### # Filename CrudeFc1.py import time from machine import Pin import rp2 # global variable H2L = 0 # Interrupt handler (ISR) def h2l( void ): global H2L H2L = H2L + 1 def frequency(): global H2L fin.irq ( handler = None ) # Int. disabled H2L = 0 fin.irq ( handler = h2l, trigger=Pin.IRQ_FALLING ) #Int. enabled time.sleep(1) # gate time of ONE SECOND fin.irq ( handler = None ) # Int. disabled return(H2L) ###