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.
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.
12-12-2007 04:32 PM
12-13-2007 09:34 PM
Hi CBJohnson,
If I understand your application correctly, you want to determine the speed of a motor by counting the frequency of pulse returned from sensors connected to the motor. In order to determine the pulse frequency, you are continuously generating a pulse train with Counter 0 that you then use to gate Counter 1. Counter 1 will then determine the frequency of the motor pulses. You know that this frequency will be from 0 to 5 kHz. Is my understanding correct?
I understand “Method 2” to be the High Frequency 2 Counter Method. When you create a Counter Input Frequency Task and use the DAQmx_Val_HighFreq2Ctr measuring method, the DAQmx driver automatically divides down the 80 MHz Internal Timebase using one counter. The driver will internally route this slower signal to the Gate of the second counter, which will then use this known period to determine the frequency of the signal connected to the counter’s Source. As such, the driver will reserve both counters for this task. This is most likely why, when you try and generate the pulse train and do the routing manually, you are receiving this Resource Reserved Error. You do not need to do this pulse train generation, just run the CIFreqChan task and all the signal routing will be done for you.
Something to consider is that Method 2 is meant to be used when the frequency of the signal you desire to measure approaches the frequency of the internal timebase used by the counter, which is generally 20-80 MHz. Since your motor speed is significantly slower, I would suggest using Method 1, or the Low Frequency 1 Counter Method. This method uses the Timebase as the Source Signal and the unknown frequency as the Gate then internally does the math. In C, the measurement parameter for this method is DAQmx_Val_LowFreq1Ctr.
Note: I am unfamiliar with the language that you are programming in, but as it looks similar to C code, in the Implicit Timing line of your Task_Handle8 could you have meant ContSamps, without the t?
I hope this explanation helps, Mallori M.
12-14-2007 09:18 AM
Hi Mallori,
Thanks for the great reply message. I do appreciate your help.
Yes, I think you understand my application. The motor can turn from zero to about 5K RPM and one pulse is generated with each turn of the motor.
This application is using Agilent VEE but the statements are "C-like" so that's why I posted them like that. I can't "cut-and-paste" directly from the VEE statements and I have to type them. I mis-typed the Implicit Timing statement. It was missing an "_". It should have been:
AGniDAQmx_CfgImplicitTiming(instrHandle,Task_Handle8,DAQmx_Val_ContStamps,1000)
I think I understand what you are saying about DAQmx_Val_HighFreq2Ctr using the resources from both counters That explains why I get the message about resources not being available.
I have tried to use Counter Method 1 and it *almost* worked. A problem comes about when the motor speed is zero (stopped) and, since these motor pulses are being fed into the Gate of the counter, the zero value makes it simply time out. Increasing the timeout value to infinite (-1) makes the entire program hang. I need it to go on -- looking for other user input, reporting other data being collected, etc. If the counter is waiting for the Gate signal to rise to start counting and to drop to stop counting and do the calculation, it will not work since it just times out. I went to this counter method (actually called counter method 3 in the DAQ manual) because then I am trying to generate the pulses of known period and send these pulses to the Gate. Then I am feeding my pulses into the Source of the counter and letting it determine how many pulses occured during the "gate time". In this case, zero pulses during the "gate time" should be OK; it should simply report that zero pulses were detected and start counting again on the next rise of the Gate pulse. I thought I could simpy adjust the length the "gate time" to measure my range of frequencies.
Make sense? Any way to do this with the two counters of the USB-6211?
Thanks, Mallori,
-Craig
12-14-2007 02:52 PM
I just got done answering a similar question about reading counter frequencies that approach 0 using single counter freq measurement. Have a look at this suggested workaround.
12-14-2007 02:59 PM
12-14-2007 03:11 PM
I'm sure the timeout spec is a little bit approximate and is probably subject to some whims of the OS. So it'll probably usually be correct to within some msec, but the read function may occasionally take a little longer to timeout.
But remember that the timeout only happens as you approach that low freq threshold and fail to get a pulse within the time limit you choose. The rest of the time you *don't* timeout and you get true measurements with oscilloscope-like accuracy based on timing between gate pulses.
-Kevin P.
12-14-2007 03:13 PM
12-17-2007 12:53 PM
12-17-2007 01:58 PM - edited 12-17-2007 01:59 PM
Hey,
Just my two cents: Along with just waiting for a timeout, you can set the number of samples to read to -1, and if no values are in the PC buffer then the read will return without an error. That way you don't have to worry about the timeout. The only real downfall of this is that once you get up and running, you'll probably get a large indeterminate number of samples from the read - which can be a pain when allocating memory. After your first set is acquired and your machine is up and running you can grab a specified amount.
Also, I haven't tried the wait for a timeout method but it should work. I believe it is the case that you will have to restart your counter task, but you can reduce the setup time by commiting your task before you start it with DAQmxTaskControl ().
Cheers,
Andrew S
12-18-2007 08:09 AM