10-21-2008 08:47 PM
Solved! Go to Solution.
10-22-2008 12:29 PM
Hi PraveenB,
Is the Express VI for logging inside your while loop? You might consider buffering your writes to limit the time spent in overhead writing to the file, you can implement this with a Producer Consumer architecture which you can read about here. Or even taking the write outside the loop and do all the writing once the program is done depending on how long this needs to run.
If it is still running slow I would like to see your VI or a screen shot of it so that I can more easily assist you.
10-22-2008 02:20 PM
Hi Jason,
Thankyou very much for your reply.
I removed the express VI datalogging which was inside the while loop. The only thing i am doing inside the while loop is reading the frequency of the signal at the gate of Counter. I varied the input frequency of the signal from 50 Hz to 500 Hz. Every time i measured the time it takes for each iteration for reading the frequency of input signal at the gate. The time taken is around 60 ms. This is true for any input signal frequency and it does not change. So essentially if i am using a single counter low frequency measurement, and trying to read the frequency of a 500 Hz signal at the gate (2 ms period), why does the while loop take 60 ms to read out this value of 500 Hz?
According to my understanding, counter is internally using a 20 MHz time base and counting pulses between two rising or falling edges of the signal at the gate. So the counter should take a maximum of 4 ms to measure the frequency of 500 Hz at the gate input with two rising edges 2 ms apart. But the labview program takes around 60 ms to get the measured value from the counter. Why does it take so long ? Can i make it read faster than this in the while loop ? I have attached the block diagram of my program.
Best regards,
Praveen B
10-22-2008 04:48 PM
PraveenB,
Your VI is being software timed the way it is currently constructed. Try adding a DAQmx Timing VI (continuous samples if you so choose) and a DAQmx Start Task VI.
10-23-2008 06:41 PM
Hi Jason,
I added a DAQmx Timing VI and DAQmx Start Task VI outside the loop and now the DAQmx Read VI takes around 20ms to read the frequency value. This is sufficient for my work. Thankyou for the suggestion.
But now i am facing a different problem. I am using a DAQmx Channel property node channel to set the digital filter minium pulse width and enable it, as my input signal is noisy. I have used this after the DAQmx create channel task VI. But now when i run the program, i get an error in the DAQmx Start Task VI task. The error number is -200774. The description is "Terminal has already been configured with a different Minimum Pulse Width by another propery in this task". So how do i override with my property settings ?
Attached is the screen shot.
Sincerely,
Praveen B
10-24-2008 10:21 AM
PraveenB,
I just tried a replication of your code and it worked fine. What is your minPulseWidth, Timing Clock Source, and Sampling Rate. I set minPulseWidth to 125ns.
After which VI is the error being generated? The Start or the Timing?
10-24-2008 11:02 AM
Hi Jason,
I have set the following -
minPulseWidth = 6.425e-6 (Property Node)
Timing Clock Souce (Source) = /Dev1/PFI2 (Timing VI) - This is the pin for which i need frequency measurement
Counter(s) = Dev1/Ctr1 (Timing VI)
sample mode = continuous samples (Timing VI)
samples per channel (buffer size) = 100 (Timing VI)
rate (samples/second) = 20.00 (Timing VI)
I get an error after Start VI. May be the Start VI is receiving the minPulseWidth = 0 from some other SubVI internal to it. I am not sure.
If i dont use the propery node, then it works fine with no error and measures the frequency correctly with the above settings.
Sincerely,
Praveen B
10-24-2008 11:40 AM - edited 10-24-2008 11:43 AM
PraveenB,
Here is a table of the Counter terminals and related PFI lines. This can be found in the NI DAQmx Help. (http://digital.ni.com/public.nsf/allkb/CCDFC93878BD8781862570FC00559980?OpenDocument)
Counter/Timer Signal | Default Pin Number | Signal Name |
---|---|---|
CTR 0 SRC | 1 | PFI 0 |
CTR 0 GATE | 2 | PFI 1 |
CTR 0 AUX | 1 | PFI 0 |
CTR 0 OUT | 6 | PFI 4 |
CTR 0 A | 1 | PFI 0 |
CTR 0 Z | 3 | PFI 2 |
CTR 0 B | 2 | PFI 1 |
CTR 1 SRC | 4 | PFI 3 |
CTR 1 GATE | 3 | PFI 2 |
CTR 1 AUX | 4 | PFI 3 |
CTR 1 OUT | 7 | PFI 5 |
CTR 1 A | 4 | PFI 3 |
CTR 1 Z | 2 | PFI 1 |
CTR 1 B | 3 | PFI 2 |
FREQ OUT | 8 | PFI 6 |
When you choose counter 1 in the Create channel VI it automatically reserves the gate which is PFI2. If you use Counter 0 then PFI 2 will work fine. Likewise if you use Counter 1 you can use anything but PFI 2.
10-24-2008 03:13 PM
Hi Jason,
I got it right now after configuring the source of the timing VI properly.
Thankyou very much for all your help.
Sincerely,
Praveen B
11-02-2009 04:35 PM - edited 11-02-2009 04:37 PM
Hello to you all,
I apologize for resurrecting this old thread, but my issue is similar. I followed the advice and used timing VI, but I'm getting error 200300 Invalid timing type.
The project is simple. I have encoder with 1000 pulses per rev and it is mounted on a shaft. I'm trying to monitor the frequency and thus the rotation of the shaft. At the end there will be 2 channels per each encoder and ~3 encoders total. I'll be using PCI6602 DAQ, but right now for the development I'm using USB6221. Let's say the frequency is between 10kHz and 20kHz. What am I doing wrong??
Thanks
Marty