LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use mathscript to operate on multi-channel data?

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?

Thanks,
Qifu

Message Edited by Qifu on 05-01-2007 02:49 PM

Message Edited by Qifu on 05-01-2007 02:49 PM

0 Kudos
Message 1 of 17
(2,177 Views)

Message Edited by Adnan Z on 05-02-2007 05:54 PM

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 17
(2,143 Views)
Qifu,

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.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 3 of 17
(2,139 Views)
Adnan,

Thanks for your reply. Are there any other methods to read multi-channel data and do mathscript operation after measurement?

Qifu
0 Kudos
Message 4 of 17
(2,135 Views)
Qifu,

Your solution seems best to me. Are you facing any problems with the current implementation?
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 5 of 17
(2,119 Views)
Adnan,

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?

Thanks,
Qifu
0 Kudos
Message 6 of 17
(2,116 Views)
Hi Qifu,

I think that is a limitation we would need to deal with.

If your DAQ is hardware timed, then that should not affect the sampling rate; it will have a small affect on software timed DAQ.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 7 of 17
(2,107 Views)
Adnan,

Thanks for your replay.

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?

Bei
0 Kudos
Message 8 of 17
(2,102 Views)
Hi Qifu,

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.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 9 of 17
(2,085 Views)
Adnan,

Thanks for your reply.

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.

Qifu
0 Kudos
Message 10 of 17
(2,077 Views)