07-24-2012 03:33 PM
I'm a newbie when it comes to programming in labview so please go easy on me.
I'm trying to put a program together that will start a timer when the voltage on channel 0 is greater than 10VDC and then record the elapsed time when voltage on channel 1 is greater than 10VDC or when the user pushes the stop button and then record elapsed time one last time when the voltage on channel 2 is greater than 10VDC or the user pushes the stop button. Attached is what I've put together by way of borrowed code from examples found online and locally. Eventually, this will be an executable.
Thanks for your help.
07-24-2012 03:52 PM
I forgot to mention that I'm also trying to output the recorded elapsed times to an excel spreadsheet and I do not have the report generation toolkit.
07-25-2012 09:35 AM
Just realized that I didn't give any specifics regarding the hardware being used. My system consists of the following:
cDAQ9178
NI9221 x2
NI9481 x3
NI9265 x2
07-26-2012 05:35 AM
Hi
could you post a lower version vi? I am using LV 2010. Could not open the file.
07-26-2012 09:03 AM
here's the file save in v10 format.
07-26-2012 09:15 AM
Hello JPROC,
If I understand, you would have an idle state in which you are monitoring CH0, if the voltage is greater than 10 V, you need to start a timer. Inside of this case, you will be monitoring if the user pushes the stop button or the voltage is greater than 10 V both in CH1 or CH2. If this happens you will pass to a new state in which you are measuring the elapsed time and stop the program.
If this is true, I imaging a state machine architecture with 3 states: Idle, Start Timer and Elapsed Time. You can have a logical comparison Greater or Equal to in the channels and an Or comparison to check if any of them is true. This true/false value would be wired to a case structure that has in the true case Elapsed time state and in the false state continue in the same state.
Best Regards,
07-26-2012 10:01 AM
A little more the the purpose of this program. When the start button is pressed the following events will happen:
1. channel 3 on a relay module will close which will inturn activate a solenoid.
2. The solenoid will initiate the discharge of a nitrogen cylinder.
3. There is a N.O. pressure switch that will close once the pressure from the cylinder makes it to the discharge manifold. When that pressure switch is closed a voltage >10VDC should detected on channel 0 of Mod0 which signifies that the solenoid did infact trip and the cylinder is infact discharging and that is when I want the timer to start.
On the "10 Minute" case structure I want to stop the timer when the user pushes the stop button. On the "30 Minute" case structure #3 above will be repeated two more times with the only difference being the pressure switch that is being activated as the system has 3.
I thought about using a flat sequence but just couldn't wrap my head around how to start/stop a timer(s) using the rising edge of an analog signal.
Also, I made a couple changes to remove bits and pieces of code that aren't needed at this point.
07-26-2012
04:16 PM
- last edited on
05-12-2025
04:33 PM
by
Content Cleaner
Hello JPROC,
Thanks for the information. I still believe that the State Machine Architecture can fit your application. I'm linking some information on State Machines.
Using a State Machine (Event Driven) Structure
Application Design Patterns: State Machines
Best Regards,
07-27-2012 09:27 AM
Thanks, I appreciate the links but I still can't wrap my head around how to use a state machine to handle this.
I don't know how to start or record elapsed time on the rising edge of an analog signal.
07-30-2012 11:02 AM
Hello JPROC,
I was recommending a state machine because you can determine which case will execute depending on the prior cases. For example, if I understand correctly (I'm not very sure if someone states are supposed to execute simultaneously or not):
State 1: configuration, start button, if true, go to ‘’State 2’’, otherwise stay in ‘’State 1’’
State 2: Channel 3 closes, activates solenoid, starts discharge of the cylinder, go to ‘’State 3’’
State 3: cylinder discharging, when the pressure switch is closed, CH0 > 10 V, if true go to ‘’State 4’’, otherwise stay in ‘’State 3’’
State 4: Time starts, check for two cases: 10 min or 30 min (could be a case structure with a boolean control). If true, go to ‘’10 min’’, otherwise, go to ‘’30 min’’
State 10 min: if the user presses stop, go to ‘’Stop’’ case, otherwise stay in state ‘’10 min’’.
State 30 min: go to state ‘’10 min’’, check if time elapsed, if true, go to ‘’Change switch’’
Change switch: change switch, go to ‘’10 min’’ case
Stop case: stop the VI
I was thinking in a state machine structured in this way. I imagine you’re reading a 2D array for your channels. You could do a logic comparison Greater or Equal to? for CH0, if true, goes to ‘’State 4’’. In here, you could be monitoring the voltage in CH1 and CH2, if they are greater than 10 V, sends a true and passes to the next state and so on.
Best Regards,