Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

ConfigureChangeDetection with NI PXIe-6535

We have a NI PXIe-6535 module. We want to monitor all 32 DIO lines as inputs in a single Task() using the ConfigureChangeDetection technique to receive a callback whenever a value changes.  We started by modifying the NI C# sample application called:

 

"NI-DAQ\Examples\DotNET4.5\Digital\Read Values\ReadDigChan_ChangeDetection_Events"

 

The modified start button click handler is in the next reply.(10,000 char post limit). The only real change we made was the hard coding of the device and edge parameters. We did this simply for this post.

 

It works for some amount of time and the callback stops firing. The amount of time varies between a few seconds and up to 30 seconds. Each callback simply echoes out how many elements are in the boolean array using Trace.WriteLine(). We do not attempt to update the UI as it is set up for 8 bits not all 32.

 

I created another post about not being able to use multiple tasks per device. It's unanswered so far:

 

http://forums.ni.com/t5/Measurement-Studio-for-NET/How-to-create-a-mutliple-tasks-to-read-Digital-ch...

 

 

Bottom line is we need a way to monitor all 32 bits from a single task or multiple tasks. Right now we are only doing Digital inputs. Eventually we will need a mix of inputs monitored continously while writing to outputs.

 

Is this not supported? Are tasks not supposed to be long lived? Should we create a task every time we need to do something? The confusing part is that the test Panels for the NI PXIe-6535 support this exact thing. Why can't we do it from a C# application?

 

 

0 Kudos
Message 1 of 5
(5,518 Views)
private void startButton_Click(object sender, System.EventArgs e)

{

Cursor.Current = Cursors.WaitCursor;

try

{

// Create the task.

 port0Task = new Task();

// Create channel

 port0Task.DIChannels.CreateChannel("PXI1Slot2/port0_32", "", ChannelLineGrouping.OneChannelForAllLines);

// Configure digital change detection timing

 port0Task.Timing.ConfigureChangeDetection("PXI1Slot2/port0_32", "PXI1Slot2/port0_32", SampleQuantityMode.ContinuousSamples, 10000);

// Add the digital change detection event handler

// Use SynchronizeCallbacks to specify that the object 

// marshals callbacks across threads appropriately.

 port0Task.SynchronizeCallbacks = true;

 port0Task.DigitalChangeDetection += new DigitalChangeDetectionEventHandler(port0Task_DigitalChangeDetection);

// Create the reader

 port0DigitalReader = new DigitalSingleChannelReader(port0Task.Stream);

// Start the task

port0Task.Start();

 startButton.Enabled = false;

 stopButton.Enabled = true;

 physicalChannelComboBox.Enabled = false;

 risingEdgeLinesComboBox.Enabled = false;

 fallingEdgeLinesComboBox.Enabled = false;

}

catch (DaqException exception)

{

port0Task.Dispose();

MessageBox.Show(exception.Message);

 startButton.Enabled = true;

 stopButton.Enabled = false;

 physicalChannelComboBox.Enabled = true;

 risingEdgeLinesComboBox.Enabled = true;

 fallingEdgeLinesComboBox.Enabled = true;

}

Cursor.Current = Cursors.Default;

}

 

 

0 Kudos
Message 2 of 5
(5,517 Views)

When you use the original NI example, does it behave as you would expect it to, or is there any unexpected behavior with that as well?

Rick C.
0 Kudos
Message 3 of 5
(5,472 Views)

It does not behave as expected. That's how we started, I modifed it simply to make the post easier to understand.

0 Kudos
Message 4 of 5
(5,462 Views)

Does the exception handler return an error?  The onboard buffer could be filling up if the read isn't executed properly.

 

Other than an error being thrown, I can't think of any reason that it would work a few times then stop.

-Jim B
Applications Engineer, National Instruments
CLD, CTD
0 Kudos
Message 5 of 5
(5,439 Views)