07-26-2012 09:26 AM
Hello all,
I'm writing my first Labview program. I used an architecture I found on the forums here, and it has been very helpful in getting me started. This architecture uses two while loops, one containing an event structure and one containing a case structure. (This is a queued state machine architecture, I believe).
Part way through the programming, we decided we needed a sensor to make sure the part was in the test fixture during the test. If the part is removed during the test, we'd like to safely stop the test. So basically, I need to monitor a digital input (on an NI-USB-6525 module) and enter the "Stop" case if the digital input turns off. I would also like to make sure this digital input is on before entering the "Start" case. I don't care if the input changes state when the test is not running, nor do I care about its state during the "Exit" case.
I'm really not sure how to add this functionality to my "stop" case. I don't even know if it's possible. I've been researching DAQmx events, but I haven't found an example or answer that aligns with my particular problem.
I've attached my code. It's incomplete right now - I still have a large number of steps to add. I wanted to get this issue figured out before I programmed any more steps. A preview of the code showing the basic architecture is shown in the picture below.
Does anyone have any ideas or suggestions for me, or questions if my problem is unclear? Also, if you see anything else in my code that will be problematic, please let me know.
Thanks in advance!
07-26-2012 09:30 AM
I should also add that I looked into event dynamic registration, but it seemed incompatible with my issue. I don't want my top loop to run only when an event triggers it - I want it to run all the time so that it can immediately respond to button presses. Also, most of the triggering I found was based on value change. I care about the actual value, not just that it changed.
I don't want to do anything that will bog the code down too much since it is important that the system respond immediately to inputs, especially to the stop or exit button presses.
I'm sure I am missing something very basic here. I'm used to ladder logic, where everything is simple and straightforward. ![]()
07-26-2012 09:35 AM - edited 07-26-2012 09:37 AM
i would use"generate user event" in your case statement that you monitor that digital input. send it back to the "event structure" dynamically to your stop case to enqueue your shutdown process![]()
07-26-2012 10:02 AM
07-26-2012 10:04 AM
apok, see this post.
07-26-2012 10:06 AM
thnxs!
07-26-2012 10:37 AM
My understanding of dynamic even registration is that if I use it in as an input to my event structure, the event structure will only activate if the event is true. So in other words, the event structure wouldn't look for the various buttons to be pressed on the UI unless the sensor was on. Is this correct? If so, it won't work for me.
It just seems like there HAS to be a simple way to do this. Digital I/O is such a common trigger....
07-26-2012 10:43 AM
your generating an event by your digital input and sending it to the whatever event structure case you want to happen, in this case you want a shutdown from your stop case. anything in your event structure will still respond to the UI front panel regardless...
07-26-2012 01:33 PM
I do appreciate your help, apok, and I'm not trying to be argumentative... but I'm still looking for something simple. Can't I just generate an event in an event structure if an input goes from low to high?
07-26-2012 07:21 PM
Put a generate user event in the true case of a case structure. To make sure you only send one event you might want to use a boolean shift register for "event already sent". If you really don't want to use user events you can trigger a value change on an existing event by writing to the Value (Signaling) property. Keep in mind that is not really a value change event meaning that if you write the same value you will still generate an event.