10-31-2008 09:28 AM
Hi,
Im using distance sensor ELGO EMIX3 (10-30 VDC square wave output). Max resolution is 0.01 mm while using 4 edge triggering.
Current principle is to count rising edges from the signal (attachment)
Problem is that I'm not able to count pulses as fast as needed. maximum speed for the sensor is 4 m/s and I'm nowhere near! I Would be happy for 0.1 m/s speed
Is there a better way to count signal edges using NI 5124
regards,
Asmo
10-31-2008 11:02 AM
There are a lot of different ways to make this measurement. The 5124 is capable of making this measurement. I've attached some code that I created to measure the frequency of a signal by counting edges and then dividing by the time period. This is way more than you need, but should cover your use case.
The example basicly streams records off the board. Each record is triggered by an edge trigger (you'll have to adjust your trigger level). The code counts the number of records (which is the count you are looking for) and divides by the time period of those records to get the frequency of the signal.
10-31-2008 11:06 AM
11-05-2008 07:57 AM
Thanks HSD,
Code you provided does the trick and the system is able to count edges very fast.
First I had to upgrade SCOPE driver software, because I got several errors about memory overload and one like this:
> Component Name: nimxslu proxy
> File Name: This is NOT an error in nimxslu. See nimxsl/tStatus2KernelProxyWrapper.cpp for information
> Line Number: 290
> Status Code: -218802
Further, i tried to modify your code to count rising edges from two sensor signals with no success.(attachment)
I added input channels 0,1 and get waveform array size 2. I also ensured that waveform array consist different signals from channels 0 and 1. Anyway, total records still show pulses from only one channel. I guess this has something to do with fetch records property node?
and further..
I need to count both rising and falling edges from two channel input. Sorry, Im not familiar using scope property nodes. Is it possible to modify this code you suggested earlier to count rising and falling edges?
11-05-2008 08:58 AM
The code I provided is doing a multi record acquisition which means the hardware is automatically rearming the device to trigger another acquisition. Each acquisition is acquired into a separate buffer. As long as your system has the bus bandwidth and processing power the example will run forever without ever missing an edge. If you run low on either bus bandwidth or processing power you recieve an error (so you can always know if you are getting good measurements).
You can make the code I gave you trigger on both edges by changing the trigger type from analog edge trigger to window trigger. You should set the high and low levels to something close to your trigger level. The polarity option should be set to entering if you want the triggering to begin on a rising edge and leaving if you want the counting to begin on a falling edge.
The NI digitizers can only trigger on one channel at a time, so there is no way to make the code I gave you work for more than one channel on a board. The only work around I can think of is to use two boards. You can use TClk to synchronize the two channels on the different boards, so that the results from both channels can be compared (TClk has the ability to synchronize to 100s of picoseconds).
An alternative is to stream all the data to a disk and post process the data. Unfortunantly, the 5124 can't stream all its data at its maximum sample rate. If your application can support sampling at a slower rate (20 MS/s) then this method could work. An another alternative is to use the PXIe-5122. That device can stream data to disk at full rate.
Hope this helps.