11-14-2007 09:12 AM
11-16-2007 04:36 AM
Hi Alexandra,
I hope all is well with you. From my understanding you are using Traditional NI-DAQ, Measurement Studio (Visual C++) to do digital write and read on your NI 6533. You mentioned that you have connected your digital output to your digital input to read in what you wrote out. I am assuming that you are using windows XP.
I would like to give a brief description of the DIG_Block_out function that you are using. If you would like more information on it, you can find it in the Traditional NI-DAQ C Function Help. You can get to this help by going to Start>>Programs >>National Instruments>>NI-DAQ>>Traditional NI-DAQ Function Help.
DIG_Block_Out
DIG_Block_Out initiates an asynchronous transfer of data from your buffer to a specified group. The hardware is responsible for the handshaking details. Call DIG_Grp_Config for the DIO-32F and 653X devices, or DIG_SCAN_Setup for the other devices at least once before calling DIG_Block_Out to select the group configuration for handshaking.
In other words, DIG_Block_Out takes an specified amount of data, and throws it out using the current setup of the board, once initiated, the call to the driver returns, and program flow continues.
It sounds like you are developing code for this application. My suggestion is for you to upgrade to the current driver for your hardware. It is much easier to develop in and there are already examples that do what you are trying to do. You can download the DAQmx driver for free online and use it with Measurement studio and your 6533.
What value to you get when you write just $FF?
11-27-2007 01:48 AM
Hello,
Sorry for the delay, but I had something else to work on.
When I write 0x00FF it receives back 0x00FF. So that works. But for 0xFF00 I don't receive 0xFF00.
But if the board has the option to group the ports in order to be able to send 16b or even 32b, then it should be able to be done. However, the functions avaiable for sending/receiving data use i16 (a signed type) which inables me to set all the bits of the grouped ports.
Here is the pice of code I use:
iStatus = 0;
iDevice = 4;
for (i=0;i<200000;i++)
{
piBuffer[i] = 0;
outputBuffer[i] = 0;
}
ulCount = 200000;
numdone = 1;
iGroupSize = 2;
iPgConfig =1;
iReqSource = 2;
iPgTB =1;
iReqInt = 10;
iExtGate = 0;
iIgnoreWarning = 0;
iYieldON = 1;
iGroupOut = 1;
iGroupIn = 2;
iPortOut = 0;
iPortIn = 2;
iDirIn = 0;
iDirOut = 1;
iDeviceCode;
iReqSourceOut = 0;
wordTransferCount = 200000;
iModeOn = 1;
iOldDataStop = 0;
iPartialTransfers = 1;
iNchanges = 2;
iStatus = Init_DA_Brds(iDevice, &iDeviceCode);
iRetVal = NIDAQErrorHandler(iStatus, "Init_DA_Brds", iIgnoreWarning);
// Configure port 0 as group 1 and as an output port
//
iStatus = DIG_Grp_Config(iDevice, iGroupOut, iGroupSize, iPortOut, iDirOut);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_Grp_Config", iIgnoreWarning);
// Configure internally timed pattern generation with timebase -3,
// interval 20 ( final clock = 20 MHZ), and no external gating.
//
iStatus = DIG_Block_PG_Config(iDevice, iGroupOut, 0, iReqSourceOut, iPgTB, iReqInt, iExtGate);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_PG_Config", iIgnoreWarning);
iStatus = DIG_DB_Config(iDevice, iGroupOut, 1,0,1);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_DB_Config", iIgnoreWarning);
iStatus = Set_DAQ_Device_Info(iDevice, ND_DATA_XFER_MODE_DIO_GR2, ND_INTERRUPTS);
iRetVal = NIDAQErrorHandler(iStatus, "Set_DAQ_Device_Info", iIgnoreWarning);
/* Clear all messages */
iStatus = Config_DAQ_Event_Message (iDevice, 0, "DIGRP2", 1, 1, 0, 0, 0, 0, 0, 0, (DWORD)MyMessage);
iRetVal = NIDAQErrorHandler(iStatus, "Config_DAQ_Event_Message", iIgnoreWarning);
/* Configure the group for port assignment (2) and direction (input) */
iStatus = DIG_Grp_Config(iDevice, iGroupIn, iGroupSize, iPortIn, iDirIn);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_Grp_Config", iIgnoreWarning);
/* Configure for Change Detection */
iStatus = DIG_Block_PG_Config(iDevice, iGroupIn, iPgConfig,iReqSource, iPgTB, iReqInt, iExtGate);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_PG_Config",iIgnoreWarning);
/* Configure for double buffering */
iStatus = DIG_DB_Config(iDevice, iGroupIn, iModeOn, iOldDataStop, iPartialTransfers);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_DB_Config", iIgnoreWarning);
iStatus = Config_DAQ_Event_Message (iDevice, 1, "DIGRP2", 1, iNchanges, 1, 0, 0, 0, 0, 0, (DWORD)MyMessage);
iRetVal = NIDAQErrorHandler(iStatus, "Config_DAQ_Event_Message", iIgnoreWarning);
}
Send_Receive::Send(i16 msg)
{
outputBuffer[0] = msg;
iStatus = DIG_Block_Out(iDevice, iGroupOut, outputBuffer, wordTransferCount);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_Out", iIgnoreWarning);
iStatus = DIG_Block_Clear(iDevice, iGroupOut);
}
Send_Receive::Receive()
{
int i;
unsigned long time;
for (i=0;i<32;i++)
piBuffer[i] = 0;
iStatus = DIG_Block_In(iDevice, iGroupIn, piBuffer, ulCount);
iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_In", iIgnoreWarning);
for (i=0;i<32;i++)
printf("%d",piBuffer[i]);
printf("\n");
iStatus = DIG_Block_Clear(iDevice, iGroupIn);
}
Thank you for the support,
Alexandra Mazilu
11-28-2007 11:06 AM
11-28-2007 11:21 AM - edited 11-28-2007 11:23 AM
11-30-2007 01:21 AM
Hi Alexandra,
You do not mention what exactly you get when you enter xFF00. Do you receive the -193 and a buffer overflow? I believe the problem is with the grouping of the channels since FF works but FFFF does not. I would like you to also try entering 5555 and then post back the result.
11-30-2007 07:51 AM
Hello,
For 0xFF00 I get -256.
The thing is I haven't connected 2 pins (PortA pins 6,7 with PortC pins 6,7), because I run out of wire :P. That means that for 0x00FF I receive 63 = 0x003F (for 0x0FFF I get 0x0F3F). And that's probably why I receive -193. If I convert this number using the Windows Calculator, from decimal to hexadecimal, it look like this: 0xFF3F, which is correct.
So the result read is correct, only the way it is displayed is not ok. I'll try some bit shifting.
Thanks,
Alexandra
11-30-2007 07:55 AM
OK, I've solved the problem.
I used an additional u16 variable:
u16 x;
x = piBuffer[i];
And now x contains the proper value!
Thanks,
Alexandra
12-03-2007 09:39 AM
Hi Alexandra,
I am glad to hear that everything is working. Thank you for posting the solution for the benefit of others.
I wish you the best on your application.