From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

digital in to frequency

Hey, sorry for all the newb questions: but here's another that should be easy. I've been looking through the examples, and I'm not quite sure what to do. I have a digital input (from a LabJack) and I want to get a frequency from that input that I can then put on a graph, output on a gauge, etc. The only output on the digital in function is a "state" output. How do I change that to a frequency? Thanks.
0 Kudos
Message 1 of 7
(2,767 Views)
You may have a big challenge. I'm not all that familiar with the LabJack but I think the only thing you can do is poll the digital output as fast as you can, mark the time, check when the output changes state, calculate the time between state changes, and convert that to a frequency. Your success is going to depend on how fast you can retrieve a value from the LabJack, the resolution of the windows clock, and how fast the digital signal is changing. If your acquisition is strictly software timed, don't count on anything better than a 1msec resolution. You would probably be better off using an analog input to capture the signal and using something like Extract Single Tone Information to read the frequecny.
0 Kudos
Message 2 of 7
(2,754 Views)
How would using an analog input help? Let me explain my situation better, so that perhaps you could better judge if I should use a digital or analog input. I'm measuring RPM through a homemade optical tach. I have a UV LED on one side of a spinning disk with slits in it, and a photodiode on the other side to detect the light. I assumed that a digital input would be best b/c it would only be on/off, rather than having to determine if it is on/off based on an analog signal. Thanks for the help.
0 Kudos
Message 3 of 7
(2,748 Views)
The digital input would only work if your frequency is pretty low. As I said, probably the best time resolution you can get is 1msec. If your frequency is hight than 1khz, you'll never see all of the digital transitions. If it takes 5 msec to get a reading from the LabJack, the highest frequency you can possibly measure is 200 hz. Do some experiments and see how fast you can acquire digital data. If you have LabVIEW 7.1, use the timed loop to get some determinism in timing. Analog is nice for higher frequencies (assuming the LabJack has some sort of hardware timing) because you could capture at least several pulses with a single acquisition and functions exist to calculate the frequency of a captured waveform. Again, low rpm, digital could be made to work, high rpm, use analog capture when you don't have a dedicated counter/timer in hardware.
0 Kudos
Message 4 of 7
(2,744 Views)
Does the LabJack hardware not have any counters available for general-purpose use? A quick glance at their Web site suggests that at least some of their boards do.

It seems like that would be the easiest way to measure the frequency of the pulse train from the tach.

--John
0 Kudos
Message 5 of 7
(2,727 Views)
I belive that the labjack does indeed have a hardware counter availiable. How would I go about using this to get a frequency in?
0 Kudos
Message 6 of 7
(2,717 Views)
What you need to do is find the examples that ship with the Labjack driver, and I'll bet the answer will be there.

The general concept is to use the pulses from your tach as the gate for a counter whose source is attached to a known-frequency signal. See Period Measurement with a Counter" for more info.

This is a very straightforward concept; any difficulty will come with configuring the counter appropriately and communicating with it via software to get meaningful results. This is where Labjack and its software comes into play, and I would be surprised if there wasn't already a measure-frequency LabVIEW example that is bundled together with their driver. The problem is that few people on this forum has used a Labjack device.

I've remember someone saying that the Labjack support is good, so if you can't find an example, you ought to try out the forum they have on their site.

Regards,
John

Message Edited by Johnner on 04-05-2005 09:38 PM

0 Kudos
Message 7 of 7
(2,712 Views)