Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write from buffer to PCDIO96 output port?

Hello,
 
This should be a simple question, but the things I've tried have not produced any output on the 8-bit Port 0 and 1 lines of PC-DIO96 card. My assumptions are as follows:
 
(i) From the NIDAQ documentation I've read I should be able to do fast data transfers from a buffer directly to PC-DIO96 card output ports.
(ii) The function code enclosed should be outputing values of "15" to ports 0 and 1 of my PC-DIO96 Card
(iii) This writing should happenned as fast as the PC is able to allow my PC-DIO96 card to run
(iv) The values of "15" from the buffer should be translated into port 0 bits 0,1,2,3 being set high (+5V).
 
I am using the DIG_SCAN_Setup and Dig_Block_Out commands as primary vehicle to acheive these data writes, as shown in the enclosed function below. Have I made any errors in interpreting the capabilities of these commands? The PCDIO96 card is capable of doing what I have read it is supposed to regarding buffer to output port writes? Right?
Comments or guidance would be sincerely appreciated.
 
Thanks,
GregXLR

// Local Variable Declarations:

i16 iStatus = 0;

i16 iRetVal = 0;

i16 iDevice = 1;

i16 iGroup = 1;

i16 iGroupSize = 2;

static i16 piPortList[2] = {0, 1};

i16 iDir = 1;

static i16 piBuffer[200] = {15};

u32 ulCount = 100;

u32 ulRemaining = 1;

i16 iIgnoreWarning = 0;

i16 iYieldON = 1;

iStatus = NIDAQMakeBuffer(piBuffer, ulCount, WFM_DATA_I16);

if (iStatus == 0) {

 

/* Configure a "scan" group of ports as output, with

handshaking. */

iStatus = DIG_SCAN_Setup(iDevice, iGroup, iGroupSize,

piPortList, iDir);

iRetVal = NIDAQErrorHandler(iStatus, "DIG_SCAN_Setup",

iIgnoreWarning);

/* Start the handshaked buffered output of 100 "items". Note

that the size of piBuffer is ulCount * iGroupSize. */

iStatus = DIG_Block_Out(iDevice, iGroup, piBuffer, ulCount);

iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_Out",

iIgnoreWarning);

printf(" Apply your handshaking signals to the appropriate handshaking I/O pins.\n");

while ((ulRemaining != 0) && (iStatus == 0)) {

 

iStatus = DIG_Block_Check(iDevice, iGroup, &ulRemaining);

iRetVal = NIDAQYield(iYieldON);

}

 

iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_Check",

iIgnoreWarning);

/* CLEANUP - Don't check for errors on purpose. */

/* Clear the block operation. */

iStatus = DIG_Block_Clear(iDevice, iGroup);

/* Unconfigure group. */

iStatus = DIG_SCAN_Setup(iDevice, iGroup, 0, piPortList,

iDir);

printf(" Digital handshaked buffered output is done!\n");

}

else {

printf(" The buffer was not made correctly. Check the parameters for NIDAQMakeBuffer.\n");

}

0 Kudos
Message 1 of 2
(3,441 Views)

Hello GregXLR,

Thank you for contacting National Instruments. 

The PC-DIO-96 card can use the DIG_Scan_Setup and DIG_Block_Out commands to perform hardware handshaking on a buffered output. 

It seems that the NIDAQMakeBuffer command might not be exactly what you are looking for in when creating your buffer for this code.  This command is primarily used in our examples to create an arbitrary buffer.  The help file attached to this knowledgebase provides information regarding the NIDAQMakeBuffer command.  The WFM_DATA_I16 will create a square wave output listed as ideal for analog output.  It might be better to directly create the array piBuffer so that the desired output matches the requirements of DIG_Block_Out.

Next, if the DIG_SCAN_Setup command is executing properly, the issue is most likely in the DIG_Block_Out command.  This command is the one responsible for actually outputting the piBuffer to the card.  If you go to Start->Program Files->National Instruments->NI-DAQ-> Traditional NI-DAQ (Legacy)™ C Function Reference Help, you can look for commands specific to your device.  This is located under Traditional NI-DAQ Legacy Functions->Listed by Hardware Product-> Traditional NI-DAQ (Legacy) Functions Listed by Hardware Product.  From there you can reference all of the commands accessible by the DIO-96.  It looks like the issue could be coming from the initialization of piBuffer.  Make sure to initialize the array properly and have it match its format to the information provided under the DIG_Block_Out command reference.  You might consider setting the value at each index of piBuffer to 0xFFFF to ensure the binary values written to the port are all ones.  Try placing breaks on the DIG_Block_Out command and in the while loop for the DIG_Block_Check command to ensure that the data is indeed being written and is in the proper format. 

Please post back if you have any further questions.

Regards,
Browning G
FlexRIO R&D
0 Kudos
Message 2 of 2
(3,400 Views)