1
\$\begingroup\$

I want to interface Agilent 34401A Digital Multimeter over the RS232 interface. The settings (baud rate, parity, number of start and stop bits) are set to be same on multimeter, pc (device manager) and on the application that I use for terminal. Programming language is SCPI.

I successfully control the multimeter, that is I execute the commands such as: syst:rem; :meas:volt:dc? 10, 0.003; :conf:volt:dc 10, 0.003; :sens:volt:dc:rang 100; but I get no response over RS232 interface from my multimeter.

For example when I execute the command :meas:volt:dc? 10, 0.003; the measurement is performed and the voltage is displayed on multimeter’s display, but the value is not sent over RS232 to my terminal. No response what so ever.

In the manual for the multimeter there is a statement after each command -- “bus enter statement". Relevant extract provided below.

enter image description here

I could not find any reference or explanation what is meant by this. Does a special command exist for retrieving data from the multimeter?

:read? makes no effect on the multimeter.

Useful hint for someone who is also trying to set up RS232 communication with this device: Even if in the manual the colon preceding the SCIP command is not given, the multimeter returns “unknows header” error if it is not present.

\$\endgroup\$
2
  • \$\begingroup\$ I did this a couple years ago to make a test jig using some Python scripts, I recall the meter was very picky about the port wiring, had me tearing my hair out for a few hours. Modern LXI is better for test equipment automation, IMO. \$\endgroup\$ Commented Oct 19, 2017 at 15:21
  • 2
    \$\begingroup\$ As a tip, when you're just trying to verify you have working communication with a test instrument, start out by just sending the "*IDN?" query. Once you can get a good reply to that, then start sending actual measurement commands. \$\endgroup\$
    – The Photon
    Commented Oct 19, 2017 at 15:52

7 Answers 7

3
\$\begingroup\$

The problem was in the way I send a command over terminal. After a command the multimeter expects line feed character, in PuTTY this is <ctrl-j>.

The code below successfully gets response with a value of a voltage.

syst:rem; 
:meas:volt:dc? 10, 0.003;
<ctrl-j>

I found solution reading through this forum question: https://www.eevblog.com/forum/testgear/34401a-serial-interface-problems/

\$\endgroup\$
1
  • \$\begingroup\$ PuTTY Configuration -> Terminal -> "Implicit LF in every CR" and "Implicit CR in every LF"? \$\endgroup\$ Commented Oct 19, 2017 at 18:16
2
\$\begingroup\$

I had to deal with this matter today. Briefly, the matter is that Agilent has uses an unconventional hardware flow control handshake.
Long story short, the instrument needs to see a high voltage on its DSR input.

If you're using C#, keep note it is possible to set DTR (which connects to DSR using a regular null modem cable) to either 'high' or 'low' regardless of using or not Hardware flow control.

Thus, to make it work:

  • In Visual Studio, set your COM port to the instrument's baud rate and parity.
  • Set your flow control to NONE.
  • However, set and leave the DTR line to "high" (my line shows about 5.8 volts). You may trigger it low and high to confirm you can control it. This is recommended since this behavior may vary according to your specific serial port hardware or USB to RS-232 adapter.
  • Remember, prior to issuing commands set the mode to 'remote' using the command SYSTEM:REMOTE.
  • Also remember to finish your commands with \r\n.

Here's some functional code:

 
/* 
Agilent A34401 Test Program
---------------------------
Copyright (C) 2021, Diego Velez
The code below is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License 
*/ 

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AgilentTest
{
    class Program
    {
        public static SerialPort sp;
        public static Stopwatch sw = new Stopwatch();

        static void InitSerial()
        {
            sp = new SerialPort("COM16", 9600, Parity.None, 8, StopBits.One);
            sp.Handshake = Handshake.None;
            sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
            sp.ReadTimeout = 5000;
            sp.WriteTimeout = 5000;
            sp.Open();
            sp.BreakState=false;
            sp.DtrEnable=true;      // Important: this tells the instrument we're ready to receive data,
                                    // in spite of not actually using hardware flow control
        }

        static void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort mysp = (SerialPort)sender;
            string indata = mysp.ReadExisting();
            Console.Write(indata);
        }

        static void Main(string[] args)
        {
            InitSerial();
            sw.Start();
            int seconds;
            bool flag_running=true;
            int time_stamp_last_command=-1;
            sp.Write("SYSTEM:REMOTE\r\n");
            // To leave the loop, find a way to set flag_running to false
            while (flag_running)
            {
                seconds=(int)sw.ElapsedMilliseconds/1000;
                if ( ((seconds % 10) == 0) && (seconds!=time_stamp_last_command) )
                {
                    time_stamp_last_command=seconds;
                    Console.WriteLine("{0} sent command", seconds);

                    sp.Write("MEASURE?\r\n");
                }
            }
        }
    }
}
\$\endgroup\$
1
\$\begingroup\$

I found that to get the MEAS:VOLT:DC? command to work with my 34401A, I first had to put the system into remote mode.

So, in LabVIEW I first sent

SYST:REM\n

then I sent

MEAS:VOLT:DC? 10,0.003\n

over my VISA port. When I read back the buffer I got the voltage as desired as a text string.

Note that the \n is the LabVIEW "Linefeed" string constant, I concatenated that to the end of the main part of the string using the concatenate string block.

This was using a RS-232 to USB converter from plugable.com, with no cross-over (null-terminal) or anything else.

\$\endgroup\$
2
  • \$\begingroup\$ Also port was set up as 9600 baud, 8 data bits, no parity, 1 stop bit, and no flow control using the property node block. \$\endgroup\$
    – R White
    Commented Jul 24, 2018 at 19:36
  • \$\begingroup\$ Finally, sometimes it has an error - usually the first time I run or something. I wrapped the whole thing in a While loop and check the status bit on the error out. If there is an error I just re-run the whole thing (re-open the port, etc etc). \$\endgroup\$
    – R White
    Commented Jul 24, 2018 at 19:37
0
\$\begingroup\$

The Agilent devices require a somewhat esoteric form of flow control - DSR/DTR. You'll need to set that up before you can read data.

\$\endgroup\$
1
  • \$\begingroup\$ Can you please elaborate a bit on this "esoteric form of flow control". What needs to be setup? I have just put and tried on my pc flow control to hardware (there is no DSR/DTR option) and in putty terminal I set to DTR/DSR option. Still no response over RS232 from the multimeter. I will appreciate any reference to where I can find more data. \$\endgroup\$
    – balboa
    Commented Oct 19, 2017 at 15:59
0
\$\begingroup\$

The serial cable pin-out From:

34398A/99A RS-232 Cable Kit/Adapter Kit User's Guide

34398-90001.pdf

I remember wiring some of these up when I was in the same situation...

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ What code or program are you using to send/receive data? \$\endgroup\$ Commented Oct 19, 2017 at 16:02
  • \$\begingroup\$ I have all connections as in the figure above, except for the connection between the pin 9. I use PuTTY. \$\endgroup\$
    – balboa
    Commented Oct 19, 2017 at 16:15
0
\$\begingroup\$

In addition to insert a Line Feed after each command, I had to also set DTR (Data Terminal Ready) to be able to recieve any response.

\$\endgroup\$
0
\$\begingroup\$

Take a look at the linked document. See if the fetch? command returns anything similar to what the document shows. Also, check if your cable is wired the same as in the image on the last page. Using HyperTerminal with Agilent General Purpose Instruments

\$\endgroup\$
2
  • \$\begingroup\$ Fetch? command gives error -230: Data stale - a FETCh? command was received but internal reading memory was empty. I read out the error code on the display, and found description in the manual, still no response over RS232. \$\endgroup\$
    – balboa
    Commented Oct 19, 2017 at 15:56
  • \$\begingroup\$ I use null modem cable. All connections are as in the user manual, except the pin 9 (RI - ring indicator). At my cable I have it open, but I suppose this should not cause the issue. \$\endgroup\$
    – balboa
    Commented Oct 19, 2017 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.