Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure RPM on Digital input

Hi all,
 
I would like to know whether it is possible to measure a rpm of a fan through a digital input. The reason I'm using a digital input is because I need to drive up to 12 fans and have insufficient counter to read the tachometer feedback.
 
Items on test are:
1. Nidec Gamma 27 Fan. (Model: D06F-24SH). Moves upto 6000rpm with a tachometer output.
2. NI PCI-6509 DIO Card.
 
Basically what I've done to is to add a pull up resistor and placed the tachometer signal into the input and the other pull up end to the 5Vdc.
 
However right now I'm getting only a high signal (5V) and is not able to detect pulses. Appreciate any help.
 
Thanks....
0 Kudos
Message 1 of 8
(4,120 Views)

Hello Scuzzy,

 

You are correct that a counter would be the preferred method for measuring a digital frequency.  If you use a counter then the measurement is trivial as there are built in VIs for doing this measurement.  If you want to try to measure frequency with a digital input there are a couple things to consider:

 

1.  The digital input lines on the PCI-6509 are software timed.  That means that it will be difficult for you to sample quickly enough to accurately read in a 6 kHz signal.  The actual sample rate you can obtain with software timing is highly dependent on your computer so you will need to test this out.  Assuming you are able to acquire fast enough then you'll need to consider the second step.  If you can't acquire quickly enough then you should look into getting a Counter/Timer Board to do this measurement or at least a board with correlated digital I/O lines (Like those available on the M Series DAQ devices).

 

2.  While counters are by far the most accurate and efficient way to measure a digital frequency you could also do post-processing to determine the frequency of a measurement.  A counter frequency measurement is returned as a frequency, but if you use a digital input line you will get a digital waveform.  To use a digital input line you will need to determine the position of rising edges in the waveform and then divide by the time between them to find the frequency.  The error associated with this is +/- 1 sample rate period (several kHz on your board; up to 1 MHz on M Series Boards or 10 MHz+ if you get a High Speed Digital I/O board)  while the error with the counter is +/- 1 timebase period (which is 20 or 80MHz).  When using a digital line you will have greater error and there will be a delay in your measurements, but it can be done.

 

As far as only reading 5V with your current set up its possible that you're sample rate is in phase with the fan and so you're only sampling with the tachometer output is high.  Another possibility is that you're wiring isn't quite right; to resolve this I would recommend referencing the fan's manual.

 

I hope this helps get you started and have a great day!

 

Cheers,

Brooks
Message 2 of 8
(4,086 Views)

Hi Brooks_C,

 

Thanks for your input. I suspect as much and just wanted a confirmation. Anyway I manage to see pulses by adding an extra grounding and increasing the sampling rate. Thanks.

 

0 Kudos
Message 3 of 8
(4,073 Views)

Hi Brooks_C,

 

Regaarding the step 2 you mention, do you have any VI that I can refer to? Thanks...

0 Kudos
Message 4 of 8
(4,056 Views)

Hello Scuzzy,

There are a couple examples you can look at in the LabVIEW Example Finder.  To access these examples, open LabVIEW and go to Help>> Find Examples...

1.  Navigate to Hardware Input and Output>> DAQmx>> Digital Measurements>> Read Digital Channel.vi.  This VI does a software timed acquisition of digital lines that will work with your PCI-6509.  You'll need to add in some shift registers to check for rising edges and then manually count them.  I'd suggest using a shift and using a Boolean To (0,1) VI to check if the previous iteration's value for a given line is less than the current value.  This should allow you to correctly identify rising edges in software; then you just need to increment a value to count the edges.  Once you count the edges you can divide by the elapsed time--which you can get by using a "Get Date/Time VI" before and inside the loop to find out how long it took the loop to execute.  You'll likely want to average these values over several loops or add a Wait (ms) VI to the loop to make the timing more stable.

2.  If you want to take a look at the counter frequency measurement VI you can go to Hardware Input and Output>> DAQmx>> Counter Measurements>> Digital Frequency.  There are several options available and "high" and "low" frequency are relative to the card’s timebase which is 80 MHz for the M Series boards or newer counter boards.

I hope this helps, and if you find that you need to switch over to counters feel free to contact National Instruments directly for more information or help deciding on a particular product by going to www.ni.com/contact.

Have a great day!

Cheers,

Brooks
0 Kudos
Message 5 of 8
(4,042 Views)
Hi Brooks_C,
 
Based on what was described I wrote the VI below (Counting Digital Edge of the Input and calculating RPM) but it seems off. I think I misunderstood certain parts of your explaination. Would you be able to give some pointers as to where is the error? THanks. FYI the fan outputs 2 pulses per revolution.
0 Kudos
Message 6 of 8
(4,034 Views)

Hello Scuzzy,

 

One thing that would help you would be to expand your shift registers on the left hand side of your loop.  Shift registers may be expanded to have multiple values.  The top left shift register holds the value from the previous iteration and the one below it holds the value from two iterations ago and so on--it makes taking the difference between the previous values much easier.  You should expand one shift register to hold the last two values you read on the Boolean input.  This will allow you to compare the previous two values easily. 

 

Since RPM is Rotation/Minute the goal is to obtain a measurement for a number of rising edges which correspond to the number of rotations and divide by the amount of elapsed time.  You can convert the difference between the starting time and current time in ms to minutes by dividing by 60000 (you don’t need a shift register for this, just use one Tick Count (ms) VI before the loop and then subtract it from the Tick Count (ms) VI value from each iteration), and then you can divide the total number of revolutions (rising edges / 2) by this time to get RPM.

 

Since each loop iteration can only count either 0 or 1 rising edges it doesn't make sense to calculate the RPM each iteration--you need to count a number of rising edges and divide by the total time to average out inconsistencies.  If your fan is not moving at a roughly constant speed then you'll need to change your current loop into a for loop that executes X times and then put that for loop inside of a while loop.  This will allow you to average the RPM for X iterations and get a much more accurate count.  You'll need to play with the number X b/c you're making a tradeoff between accuracy and time it takes to get the measurement.  If your actual RPM value is changing quickly then if X is large you won't see these changes as clearly, however if X is small then you'll see the effects of jitter in your loop execution time since loops in a Windows environment don't necessarily take the same amount of time to execute each time they iterate.

 

Once again I want to stress that this is certainly a work around and counters are really the way to go.  If you run this loop at 200 Hz then you'll have difficulty accurately counting all the rising edges of a digital signal that is near or larger than 100 Hz.  If the digital signal is in sync with the loop then you can accurately measure 50% of your loop speed, but any faster than that and you will be losing rising edges for sure, and even if you're slower you'll still miss rising edges occasionally unless the incoming frequency happens to be an exact factor of the loop iteration rate (Note:  the loop iteration rate when using software timing like this is not constant--Window's processes can and will interfere with VI execution)  The reason for this is that since we're counting rising edges based off the digital input changing from 0 to 1 it takes at least 2 iterations to get 1 rising edge since after we get one rising edge we have to sample the signal at a low value before we can count another.  Really I wouldn't be comfortable measuring a signal that was more than 10% of my loop rate--if the incoming signal is really that much slower than this may be a fairly accurate way to measure the frequency.

 

Have a good night,

Brooks
0 Kudos
Message 7 of 8
(4,024 Views)
Hi Brooks,
 
Understand your concern and I've actually got a VI that would read from the counter. THanks!
 
Warm regards...
0 Kudos
Message 8 of 8
(4,017 Views)