LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

two while loop can not synchroniclly run

I didn't understand what you said''add the second channel to one task''and how you define ''task'' . In the block diagram, the things in the loop can be defined as ''Task'', the elements outside the loop can also be defined as ''Task''. Now I have already combine two loops into one. If you mean the elements outside should also be combined, I will do it.

 

0 Kudos
Message 11 of 21
(942 Views)

and because the settings for each channel are also diffrent, it's very hard to use one setting for two channels. This causes unprecise value.

0 Kudos
Message 12 of 21
(940 Views)

One task means one continuous task wire from function to function - not the two separate ones you have. Use two separate DAQmx Create Channels if the settings are different. Just wire one to the next.

0 Kudos
Message 13 of 21
(933 Views)

@jimmykingboy wrote:

I didn't understand what you said''add the second channel to one task''and how you define ''task'' . In the block diagram, the things in the loop can be defined as ''Task'', the elements outside the loop can also be defined as ''Task''. Now I have already combine two loops into one. If you mean the elements outside should also be combined, I will do it.

 


And a task is a DAQmx Task in this matter, the purple wire.

 

To be able to read/sample two or more analog channels from the same device you can only have one DAQmx Task.

Never ever close or clear a DAQmx Task in a loop, once you have cleared it, you can't use it in the next loop iteration.

Before clearing a DAQmx Task you need to stop the task, use the DAQmx Stop Task.vi for that.

 

And yes, you combined the two loops, with all the vi's from both loops.

Do you really need two different wait's ? What do you think will happen ?

You are reading the same file over and over in the loop, why not just read it once before the loop starts ?

You are opening a refnum to a file, with the open/create/replace file.vi, but you never close the refnum. Remember to close the refnum.

 

0 Kudos
Message 14 of 21
(914 Views)

sorry, I tried 4 days not still not working. It's very nice of you if you can give me more adviece, Thank you very much.

0 Kudos
Message 15 of 21
(887 Views)

I remove the read task and also wired two tasks together, but now nothing shows when i start the programm. Can you give me more advice? or modify my file so that I can understand better, thanks

0 Kudos
Message 16 of 21
(886 Views)

You are still using two separate tasks with two separate DAQmx Reads. ONE and ONLY ONE.

 

Once you are done, please clean up your block diagram. A rule of thumb is that it should not be bigger than one screen. If you have a huge monitor, shrink the block diagram so mere mortals can actually see it without a lot scrolling. It's just too difficult at this time to bother with.

 

0 Kudos
Message 17 of 21
(872 Views)

Thank you very much. I appogize for the chaos of my block diagram and i simplified it a little.

 

I still have a question on your block diagram. Your block diagram shows only one output (waveform) but what i need are two seperated outputs, because i need them for futher calculation with different parameter. Now I add some elements(Index Waveform array) to seperate this wave into 2 outputs, it seems work, but the program run only one time and then stopped, Is that because we use ''DAQ clear Task''? Do i need to delete this fuction? 

 

0 Kudos
Message 18 of 21
(862 Views)

Your loop condition is set to 'Continue if True'. Right click on it and change it. The default is 'Continue if False' so you changed it for some reason.

 

You would want the clear task outside the loop.

 

Why are you using the Build Array on the waveform you have indexed? That's just silly. Instead of the WDT Index Channel, you could simply use an Index Array function. You only use one of those to get both waveforms.

0 Kudos
Message 19 of 21
(860 Views)

Thank you so much. I tried your ways and it runs finally. As you can see in the picture, after combination, one side of the maschine shows much smaller value than the other side, it should be almost the same because the force was loaded geometriclly, and if I use the simple loop (which i used before i combined both side into one) to test any side of the maschine, it showed the value correctly(around 10Newton while 20 Newton als given force) . So i am confused. normally two outputs from the waveform should almost the same, but in this situation only one get correct value, the ohter one is too small. Is that because we combine two channels together and the Purple Line could not keep them seperatly?

 

 show

 

 

Attachment:

Test2. vi ist the combinated Program, the other one is the program for one side of the maschine.

Thank you 

Download All
0 Kudos
Message 20 of 21
(835 Views)