03-25-2021 02:57 PM
Hello All,
I've inherited code that looks similar to the NI change detection event example here:
How Do I Handle Digital Change Detection Events In LabVIEW? - National Instruments (ni.com)
This works fine for our needs, but I would like to, as unobtrusively as possible, read the initial value of the system before a trigger occurs. What is the best way to do this?
Solved! Go to Solution.
03-25-2021 03:14 PM
This is quite simple to implement. This is what I did in the past.
As part of my "initialization" routine when the program spins up, I make an initial read of the system. This involves creating a task, reading, then closing and clearing the task. After that initial read, I can set the change detection event and know what I started with. Below is a snapshot of the initial read routine.
mcduff
03-25-2021 10:05 PM
Your question is vague (to me) -- I don't understand what you are talking about and what you want to do. Perhaps if you attach some LabVIEW code (meaning probably a .VI file), it will be clear and we can provide some help. [Based on what I think you want to do, there's a simple solution ...].
Bob Schor
03-26-2021 08:13 AM
@Bob_Schor wrote:
Your question is vague (to me) -- I don't understand what you are talking about and what you want to do. Perhaps if you attach some LabVIEW code (meaning probably a .VI file), it will be clear and we can provide some help. [Based on what I think you want to do, there's a simple solution ...].
Bob Schor
The change detection DAQmx event uses an event structure to monitor digital lines. The event triggers when the line goes from lo to hi or hi to lo. It is a useful way to monitor state changes in the lines without constantly polling.
The OP wants to get the initial state of the lines when the program starts, before any possible event occurs.
mcduff
03-26-2021 03:39 PM
@mcduff wrote:
The change detection DAQmx event uses an event structure to monitor digital lines.
@mcduff,
Thanks. I'd not (yet) encountered DAQmx Events. I went looking for them in the Palette, where I found them buried in a sub-Palette of a sub-Palette (the last entry, naturally). I also found an NI White Paper called "Getting Started with DAQmx: DAQmx Events" that has a figure supposedly showing how the Event Structure works with DAQmx Events that (are you ready for this?) has no Event Structure. It, instead, talks about a Timed Loop, and still doesn't make complete sense to me.
Bob Schor
03-26-2021 04:47 PM
@Bob_Schor wrote:
@mcduff wrote:
The change detection DAQmx event uses an event structure to monitor digital lines.@mcduff,
Thanks. I'd not (yet) encountered DAQmx Events. I went looking for them in the Palette, where I found them buried in a sub-Palette of a sub-Palette (the last entry, naturally). I also found an NI White Paper called "Getting Started with DAQmx: DAQmx Events" that has a figure supposedly showing how the Event Structure works with DAQmx Events that (are you ready for this?) has no Event Structure. It, instead, talks about a Timed Loop, and still doesn't make complete sense to me.
Bob Schor
This may be heresy to you, but one of the main reasons I use Events for inter-process messaging, and not channels, is DAQmx events.
The same "mailbox" can accept a user event, a front panel event, a DAQmx Event, etc. Messages from different senders can be handled in the same loop. Below are pictures, I know code is better, but these are from projects whose sponsors do not want me to share. (Read Captions for descriptions)
This loop responds to both a USER EVENT and a DAQmx Event (N Points in the buffer). The DAQmx event is set to run about every 100ms, thus I am not polling for points, have a separate loop etc. In between those 100ms I can send other commands, such as save, exit, etc, in one loop.
Here is a DAQmx Change Detection Event, good for seeing when interlocks have tripped or are ready. Once again no polling necessary.
Only Read the Digital lines when something has changed, then decide what to do
A little more work in the beginning, but greater flexibility in the end. I like being able to send different messages with potentially different data types to the same mailbox.
mcduff