Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Detection - too many samples on rising edge - PXI 6289

KANNAN
 
I'm using PXI-6289 board for monitoring couple of input lines. I'm implementing change detection event for notifying application of any change in input lines. I have implemented in C# (.NET 2.0). My problem is whenever line changes from low to high (at rising edge), I'm getting too many samples (too many calls are received at my change detection handler and when I look into the stream object property I could see total number of samples sometimes 20/30 etc) and all of them are alternating (true/false). But when the line changes for high to low (falling edge) I'm getting only one sample and the value is proper.
 
I have verified with oscilloscope for any jitters in the line and found the line is normal.
 
I have tried using the sample project "ReadDigChan_ChangeDetection_Events" and I had the same result. Can anyone help me to get only one event for each change (from low to high or high to low). I have also tried configuring the reference clock rate but not working.
 
Following is the piece of code I have used
 
//Code for creating task

private void Initialize()

{

m_oTAMReaderTask = new Task();

m_oTAMDIChannel = m_oTAMReaderTask.DIChannels.CreateChannel(szTAMLine, "TAMChannel", ChannelLineGrouping.OneChannelForAllLines);

m_oTAMChannelReader = new DigitalSingleChannelReader(m_oTAMReaderTask.Stream);

m_oTAMReaderTask.Timing.ConfigureChangeDetection(szTAMLine, szTAMLine,

SampleQuantityMode.ContinuousSamples,1000);

m_oTAMReaderTask.DigitalChangeDetection +=

new DigitalChangeDetectionEventHandler(DigitalTAMChangeDetectionHandler);

m_oTAMReaderTask.Control(

TaskAction.Verify);

m_oTAMReaderTask.Start();

}

private void DigitalTAMChangeDetectionHandler(object oSender, DigitalChangeDetectionEventArgs oArgs)

{

try

{

m_bArrTAMReadBuffer[0] =

false;

m_bArrTAMReadBuffer[0] = m_oTAMChannelReader.ReadSingleSampleSingleLine();

if (m_bArrTAMReadBuffer[0] == m_bArrTAMPreviosState[0])

return;

m_bArrTAMPreviosState[0] = m_bArrTAMReadBuffer[0];

m_bArrIOState[2] = m_bArrTAMReadBuffer[0];

m_oReportHandler(m_bArrIOState); //reporting to application

}

catch (Exception oExcept)

{

throw new ApplicationException("ERR_321", oExcept);

}

}

Thanks

Kannan

0 Kudos
Message 1 of 4
(4,201 Views)

Hi KANNAN,

If I understand you correctly, you are trying to do change detection on a single line on your 6289 but are receiving too many samples on rising edge transitions. Those samples are alternating between true and false. Everything is behaving as expected with a falling edge transition.

Since you are getting the same result in an example program, I think the problem could be connection related. M-Series devices can do digital change detection, but only on port0. Double check that those input lines are all on port0 lines.

Try connecting a digital out line to your szTAMLine line. Run the “ReadDigChan_ChangeDetection_Events” example and change the value of the digital out line manually from a test panel in the Measurement & Automation Explorer. Verify that you see a single value for each change that you make to the digital out signal.

What are you trying accomplish with change detection? I’m not really sure why you’re using szTAMLine as the digital input line, rising edge physical channel, and falling edge physical channel. The result will always be a waveform that alternates between true and false (as you have experienced). More background on your application will help me better understand how to help you.

Have a great day!

Ryan D.
District Sales Manager for Boston & Northern New England
National Instruments
0 Kudos
Message 2 of 4
(4,182 Views)

Hi Ryan,

Thanks for your prompt reply. Your understanding is correct as far as the problem is concerned. Here is some more information about entire idea. 

I have a safety door with my measurement setup and I want to know the state of this door at run time to stop the application as soon as the safety lock opens. This is one of the 'must have' features.This safety door status line (digital IO line) is connected to the measurement board (/port0/line2) and from there I need to find the status of this line. One way to accomplish this is keep polling the line for its state but this takes away some performance of CPU which I cannot do since my application requires most of the processor time (nearly realtime!). Also I want to know exact time by which it occurs. From the DAQmx documentation I came to know about the "change detection" event so I'm trying to use this event based mechanism to accomplish my task since it does most of the change detection activity within the board.

In a simple way I need to implement a digital IO monitoring.

I'm using one of those lines in port0: line number 2 (line 0 & 1 are free, would this be a problem?)

Thanks & Regards,

Kannan

0 Kudos
Message 3 of 4
(4,178 Views)

Hi Kanaan,

Thank you for providing more information about your application.  To answer your last question, there should not be a problem with leaving lines 0 and 1 open and just using change detection on line 2.  When you configure which rising edge and falling edge lines you want to detect, a mask is defined for the entire port.  In your case since you are just monitoring line 2, it might look like this

Port size: 8 bits

Mask:                                    00100000 (0’s mean we don’t monitor those lines)

Lines to Monitor:                xx1xxxxx (derived from the mask)

The hardware will then monitor the line and when there is a change on line 2, the entire port will be latched into memory.

You might want to try just monitoring line 2 with rising edge changes by itself.  Use the same example ReadDigChan_ChangeDetection_Events and set line 2 as the rising edge lines and a line that is not used for the falling edge lines (i.e. line 0 or 1).  Then check if the number of samples at the rising edge is still too large.  This way you can isolate the problem and rule out the possibility that detecting changes from the same line for rising and falling edges is sending too many calls to the change detection event handler.

Finally, I see that Ryan mentioned outputting values with Measurement and Automation Explorer Test Panels and then running the same code to check the samples. Did you try implementing this?  Also from your explanation of your setup, it seems you only want to detect a single change for the state of the door.  Is it then necessary to get the rising and falling edge values? 

 Hope this information is helpful and please post back with any more information you can provide!

Regards,
Vanessa L.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(4,157 Views)