Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Running a number of subVIs out of phase in simultaneous 24 hour simulation

Hi all!
 
Not sure if this is the adequate section to post this question but it seems to be such.
 
I am developing a tool that should perform a set of calculations a number of times (the number will be determined by the user, i.e. he chooses to execute it 4 times for example). The calculation set consists of a sequence within it and for more than one execution, all the calculation sets following the first one need to be executed at a certain time within that sequence of the preceding set. All this needs to be simulated in a 24-hr time.
 
It could be illustrated as follows:
 
The user chooses 5 times of executing the same sequence for some calculations:
 
 
Sequence Set 1:   ¦-------------------¦
                             0hours             16 hours
Sequence Set 2:                ¦--------------------¦
                                        8hrs                   24hrs
Sequence Set 3:                                        ¦-------------------¦
                                                               23hrs                1day 15 hrs
Sequence Set 4:                                              ¦--------------------¦
                                                                      1day 2 hrs          1 day 18 hrs
Sequence Set 5:                                                             ¦-------------------¦
                                                                                   1day 14hrs          2days
                                                                                                               ¦------------    ....
 
and then it would loop, starting with Set 1.
 
For now i need the exact same sequence, possibly varying some controls here and there.
 
 
 
Could anyone suggest which techniques, functions or methods I can use to achieve this with as much user control as possible at the same time maintaining the smooth flow of calculations with real time? I am developing this in vista, Labview 8.2, also can use 7.1 with Control & Simulation Plugin.
 
 
Thank you in advance for any suggestions and looking into this concept.
 
 
0 Kudos
Message 1 of 3
(3,062 Views)
Hello!

I've had a look at your post and read over the concept of what you're trying to achieve. I've created an example which I hope you will find useful.

The example takes timestamps (as many as you want; simply expand the array on the front panel) and runs a VI at the times you specify (which can be accurate to a second; you can improve the accuracy if necessary). Once the VI has begun running for that time, a boolean indicator turns on. In this case, the VI has no inputs and the ouput values are written to file, which I hope would be suitable for long-term calculation logs.

I hope you find that the code is clear and documented. If you don't understand what I've done somewhere, please let me know and I'll clear it up for you.

Some considerations and areas for possible expansion which you might find useful:
  • The calculations VI must be thread-safe. The same VI will be being run in multiple instances, so if that VI accesses a given resource it could be that the multiple instances of the VI try to write data to the same place at the same time. This can give unreliable results. In the example I have provided, each instance of the VI writes to a different file, so no resources are shared (the filenames are based on the timestamp of the end of the calculations). For more information on thread-safe programs as a concept, you could refer to http://en.wikipedia.org/wiki/Thread-safe.
  • The calculations VI is specified as being re-entrant. This means that LabVIEW can run multiple instances of the program, as mentioned above. To set a VI to run re-entrant, go File»VI Properties and select Execution; next set the "Re-entrant execution" radio control.
  • The calculations VI is run using VI server. Two things are important to bear in mind in this instance:
    • When opening the reference to the VI, a hex code of 0x08 (8 in decimal) must be supplied to the "options" terminal to specify that this VI will be run re-entrant, as discussed.
    • When closing the reference to the VI, it is important to note that explicitly closing it will end the VI prematurely. Instead, specify "Auto Dispose Ref" as TRUE on the "Run VI" invoke node. This will close the reference once the VI has finished running.
  • A quick and easy way to provide inputs to the calculations VI is to use an invoke node (like the "Run VI" node) to "set" or "get" front-panel values. When the VI is run, it will use the values you have set programmatically on the front panel.
I appreciate this example isn't going to be perfect for you straight away, but I hope it shows how you can approach your program and what issues you may encounter. If you have any other questions, please post back.

Regards,
Tom

Applications Engineering, NI UK
0 Kudos
Message 2 of 3
(3,036 Views)
Thank you very much indeed. The solution seems like something I could deal with. I thought it would be more cmplex with simulation tools involved. I did consider Run VI function. The bits and pieces of documentation still need my attention though as I need to switch my current operating soft to 8.2 so I can work only with this one.
 
I will get back to this post as soon as I try to launch my code and try to analyze the possibilities.
 
Thank you again, and you are more than welcome to keep an eye on this thread,
 
Regards,
MJ
0 Kudos
Message 3 of 3
(3,018 Views)