08-06-2009 09:19 AM
I currently have the setup below and the XValue timestamps from the Write to Measurement File are not exactly at the rate I specified in the DAQ Assistant. The DAQ Assistant just has analog channels with Samples to Read set as 10 (or 1, which does not affect this example) and the Sample Rate (Hz) set to 10 Hz. The main problem that I am having is that the analog channels seem to follow the Frequency Counter in the sense that it alters the XValue timestamps in the Write to Measurement File and will only log the analogs and frequency channel when the encoder (frequency counter) encounters the edge of a pulse. How do I get the analog channels in the DAQ Assistant to log as well as getting the Frequency Counter to log simultaneously with the correct XValue timestamps from the Write to Measurement File with or without the encoder moving?
Also, is the 100 ms Wait Until Next ms Multiple needed for the Frequency Counter?
Thanks in advance for the help.
08-07-2009 02:39 AM
This is a very interesting programming style.
I would suggest to have a look at some of the DAQmx Examples on Counter Measurements and Continous Buffered Analog Acquisition.
Christian
08-07-2009 04:20 PM
As Christian mentioned you might want to try starting from an example program. I will however expand a little and highlight some of the other issues with this VI.
1) You want to initialize,setup, and close your VI outside of the while loop so that we to not have to perform these actions repetitively.
2) In general we can add a single line to a dynamic line by using VIs without having to route each of the signals.
08-10-2009 06:56 AM
I moved the items out of the while loop as suggested and the reason I have all of the data lines separated is because I intend to do different kinds of math on each of those lines. I left them out intentionally so they wouldn't distract from the first questions I asked. With this setup, how to I get the counter to sample at a certain rate in which it will not affect the rate in which the analog channels is being sampled at as stated in the DAQ Assistant.
08-11-2009 12:06 PM
Vlee,
The Analog output will be using its own timing engine for the DAQ assistant, the counter task will be using the counter to keep an accurate count of the data events as they come in. You will only return counts to "Encoder (Counter)" Variable when your while loop executes. How are you timing your DAQ assistant, are you using software timing or hardware timing? If you are using software timing you will only acquire samples when the DAQ Assistant is called in the while loop. Could you post a screen shot of the settings of the DAQ assistant?
Thanks!
08-11-2009 12:59 PM
I am using no triggering and the Advanced Timing tab consists of the Sample Clock Type being Internal and the Timeout(s) is set to 10. The configuration is shown below.
Thanks,
08-12-2009 08:56 AM
The *.vi works correctly except for the fact that when the encoder is not reading any pulses, not moving, it delays all data acquisition for all channels (analog and counter) until the encoder rotates again or the counter channel for the encoder times out according to the timeout specified. I would like for all of the channels to be able to continue logging at the specified rate in the DAQ Assistant for the analog channels and the specified rate for the counter channel (encoder) if the encoder is not reading any pulses. Also, when the counter channel is reading pulses, the timestamp XValue of the Write to Measurement File is not at the exact rate I specify in the DAQ Assistant. An example of some data is shown below.
X_Value | Analog | Encoder |
0 | 2.231008 | 0 |
9.237507 | 0.942442 | 0 |
20.366281 | 3.523876 | 5.227699 |
20.725778 | -4.150966 | 1.09365 |
22.304438 | 6.117589 | 70.197237 |
When the encoder is not receiving counts, it halts all data to be written to the Write to Measurement File and the X_Value timestamps are not exactly at 10Hz as I requested in the DAQ Assistant.
Thanks again for any help.
08-12-2009 12:06 PM
Hi vlee,
Try running the two tasks in parallel loops.
Since DAQmx Read is a blocking call, it will not allow the continuation of your next loop until it either 1) returns data or 2) times out.
Since you are performing a Frequency measurement, this means that the counter is actually counting a timebase for one period of your encoder signal. It reports the value back after one period of the encoder. If there is no input signal, then there would be no data to send back to your program, hence DAQmx Read will wait until the timeout value has elapsed and return an error.
-John
08-12-2009 12:15 PM
08-12-2009 01:38 PM
This is a good point, but if the data is coming in at different rates anyway then how do you want it to display in the file?