I want to measure two or more channels at the same time, and then use mathscript to do some operations.
I used DAQmx Read and For Loop to do measument. The data was saved as "Analog 1D Waveform N channels N samples". The data was wired to the input of the mathscript block, which was outside the For Loop. However, the wire was broken and the data types were not compatible.
So, I extracted each channel data in the For Loop, and form two seperate waveforms. For each waveform, I got the Y component which was used as the input of the mathscript block.
My question is: can I read the multi-channel data directly into the mathscript block?
That won't work. The output of the DAQmx Read VI is a array of 'Waveform Datatype'. The Mathscript node expects data of the type double. That's why your wires were broken. Please do post if I have not answered your question correctly.
In my solution, the number of channels is two, and it is fixed. I am wondering how to read the data from every channel if the number of channels varies. I am thinking to put a For Loop inside the current For Loop.
Also, if too many operations are done inside the For Loop, will they affect the the sampling speed?
I figured out how to extract the data from every channel using the same LabVIEW file when the number of the channels is not fixed for different situations.
I have another question. If I want to measure, for example, temperature and voltage at the same time, do I need to put two DAQmx Create Channel vi? One is specified as AI voltage and the other AI Temp?
Yes, you will need to have two create channel VIs which you can then cascade to a single output. I would recommend using the DAQ Assistant to create the channels with the different configurations; and then right-click on the DAQ Assistant express VI and select Convert to DAQmx code. You can then see how it can be created and configured.
Here comes another question. The attached is the new .vi file. I compiled it to an executable file. Because the .exe file runs automatically when it is opened, I put a RUN button and a STOP button to control running. However, the .exe file didn't do everything that the .vi file did.
In the .vi file, after the run button in the toolbar is clicked, the file won't run until the RUN button is clicked. The RUN button can be clicked again and again based on how many times we want to do measurement. The file won't stop until the STOP button is clicked.
When the .exe file is opened, the run button in the toolbar is already in the status of running. Since I put a RUN button there, the file actually won't run until the RUN button is clicked. However, if the RUN button is clicked for the second time, there is nothing happened. It is same for the STOP button. Both works well only for the first click.
I am not sure if I explained my question clearly. Because the size of the .exe file is too large, I couldn't attach it. Could you guess what's the possible reason?
Thank you again for your consistent help and support.