Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

TNT4882 programming

I'm working with TNT4882 and ATmega32. Initialization works correctly and I can read and write data through GPIB bus, but only to one direction at time. When I connect GPIB cable and search device with measurement & automation explorer, all works fine when writing to my device. But I can´t read data from device. After resetting I can read, but cant write.

ADSR register didn´t refresh, it has same value regardless I´m addressing device to listen or talk. Without gpib_read and gpib_write - functions ADSR register shows correct value.

Can someone tell me what i´m doing wrong? Is problem in code or should I check my hardware?
0 Kudos
Message 1 of 11
(6,035 Views)
Here are a few things that I see:

  1. One thing that I see is that INTERFACE_STATUS doesn't appear to be initialized, so it could be any value at startup. That could cause some strange failures. It it always |= in the update_INTERFACE_STATUS method, so you will never clear any data bits out.

  2. I don't see Read_GPIB_Lines, so I don't know what the first while loop does.

  3. You have a loop to update the interface status and it doesn't set anything called SPOLL. THen, you read the ADSR and then update the interface status again. It seems like you should choose a mechanism. Either read the registers manually or use your update method, but not both.

  4. You seem to be using interrupt, but you are using a looped mechanism at the beginning. I am confused. Doing some things in loops and other things at ISR time could cause synchronization problems. I don't have a copy of your ISR, so I don't know what you are doing there.

  5. I wouldn't interrupt on ERR for a write. A device really doesn't care about this.

  6. You are overindexing your array. If in the case of E_NFF, you are writing 16 bytes to the FIFO, even though your write is only trying to write 7 bytes. (Possibly the same thing with the read, you are reading 16 words when your buffer is only a 20 element array (of ints). Depending on your algorithm, you could overindex the array). This could cause unknown errors.

  7. In the gpib_write method, you are looping on mr_isr3, but you are not initializing it to anything, so the loop may get skipped and your device could quite easily get confused.


I think this is enough for now. I think you are on the right track, but I recommend that you re-read the Software Considerations chapter in the TNT manual. I also recommend going to http://www.ni.com/support/gpib/reg_prog.htm and downloading the TNT5002 manual. This manual is newer and describes data transfers and initialization in a newer way that may make it easier to understand. YOu may also consider the ESP-488 source code, which is code written for the TNT4882 hardware in C that should be compilable in your 8-bit uP.

Good luck.
0 Kudos
Message 2 of 11
(6,026 Views)
We configured TNT5002 as
 
    - ESP-488 (non interrupt mode) as the reference to communicate with the controller.
    - Using PCI-4882 mode and NI-VISA driver to access the registers. (Since ESP-488 cannot be used in NT)
 
Currently we were able to communicate with the device and facing some problems.
 
- The device is working fine when it is addressed as listener(LACS). That means when sending data from
  controller, TNT5002 receives the data and comes back to normal state when data is received.
 
- But when it is addressed as talker mode (TACS),
    1. TNT5002 sends the data.
    2. Clears MAV bit.
    3. Checks INTERFACE_STATUS, still addressed as TACS and trying to send data again, hence showing
       Timeout interface error.
 
   TNT5002 is not getting back to normal state after sending data. Still addressed to TACS.
 
Kindly support to solve the problem.
0 Kudos
Message 3 of 11
(5,803 Views)
Hi Prabhu,
Are you receiving an error number or error message when you see the timeout interface error?  If so please post the exact error number and/or message.


Regards,
John E.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 11
(5,783 Views)

Hello,

I am stuck with the initialization of TNT5002,as in I can't verify whwther whatever I am writing to TNT5002 is getting written or not.I have written my routine as per the timing diagram given in the datasheet.If I can be guided about the initialization procedure for the chip in GEN4882 mode by experts,it will be really useful as I am finding it difficult to find a way out.

Thanks

Seema

0 Kudos
Message 5 of 11
(5,771 Views)
Hi John,
Lemme explain the scenario clearly
 
Using NI488.2 GPIB-USB-HS as System contoller(Measurement&Automation Explorer) to test the TNT5002 Interface.
Using non-interrupt part of ESP-488T/L. NI-VISA driver to access the registers in PCI4882.
 
1. When the TNT5002 interface is started, nothing is addressed and keeps looping.
2. Communicate with Instrument is started (NI488.2 Communicator)
                              'ATN asserted'
                              DCA occurs.
                              LACS Addressed
                              Remote Programming
     since the ATN asserted so the interface keeps looping.
3. When Write clicked in NI488.2 Communicator, Receives the bytes sent and again ATN Asserts, so no error.
4. But when Read is clicked in NI488.2 Communicator, TACS is addresses in TNT5002 and sends the data and it is properly
    received to NI488.2 Communicator.
5. But the interface status is having the state
        TACS Addressed
        DCA
        Remote Programming
    But now ATN is not asserted, hence TNT5002 interface trying to send data again but no listeners, hence the timeout error.
    Error: "GPIB error has occured (INTERFACE_ERROR = 3)"
 
 
        Remote Programming
 
0 Kudos
Message 6 of 11
(5,768 Views)
Hi Prabhu,
I would recommend trying your commands in the Interactive Control located at:
Measurement and Automation Explorer -> Tools -> NI-488.2 -> Interactive Control


Regards,
John E.
Applications Engineering
National Instruments
0 Kudos
Message 7 of 11
(5,745 Views)

Hello Prabhu S,

What is the device's status after your device receives the message?  After the device writes you say that DCA, REM, and TACS is set. 

Also, there could be a chance that the read was not completed on the controller side.  Was the proper termination character included in the instrument's response?  Did you set the count correctly on the intrument, or is a default large number put into the count?

There is a step by step set of directions on how to Read and Write from the TNT4882 in the Programmers Reference Manual.  These instructions are shown in the ESP you are using (the software will work with the TNT5002 with only minor changes). 

What changes (if any) did you make to the ESP?

Steven T.

0 Kudos
Message 8 of 11
(5,737 Views)

On clicking Read in the NI488.2 Communicator

Received 5 data bytes "*IDN?"

Update Interface Status 1
-----------------------
REM
RQS
IFC
LACS
DCA
LPA

Update Interface Status 2
-----------------------
ATN asserted
REM
RQS
IFC
TACS
DCA
TPA
SPMS

 

count is the two's complement as in ESP, an it is equal to number of characters,

Followed steps in TNT4882 in the Programmers Reference Manual.

I have not made any changes particular to TNT5002, if you could suggest (if any)will be greatky appreciated.

Prabhu

0 Kudos
Message 9 of 11
(5,721 Views)
Hi Steve,
Noticed that after sending or receiving data, TNT5002 device sends SRQ.
 
Monitoring the PEND(Pending Service Request) bit in SPSR, helps in avoiding the interface error 3.
ie, if(PEND == 1) then do not send/receive.
 
But the PEND clears after long time, hence reading & writing is slow.
 
Kindly suggest to overcome this problem.
 
Thanks
Prabhu
0 Kudos
Message 10 of 11
(5,683 Views)