LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Initial Value for Change Detection Event

Solved!
Go to solution

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?

0 Kudos
Message 1 of 6
(2,567 Views)
Solution
Accepted by topic author JScherer

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.

 

Snap87.png

mcduff

Message 2 of 6
(2,547 Views)

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

0 Kudos
Message 3 of 6
(2,498 Views)
Solution
Accepted by topic author JScherer

@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

Message 4 of 6
(2,478 Views)

@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

0 Kudos
Message 5 of 6
(2,462 Views)

@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.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 doOnly 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

 

0 Kudos
Message 6 of 6
(2,451 Views)