03-23-2010 10:52 AM
Hello:
I am aquiring waveform data from 4 digital channels using DAQmx vi's as can be seen below.
The four channels are labeled Reference, Absorption, Etalon and Ramp. The TDMS Write vi will create four columns with these labels on them corresponding to the data collected. I would like to add a fifth column, Temperature, with a different set of data sampled at the same frequency. However, the data source for this fifth column comes from GPIB source - not a digital channel. The vi for this yields a single numeric value, not an array.
How do I create an array of the Temperature values concurrently as the 4 channels are acquiring data through the DAQmx viat the same frequency? I know the frequency value.
How do I add this array into the waveform data coming from the DAQmx vi that the TDMS vi accepts?
Thanks.
Alfredo
03-23-2010 11:22 AM
03-23-2010 11:39 AM
You could use the method in the attached VIs as long as you are sure the measurements are taken at the same time. (That should get you started)
Personally, I would take 1 measurement from the DAQ and 1 from the GPIB at the same time, then repeat the process and use timing on a timed while loop of a for loop (indexing the output of either of these) to ensure that the measurements do actually correlate to each other. I'd also record the time since t0, rather the the frequency in case I didn't manage to read at exact time intervals. I'd record all of the data in one loop and dump it on a queue. I'd then add it to an array in a second consumer loop - which could log it to the TDMS file, and/or display it to the screen as the cycle goes on - nearly realtime display and logging of data without affecting the data acquisition.
Hope this helps
James
03-24-2010 03:43 PM
Thanks for you response.
I like the idea of picking each data point individually from the digital channels and appending it to the GPIB signal and thus create an array. The following set up is my attempt at this. I have changed DAQmx from NChan NSamp to NChan 1Samp and inserted it into a For Loop. This For Loop will have the number of samples per channel on it but for now just 100. However, it is not working.
What this does is create 100 different arrays each with 5 elements in my TDMS file.
Lets say the four digital channels output data A, B, C, D and that the GPIB outputs X. I want to arrange the data as follows:
A1 B1 C1 D1 X1
A2 B2 C2 D2 X2
A3 B3 C3 D3 X3
...
A100 B100 C100 D100 X100
I have done this in the above set up. However, the TDMS file created reads each ABCDX as one array and therefore compiles 100 of them. I was hoping it would create, instead, 4 columns with 100 elements each.
Please advise. Thank you.
Alfredo
03-25-2010 03:59 AM - edited 03-25-2010 04:03 AM
Hi Alfredo,
You've got the right idea, you've just missed out on a couple of fundamental points that will make your code better.
Initialising Shift registers - good
Building an array in a FOR loop shift register - bad (unless totally necessary) - this is a waste of memory CPU time and not efficient.
Autoindexing the output of a FOR loop to create an array - good.
You had 5 channels of data in a 100x5 array but you wanted only 4 columns to log? I assume this is a typo.
Try this second debug VI (calls the same subVI as before - temp gpib)
One of the cases of the case structure should give you the log format you want.
(I haven't tried any of these, I just coded them and assumed they should work based on having done this lots before)
James
Edit: If your "Get Temp.vi" is unique to this project - which I assume it is, or just for ease of compatibility with logging functions in other projects I would have coded the output as double data type so as not to need the type conversion in the FOR loop. It's also goo practice to pass error out for sequencing purposes even if there will never be an error and you don't wire it.