LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx in Event structure / avoid multiple events

Hi all 🙂

I've started creating program for acquisition and analysis of data . I don't have much experience in LabVIEW, but it's important to me to start creating this application in good way. Can you give me some advice about things below?

I prepared template with Event structure, based on some article .

First question is how exactly place DAQmx blocks in it. Now they are all on one state of case structure "test", but I'm not sure that's correct because most of the example on NI side have initialization (like sample rate, number of saple) outside of the loop? It's important to make it possible to change parameter between measurements.

Second. How to avoid multiple events. In example: button TEST is pressed, measurement is taken. This measurement take a long time. I've started bored, and some other buttons (maybe TEST ) accidentally were pressed. When measurement is completed  it would be good idea to destroy this events associated with accidently pressed buttons. It is possible to do it? What's the best way when there's a lot of buttons(when analysis part of program will be added)?




Best Regards

------------------------------------
PS. sorry about my english

 

 

Download All
0 Kudos
Message 1 of 3
(2,449 Views)

Dear Finch!

 

Welcome to NI Forums!

 

My first advice regarding your code would be to use shift registers instead of Queues as your state storage, since (as you've said) there is no reason to store multiple events that have happened. The state machine design pattern, which I strongly recommend in this scenario is built into LabVIEW, you can use it as a template if you go to the New.. menu.

 

Please check out these materials for further discussion about state machines.

 

You are correct in that most of the DAQmx VIs can be placed outside of the loop, only DAQmx Read (the function we actually use more then once) must be placed inside the loop, the rest can stay out. If you want to modify some parameters (like Timing) mid-execution, you only have to stop the task, set them, then start it again.

modify1.jpg

This can be easily done in a different state, which can execute only when some parameters have changed.

 

Also, if you want your user to be unable to interact with certain controls while the test is being taken, you can programmatically disable them with a Property Node

 

Please get back to me if you have any other questions.

 

Best regards:

 

Andrew Valko

NI Hungary

Andrew Valko
National Instruments Hungary
Message 2 of 3
(2,425 Views)

ValkoA,

 

Thanks for your reply! and for the welcome:)
I took your advice and I've started working with state machine instead of Events. Indeed it's seems to be better choice to use this design pattern. Probably I'll have some other questions in future, during next parts of project :). At this moment I'll try working with material that you suggested.

 

Regards,

 

finch

 

 

0 Kudos
Message 3 of 3
(2,405 Views)