Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Detection using DIO-32HS (6533)

I am writing a program in LabWindows to monitor 30 digital lines that can change at maximum rate of 0.1 seconds. When any of the lines change I want to capture all 30 lines and place a timestamp with that dataset. I plan on generating a timestamp using the Timer() function since I don't have a 660X card. I'm stuck as to how I should implement this. Should I use single or double buffering using polling, events or interrupts. I have been trying some of the example programs found on www.ni.com to see how the 6533 works but they don't seem to be working correctly with my application. Any help would be appreciated. Thanks.
0 Kudos
Message 1 of 9
(4,316 Views)
I forgot to include this with the original post. How does the buffer work in single and double buffer modes? I have read chapter 4 in AP131 on how double buffering works but I'm still a little confused. Since the half buffer won't be transfered until it's full, I'll be getting the data late and my timestamps will be incorrect. Is that correct? I'd like to have immediate access to the captured data. How do I do that?
0 Kudos
Message 2 of 9
(4,316 Views)
Hi Steve,

Since you have a 6533, the best method to use is Change Detection input. What change detection does is it monitors all digital lines (you specify) and will latch the data once the data changes.

If you are reading data in continuously, you will want to use "double buffering" or continuous buffering. What this is, is a "circular" buffer. The card will transfer data as it reads data on each change to this intermediate PC buffer which is in memory. It will slowly add points and when it reaches the end of the buffer, it will start back at the beginning of the buffer and continue writting. The idea is that while the card is updating this circular buffer, your LabWindows application will read the data from this buffer so that you never lose point
s.

Since your data shouldn't be changing more than once every 100ms you could probably use a callback function to acquire the data via interrupts. Then you would also be able to timestamp the data.

Here is an example that does everything you are looking to accomplish. Hopefully it helps. Good Luck.

Using Change Detection to Monitor NI 653x Data Output
http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E70956A4E034080020E74861&p_node=DZ52319&p_submitted=N&p_rank=&p_answer=&p_source=Internal

Ron
0 Kudos
Message 3 of 9
(4,316 Views)
Thanks for the tips Ron. After looking over some sample code I decided to use double buffering. But I still wasn't sure how I should process the data. I'll give the callback function a try. Oh, the link you provided does not work.

Thanks
0 Kudos
Message 4 of 9
(4,316 Views)
Hi Steve,

Sorry about that here is a good version of the link. It should also give you an idea how to process the data. Usually, you read in data in a continuous loop and either log it to file or process it in the read loop to determine if your signal is what you expect.

http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E70956A4E034080020E74861&p_node=DZ52319&p_submitted=N&p_rank=&p_answer=&p_source=External

Have a good day.

Ron
Applications Engineer
National Instruments
0 Kudos
Message 5 of 9
(4,316 Views)
I've come across that code before in my searching. It was of some help. I found another example program, FastChangeDetection, and that's exactly what I want. So I've been modifying it to suit my needs.

Is is possible to use the general counters on the 6036E to generate more accurate timestamps of the change times using the REQ1 pin of the 6533?
0 Kudos
Message 6 of 9
(4,316 Views)
That would be no problem. I believe that the change detection will pulse out on the REQ1 pin, in which case you can measure the duration between pulses using the onboard counters on the 6036E. You would just need to use buffered simple event counting on the counters and just subtract the current count for the pulse from the previous count acquired (to time stamp correctly). Anyway, Good Luck!

Ron
0 Kudos
Message 7 of 9
(4,316 Views)
Using the 6533 I've noticed that if X lines change then there are X data points in the buffer. Does the REQ1 pin send out X pulses for each data point or does it just send one pulse per change detection regardless of the number of pins that change?
0 Kudos
Message 8 of 9
(4,316 Views)
Hi Steve,

It will send out a pulse on each Change Detection. Change Detection can operate > 1MHz so if your lines are changing but have a different propagation delay which causes them to arrive at different times, you could receive a sample for each arrival and a corresponding pulse on the REQ1 line after each arrival as well.

So the bottom line is you should see a pulse after each Change Detection which should correspond to the number of points in the buffer.

Ron
0 Kudos
Message 9 of 9
(4,316 Views)