Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Equivalent DAQmx calls for old driver code?

Hi There,

I have some older VB6 code that calls the tradional DAQ driver directly. I'm looking to transfer it to .NET and I'd like to know the equivalent code in C#.NET. I've been searching around and haven't had much luck yet. Hopefully someone can help me. Here's my old code in VB6:

    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%)

and then it makes the following call to read data in a loop:

    iStatus% = DIG_DB_Transfer(iDevice%, iGroup%, piHalfBuffer%(0), ulPtsTfr&)
    iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_DB_Transfer", iIgnoreWarning%)

So as far as I'm understanding it, it's setting up some config stuff, timeouts, etc, sets up a group to look at, and tells DAQ that it wants to transfer half the read buffer into piHalfBuffer%(0). I'd like to do the same thing in .NET. So far all I've found is code that creates say a DigitalMultiChannelReader and ReadMultiSampleMultiLine methods. So a sample at a time from the lines. Is there code that dumps have the buffer to a buffer variable in DAQmx, like it does in the above traditional DAQ code?

Thanks,
Chris

0 Kudos
Message 1 of 4
(3,441 Views)
Chris,
So in DAQmx instead of getting half buffers you specify a buffer size that gets returned each time in a callback function.  There is an example on our website that shows simultaneous continuous analog input and digital input, but you could just look at the lines that refer to the digital input.  You define a callback function that gets called every time the number of samples in your buffer size have been received, then you can do whatever you want with the returned data.  The example can be found here.
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 2 of 4
(3,425 Views)
Hi Doug,

Thanks for the help. Can you post the address for that link with the example again? It times out on me and I can't seem to get to it.

Thanks,
Chris
0 Kudos
Message 3 of 4
(3,419 Views)
Chris, I apologize, the link I sent hasn't been made live yet, so I'm attaching the file.  Hope this helps!
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 4 of 4
(3,414 Views)