04-22-2023 05:46 PM
Hi I am wondering if there is a way to create one Counter Input Frequency channel to measure frequency, duty cycle, period and pulses all at once? Do I have to create a separate channel for each one? Thanks.
04-22-2023 06:15 PM
Yes, kind of, but you'll have to do some (trivial) math on the raw readings.
If using a newer device that supports "Pulse Measurement" mode, that'll be the easiest starting point. With older devices you'd need to do semi-period measurement *and* should then also explicitly set the polarity of the "starting edge".
With semi-period measurement, specify units=seconds and starting edge=rising. When you read your array of measurements, I'd highly recommend that you always retrieve an even # of them. The array of data will alternate between high times and low times, so each length=2 subset gives you everything you need to calculate what you want. (With Pulse Measurement mode, reads return high time and low time as a clustered and identified pair, making things even easier).
period = high_time + low_time
frequency = 1 / period
pulse width = high_time
duty cycle = high_time / period
-Kevin P