07-15-2010 11:17 AM
Hello.
I'm trying to control stage by digital I/O through PCI 6503.
I wrote a Labview program using DAQmx sub VIs, but it's not working.
So I plan to use functions in DAQ legacy such as "DIG_PRT_CONFIG".
The reason what I'm doing is because I have a piece of C code from manufacturer, which is written in DAQ legacy environment.
BTW, firstly, I'm trying to read a port. I used the example code in "//National Instrument/NI-DAQ/example" folder.
The following is that code. (I slightly changed)
#include "nidaqex.h"
int main(void) {
i16 iStatus = 0;
i16 iRetVal = 0;
i16 iDevice = 2;
i16 iPort = 0;
i16 iMode = 0;
*/
i16 iDir = 0;
i32 iPattern = 0;
i16 iIgnoreWarning = 0;
/* Configure port as input, no handshaking. */
iStatus = DIG_Prt_Config(iDevice, iPort, iMode, iDir);
iRetVal = NIDAQErrorHandler(iStatus,"DIG_Prt_Config",iIgnoreWarning);
iStatus = DIG_In_Prt(iDevice, iPort, &iPattern);
iRetVal = NIDAQErrorHandler(iStatus,"DIG_In_Prt",iIgnoreWarning);
FILE *fp;
fp=fopen("test.txt", "w");"
fprintf(fp, "The digital pattern on port %d is (DECIMAL) %ld\n", iPort, iPattern);
I used "i16 iDevice = 2;", because in MAX, PCI 6503 is assigned as Dev1, first one is another board("PCI 6110E") I'm using.
And, this code gives error code -10401. I know DAQ legacy is supporting PCI 6503, so I don't know why this error is occured.
Also, I used another VI program which detects board in DAQmx, DAQ legacy. In this program, all devices are well detected by DAQmx, but not in DAQ legacy.(samely, give error code -10401).
I'm attaching the LabView program in this post.
07-15-2010 11:29 AM
Only one driver can be active at a time and it appears the DAQmx driver is active and working. You would have to do a reset in MAX in order to switch drivers but I don't see why you would want to do that. You mention that the DAQmx app is not working. That's not a good description. Provide some details such as error code/message.
The reason to get DAQmx wroking is that traditional DAQ is obsolete. I may have support for your card but it lacks support for current OS's.
07-15-2010 11:42 AM
Thanks for advice.
What I'm trying to do is controlling stage.
In my setup, stage is connected to stage controller, and stage controller is connected to PCI 6503 through ribbon cable.
I have connection property of PORT A,B,C and writing/reading cycle as following figures.
Writing Cycle
Reading cycle
And also, I have C code for implemeting the cycle above. The following is part of writng cycle.
//initial configuration
status = DIG_Prt_Config(device, PORT_A, NOHANDSHAKE, INPUT);
status = DIG_Prt_Config(device, PORT_B, NOHANDSHAKE, INPUT);
status = DIG_Prt_Config(device, PORT_C, NOHANDSHAKE, OUTPUT);
//take R/W bar in port C high
CurrentState = 0x40;
status = DIG_Out_Port(device, PORT_C, CurrentState);
(Code for checking status through PORT_A is abbreviated)
//configure port A, B as output
status = DIG_Prt_Config(device, PORT_A, NOHANDSHAKE, OUTPUT);
status = DIG_Prt_Config(device, PORT_B, NOHANDSHAKE, OUTPUT);
//set address for LSB
CurrentState = 0x20;
status = DIG_Out_Port(device, PORT_C, CurrentState);
//write data
status = DIG_Out_Port(device, PORT_A, (int)lobyte);
status = DIG_Out_Port(device, PORT_B, (int)hibyte);
// Take the STROBE line high to LATCH in the LSB data
CurrentState = CurrentState | 0x80;
status = DIG_Out_Port(device, PORT_C, CurrentState);
//set address for MSB
CurrentState = 0x10;
status = DIG_Out_Port(device, PORT_C, CurrentState);
//write data
status = DIG_Out_Port(device, PORT_A, (int)lobyte);
status = DIG_Out_Port(device, PORT_B, (int)hibyte);
// Take the STROBE line high to LATCH in the MSB data
CurrentState = CurrentState | 0x80;
status = DIG_Out_Port(device, PORT_C, CurrentState);
I'm not sure this code is really following the writing cycle. Because, in writing cycle, output of Port C is made while output of Port A,B, but in this code, output of Port C is made after Port A,B.
BTW, I transformed that C code to Labview program based on DAQmx, and reading seems to working, but writing is not working.
So, nowadays, I'm just trying to use that C code itself by recognizing the PCI 6503 in DAQ legacy.
I'm attching Labview program I wrote and whole C code provided by company.
07-16-2010 04:24 PM
Hi milistaff,
Can you provide an example of the probelm you are experiencing?
Thanks!