1

I'm attempting to communicate with a Solartron 7060 Voltmeter through IEEE in LabVIEW. I have to convert some old C code that was originally used to communicate and cannot find a way to get out the main data from the Solartron.

Here is the C code:

#include "ieeeio.h"
#include <stdio.h>

double DATDVM(int dvmtime,int lasttime)
{
  float value;
  double Volt,volt;
  int j,response=0;

    if (lasttime!=dvmtime)
    {
      if (dvmtime<1)
      {
    if (ieeewt("clear 16\n")==-1) IEEEERR();
    if (ieeewt("abort\n")==-1) IEEEERR();
    if (ieeewt("output 16;D2F1M0R3\n")==-1) IEEEERR();
      }
      else
      {
    if (ieeewt("clear 16\n")==-1) IEEEERR();
    if (ieeewt("abort\n")==-1)  IEEEERR();
    if (ieeewt("output 16;D3F1M0R3\n")==-1)  IEEEERR();
      }
    }
    if (dvmtime<1)
    {
      if (ieeewt("abort\n")==-1)  IEEEERR();
      if (ieeewt("output 16;G\n")==-1)  IEEEERR();
      while (response != 24)
      {
    delay(50);
    if (ieeewt("spoll 16\n")==-1)  IEEEERR();
    if (ieeescnf("%d",&response)==-1) IEEEERR();
      }
      response=0;
      if (ieeewt("enter 16\n")==-1) IEEEERR();
      if (ieeescnf("%*5s%e",&value)==-1) IEEEERR();
      Volt=value;
    }
    else
    {
      volt=0;
      for (j=0; j<dvmtime; j++)
      {
    if (ieeewt("abort\n")==-1) IEEEERR();
    if (ieeewt("output 16;G\n")==-1) IEEEERR();
    while (response != 24)
    {
       delay(50);
       if (ieeewt("spoll 16\n")==-1) IEEEERR();
       if (ieeescnf("%d",&response)==-1) IEEEERR();
    }
    response=0;
    if (ieeewt("enter 16\n")==-1) IEEEERR();
    if (ieeescnf("%*5s%e",&value)==-1) IEEEERR();
    volt+=value;
      }
      Volt=volt/dvmtime;
    }
    return(Volt);
}

This code is sampling a DC voltage (from a faraday detector on an old mass spectrometer detected by an electrometer) at some integration time dvmtime in seconds. So as to tell the 7060 DVM to take a reading volt for a set integration time Dvmtime.

I have tried the following LabVIEW code, part of which I took from the .vi that controls a Solartron 7061 multimeter. In this code I'm sending D3F1MOR3, that comes from the ieeewt functions in the first block of the C code. However, I'm having trouble finding a function that is equivalent to ieeescnf in LabVIEW.

The first time I run the .vi it returns the correct voltage reading, then it returns 0 on the second run, and a large number on the third run. Also, the time it takes to run each varies substantially.

Any help would be appreciated, as I'm not sure exactly what this C code is doing at every stage.

LabVIEW .vi that I have tried so far

Jesse
  • 244
  • 2
  • 15

2 Answers2

1

ieeescnf() seems to be a read GPIB + scAnf() function, GPIB read should do the job.

You may want to take a look at the ScanFromString and the FormatIntoString function - LabVIEW format string differs from C:

https://zone.ni.com/reference/en-XX/help/371361R-01/glang/scan_from_string/

https://zone.ni.com/reference/en-XX/help/371361R-01/glang/format_into_string/

Taking a look at the LabVIEW GPIB documentation, you do not seems to be using the correct terminaison mode. '\n' terminaison in ieeewt should correspond to write mode 2 or 5, assuming your C library does not append additional characters :

http://zone.ni.com/reference/en-XX/help/371361R-01/lvinstio/gpib_write/

When poking not-yet-correctly-handled devices, it's perfectly normal to have variable responses times. Don't forget to reset your voltmeter between probing it with test commands, as errors may be carried over.

Dtty
  • 26
  • 1
  • 1
0

The instrument you are communicating with appears to support SCPI (plain-English commands) which helps things tremendously.

The first thing to try is to go into NI MAX (Measumrement and Automation Explorer) and simply type the commands you wish to send into the interactive communication control. Much easier than debugging in software, plus you can figure out things like what termination characters to use and how the instrument responds to your queries. Another way to get insight would be to use NI I/O Trace to sniff out the GPIB calls made by the original program and fully decipher the protocol that way.

Secondly, if you cannot find documentation for the device, write your own communication spec based on your debugging - list all the commands you intend to send, all the responses you expect back and the required timings.

Thirdly, implement the communications in LabVIEW. I strongly suggest using NI-VISA instead of low-level GPIB calls - NI-VISA abstracts out the physical interface and for IEEE instruments it's quite straightforward. Basic flow: VISA Open (initialization) -> VISA Read/VISA Write as required (main program loop) -> VISA Close (clean-up on close).

I think you're putting the cart before the horse a little bit by diving directly into the coding without understanding the implementation fully.

Adam Lawrence
  • 212
  • 1
  • 8
  • 16