10-13-2019 03:50 PM
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
10-15-2019 08:57 AM
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
10-15-2019 11:40 AM
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.
10-16-2019 06:04 PM
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
10-21-2019 01:13 PM
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
10-22-2019 05:01 AM
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
10-22-2019 12:13 PM - edited 10-22-2019 12:17 PM
@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:
And here is the code that actually started the task and created the event reg:
10-23-2019 01:56 AM - edited 10-23-2019 01:57 AM
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
10-24-2019 07:33 PM
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
11-13-2020 11:40 AM
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?