LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat an event in an event structure

Hello,

 

I have an event structure for the user to create a signal, which is composed of different types of signals (ramp, step ramp, multi tone, sine) arranged one after the other. I need to modify this so that two signals can be created, because I have two valves on a pipe rig that I want to control via a current output from a DAQ. 

 

I have tried using a for loop around the while loop of the event structure with two iterations and have also tried to create a new case in the event structure where the user first selects one of the two valves to create a signal for but I can't get either method to work. Also, these two signals must be stored and then output at the same time from a DAQ to the valves, therefore I don't think I can use a producer consumer queue because that follows the rule 'first in first out'.

 

I am relatively new to LabVIEW but have looked at the inbuilt help examples and have read other posts but can't figure out how to code this up.

 

Thanks in advance for any help.

 

I have attached my code so far, the sub VIs haven't been included but that's OK because they're not needed, it's currently set-up with a case for first selecting the valve.

 

Laurence

 

0 Kudos
Message 1 of 11
(3,431 Views)

Add a "Send" button and event in which case you gather up the information and send it out.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 11
(3,424 Views)

I think Yamaeda has the right idea.  I also think that Producer/Consumer may be an appropriate architecture for what you are trying to do.

 

1. Signal Type is used in more than one place.  I would place the control terminal in the Signal Type: Value Change case and pass the value to other locations via a shift register.

2. I would probably put the signal creation in the Consumer loop.  The Producer would be primarily to handle user inputs and generate commands and parameters (such as Signal Type) to be sent to the Consumer.

3. As Yamaeda suggested add a "Send" button.  When pressed, it would command that the accumulated signal be sent to the valves.

 

Lynn

0 Kudos
Message 3 of 11
(3,406 Views)

Hi Lynn,

 

Thanks for the feedback.

 

Your right about the shift register it was missing I must have accidently deleted it before posting.  When you say control terminal do you mean the enum for the valve type and putting that in the case for Signal Type: Value Change. I'm unsure how to code this in the case structure.

Also I have a send button in a separate case called 'add final signal to DAQ' but this needs to be modified to send the two signals and not just the one, which I'm unsure how to do.

 

Would it be possible to give me more details.

 

Thanks,

Laurence 

 

 

0 Kudos
Message 4 of 11
(3,393 Views)

I think I see your problem.  You have the output tunnels from the event case set to "Use Default if Unwired." Thus the only value coming from the Add Value Change event is the last one.  Turn off that setting on all except the case which stops the loop.  You also need to wire the shift registers through all cases.

 

See the images below for the changes I suggested.

 

Lynn

 

Add Value Change.png

 

Signal Value Change.png

0 Kudos
Message 5 of 11
(3,386 Views)

Hi Lynn,

I appreciate your help but I'm not sure what you are trying to do there. My file works to create one signal, but I need to create two: one for each valve. I have added the valve type outside the while loop similar to what you were doing but that doesn't work. Please see the new file, the corrections from the first have been made.

 

Laurence

0 Kudos
Message 6 of 11
(3,380 Views)

I misunderstood.  I thought you wanted to send two signals to one valve.

 

Use your signal creation code (you only need one copy) and then select which valve receives the signal. Keep that signal in a shift register while creating the second signal which will have its own shift register.  When you are done send both signals to the valves.

 

Lynn

0 Kudos
Message 7 of 11
(3,375 Views)

Would it be possible to attach an example code because I can not code that myself from your explanation?

Much appreciated,

 

Laurence

 

0 Kudos
Message 8 of 11
(3,367 Views)

I am going to be busy most of the day and will not have time to put together an example today.  Try to get one channel working in a Producer/Consumer architecture and post that.  It should then be relatively easy to modify for the second channel.

 

Lynn

0 Kudos
Message 9 of 11
(3,346 Views)

Hi Lynn,

I've been trying to use the consumer producer example and adding my code to that. I used a flush queue VI so that both signals would be sent simultaneously to the DAQ. The enqueue button should send the constructed signal to the consumer loop and the add to DAQ button should be pressed after adding the second (final) signal but I can't get these to work. Really need your help when you are free.

 

Thanks again,

 

Laurence

0 Kudos
Message 10 of 11
(3,337 Views)