LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to have more than one event specifier in the event case with AND operation?

Hi,

 

I am trying to add more than one event specifiers in a event case with the event of Value Change. But I see that when there is a value change in one of the event specifiers the case is activated. But I need to have both conditions true, only then my execution structure should be activated. What should I do in this case?

 

Should I add a nested event structure or any other ideas?

 

Any suggestions?

 

 

Thanks!

0 Kudos
Message 1 of 9
(4,118 Views)

Events are handled one at a time by definition, so they can't be ANDed. If there is more than one event at the same time, they are placed in a queue and handled sequentially.

 

You didn't say what you actually want to do, but if you want one event to depend on the other, my suggestion would be to raise a flag when event A happens and to look at the value of that flag when event B happens. This can simply be a value in a shift register. For example, if you want to detect mouse movement when the mouse button is pressed, you can use Mouse Down/Up to set the flag and then check the flag in the Mouse Move event.

 

Nested event structures are a terrible idea because of the way LV registers and handles events and how the structures interact with each other. It is possible in principle to make them work if you know exactly what you're doing, but I never had a case that needed this.


___________________
Try to take over the world!
0 Kudos
Message 2 of 9
(4,097 Views)

ok, to be more specific, there is a syringe pump which is activated when there is a change in volume and flow rate. It should either withdraw or dispense liquid only after the change in both parameters, volume and /or flow.

 

 

0 Kudos
Message 3 of 9
(4,081 Views)

Is it AND or is it OR you want?

0 Kudos
Message 4 of 9
(4,055 Views)

having both AND/OR is my requirement

0 Kudos
Message 5 of 9
(4,046 Views)

If you want to perform an action only when both values were changed, then keep two boolean flags (this can be a 1D boolean array). When one of them changes, you set the relevant boolean to T. When both booleans are T, you do your action and set both booleans to F.

 

If this still doesn't help you, you will need to include more details and actual code for what you want.


___________________
Try to take over the world!
0 Kudos
Message 6 of 9
(4,029 Views)

Hi,

 

Am not able to catch your idea. I attached my vi, in which I have only 2 parameters for now. But going forward I need to include more than 10 of those! 

 

I need to activate my pump 1 or 2 based on choosing parameter and then I need to do check for latest volume value inside the executing case structure. With this I need to check Flow, if >0 then Aspirate, else dispense.

 

kindly find my vi attached!

 

Thanks

0 Kudos
Message 7 of 9
(4,011 Views)

I do not understand what you want to do.  Here is my (partial) understanding, with questions:

  • You have multiple pumps, but know, in advance, how many.  For now, assume N pumps.
  • Each pump has an associated Volume and Flow.  Because there are N pumps, we can consider that we have an array of N Volumes and N Flows.
  • We can set the Volume of each pump independently.  This could be implemented as a Volume Control, an array of N Doubles.
  • We can set the Flow of each pump independently.  A Positive flow means "Pump out", a Negative flow means "Aspirate", a Zero flow means "Do not Pump".

What is not clear is the timing of the pumping action.  One possibility would be the following:

  1. "Flow" not only means "Desired Flow" but also "Actual Flow".
  2. Flow starts at 0 (meaning "Pump is off").
  3. Setting Flow to any non-zero value starts the Pump in either "Output" mode (Flow > 0) or "Aspirate" mode (Flow < 0).
  4. Pump stays on until volume has been dispensed.  If Flow is in units of "Volume/second", then Pump runs for Volume * Abs(Flow) seconds.
  5. When Volume has been dispensed, Flow is reset to 0.
  6. Changing Volume while Flow is in progress has no effect on this pump action.
  7. Changing Volume while Pump is idle does not start Pump -- only changing Flow starts Pump.

 

Is this what you want to do?  If not, please clarify further.

 

Bob Schor

 

0 Kudos
Message 8 of 9
(3,967 Views)

Like Bob said, you definitely need to define better how you want the system to behave, because maybe it's clear to you, but it certainly isn't clear to me. I would also suggest you go through some tutorials and exercises, as you will need that.

 

Some comments on your code:

 

  1. Why do you have the array? If you only need to select the item you're currently operating on, you need a single item.
  2. Even if you need the array, why are you converting it to a cluster? There are functions for manipulating arrays.
  3. If you are going to get elements from an array (seems reasonable, since you say you want N copies of the same thing), I would suggest a ring instead of a combo box, because you can use that to index the array.
  4. For the same reasons I mentioned before, you should not have two event structures in the same loop. You should not have an event structure inside a case structure. I didn't run your code, but I'll bet the VI hangs after you change a value, because the second event structure locks the FP until it can execute its event. There's a good presentation on events by Jack Dunaway and there's video of it here - https://lavag.org/topic/16091-ni-week-2012-videos (follow the FTP login instructions and look at the NIWeek 2013 presentations).

 

Again, go through the tutorials and examples. Look at different architectures. You're only dealing with the UI here, but if you have actual pumps, you will probably also need to communicate to them, which will make the code more complicated.


___________________
Try to take over the world!
0 Kudos
Message 9 of 9
(3,919 Views)