LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Relay Control via Time & Total Flow

Solved!
Go to solution

Hello everyone,

 

     I am fairly new to Labview, and have been working on a large program as of lately that uses a NI 9481 SPST Relay Module with my cDAQ-9178 to open and close 3 different solenoids. The program needs to open them at a specified time, and leave them open until a set amount of flow has passed through them. I have already finished the programming to record the total flow through the valves, and after many hours spent searching the forums I have found a way and modified some code that turns on the relays based on the amount of elapsed time, however it turns the relays on and leaves them on until the "Delay Time" is met, then proceeds on to the next cycle. I need to modify this further so that it turns on when my "Cycle Start Time" is reached, turns off upon reaching the set amount of flow for that cycle, and then continues to wait until the next "Cycle Start Time" occurs.

 

     I imagined one way to do this would be; eliminating where the clock starts a new cycle time each run, and just have it constantly comparing the "Initial Start (run)"  time to the "Sequence Start" time (when I push Start Sequence and actually begin opening the relays). Then change the "Delay Time" to "Cycle Start Time" and the (>=) function to an (=) function. So now it starts when the elapsed time is equal to the Cycle Start Time. Albeit, this brings up issues, because currently as soon as the cycle starts the relay control starts. So I would need to make my comparison outside of the 'Cycle Case' or move the relay control inside the 'True/False' case. However, then I run into the issue of how to get the program to change cases once it has seen to stop the relay.

 

     As you can see, I have about a million different things going through my head that I have toyed with. Any advice or help to get me on the right track, or examples you know of  would be great! My code is attached below, and I will post a picture after this post of how I am taking care of recording the total flow. Thank You for your time and assistance!

0 Kudos
Message 1 of 6
(3,828 Views)

Here is an image of my code for controlling total flow.

0 Kudos
Message 2 of 6
(3,819 Views)

Update:  I believe one of the easiest ways for me to cycle the relays on and off is to create new cases: Case Delays. This way the actual cases turn on the relays, and the delays turn off the relays then wait until a set amount of time and shift to the next case when a draw should start.

 

     I attempted controlling the "On Relay" cases via my flow case. I am determining my Draw Flow by recognizing that if a solenoid is open then there will be flow greater than 0.2 and I should start my case to begin recording the flow data. I attempted to use this same logic to control whether my relay should be on. I then took my Draw volume being recorded and compared it to my cut-off value. My thought was, when the volume reached this number it would send a FALSE to my case selector and continue on to the next Cycle.

 

     What actually happens is, I start the sequence and Case 1 only runs for about 5 seconds or so then shuts off and moves on to 'Case 2 Delay'. Then Case 3 begins later, but not exactly when Case 2 Delay tells it to. I believe this is because it is not shutting off after Sequence Start Time has reached 30s, but 30s after Case 1 has finished. Last Case 2 begins, although it shuts off rapidly and continues on to Case 3 Delay.

 

     I know I have data flow issues somewhere, and any help would be greatly appreciated. Pictures of Case 1, Case 2 Delay, and Case 2 below. Thanks!

Download All
0 Kudos
Message 3 of 6
(3,799 Views)
Solution
Accepted by topic author M_Blaylock33

Hi M_Blaylock,

 

You mentioned that you are relatively new to LabVIEW. Are you familiar with some of the debugging tools?

 

http://www.ni.com/getting-started/labview-basics/debug

 

Turning on Highlight execution should allow you to see the data flow through your block diagram. Also, probing the wire right before the case structure input should let you see what data is actually getting to that case selector. If you're getting unexpected data, you can probe the steps before that to see where that unexpected data is coming from.

 

Hope this helps and good luck with your code!

https://www.linkedin.com/in/trentweaver
0 Kudos
Message 4 of 6
(3,739 Views)

WireWeaver,

 

    I actually attempted using the highlight execution feature and setting breakpoints earlier today. For some reason when the data reaches my Timeout structure it acts like it can't handle it and throws me back to the front panel. So I never get a chance to see how the data flows because it acts as if  it's getting stuck in my event structure before I even start my relay control sequence. The breakpoints kept stopping on functions that weren't set as breakpoints and never gave me enough time to start my relay control case. I will definitely follow that link and read more into it though! It is difficult to step through my program, because when it pauses it stops flow to my solenoid, therein stopping my case. 

 

    I think one issue might be that I am refrencing my "Draw Total"  to control whether or not my case sends a T/F, but that info is located outside of my event structure. This might mean that once I starrt my cycle it doesn't know to continue, because it is only processing data within my structure? I will do more research on the various types of debugging techniques. 

 

Thanks!

0 Kudos
Message 5 of 6
(3,728 Views)

Problem Solved. Simply using the probe feature to evaluate what my data was at each node allowed me to decipher where my errors were. Thanks!

0 Kudos
Message 6 of 6
(3,656 Views)