Introduction
Protocol
C Program
An Application

Introduction

Picture of the DMM The "Micronta LCD Digital Multimeter" is a fairly nice 3 1/2 digit multimeter (DMM) with an RS-232 output to report the readings. The older unit (pictured) has part number 22-182 and the newer unit has part number 22-168. The catalog list price is $129.99 but it goes on sale for $100 or $110 once in a while. The older DMM features :

Picture of the cable The DMM has a 5 pin in-line connector for the RS-232 output. A supplied cable has the mating 5 pin plug on one end and a female 9 pin D connector on the other end. The cable is configured as a DCE so it can plug directly into a PC serial port.

Other DMMs with RS-232 are available. Jameco catalog #942 lists four of them; one by Protek and three by Metex. The Techni-Tool catalog #58 lists an Extech DMM which has a serial interface.

 

Protocol

It looks like the DMM uses RTS and DTR to power the serial port. DTR needs to be set to +12 volts and RTS must be set to -12 volts. The port should be configured for 7 data bits, no parity, and two stop bits (7,N,2) at 1200 baud. Take a reading by sending a "D" character to the DMM and then read characters from the serial port until a carriage return is found. The format of the returned data is a 13 character line terminated by a carriage return.
Byte)  12345678901234
Ex.1)  DC-1.9999 V  CR
Ex.2)     1.9999MohmCR

 

C Program

The following C program takes a reading every 60 seconds.

/*
 * Name: dvm
 *
 * Description:
 *      A simple program to read a value from the Radio Shack
 *      digital multimeter every 60 seconds.
 *
 * Example:
 *      dvm /dev/tty02 > readings
 *
 */

#include <stdio.h>
#include <termio.h>
#include <sys/fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>

int main (int argc, char *argv[])
{
    int        m;        /* modem control lines */
    int        fd_dev;   /* FD for the open serial port */
    char       c;        /* char received from the DMM */
    struct  termios    tbuf;  /* serial line settings */

    if (argc != 2) {
        printf("Usage: %s [tty port]\n", argv[0]);
        exit(1);
    }

   if (( fd_dev = open(argv[1], O_RDWR, 0)) < 0 ) {
        printf("Unable to open tty port specified\n");
        exit(1);
    }

    /* set up the line parameters : 7,2,N */
    tbuf.c_cflag = CS7|CREAD|CSTOPB|B1200|CLOCAL;
    tbuf.c_iflag = IGNBRK;
    tbuf.c_oflag = 0;
    tbuf.c_lflag = 0;
    tbuf.c_cc[VMIN] = 1; /* character-by-character input */
    tbuf.c_cc[VTIME]= 0; /* no delay waiting for characters */
    if (tcsetattr(fd_dev, TCSANOW, &tbuf) < 0) {
        printf("%s: Unable to set device '%s' parameters\n",argv[0], argv[1]);
        exit(1);
    }

    /* Set DTR (to +12 volts) */
    m = TIOCM_DTR;
    if (ioctl(fd_dev, TIOCMSET, &m) < 0) {
        printf("%s: Unable to set '%s' modem status\n",argv[0], argv[1]);
        exit(1);
    }

    while (1) {
        write(fd_dev,"D", 1);
        do {
            read(fd_dev, &c, 1);
            write(1, &c, 1);
        } while (c != '\r');
        write(1, "\n", 1);
        sleep(60);
    }
    /* This program is rude in that it does not restore the */
    /* serial line parameters on exit. */

    exit(0);
}

 

An Application

Renewal Discharge Curve We use the Radio Shack DMM and the above program to measure the discharge curves for several AAA batteries. We tested two batteries in series with a load of 33 ohms. The batteries tested include Energizer, Duracell, Radio Shack, and Renewal. We use various Linux tools to format the data and we use gnuplot to build the actual plot images.
Click Energizer or Duracell ? for the full report.