Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

change detection with timer

I would like to do the following rather complicated task with an M-series board. As I have not bought the board yet, I would appreciate it if anyone can tell me if this is possible (using NI-DAQmx in LabVIEW 7.1):

5 digital input channels configured for continuous change detection (rising and falling).

2 counters (cascaded) in continuous buffered timer mode, that would latch a value whenever any of the 5 digital lines changed (i.e., recording the time at which a change detection event happened).

A way to tell which of the 5 digital lines changed, and to what state (hi or low) so that the latched time can be associated with a particular line.

Synchronizing the start of two analog input channels with the start of the counters (or some other way to align analog aquisition with the digital events specified above).

A means of generating a software interrupt (like an occurance) when one of the digital lines (lets say the first of the 5 lines in this case) changes.


I believe that it would be relatively simple to route the change detection APE to the gates of the two counters so that I can time the events, but I'm not sure how to tell which line was responsible for generating the event. Also, from what I've read, NI-DAQmx can't directly generate software interrupts, so I'd be looking at using a timed loop with the timing source set to the change detection APE on the first line. Synchronizing with the analog input should be straightforward.

If this requires multiple boards working over an RTSI bus, I would like to know what combination is the most economical.

Thanks in advance.
0 Kudos
Message 1 of 13
(6,424 Views)
Yuri33,

Unfortunately, DAQmx does not yet support change detection on the M-series boards, despite what the M-series datasheets say. This can be confirmed by looking at the online help file for the M-series boards. Otherwise, your idea sounded feasible. Change detection *is* available on the high-speed digital boards such as the 6533 or 6534 though, if you can add a board to your system.

Setting up a timed loop using the change detection pulse sounds like a good idea. However, having never tried it myself, I can't comment on how to do it or whether it's possible. Hopefully someone else can chime in.

As for knowing which digital bit was responsible for the change detection pulse -- you'll need to track that in software by comparing the bit pattern to the previous one, probably using a shift register for storage. If you do your DI Read as a U8, a simple XOR will reveal which bit(s) changed.

I agree that it shouldn't be much problem to synchronize the Analog Input to the counter "timestamping" task. The simplest would be to use the change detection pulse as an external sampling clock to give you a single sample of each analog value whenever a digital bit changes. If you need more analog data than that, then you should be able to let the change detection pulse be a digital trigger. Fortunately you can use the M-series internal timebase for both the counters and the analog input so you can count on them staying in sync.

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 13
(6,413 Views)
Thanks for the speedy reply. You seemed to indicate that change detection isn't supported now, but can/will be in a future version of NI-DAQmx. If that is the case, is there any way to know when to expect this update?

Looking around at other options (the need for multiple boards is less and less desirable for our application as we are already using up most of the PCI slots in the measurement computer for other devices), I see that the R-Series board (7831R) could also be a solution by using the FPGAs as change detectors and counter/timers. I don't have any experience with the FPGA module of LabVIEW, but is it possible to do all of the same things in this board? Finally, although it's not stated in the datasheet, the picture of the 7831R seems to show a connector for an RTSI cable. Does this board support the RTSI bus or will I have to route a trigger externally to another board?

Thanks.
0 Kudos
Message 3 of 13
(6,405 Views)
Yuri33,

I'm not affiliated with NI, so I don't know when to expect a version of NI-DAQ that will support digital change detection on the M-series boards. As a customer, I hope it'll be soon. If I had to guess, I'd look for it to come out with the next major LabVIEW release. I don't know when that will be either, but it wouldn't surprise me if it were to release this summer in time for NI-Week.

I also don't have any experience with the FPGA boards, though my limited understanding suggests you may be able to make it do what you need. However there'll be some learning curve for you to learn to program efficiently on an FPGA. It'd be worthwhile to talk through the details with your NI rep. who can give you better info.

Good luck!

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 13
(6,401 Views)
The newest NI-DAQmx 7.4 is out and it supports the 6534 board and change detection. Please download it from this link:

http://digital.ni.com/softlib.nsf/websearch/90B60D5899BCCCDB86256FC700581B89?opendocument

This driver is AWESOME! It can even simulate the 6534 for you too.

Hany
0 Kudos
Message 5 of 13
(6,347 Views)
So now that I'm reading that NI-DAQmx 8.0 can do change detection in M series boards, does someone have an example that demonstrates change detection on 2 or more digital lines, where each change detection event is hardware timestampped with the onboard counter\timers, and in addition can produce a software interrupt (via occurance, timed loop, etc.) during each event?

Thanks.
0 Kudos
Message 6 of 13
(6,010 Views)
Hello Yuri33,

Here is an example program that shows how to program a change detection event with an M-Series device:

NI-DAQmx Events: M Series Change Detection

This program shows how to configure an event structure within LabVIEW to respond to a change detection DAQmx event.  Also, have you considered using the Digital Waveform data type of the DAQmx Read VI in order to return digital data with an associated timestamp?  This may be an easy way to meet your needs.  Otherwise, I would check out this example program, which shows how to use a counter to timestamp the execution of a portion of code:

Benchmarking a portion of LabVIEW code

I hope this helps,

Travis G.
Applications Engineering
National Instruments
www.ni.com/support

0 Kudos
Message 7 of 13
(5,991 Views)
I've attached a very rough setup that I believe addresses the situation, but I would appreciate it if you would let me know if this is on the right track.  I set up an regualar analog aquisition task, then setup a change detection task, then a counter timestamp task.  I set the terminal of counter to an internal timebase, and the sample clock to the change detection event.  I then set the start triggers of the change detection and counter timestamp task to the start trigger of the analog input.  This way, all three tasks start at the same time, and (if I'm dilligent in reading all the buffers) I will continuously monitor, record, and timestamp each diginal event in synchrony with the regular analog aquisition.

Is this on the right track?
0 Kudos
Message 8 of 13
(5,984 Views)
Hello Yuri33,

That code looks great!  Your first configuring the analog input task to acquire data from a single channel at 250Hz.  You then configure a digital input task for change detection using the Change Detection instance of the DAQmx Timing VI.  You can then register a change detection event using the event structure as shown in the M Series Change Detection example program I posted above.  You then configure a buffered edge counting task to count the edges of the 20MHz internal timebase and latch that value every time a ChangeDetectionEvent occurs.  You'll have to convert this count value into a timestamp later according to the following equation: timestamp = start time + (count value/timebase frequency).  Finally, you have the digital and counter tasks configured with a start trigger, coming from the ai/StartTrigger line.  This looks perfect.  My only suggestion would be to remove the sequence structures, and force the execution by only using the error in and error out terminals of the VIs, but that's just cosmetic.  Maybe you could post another version for us to take a look at as you add more functionality?

Regards,
Travis G.
Applications Engineering
National Instruments
www.ni.com/support
0 Kudos
Message 9 of 13
(5,958 Views)
Okay, I've assembled what I believe to be a example of simultaneous analog input, digital change detection, and counter "timestampping" of those change detection events.  First, a simple continuous analog input task is configured.  Then, an continuous digital change detectino task is created.  Afterwards, a count edges task is created, assigning the ChangeDetectionEvent signal as the source.  Finally, a Register for Events node is created with 2 entries: an EveryNSamplesAcqIntoBuffer Event (50 samples) and a Change Detection Event.  The three tasks are started, and dynamic events are registered to an event structure.  For the EveryNSamplesAcqIntoBuffer event, 50 samples (0 timeout) is read from the buffer and displayed in a waveform graph.  For the Change Detectino Event, a single sample (0 timeout) is read from each digital input line and displayed as an array of booleans.  Additionally, a single sample (0 timeout) is read from the counter and converted to a timestamp (seconds).  Finally, a Stop button ends the loop and all tasks are disposed of.

This seems to work fine, but when I add digital start triggers (ai\StartTrigger) to the change detection and\or count edges task, I get error -200452 ("Specified property is not supported by the device or is not applicable to the task.").  In the attached example, I've added the start trigger sections, but disabled them.  In the current mode (start triggers disabled), the analog input task is not synchronized with the digital inputs and timestamps.  Any help in synchronizing these tasks would be greatly appreciated.


0 Kudos
Message 10 of 13
(5,890 Views)