09-28-2007 09:44 AM
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". Notethat 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");
}
10-01-2007 08:07 PM
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.