Discussion:
M-Series Hardware-Timed Digital I/O
(too old to reply)
JMBacker
2008-05-12 16:10:09 UTC
Permalink
Hey everyone,
 
Somewhat new to LABView, and I'm writing a program to take readings from a dynamometer.  I'm using a USB-6229 board.  I'm having problems figuring out how to take frequency readings on the digital input lines.  I've downloaded several of the examples from here, but none of them show me how to get a frequency number from the reading, they just display a graph.  Do I need to take a frequency reading from this graph?  Is there a better, more accurate way to get the frequency?
 
Basically I need to take RPM readings from my Digital Inputs. 
 
Any help is appreciated.
Brooks_C
2008-05-13 16:10:10 UTC
Permalink
Hello JMBacker,

 

In order to make a digital frequency measurement you'll need to use a counter rather than a digital line.  If you're using a multifunction DAQ card it?s likely that you have two counters available to you.  Assuming you have these counters you'll be able to find examples in LabVIEW to make this measurement.

 

To access these examples follow these steps:

1.  Open LabVIEW and go to Help» Find Examples...

2.  If you're using DAQmx you can navigate to Hardware Input and Output» DAQmx» Counter Measurements» Digital Frequency.  This folder has several relevant examples with descriptions you can access on the right side of the Example Finder window.

3.  If you're using a Traditional DAQ device you can find these examples by clicking the "directory structure" button.  Then navigate to DAQ» Counter» <Your device type>

 

If you're unsure what driver you?re using or what device type you have then you can post back with your card model number, i.e. PCI-6251.  I hope this helps and have a great day!

 

Cheers,
JMBacker
2008-05-13 17:10:07 UTC
Permalink
As my post says, I'm using a USB-6229.  Both of my counters are being used, I need to use the regular digital inputs to get more frequency readings.  Yes, I'm using LABView 8.5.1 and the latest version of DAQ-MX.  I believe there is a way to do this, I just haven't quite completely figured it out.  See my post in the multifunction DAQ discussion board:
 
<a href="http://forums.ni.com/ni/board/message?board.id=250&amp;thread.id=39943" target="_blank">http://forums.ni.com/ni/board/message?board.id=250&amp;thread.id=39943</a>
&nbsp;
This is what I've figured out so far.
&nbsp;
Thanks!Message Edited by JMBacker on 05-13-2008 11:52 AM
Brooks_C
2008-05-14 19:10:07 UTC
Permalink
Hello JMBacker,
Sorry I missed the device in your first post.&nbsp; Since you have correlated digital lines you have a pretty good solution available for this application.&nbsp; The primary difference between using a counter and a correlated digital line is that calculating the frequency will be a post processing step as opposed to a hardware calculation when a counter.
In order to make a frequency measurement with a digital line you will basically be sampling each digital line and then going through the data in software to look for rising edges.&nbsp; Each time you find a rising edge you should save then index.&nbsp; Then, when you find the next rising edge you should subtract the previous position to calculate the period of the incoming signal (then take the inverse to get frequency).
There is inherently an error associated with this measurement and that error is +/- 1/ (sampling frequency in Hz).&nbsp; To reduce this error you'll want to increase the digital input line sample rate.&nbsp; It looks like you're already aware that you need to provide an external sample clock for these lines (or as in your example program, you can use the AI sample clock to clock these lines).&nbsp; I do not currently have a PCI-6229 available, but since the maximum analog input sample rate is 250 kS/sec you may not be able to set the rate to 1MHz.&nbsp; Since your digital inputs can be clocked up to 1MHz and your measurement's accuracy depends on this sample rate you should try to set the analog input sample clock to 1MHz.&nbsp; If setting the analog input sample clock to 1 MHz throws an error then look at the maximum rate.&nbsp; If the maximum rate is 250 kHz then you have a couple options.
1.&nbsp; You could use a "dummy" analog output task.&nbsp; The analog output on the PCI-6229 can go as high as 833 kHz so this would be a significant improvement.2.&nbsp; You could use a truly external sample clock from a function generator or other source.3.&nbsp; I know that you're counters are already being used, but if you're using then to measure frequencies as well then you could instead use one of them to generate your digital input sample clock at 1 MHz&nbsp; This would provide the highest accuracy available for your digital line frequency measurement.Option 3 is the best (and easiest) solution, but if you're using the counters for another purpose then either of the other options will work.
I hope this helps get you started, and have a great day!

Continue reading on narkive:
Loading...