Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

REPETITIVE NRFD CONTROL SIGNALS TNT5002 ESP

We are using the TNT5002 chip in our instrument device and implemented the ESP-488TL library code as supplied by NI. The device is setup for INTERRUPT mode. I have a code loop similar to NORMAL I/O and NORMAL ADDRESSING as in APPENDIX B of the ESP-488TL MANUAL.  In normal message exchange between CONTROLLER APPLICATION (the PC) and my instrument device, the PC sends a DEL? query, the LACS bit turns on, the code RECEIVES the "DEL?" data query, processes it and then forms a message to be sent.  When the TACS bit turns on, the message is sent using the SEND command.  Everything works and we're synchronized.

1. When the PC sends a command only, the LACS bit turns on, and I receive the data then execute the command.  HOWEVER, because I am in this message loop, the LISTENER is still addressed (the LACS bit stays turned ON), and so I continue to call the RECEIVE function but it returns a data count == 0.  THe NRFD CONTROL SIGNAL on the bus also toggles every time the RECEIVE command is executed.  Is this NORMAL BEHAVIOR?  Should I be setting a control bit in the TNT5002 to stop this or should I be changing my program code to not keep sitting on the RECEIVE command?  I am looking at this with the GPIB+ ANALYZER and have noticed that other instruments DO NOT toggle the NRFD control line when they are only sent a command unlike the behavior my instrument produces.  Because I am in the loop, the timeout of 1 SEC occurs, a BUS ERROR BIT is generated, and continues endlessly because the RECEIVE command with datacount == 0 condition is true.

Thanks,

Victor

ATTACHED IS MY MESSAGE LOOP CODE:

while (1) { // MAIN() program while loop

////////////////////////////////////////////////////////////////////////////////

#ifdef ETHERNET_ENABLED

ENET_Handler()

// service the Ethernet

#endif

if ((ch = serEgetc()) != -1) // any chars available from MicroTerminal?

stateSER_CHAR = TRUE

// check Serial Port E

#ifdef GPIB_ENABLED

Update_INTERFACE_STATUS()

/* Update status word */

#endif

if (INTERFACE_STATUS&LACS) { /* If listener

addressed */

#ifdef DEBUG_MSGS

printf("gpib (listen) INTERFACE_STATUS =

0x%X\r\n",INTERFACE_STATUS)

#endif

Receive(buf,50,EOI)

/* Read up to 50 bytes */

// if TIMEOUT is disabled, then Receive may never return //

if (DATA_COUNT == 0) {

#ifdef DEBUG_MSGS

printf("DATACOUNT == 0\r\n")

#endif

} // endif DATA_COUNT == 0

if(DATA_COUNT>0) {

#ifdef DEBUG_MSGS

printf("\r\nReceived %lu data bytes\r\n",DATA_COUNT)

//sprintf(DISPLAY_LINE,"gpib (receive) %lu bytes \r\n",DATA_COUNT)

//prtTERM(DISPLAY_LINE)

#endif

for (i=0

i<DATA_COUNT

i++) {

gpibBUFFER_IN[i] = buf[i]

} // end for

gpibBUFFER_IN[i] = 0x00

// buf doesn't terminate so add NULL to mark end

stateGPIB_DATA_IN = TRUE

//indicate data from GPIB is here to process later

stateCMD_FROM_GPIB = TRUE

//command was from GPIB

} //end-if DATA_COUNT > 0

} // endif

else if(INTERFACE_STATUS&TACS) { /* see if TACS Talker

addressed */

/* Send data out only if it is available */

if (stateGPIB_DATA_OUT == TRUE) {

Send (gpibBUFFER_OUT,strlen(gpibBUFFER_OUT),EOI)

//send the data out

if(DATA_COUNT > 0) { /* If data bytes sent

print

it */

#ifdef DEBUG_MSGS

printf("\nSent %lu bytes\r\n",DATA_COUNT)

//sprintf(DISPLAY_LINE,"gpib (send) %lu bytes\r\n",DATA_COUNT)

//prtTERM(DISPLAY_LINE)

#endif

stateGPIB_DATA_OUT = FALSE

Clear_4882_Status(STB,0x10)

/* Clear MAV bit */

} //end-if

} //end-if

// what should be done if Talker Address and NO DATA available nor

will be available to be sent ??

} // endif

if (INTERFACE_STATUS & ERR) {

#ifdef DEBUG_MSGS

//sprintf(DISPLAY_LINE,"gpib (error) %d\r\n",INTERFACE_ERROR)

//prtTERM(DISPLAY_LINE)

printf("gpib (error) %d\r\n",INTERFACE_ERROR)

#endif

INTERFACE_STATUS &= ~ERR

INTERFACE_ERROR = INTERFACE_ERROR

} //end-if

//12.05.06

if (INTERFACE_STATUS & TIMO) {

#ifdef DEBUG_MSGS

printf("TIMO %d\r\n",INTERFACE_STATUS)

#endif

INTERFACE_STATUS &= ~TIMO

} //end-if

 

if (g_DEVICE_CLEAR) {

#ifdef DEBUG_MSGS

printf("g_DEVICE_CLEAR %d\r\n",INTERFACE_STATUS)

#endif

g_DEVICE_CLEAR = FALSE

DEVICE_CLEAR()

}

0 Kudos
Message 1 of 2
(2,829 Views)
Hi Victor,
 
Take a look at the attached code (NonCIC.c), as this may prove useful to you as a way to avoid performing the RECEIVE call within your loop.  This is accomplished by "or"ing the address status byte with a mask byte and then LACS or TACS.  So, if LACS is on, the device goes into listen mode, then after reading, the device goes into a state where it will not go into listen mode until other things happen.  Hope this helps!

Regards,
Anna M.
National Instruments
0 Kudos
Message 2 of 2
(2,793 Views)