Is it possible to measure the frequency of a PWM using the U3-LV? | LabJack

# Is it possible to measure the frequency of a PWM using the U3-LV?

4 posts / 0 new
Is it possible to measure the frequency of a PWM using the U3-LV?

Is it possible to measure the frequency of a PWM using the U3-LV? The idea is to connect the PWM output to an input of the U3-LV and scan the input to measure the PWM frequency. The PWM has a frequency range of 90KHz to 200KHz. If possible ... Where can I find an example of how to do it? Thanks in advance.

LabJack Support
The following is a general

The following is a general old forum topic discussing ways to measure frequency:

https://forums.labjack.com/index.php?showtopic=1105

Since your frequency is quite high, up to 200 kHz, I suggest you use the count-over-time technique.  You will want to configure a digital input (FIO4 would be typical) as a hardware counter and then read that counter at some software timed interval:

https://labjack.com/support/datasheets/u3/hardware-description/timers-co...

I suggest you try it first using the test panel in LJControlPanel.  Once you see it working there, then try it in Python.  I'm sure we have a counter/timer example for Python, but let us know if you need more help with that.

Thank you for the support!

Thank you for the support!

I have tried first with LJControlPanel, configuring Timer0 in Mode2=RisingEdge (default pin FIO4), and TimerClockBase 48Mhz.

When my PWM frequency is 90KHZ it works fine, I read the counter value=535 so PWM period is 535/4800000=11uS ==> F=90Khz

When I increase my PWM frequency to 200KHz I have some errors, some times the counter give me the correct value 241, but some times give me an error value 482 its (2x241) so when I calculate the frequency sometimes give me the wrong value of 100Khz.

How can I avoid this error?

For an other test, i need to measure the Duty Cycle of My PWM, I know its 50%.

For this test I configure Timer0 in mode4 DutyCycle (default pin FIO4), and TimerClockBase 48Mhz.

For the frequency of 90Khz (DutyCycle 50%)  the LJControlPanel give me a distintc value on every Timer read, giving a scaled value of 100% or 0% ¿?

How can I read the correct DutyCycle?