LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic registration for multiple events

Hello LabVIEWers!!

 

I am using a User Event with an Event structure to act as a "queue" for a Queue-Driven State Machine. I want to use it for the data acquisition portion of my application. The User Events would be commands sent to that QDSM from other parts of the application. I also want that QDSM to be activated by data acquistion events, specifically when a finite acquisition is completed. Thus, I am attempting to dynamically register for 2 different events (using the same node). This application conducts a series of user-configured (channels) and user-initiated finite acquisitions.

 

I completed the application and successfully ran it through integration testing on the real hardware. Everything looked good until I tried to run it on a computer without any analog input channels.

 

My application uses cDAQ exclusively. I notice that if I create an AI task without any channels configured (because none are available), and pass that to the dynamic registration function, it returns an error. My application uses the first available AI channel for registration at startup. The AI Config is typically changed during program execution by the user. When the user is ready to commit to a configuration {arm}, I create the new AI Task and dynamically register it. This latter part works fine.

 

The problem is, the dynamic registration node either dynamically registers for all events or none; it does not execute top to bottom until an error occurs, like a propery node. The consequence of an error in registering for the DAQ event is that it also does not register for the user events. This means the event structure controlling the DAQ QDSM cannot accept commands from other parts of the code. Net-net, if the system that I run this application does not have at least 1 suitable analog input channel, the dynamic registration fails at startup and I cannot shutdown the DAQ QDSM (so the program hangs on shutdown). Also, the program cannot recover if there was no DAQ channels available at program startup, even if channels are later added.

 

Is there another way to make this work, preferably still using User Event/Dynamic registration?

0 Kudos
Message 1 of 5
(321 Views)

To simulate you need a "real simulated " device in a "real simulated" chassis or the channels cannot be created without a real error.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(317 Views)

@LabVU_Dog wrote:

 

Is there another way to make this work, preferably still using User Event/Dynamic registration?


Yes - It would be easier to offer you a solution if you provided code, but it can be done and I will have to make to guesses from your small screenshot. I'll provide some screenshots since you like pictures. 🙂

 

Guess - From your screenshot you are registering for the Event outside of the event loop. You can also register for the event inside of the event loop.

 

In the screenshot below, I register for a User Event and a "blank" DAQmx Event. I recall having to bundle the events in a cluster to get things to work. That may have been a bug that has since been fixed, but there is no real harm in using a cluster.

 

The empty DAQmx event is just a placeholder for the "Real" Event registration.The empty DAQmx event is just a placeholder for the "Real" Event registration.

The next step is to scan to see if your instrument(DAQ) is available, if so, then register for the event. (Do this in your State Machine.) The image below shows the registration being done inside the loop that contains the Event Structure.

 

A subVI in the While loop which contains the Event Structure that registers the event.A subVI in the While loop which contains the Event Structure that registers the event.

 

To make this work you need to add a shift register and wire the dynamic event terminal like below. Then update the shift register as needed.

 

Snap139.png

Dynamic Event registration is now updated for the DAQmx EventDynamic Event registration is now updated for the DAQmx Event

 

 

Message 3 of 5
(280 Views)

I'm pretty sure this is exactly what I was looking for. I haven't had a chance to implement it, but I should over the next week or so.


Thanks for taking the time to demonstrate this!

0 Kudos
Message 4 of 5
(137 Views)

You can use separate registration nodes, then bundle the registrations:

dr.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 5
(126 Views)