while-looplabviewshift-register

Run a loop in LabVIEW for a set amount of time, periodically


I'm using LabVIEW to operate and record data from a wastewater reactor. I currently have a program set up to monitor pH continuously, and then use pH data to turn on either an acid or base pump.

My problem is that I want to monitor and record pH data 24/7, but I only want my acid/base pumps to be activated for one hour, every three hours. Ideally, I'd like to tie these operating times to the computer's clock.

For example, from 10:05 am to 11:05 am, I want my acid and base pumps to use data from the pH sensor to either turn on or remain off depending on the pH measured. My goal pH is 7.0 +/- 0.3. For example, if the pH measured was 6.5, the base pump would turn on until a pH of 6.7 is reached. If the pH measured was 7.5, the acid pump would turn on until a pH of 7.3 was reached. If the pH was 7, both pumps would remain off. So far, my code does this, but pumps are turned on and off constantly.

At 11:05, both pumps would be "deactivated" and turn off, though pH measurement should continue. Then, 3 hours after the initial pump start time (3 hours after 10:05 am = 1:05 pm, or 2 hrs after the 11:05 am stop time) this cycle would start again, running again for one hour. I want this cycle to continue over and over (i.e. pumps on in response to pH measurements for 1 hr, every 3 hours).

Is it possible to do this in LabView? (I'm extremely new to LabVIEW also). Thanks!

code snippet


Solution

  • Yes, it's certainly possible to do this.

    The simplest way to achieve what you describe would be to add extra logic to the pump control code inside your loop. Each loop iteration, get the current time (e.g. with Get Date/Time in Seconds) and calculate whether the pumps should be enabled or not (you might find Quotient and Remainder useful). Then you could use an And function to enable each pump if both the pH calculation and the enabled-time calculation produce a True output.

    I'd suggest using functions from the Programming palette for your greater than, less than, And, etc operations as they take less diagram space and are easier to understand than the Express functions in my opinion.

    A more sophisticated and scalable approach might be to separate the pH measurement and the pump control into two different loops and use some mechanism to transfer the latest pH value into the pump control loop (a notifier, local variable, functional global or channel wire would all be options here). A state machine would then be a good pattern for the pump control logic.