Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Digital Output C#

Hello,
 
I am currently using the NI PCI-6220 M SERIES DAQ ( Item# 779065-01 ) with the BNC-2110 ACCESSORY ( Item# 777643-01 ). I am programming in Visual Studios 2005 with C# and the newest ( I believe ) version of Measurement Studios. I am trying to write a program that will read in from an Analog input channel at 40khZ and output to 16 Digital channels in different time intervals. I have set up the timing for the input with no problem and as of right now I do not need the input for the output, but I still need it set up for both of them to run at the same time. For the Digital output though, what I need to do is turn on output 1, wait 1/40000 of a second (or 1 cycle of 40khz) then turn on output 2, wait another 1/40000 of a second and turn on output 3. Continue this all the way to output 16, then turn them off starting at 16 and stepping down in the same 1/40000 of a second interval. I can not figure out how to set the timing for the output. I have tried setting the timing in the same fashion as you set the input timing but it does not seem to like that. I have attached a file of what I have so far. It's just the basic skeleton that sets up the input and output. Please disregard the file output and a few other things that I use for debugging.
0 Kudos
Message 1 of 3
(3,278 Views)
Cleaned up my file a little, better than the first one anyways as far as readability goes
0 Kudos
Message 2 of 3
(3,276 Views)

Hi Brian

 

Before we get to writing to your digital lines, I want to let you know that the 6220 only has 8 DIO lines that support hardware timing, and they are all located on Port 0 (lines 0 to 7).  In order to achieve deterministic timing as you have specified (on update every 1/40,000 of a second) we need to use hardware timing.  It is not possible to use software timing for this sort of application because typical operating systems are not deterministic and it is impossible to guarantee an update rate of this speed.  The fastest you can expect to go with a software timed task is about 1 update per millisecond.

 

Here are a few good form threads that go into more detail.

http://forums.ni.com/ni/board/message?board.id=70&message.id=5329&requireLogin=False

http://forums.ni.com/ni/board/message?board.id=70&message.id=5241&requireLogin=False

The 6254 and 6259 both have more hardware timed DIO ports that may be better for your application. 

In order to set a sample clock for your hardware timed DIO, please see the following knowledge base article.  It explains what different options are available. 

What Options Do I Have for Hardware-Timed Digital I/O on my M Series DAQ Device?
http://digital.ni.com/public.nsf/allkb/51754212AD10BDCE862573BD007BFDD2?OpenDocument

There are also some good DIO examples located here

C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0\Digital\Generate Values

Chris_K

0 Kudos
Message 3 of 3
(3,241 Views)