LabVIEW drivers - Carlo Gavazzi WM14 power analyzer and Modbus
Carlo Gavazzi - WM14 power analyzer
The information provided by Carlo Gavazzi is a good starting point for creating a vi to control the WM14 power analyzer. The following text describes the requirements for controlling several power analyzers.
Making the connection
The WM14 can be connected to a PC trough a RS485 connection. Your PC should be equiped with a special add-on card or you should apply a RS232-to-RS485 converter. You can select either a 2 wire or a 4 wire connection. A proven connection is 2 wire with a 2 channel Advantech RS422/485 card.
Establishing the right protocol
The protocol the WM14 uses, is a subset of the Modbus protocol. The settings for the serial connection are as follows:
- baudrate 9600 (1200-38400),
- 8 databits,
- 1 stopbit and
- no pariy.
Commands and responses are allways followed by an error check. A command consists of:
- the address,
- the command number (usually 3 or 4, which both request information from the WM14 memory registers),
- the memory location to read from,
- the number of bytes to read (no more than 12) and
- an error check.
After sending the command the power analyzer will give the following responses:
- the address,
- the command number and
- the answer string containing the original command (echo).
The right address
Several power analyzers or modules can be connected to a single RS485 port when each module has been given an unique address. The modules can be given an address from 0 upto 255; the default address is 0.
The address can be changed with the front panel menu.
Library file containing:
returns the error-checking character used by the Modbus protocol
empties the serial port in case a previous return string was left unread
sends out the Modbus command and reads back the required number of characters (=return string). By default this vi uses COM4 to communicate.
global variable; correction factors for current and voltage values
returns the memory location, byte size and conversion method for a given variable
returns the unit and conversion factor for a given conversion method
returns the correction factors for current and voltage values for a given module
global variable; reference list with memory location, byte size and conversion method for all power analyzer variables
returns the reading for a given variable of a given module
global variable; list of units and conversion factors for all conversion methods
top-level vi; test program which allows to select any module and variable
Note: This library has been made with LabVIEW 6.1 Full Development System. It allows reading both 2 and 4 byte data.
Power management application for methanol factory.
Bart Boshuizen, 2006/04/05