LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute a case structure at timed intervals

Hello LabView Experts,

 

I have an existing case structure in a sub VI that executes when a measurement falls below a value that I define in a control setting.

 

The sub VI (Check Conductivity (Pump Relay)2.vi) turns on a relay (using DAQmx) when data from an instrument falls below the set point.  This is determined with a comparator.

 

As it stands, the relay kicks on every few minutes, but I want to change this to kick on every 60 minutes until the instrument reads above the set point.

 

For a test, I tried putting the sub VI in a while loop that is surrounded by a case struture which is true every 20 seconds.  I was hoping that the relay would kick on and stay on until the condition is met, but instead it turned on then turned off after only 1 second.

 

My question is how do I active the sub VI every 60 minutes, but not turn off until the condition is met by the comparator?

 

I'm attaching my main VI (DS flux 3-cell.vi) and my sub VI (Check Conductivity (Pump Relay)2.vi) and a screenshot of the main VI.

0 Kudos
Message 1 of 8
(6,804 Views)

And here is a screenshot of my sub VI

0 Kudos
Message 2 of 8
(6,801 Views)

I'm going to assume that all of the VIs in your project (which might also "live" in a LabVIEW Project, a .lvproj file) are contained in a folder.  Compress the folder and attach the resulting .zip file -- that way, we'll have access to all the code and won't have to refuse to look at pictures of code (which are pretty useless to us if we're trying to help you fix something).

 

Bob Schor

0 Kudos
Message 3 of 8
(6,762 Views)

Hi,

 

Have you tried using a state machine architecture? You could have a structure like the one following (rudimentary pseudo-code):

 

case 1:

check if the 1 hour timer has elapsed

if yes, proceed to case 2

else, stay in case 1

case 2:

call your VI that does the tasks you need

if the task is over, proceed to case 1

else, stay in case 2

 

A more elegant implementation could use a queued state machine.

 

Please see further documentation:

Elapsed time express VI

State machine

 

Best regards,

Rares C.

0 Kudos
Message 4 of 8
(6,749 Views)

Hi Bob,

 

Here's the compressed folder of all the LabView VIs.  The main VI is called "DS flux 3-cell.vi" and the sub-VI I am referring to here is called "Check Conductivity (Pump Relay)2.vi".

0 Kudos
Message 5 of 8
(6,734 Views)

Hi Raresc,

 

I wil try that today.  

 

Alternatively, how would you suggest I execute the sub-VI for a set duration.  For example, what kind of loop would I need to run the sub-VI for 5 minutes at the end of every hour?

 

I posted a zip file of my LabView folder in this thread if that helps.

0 Kudos
Message 6 of 8
(6,732 Views)

Timed event structures are also really good for making things happen at fixed intervals. Check into some of the documentation for those- they're really useful!

 

Hope that helps Smiley Happy

0 Kudos
Message 7 of 8
(6,726 Views)

cmorrow8,

 

Since the whole process in synchronized,

1. I would suggest you to use a single timer/counter to all the necessary sync actions (ON/OFF) 

2. Keep the While Loop delay to Minimum say 250 msec and use a Shift register U64 Integer as a counter (4 Counts equals a second if 250 msec is used for while loop delay)

3. Pass the counter value to the Check Conductivity (Pump Relay)2.vi and use a case structure to do the ON and OFF logic over the comparator logic

 

 

As raresc suggested, always use some standard requirement specific architectures to handle these kinda situations.

 

-John

-John Theodore
Certified LabVIEW Architect, Certified TestStand Architect
0 Kudos
Message 8 of 8
(6,689 Views)