I am trying to query a 24-year-old, scrapped power meter via RS-232C port with ModBUS/ASCII protocol. And to be a challenge: without external ready-made functions, with direct hardware access, in real mode, with Turbo Pascal, on an old DOS machine.I. The device
The device to be tested was manufactured by the Hungarian DATCON Ipari Elektronikai Kft. in the 90s. The company was founded even before the regime change, in 1982, and has been working in the field of industrial electronics ever since.
The device type is DT510. This is a single-phase electrical power meter. Made in several versions, this uses RS-232C serial connection and ModBUS/ASCII protocol for communication. In addition, it has three configurable analog outputs.
The connection of the device is included in its datasheet.
- Urms: effective voltage in V
- Irms: effective current in A
- P: active power in W
- Q: reactive power in VAr
- S: apparant power in VA
- Wp: active power demand in Wh
- Wq: reactive power demand in VArh
- Ws: apparant power demand in VAh
- cosFi power factor
- TPF: technical power factor
The device can be set with its own setting program via serial port.
The datasheet of the device and the adjustment program can be found in the attached materials.II. Monitoring tool
The number of tasks that can be run simultaneously on DOS (1) did not allow live monitoring of the data traffic of the serial line.
Its operation is very simple: The data of the line selected with Sw1 can be observed on the computer connected to the Out A port when inserted into the serial line. The LEDs show the current logic level of the lines. With Sw2, the RXD and TXD lines of the Out B port can be replaced according to the needs of the connected device.
The schematic can be found in the attached materials. (OrCAD/SDT III v3.21  format and PostScript format.)
The device can be attached to a DIN rail with the help of the fastener mounted on the bottom.
The cables connected to the PC and the Out B port are straight modem cables. The cable connected to the Out A port is a null-modem cable. Only RXD, TXD and GND are soldered in each cable.
How to use?
The control computer must be connected to the PC port, the monitoring computer must be connected to the Out A port, and the device must be connected to the Out B port.
ModBUS/ASCII traffic can also be monitored with a simple serial terminal (e.g. Telix, Minicom), but it is more convenient to use a special program for this (e.g. CleverTerm).III. Software
The program was written in Turbo Pascal. The source code consists of the main program and three additional units.
Unserial.pas: this unit contains the routines that manage the serial port. The port is managed by the BIOS INT 14H interrupt. It uses the serial port interrupt to indicate received data and to read it.
Unmodbus.pas: this unit is responsible for data transfer according to the ModBUS/ASCII protocol. Only reading the holding register (Function code: 3) was implemented in the unit, because the others were not needed now. The unit stores the values of all possible (9999) holding registers. These can be referred to by the register number. It also includes the Longitudinal Redundancy Check (LRC) calculator.
Undt510.pas: this unit is responsible for converting the received raw values into real values.
After the program starts, it sets the operating parameters of the COM1 serial port and then sends the data request.
The received response telegram is processed by the program, the measured values are converted, and then all are displayed in raw and real values.