Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

TNT4882 lose one middle byte

void ReadSetup(void)

{

GPIBDataWrite(TNT_CMDR,0x10);  //reset fifo  setp 2 
 GPIBDataWrite(TNT_CNT0,(char)(count));  //config CNTS   setp 4   
  GPIBDataWrite(TNT_CNT1,(char)(count>>8));  //0x01  0xe0  
  GPIBDataWrite(TNT_EOSR,0xa);
  GPIBDataWrite(TNT_AUXMR,0x96); //end on eos(8bit),holdoff when end
  GPIBDataWrite(TNT_CFG,0x20);  //config CFG   setp 3  
  GPIBDataWrite(TNT_IMR0,0x80);  //set NLEN     setp 6  
  GPIBDataWrite(TNT_IMR1,0x10);  //set END IE bit  setp 6  
  GPIBDataWrite(TNT_IMR3,0x07); 
  GPIBDataWrite(TNT_CMDR,0x04);  //go       setp 7
  GPIBDataWrite(TNT_AUXMR,0x03);  //release holdoff

}

 

void receive(void)

{

  
    while(!((mr_isr3=GPIBDataRead(TNT_ISR3))&0x1))
  {
        
       if((!(mr_isr3&0x4)) || (ReceivedCount>=8192)) 
    {
      if (ReceivedCount>=8192)
      {
        ReceivedCount=0; 
      }
      break;
    }
    if(mr_isr3&0x4)
    {
     RecData[ReceivedCount]=GPIBDataRead(TNT_FIFOB); 
     ReceivedCount++; 
     i++;
     }
    }

 // GPIBDataWrite(TNT_CMDR,0x04);  //go       setp 7
 //GPIBDataWrite(TNT_AUXMR,0x03);  //release holdoff  setp 8 

}

 

In receive(void) function, If I don't cancel the last two lines "GPIBDataWrite(TNT_CMDR,0x04);" and "GPIBDataWrite(TNT_AUXMR,0x03);", I can continously send command to TNT4882  with my test application embedded with agilent VISA library and never lose one byte. But use NI488.2 I can only send command every two times successfully, First is OK. Second will be timeout error. If I add the last two lines, NI488.2 will successfully send command to TNT488.2 every time, but when I  use my test application, sometimes TNT4882 will lose one middle byte of SCPI. Someone can tell me why? Whether I should add the two lines? Help!

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

Hello,

 

I have worked with Solar on other problems, so he emailed me with this problem.  After working on this problem over email, we found a few things. 

 

1st the commented lines at the bottom of the code should not be performed at the end of the read.  The stop command should be sent instead (see page 4-12 of the TNT4882 manual).  Solving this issue stoped the middle bytes from being lost.

 

However, Solar still has a problem with his instrument not getting re-addressed when multiple non-query commands are sent.

 

1.  Controller sends *RST to instrument (success)

2.  Controller sends *RST to instrument again (Timeout)

 

To  solve this issue, the instrument needs to constantly be reading while it is addressed to listen.  It should not stop reading just because one communication compelted. Continue reading (ignoring timeouts on the instrument) until the addressing changes.  Technically, the instrument should accept all data no matter how many communications have already completed (even if the instrument is not readdressed).

 

Thanks,

Steven T.

0 Kudos
Message 2 of 2
(3,317 Views)