LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I perform Analog input acquisition and Detect digital change at the same time.

I can detect Digital In port changes using the code below. But while it is running I need to be able to continuously monitor analog inputs on my NI USB-6341. My Digital port inputs may not change at all as I am monitoring switches on a device during vibration testing. I have to be able to detect mechanical switch faults during vibration.

Also, I need to take continuous Analog Input measurements at the same time as I monitoring the Digital in Lines. The problem I am having is if there is not any changes occurring on the Digital In lines the while loop will just not run as "DAQmx Read" is waiting for a change to take place. So, I cannot figure out the best way to continuously acquire analog input measurements if the VI is stuck waiting on this While Loop to run. I have not included any analog input measurement code in the snippet because what I have tried never worked correctly. Help would be greatly appreciated if someone can point me in the right direction.

I have done plenty applications using analog acquisition measurements. I just can't seem to get something working correctly when combining it with "Digital Change Notification".

Thanks,

Bryan

 

 

DI_Change_Detect.png

0 Kudos
Message 1 of 3
(2,333 Views)

For the DAQmx part you will create another task, very similar to what you have done for the digital input, but you won't need to register for the event.

 

For reading continuously you have a couple options. You can change the event structure timeout to something >=0 and put your analog channel reading code there. So if you set it to 100ms you would read data every 100ms except when boolean event triggers. So your timing might look like:

100ms - Read Analog >> 200ms - Read Analog >> 238ms Boolean Event >> 338ms - Read Analog...

 

If that doesn't seem acceptable to you, you can create a separate while loop beneath the one you already have, and read the analog channels there.

Message 2 of 3
(2,325 Views)

Thanks, I will try your suggestions.

Bryan

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