LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure for Turnining ON/Off VI

Hello all,

 

Please take a look at the following VI and please make your suggestions:

I am using it to turn a particular signal ON/OFF when required without tuning the VI off, and thought about employing an Event Structure and learn about it more at the same time.

Only when the " Enqueue Element" button is clicked, the signal from the Generator Starts. Consequently, when the "Turn O/P OFF" button is clicked the Signal Generator stops, but the VI still runs, I don't want it to stop.....(in this case it does nothing). However, this sequence works only once. If you click on Enqueue Element button again - nothing happens.

I would like to turn it on and off again and again.....(or at least repeat above-mentioned sequence twice) at any time whithout terminating the VI. Is it possible? What would be the best way to implement such function?

 

Thanking everyone who spared their time reading and helping in advance......

0 Kudos
Message 1 of 19
(2,645 Views)

Hi!

If you press "Turn OP Off" the consumer loop goes to "Wait for event" case.

As a result of the True constant the consumer loop will exit (that is: no more commands will be consumed)

On the contrary the produced loop will keep running....

With a consumer dead and a producer still running it's not a surprise this vi works only once.

 

Regards,

Marco

 

0 Kudos
Message 2 of 19
(2,640 Views)

Hey Marko,

 

Thanks for your reply. If making it to work as simple as changing the True constant, I've tried both and both times unsuccessful. Please elaborate more on your comments.

 

 

0 Kudos
Message 3 of 19
(2,633 Views)

I think you should revise your consumer loop adding a case to stop the generation of the signal.

Then you shold add a case to restart the generation.

Upgrade the user interface and the producer loop consequently.

 

Example: create a "Signal Off" button, add an event case queuing a "Stop task" command, add a case in consumer loop in which you execute the "Stop task "DAQmx vi.

 

Regards,

Marco

0 Kudos
Message 4 of 19
(2,616 Views)

Hello,

 

I hope attached VI should be fine.

 

LV 2011

 

Regards,

Bijay

0 Kudos
Message 5 of 19
(2,606 Views)

Hi there,

 

Marco, thank you for your suggestions, I'll try to add a new cases and see if that works......

 

Bijay, thanks for the modification to my VI. However, it does not work properly..... After hitting the Stop O/P button, the generation stops, but never re-starts when clicking on Enqueue Element button. So, it's kind of back at the same problem as before....

 

Thanks for the try.

0 Kudos
Message 6 of 19
(2,580 Views)

LabView 2012 (64 bit), Windows 7, DAQ USB 6212......I should have mentioned that before, but don't think it makes any difference. 

0 Kudos
Message 7 of 19
(2,575 Views)

Have a look at the attached.

When dealing with QSM's, be extra carefull of the way you handle messages. Have a look at the thread below about QSM's. Should be plenty more reading material and examples that you can find around.

 

http://lavag.org/topic/16154-qsm-producerconsumer-template/#entry98307

 

Kas

0 Kudos
Message 8 of 19
(2,560 Views)

Hey Kas,

 

Thanking you for the link provided...... it's right on the subject.....

Appreciate your time and effort on making mods on the VI.

 

Best Regards,

 

eleorka

0 Kudos
Message 9 of 19
(2,556 Views)

Hi Kas,

 

I regret to say that I am still experiencing some problems here.  Your design VI works fine by itself.

I think the problem is in the way how the Waveform Generator is coded. After including it in your design the stop button doesn't stop the signal generation.

You have to hit it twice for it to react. After that the re-generation doesn't work as before. What is the problem here?

I left the incrementing part of your design just to use the difference in loop speed variation.

0 Kudos
Message 10 of 19
(2,542 Views)