ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two loops with different durations within a big loop... Is it possible???

Hi everyone,
 
I am using labview 7.1 to write a program which would need some expert help. It starts off with a very simple logic but got expanded to a very complicated situation (as least to me). And I am sorry about the length of this message due to the complexity of the situation.
 
Here is some details about my program.
My program consists of two major parts. The main program is a stand alone program, which can run on its own, and it performs a series of procedures. This program lasts for about an hour. During my experiment, I also need to record all the temperature and pressure in my system, probably every 2-3 seconds, therefore, I also have another program that consists of a big while loop to measure and save all the data. I got the combine program to work by simply putting my main program VI outside of my measurement loop.
 
Now, I want to improve my program in order to embed it to my field point controller. To fit my purpose, this improved version should be able to
1. stay in my controller memory practically forever (unless I physically stop and remove it).
2. this program should also has the ability to stop by a user via a toggle button (without termination of the program) and start the experiment (from the beginning of the experiment) via a toggle button.
 
I had an idea of putting all my existing program within a big loop that runs forever, but this creates some practical problems when I actually run it. Since the real program is too big, so I include a simplify version here in the attachment, and below is a brief summary of what I was intended to do. Hope somebody would be able to help me solve this program.
 
1. The while loop B resembles my data recording loop. It refreshes every 2-3 second to read the measurements, and then save them to a text file. This should last forever unless the user stops it. Within this measurement loop B, I have a case structure (structure C), which should only be run ONCE everytime when loop B starts (to create the file name and header information for my data file).
 
2. The rectangle represent my main program, and it comes with all the complexity. This main program lasts for an hour. And I need it to be actuvated TOGETHER with the measurement loop (loop B).
 
 
If I were to put the main program within loop B, loop B does not loop any more because it has to wait until my main program finishes. But when my main program finishes, loop B does not resume and was stuck. If I were to put my main program outside of loop B, the main program won't starts because loop B has not finish. I tried to use local variable and didn't get much luck.
 
Can I really do what I want to do? Does anyone has a good suggestion for me?? Is it my logic of thinking has a problem? Many thanks in advance.
 
 
tak
Download All
0 Kudos
Message 1 of 14
(4,822 Views)
I apologize in advance for this... 

I'm not the best person to help you, as I've never dealt with FP controllers, and wouldn't have a clue about FP memory management.

I noticed however, when I looked at your image, that your system font is different than normal, did you change that yourself?  And if so, how did you change it?  Again, I sincerely apologize for hijacking your post - especially about non-LV stuff, but I've been caused a lot of grief about this (the larger-than-normal font is wreaking havoc on some machine's displays), and have not been able to find out how to change it.

Feel free to completely ignore this, but if you've got any inkling of how to change it, I'd be forever in your debt.  Thanks


0 Kudos
Message 2 of 14
(4,810 Views)
Hi Novatron,

I may at one point change my font because it didn't look very nice, however, I do not quite remember.
I believe you may change your own setting via the pull down menu as indicated.
 
 
tak
0 Kudos
Message 3 of 14
(4,801 Views)
Hi Novatron,
You can change your Dialog- and Application Font in Tools>>Options... >>Fonts, going to Appl. Font, setting to "Custom Font", choosing the Font and then restarting the LV-system. This is the long way. The short way ist to open the Font- Dialog (Ctrl+0), setting the new Font and size and clicking "Panel default" & "Diagram default".
Then it works immediately.
Greets, Dave
Greets, Dave
0 Kudos
Message 4 of 14
(4,779 Views)
Hi tak,
my suggestion is to place the main prog outside the loop B but inside loop A. This makes sure, that Loop A is turning once with every execution of the main prog. Beside this Loop B is executing independently. Then you need some communication between your main program and the loop B which can be implemented easiest with global variables, one for each communication direction. This could look like this to abort the main prog on "emergency":


and to tell the Loop B to stop on finish of the Main prog:



In the main prog- VI (which is a bit weird, because the while loop execute always and only once and therefore is unnecessary) your experiment shoult execute in a while loop, since it is abortable dynamically. The for loop will execute the predefined count, defined by wiring the "loop count"- terminal or wiring an array with autoindexing.

I hope this helped a bit,
dave

Message Edited by daveTW on 06-17-2006 02:13 AM

Greets, Dave
Download All
0 Kudos
Message 5 of 14
(4,777 Views)
A couple of suggestions on your main question....

Many FP controllers don't have infinite life on the memory write operations, you may want to consider this with respect of your data logging files if they will be written to the internal memory.

You should possibly consider the 'Timed Loop', to ensure that things happen when you want them to.  Field point aplications normally imply some level of deterministic behavior and it will be better achieved with timed loops. This will probably help with a redesign as well when you understand how powerfull they are.

Be wary of using the term 'Emergency Stop'. This can have specific, important meanings; especially in Field Point type embedded applications where hardware such as motors or other actuation might be involved.

My guess is that the whole thing will be a lot simpler and clearer when you start to use timed loops, also sounds like a good time to consider 'state diagrams' etc.
0 Kudos
Message 6 of 14
(4,752 Views)
Hi Dave,

Thank you first of all. I think I did try putting the main program outside of loop B before, but wasn't able to get it to work. Maybe I did something wrong. But I will certainly try it again with your suggestion. Thank you very much.


tak
0 Kudos
Message 7 of 14
(4,745 Views)
Hi Conseils,

Thank you for your information. Actually, I should not really say infinite time. But my experiment lasts for a rather long time. Each successful run should last about 1 hour and the entire procedure will be repeated for 8 times.

It sounds rather interesting about the "timed loop" that you have mentioned. Do you mean by putting a specific time constraint on some loop action? Can you be a bit more detail on that? I am still learning labview at this stage and not very familiar with lots of things in labview.


tak
0 Kudos
Message 8 of 14
(4,744 Views)
Hi Dave,
 
I have modified my program as you suggested but I don't think it is doing what I want it to do though (modified program is attached). Maybe let me explain it more.
 
What I really want to do is to have the experiment program start first, and my loop B to activated shortly after that. The main program should just run without stopping (and in the actual program, this whole process lasts for 1 hour). Within this 1 hour, I need the loop B to continue to run as long as my main program is still active, to record data.
 
In the suggestions you gave, the experiment program run from start to end BEFORE loop B was activated.
 
 
tak
0 Kudos
Message 9 of 14
(4,722 Views)
Hi Tak,
first excuse me not to answer the las days (quite busy).
I altered your VIs and hope, this is what you need.



and "experiment.vi":



What I don't understand is the function of the switch "Start/Stop monitoring". Can you explain its function? And shall Case Structure C only run one time after pressing this switch? Or shall it run every third loop-count?
Greets, Dave

Message Edited by daveTW on 06-23-2006 03:33 PM

Greets, Dave
Download All
0 Kudos
Message 10 of 14
(4,668 Views)