LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Program for stepwise dosing - How do i add a start stop funktion?

Hey guys

 

I'm a all new labveiw user, startet last friday, so if there is a simple sulution to my problem bear with me:P

Anyways I have been working on a program, for stepwise dosing of liquid, and i am all done now. Now i would like to implement it in an old layout of the program where a range of other functions has to run simultaniously. And thus i must be able to start and stop the program while the rest of the old program keeps running. Now i have no idea to do this, i have tryed some of the stuff that came into mind, like bolean on/off, but in didn't seem to work out. So if you by chance have any idea how i might achive this, i would be very gratefull:)

 

I'm useing labveiw 2010.

 

The program is full of random indicators, that i have used to design the program. They will ofcause be cleaned up in the finished version! 

0 Kudos
Message 1 of 5
(2,746 Views)

Bump 😄

0 Kudos
Message 2 of 5
(2,733 Views)

Generally to run two parts of the program in parallel it is necessary that they do not have any data dependencies. LabVIEW is a dataflow language. A data dependency occurs when the output of one node is used as in input to another node.  The second node "depends" on the data from the first one.

 

It is relatively easy to make two parts of the program run in parallel.  The case structures in your VI could in principle run in parallel.  The trick how to make things start and stop at particular times.  Since your VI runs until it stops automatically, stopping is only an issue if none of the Total time (s) elements is exactly zero.  It is not a good practice to use =0 comparisons on non-integer numeric data types because of way numbers are represented in binary often leads to values which may be very close to zero (~1e-16) but the =0 comparison will return false.  Starting can be done by VI server methods.  That can take some learning curve for a LV beginner.  Another approach is to have the subVI run all the time, but stay in an idle state until a command has been received to start. Then it runs its calculation and returns to the idle state to await the next command.  To shut it down when the program is done requires another command (halt or stop).  The commands can be sent via a queue or notifier.  Similarly data inputs and outputs can be transferred via queues.

 

Some general comments about your VI: Use integer datatypes for indexes. You have at least 5 Get Date/Time Seconds fucntions inside the loop.  It is likey that all are ineteded to report essentially the same time.  Use just one and wire its output where needed. The two timing case structures can be combined into one.  One is always false when the other is true. The code generating Time of one dose (s) and Time actual dose does not make much sense.  Why initialize an array and then index the value back out.  Just use the value that went to the initialize input.  Add some comments to remind yourself and anyone else looking at the code what things are supposed to do and why you did it that way.  You will thank yourself for that 6 months from now.

 

Lynn

0 Kudos
Message 3 of 5
(2,715 Views)

Hey Lynn

 

Thanks alot for your reply. You have given much fruit for thougth. I will upload a sheme that is more easy to follow, on the morrow. The reason why i have so many different times, is that i need 2 different countdowns that needs to act differently when time is up. It was the only way i saw to make this work.

0 Kudos
Message 4 of 5
(2,710 Views)

If you want to learn to do it right, spend some time looking at the state machine architecture. I mentioned the Idle, Calculate, and Halt states in my previous posts.  The main program likely will also be a state machine. There are examples and Design Patterns which ship with LV to get you started as well as numerous posts on this Forum.

 

Lynn

0 Kudos
Message 5 of 5
(2,702 Views)