Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading all digital input from 6515 and 6511

I'm working with an NI PCI 6515 and NI PCI 6511.  What I would like to do is grab all in the Digital inputs at once.  Ideally I would be able to event this on Data Changed, however polling is ok too.
 
I am currently polling and looping through several DigitalSingleChannalReaders to get all the data, but I am finding that I am missing signals because of timing with the loop.  If I speed up the loop I still miss signals. 
 
Thoughts on a better solution are always welcome.
0 Kudos
Message 1 of 5
(4,688 Views)
Thanks for posting on the NI forums!  I understand that you want to acquire all digital inputs and event this on Data Changed.  The 651x boards do support change detection.  There is not an official benchmark for how fast these boards can do change detection.  You can expect overflow around 2-3 kHz.

What programming language are you working in?  There are several examples that ship with the DAQmx driver for Measurement Studio.  Check the Digital»Read Values folder (see this KnowledgeBase for the .NET examples location).  I would also do a search for “change detection” in our Developer Zone.
Rod T.
0 Kudos
Message 2 of 5
(4,649 Views)

Thank you for the reply Rod.

I am able to do eventing. (I don't know if its done via hardware or the NI .net library)  I can event on one channel at a time.  The example "ReadDigChan_ChangeDetection_Events.2005" shows this.  However, it only allows me to event on individual lines or on a port at a time.  I want to event on all inputs or event just be able to read all inputs at once.  It appears that I can only have one task running at a time to read the events.  I can setup change detection on one port fine.  When I try to set it up on a second when the first is running I get an exception. 

What I am looking for is this.  I have a PC which may have 1 or more 6515's or 6511's or a combination of the two in there.  The inputs are going to be wired up to various machines as needed.  I am looking for an efficient way of collecting all of the data.  I will know up front which inputs are connected.  I currently have it implemented as something similar to this.

private Dictionary<string, DigitalSingleChannelReader> PortReaders { get; set; }

private Dictionary<string, Task> Tasks { get; set; }

foreach (KeyValuePair<string, DigitalSingleChannelReader> kvp in PortReaders)

{

byte b = kvp.Value.ReadSingleSamplePortByte();

// do something with b

}

I am looking for a way to read everything at once instead of having to loop through like this to read the data.

 

 



Message Edited by CodeHulk on 07-08-2008 07:58 AM
0 Kudos
Message 3 of 5
(4,640 Views)
Ah, now I see your question.  You can only have one digital input task running at a time.  I assume you are using the following function to create the channel.

int32 DAQmxCreateDIChan (TaskHandle taskHandle, const char lines[], const char nameToAssignToLines[], int32 lineGrouping);

To access all the ports and lines, use the following syntax for the lines parameter.

"Dev1/port0/line0:31, Dev1/port1/line0:7, Dev1/port2/line0:7"
Rod T.
0 Kudos
Message 4 of 5
(4,622 Views)

Thanks again for the reply Rod,

I couldln't find the method you were referring to. I am actually using the

public DIChannel CreateChannel( string lines, string nameToAssign, ChannelLineGrouping grouping);

on the DIChannelCollection object.

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