Hi,
I've actually posted something about this question before, but moved on
to other things for a while. Now I'm back and have a better idea of
what I want to ask. So I have some VB6 that uses the traditional NI
legacy drivers to access a DIO card that we have (PCI-DIO-32HS to be
exact). Now the snippet of the old code that's important is the
following:
// setup code
ARRAY_SIZE = 2^14
Dim piHalfBuffer(ARRAY_SIZE * 2) As Integer
Dim iDevice As Integer
Dim iGroup As Integer
Dim iGroupSize As Integer
Dim iPort As Integer
iStatus% = Timeout_Config(iDevice%, lTimeout&)
iRetVal% = NIDAQErrorHandler(iStatus%, "Timeout_Config", iIgnoreWarning%)
iStatus% = DIG_Grp_Config(iDevice%, iGroup%, iGroupSize%, iPort%, iDir%)
iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_Grp_Config", iIgnoreWarning%)
iStatus% = DIG_Block_PG_Config(iDevice%, iGroup%, 1, 1, -3, 2, 0)
iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_Block_PG_Config", iIgnoreWarning%)
iStatus% = DIG_DB_Config(iDevice%, iGroup%, iDBModeON%, iOldDataStop%, iPartialTransfer%)
iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_DB_Config", iIgnoreWarning%)
iStatus% = DIG_Block_In(iDevice%, iGroup%, piBuffer%(0), ulCount&)
iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_Block_In", iIgnoreWarning%)
// read code
iStatus% = DIG_DB_Transfer(iDevice%, iGroup%, piHalfBuffer%(0), ulPtsTfr&)
iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_DB_Transfer", iIgnoreWarning%)
The basics of it is that the VB6 program asks for a buffer of data from
the DIO card which is connected to an FPGA board which has stored time
tags on it. Once it gets the buffer back then it parses it.
Alright, so someone gave me some example code before for digital reads
in DAQmx. I'm in the process of going through it and customizing it to
what I want. Here's what I have so far.
myDigitalTask = new Task("diTask");
myDigitalTask.DIChannels.CreateChannel(cbPhysicalChannel.Text,"",ChannelLineGrouping.OneChannelForAllLines);
myDigitalTask.Control(TaskAction.Verify);
myDigitalReader = new DigitalSingleChannelReader(myDigitalTask.Stream);
myDigitalReader.SynchronizingObject = this;
myDigitalAsyncCallback = new AsyncCallback(DigitalReaderCallback);
//myDigitalReader.BeginReadMultiSamplePortByte(numberOfSamples,myDigitalAsyncCallback,null);
myDigitalReader.BeginReadMultiSamplePortInt32(numberOfSamples,myDigitalAsyncCallback,null);
I create my tasks and channel, create a channel reader, assign a
callback, now the example code originally used a byte read, but I got
an error that there was 32 bit data there and I needed to use the Int32
method. So I've tried that. So I've made my callback and it does this:
int[] digitalData = myDigitalReader.EndReadMultiSamplePortInt32(ar);
// parsing stuff
myDigitalReader.BeginReadMultiSamplePortInt32(numberOfSamples,myDigitalAsyncCallback,null);
So as far as I can tell, what I've done seems correct, set up the
channel, write my callback, start a read, parse the data in the
callback and start another read. Couple of questions, the VB6 code
never set a port it got set with some legacy code, do I have to worry
about this? Secondly, there was no mention of lines (ie. /port0/line0)
in the VB6 code, what do I do in the DAQmx with lines? (this is in my
CreateChannel call)
Thanks for anyone that might be able to try and help me. Sorry that my
explanation is a little lacking, I haven't done any traditional legacy
driver programming before and I'm just getting into the DAQmx
programming, so that's why I am appealing for help. If you need more
info, or don't understand my question by all means ask. What I'm trying
to do is port the traditional daq code to DAQmx calls in C#.NET.
Chris