DQMH Consortium Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Incorporating NI-DAQmx change detection (events) in DQMH module

I am very new to Delacor framework but I already like it a lot. 

I am working on the module that is responsible for rising/falling edge detection on a couple of digital lines (with NI-6509).

I used this example to get corresponding User Events

https://forums.ni.com/t5/Example-Programs/DAQmx-Change-Detection-Event-Registration/ta-p/3502871

 

I thought that the NI-DAQmx initialization part can be done in "Start Acquiring" frame (of Acquisition MHL from DQHM CML example) and detection itself can be in the "Helper" Loop. But it is not clear to me what would be the proper way of either passing refnum/registering for hardware events from MHL to Helper.

Any suggestions?

 

It seems like this question has not been answered here

https://forums.ni.com/t5/Delacor-Toolkits-Discussions/Using-NI-DAQmx-Events-with-DQMH/td-p/3798769

0 Kudos
Message 1 of 16
(4,634 Views)

My suggestion would be to let the helper loop deal with theDAQmx task.

 

I would create a request "start helper loop" for which the argument contains all the parameters required to create/open the DAQmx task.

 

This way you can start the helper loop directly from the Tester with whatever params you want.

 

What are you planning to do when an edge is detected?


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 2 of 16
(4,561 Views)

Thanks a lot for your response. I believe I was doing what you suggested. I was not sure how one can register Event Structure for both User and Signal Events.

Since it is not a typical Helper Loop (with measurements performed in timed out case) I followed Joerg Hampel recipe here (UPDATE 2018-03-02)

https://www.hampel-soft.com/blog/dqmh-actors-self-messaging-or-helper-loops/

I think it can fit the category of the second kind of helper loop he describes. I attached a snippet of what I have at the moment. The "board init" VI prepares DAQmx as you said  and Helper Loop initiates detection. I still need to add Stop Module and Stop Edge Detection requests etc and test the whole thing.

Once edge is detected on one line it has to be broadcasted so that the trigger rate of other modules has to change (and the opposite on the other line). It also need to check timing between two edges and broadcast alarms if timing is wrong. Finally it has to update EPICS PV with some time delay which I plan to do in yet another helper loop.

Message 3 of 16
(4,547 Views)

Hi TiTou,

 

The snippet I showed last time did not actually work. The DAQmx constant I used as a placeholder to register event on an invalid object as suggested here http://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/create_event_placeholder/ generates DAQmx error 200088 "Task specified is invalid or does not exist". I could not find a work around it without destroying the logic of the Helper Loop.

Am I supposed to create "change detection loop" INSIDE the "Helper Loop"?

I am not sure how I would pass Stop Module/Detection and Settings requests to it since it will never be "Done" (as opposed to the Helper Calibration state machine in the CML example).

 

Thanks a lot for reading this

0 Kudos
Message 4 of 16
(4,514 Views)

I came up with two "solutions" that seem to "work" for those who run into the same issue. But I still hope to get a feedback from Delacor gurus on how to properly deal with it.

 

I realize that the main issue is more related to DAQmx functionality rather than to Delacor:

1a) from several discussions I found that "... the event needs to be registered with a valid DAQmx task name before you can unregister it..."

1b) one cannot unregister events by feeding Not a Refnum constant to Register for Events function on a running DAQmx task

 

My solutions were:

2a) create valid DAQmx task outside EH, MH, Helper loops and use Stop Task to unregister events (attached)

2b) have Helper Loop in MHL and Stop and Clear Task every time to unregister events (attached)

 

I think both of them are bad (especially 2b is no no) but I do not know what else can be done here

thanks for any input

 

 

Download All
0 Kudos
Message 5 of 16
(4,470 Views)

Indeed, 2b is clearly a no no.

I've never implemented a helper loop that deals with DAQmx event detection so I'm not sure what the correct way to do it is - I'm sorry I don't have time to dig into this right now - but I'm pretty sure a variation around 2a is possible to implement.

 

One thing you can try is to pass a string constant instead of DAQmx task to create register the event before entering the helper loop, when you start the helper loop, create an actual task with the same name you previously passed in.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 16
(4,457 Views)

@indium97 wrote:

Hi TiTou,

 

The snippet I showed last time did not actually work. The DAQmx constant I used as a placeholder to register event on an invalid object as suggested here http://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/create_event_placeholder/ generates DAQmx error 200088 "Task specified is invalid or does not exist". I could not find a work around it without destroying the logic of the Helper Loop.


Are you aware you can bundle multiple Event Registrations into the same Event Structure?  Your problem is that you have tried to create one Registration both for valid communication User Events and invalid DAQmx events.  Make two different Registrations and bundle.  

 

Here is an image from a past project using DAQmx:

Default Type for DAQmx Events.png

And here is the code that actually started the task and created the event reg:

Start Tasl DAQmx Events.png

Message 7 of 16
(4,439 Views)

Here's a quick implementation (it's quick dirty, I hope you don't suffer from "bent wire phobia"), I don't have HW so I created a simulated NI-6509 to test and it seems to work.

I've used MGI Panel Manager - DQMH Panels , so you'll need to install it with VIPM.

 

The secret was to not use the error out of the register for event before the helper loop, as James' example show with the "clear error" vi 😉


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 8 of 16
(4,414 Views)

Hi indium97, 

 

Thanks for your trust in DQMH, I am glad you are liking it. Sorry for my late reply, thanks to everyone else who has been helping indium97.

 

I would suggest you use the approach bundling the two separate registrations and clearing the error like it was shown above. You want to define the "registration type" and then initialize the task inside the helper loop as you did in one of your first snippets.

 

I think I will have more time this weekend to look at what Titou attached as an example and try something that I have in mind. 

 

Regards,

Fab

 

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 9 of 16
(4,386 Views)

Hi,

 

I tried implementing this solution, but LV crashed immediately.  Running TiTou's code, the same thing happened.  I'm wondering if there is something in LV 2020 that prevents this type of implementation in which the events are registered outside the helper loop with an empty task.  Any ideas? 

0 Kudos
Message 10 of 16
(3,790 Views)