ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding multichanel abilities to existing code

I have put together a VI that is working great. It acquires all of the data I need, and is able to calibrate it, and then save it to a .csv file. However, I would now like to be able to run 4 of these simulations simultaneous, with different calibrations for the data (ie the math functions that I am using to change from one unit of measure to another) What would be the best way for me to implement this based on my existing code. I am uploading a picture of the code for reference.


0 Kudos
Message 1 of 11
(4,142 Views)

Hi Robert W,

I understand that you want to acquire data from 4 different AI channels and apply a different scale to each channel. You can do this by creating an Analog Input task, add the four channels to it and apply a different scale to each channel. There is a create scale vi, part of the DAQmx drivers, that creates and configures a scale. I think it could be really helpful in your application since it applies the scale to the input (or output) data. You can find it in the Functions palette > Measurement I/O > NI-DAQmx > Advance > Scale Setup > DAQmx Create Scale.vi. This screenshot should be helpful in how to setup the channels (and uses the create scale vi). I hope this is helpful, if I misunderstood your goal please post back.
Message Edited by Ana P on 03-27-2008 05:16 PM



Message Edited by Ana P on 03-27-2008 05:19 PM
Ana P
National Instruments
Applications Engineer
0 Kudos
Message 2 of 11
(4,111 Views)
Hi, when I do what you suggested, I still only see one set of data being graphed on my waveform. Also, how would I go about writing this data to a .csv or .xls file now.

Thanks,
Robert
0 Kudos
Message 3 of 11
(4,077 Views)
Hi, when I do what you suggested, I still only see one set of data being graphed on my waveform. Also, how would I go about writing this data to a .csv or .xls file now.

Thanks,
Robert
0 Kudos
Message 4 of 11
(4,076 Views)

Did you change your DAQmx Read to NChannel from 1Channel?

Once you have NChannel, this will return either a 2D array or 1D Waveform array. Use the 2D input of Write to Spreadsheet file or use Export Waveforms to Spreadsheet File.

0 Kudos
Message 5 of 11
(4,065 Views)
Does the write to excel or spreadsheet vi go inside or outside of the loop? I already made the change regarding the 2D array files.

Regards,
Robert
0 Kudos
Message 6 of 11
(4,059 Views)

Inside if you want to save all of the results. Something like below with the Array to Spreadsheet String function.

You can also place the file write in a separate loop and pass data to it via a queue. This has the advantage of not slowing down your acquisition loop.



Message Edited by Dennis Knutson on 04-01-2008 08:09 PM
0 Kudos
Message 7 of 11
(4,044 Views)
Can you explain using a qeue to pass data into a seperate loop. I am having trouble with a program that executes fine while I am not saving the data, but slows when I do to the point it causes problems. I have tried passing to a seperate while loop with a local variable, but this did not seem to change the speed.
0 Kudos
Message 8 of 11
(4,026 Views)

Another option, without having to go into queues, sorry Dennis, is that you can index your array in the loop and then write the data all at once outside of the loop.  There are pros and cons to all of these solutions so use which one works best for your application.  It is going to be a tradeoff between programming knowledge and complexity, speed, memory, and robustness.

 

StuartG

0 Kudos
Message 9 of 11
(3,991 Views)
Don't have to apologize. And, just to add another option, instead of writing as text, inside the loop, save as binary. Either the Write to Binary or the TDMS format like some of the shipping examples.
0 Kudos
Message 10 of 11
(3,987 Views)