LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you toggle between multiple channels to indicate from which channel to acquire data from?

Solved!
Go to solution

Pretty nice system aeastet.  A value change event triggers all the states necessary to reconfigure the channel list.  Are your VIs in 8.5?  That is what the OP has.  He mentioned that he couldn't open your previously posted VIs.


 

 Thanks for the compliment. It is a very effective system. You should see all of the complicated stuff that we have to go with it.

 

 

Here is an 8.5 version.

 

 

Tim
GHSP
0 Kudos
Message 11 of 28
(1,152 Views)

Hi,

  Thanks a lot for all the help. I am a beginner and the VI that you sent me was a little complicated for me, though I could figure out some parts of it. Its an excellent VI.

  But I was wondering if we could achieve this using just For loops or If loops. If you have taken a look at what I have in the VI that I sent you, I can toggle between two channels. So is there anyway that I can have an execution control which can allow me to toggle between the channels that I set as Active (or ON) using simple boolean (TRUE/FALSE)? Please correct me if I am wrong in saying that.

 

Thanks.

0 Kudos
Message 12 of 28
(1,138 Views)
If you are going to change the number of channels that are going to be collected without shutting down your process, then you are going to have to use an arcatecture that allows for you to stop and start the data acquisition loop. The easiest way to do that is using a state machine system with an event structure.
Tim
GHSP
0 Kudos
Message 13 of 28
(1,127 Views)

This will become extremely complicated, ksurdi, so you better learn Labview quickly.  Your vi will have to become a subvi. 

 

The main will control when the subvi runs and when it stops.  You will need a boolean OK button on the main to signal when to change channels.  You will need a control reference of this boolean to send to the subvi.  Inside the subvi, in your DAQmx read loop, you will have to check the value of the control reference.  If it turns true, stop the loop and the subvi will finish (must clear the DAQmx session as you have in your vi).  The main will have to call the subvi again with the new channels.

 

So you will need a loop in the main that calls the subvi with the channels specified in a front panel control.  The subvi will run until the OK button is pressed.  Then the subvi will end and the main loop will go to the next iteration.  You have to change the channel list before you press OK.  On the next iteration, the subvi is called again with the new channel list.  This continues until you end the program.

 

End the main loop with a stop button.  You will also need a control reference for the stop button, and will have to check its value in the subvi read loop (where you check the OK button).  Either button should stop the read loop.

 

This will work without the much more complicated method of using an event structure and a state machine.  Well, that is my opinion.  Maybe someone could come up with a scenario where a state machine and event structure would be simpler.

 

Try to implement what I said.  Post your code and ask for help when you run into a snag.  To start you off, these two attached vi's show an example of how to use control references to stop a subvi from the main.  They are in LV2009.  If you need to downconvert, copy the files and post them to the Downconvert VI Request thread on this forum and someone will convert them for you.

 

Good Luck.

 

- tbob

Inventor of the WORM Global
Download All
0 Kudos
Message 14 of 28
(1,112 Views)

Replying to my own post.  I just thought of a simpler way.  Just put a while loop around your entire vi.  Rename your stop button to Change Channels.  Add another stop button.  Use the new stop button to stop the new while loop.  That is it! Smiley Happy

 

While running, enter your new channel, then press the Change button.  The read loop will stop and the rest of the code will execute, closing the DAQ session.  The outer loop will go to the next iteration.  A new DAQ session will be started with the new channels.  This continues until you press the Stop button and the Change button too.  You could make it better by creating a local variable of the stop button and putting it inside the read loop so that the stop button alone will stop both loops.  If you do this, you will have to change the mechanical action of the stop button from latched to switch.  After the main loop, set the stop button back to false.  Use a flat sequence, put the code to wire a false to another local variable of stop, and put a wire (any wire) from the main loop to the flat sequence.  This way, the stop button does not get set to false until the main loop finishes.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 15 of 28
(1,101 Views)

Hi tbob,

   Thank you very much all the help.. I will try to implement what you told me now. Will let you know if I have some problems running it. Thanks again. 🙂

0 Kudos
Message 16 of 28
(1,094 Views)

Hi tbob,

   Would it possible for you to give me a LabVIEW 8.5 version of the VIs that you sent me, so that I can open it up on my laptop too? Thanks.

0 Kudos
Message 17 of 28
(1,083 Views)

Sorry, I don't have 8.5.  Copy my vi and submit it to the Downconvert VI Request thread on this forum.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 18 of 28
(1,065 Views)

Hi,

  Firstly thanks for all the help. As I am new to LabVIEW, I am not that savvy with using all the functions in it.

For the problem I mentioned earlier, I am trying to use strings and the Flatten Channel VI for turning different channels ON and OFF. What I actually want to do is to make a table in the front panel which would have columns consisting of the number of channels, Channels Active (ON or OFF), Calibrations factor and Calibration Units.

  So, for example, out of 16 channels if I want only channels 2, 4, 6 active (ON) I should be able to input the claibrations factors and units for these channels according to the type of measurement, and get the corresponding waveforms for them. So can you use arrays and clusters to achieve this? Also, it should allow me to add or subtract channels even when the porgram is running.

 

Please help as I need it very urgently.

 

Thanks.

0 Kudos
Message 19 of 28
(1,021 Views)

Do you want the user to select from a list of available channels?  Have you been able to get my code downconverted to 8.5, and have you taken a look at it?

 

You would have to form a cluster with a channel name and its cal factor and unit.  Then create an array of this cluster.  The user would then select which channel or channels to use.  You would extract the info from the selected clusters to send to your program.  For the DAQ channels, extract the channel names selected and form a string with the names separated by commas.  Send the string into a Create Task function.  The task out from that should be wired to the task input for Create Virtual Channels.

 

For selection, you could also have a checkbox list of items where the user checks off the channels he wants to use.  Then you use the selected indeces to grab those clusters in the array.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 20 of 28
(970 Views)