Friday, 9 March 2012

Modbus RS232, RS485 and TCP/IP

There are 3 main physical layers for Modbus.
RS232 : One master and one slave. Typically a cable with 3 conductors with max length of approx a couple of hundred feet. Usually easy. Sometimes some jumpers are required at one end to defeat handshaking.

RS485: One master and up to 128 slaves but take care to read more if you plan on more than 32. There are two wiring systems – so called 2-wore and so called 4-wire. They can be incompatible but usually 4-wire devices can be made to work on 2-wire systems. Each device must have a unique address and all devices must be set to the same baud rate, data bits, stop bits and parity. Usually easy to implement. The RS485 physical layer allows up to 128 devices to be installed on a single network with a max physical length of 4000ft and speeds up to 115k baud. Using repeaters allows the length to be increased. Compare to Ethernet where the spec allows a max of 100 meters (330ft) on a single unrepeated segment.

TCP/IP: All devices are essentially peers. A single device can be a master and a server. Routers can be used to connect sub-nets together. Broadcasts are almost ever used so are not an issue.

Thursday, 8 March 2012

Modbus: Old device – slow processors – limited capability

Many older devices have old microprocessors that can't do too much work at once. Often this microprocessor is used to run the device and handle the Modbus communication.

It is not uncommon to see device with the following limitations.


  • You can only read one data point per message. I.e length must be 1.
  • You must have a delay between sending messages.

Wednesday, 7 March 2012

Modbus: What about errors / exceptions

Modbus & Gateways
 
Modbus has a limited way of reporting errors. A server / slave device can respond to a message in a way that reports an error.

These are called exception messages.

If you are looking at a message byte stream, exceptions are easy to identify.






Code     Name / Meaning
1           ILLEGAL FUNCTION

The function code received in the query is not an allowable action for the slave. If a Poll Program Complete command was issued, this code indicates that no program function preceded it.


2           ILLEGAL DATA ADDRESS

The data address received in the query is not an allowable address for the slave.

3           ILLEGAL DATA VALUE

A value contained in the query data field is not an allowable value for the slave.

4           SLAVE DEVICE FAILURE

An unrecoverable error occurred while the slave was attempting to perform the requested action.

5           ACKNOWLEDGE

The slave has accepted the request and is processing it, but a long duration of time will be required to do so. This response is returned to prevent a timeout error from occurring in the master. The master can next issue a Poll Program Complete message to determine if processing is completed.

6           SLAVE DEVICE BUSY

The slave is engaged in processing a long–duration program command. The master should retransmit the message later when the slave is free.

Tuesday, 6 March 2012

Floating Point Numbers in Modbus

Modbus was not designed to transport floating point numbers. After the protocol was released and in use – some people came up with a scheme to using two consecutive 16 bit registers to transport one floating point number. The scheme is essentially a set of rules for interpreting the bits in the 2x registers as the elements of a floating point number(like a mini protocol). Other people came up with other schemes.

One of these schemes has come to dominate. It is called standard IEEE754.

Some devices (servers) do not support floating point numbers.

Many clients (masters) do not support floating point numbers.

A master and a server must use the same floating point scheme to work together.
Read more in Appendix.

Scaling in Modbus

Monday, 5 March 2012

MODBUS - INTRODUCTION

Because it is so commonly used, because it is so limited, because some vendors went to a lot of trouble and because some vendors hired bad programmers, Modbus, as simple as it seems, can offer lots of complications. Modbus was invented to transfer data as well as to program/configure PLC’s. For the purposes of this article, we are only interested in the data transfer functions.

There are 4 types of data

Holding Registers

An area of 16 bit words. Intended as read / write. Originally used as programmer scratch pad area and for analog outputs in old Modicon PLC’s. Also known as 4xxxx registers (xxxx is the place holder for the specific holding register’s point number).

Input Registers


Think Analog inputs. 16 bit words.
Also known as 3xxxx registers (xxxx is the place holder for the specific input register’s point number).

Inputs


Think Binary inputs.
Also known as Inputs.
Also known as 1xxxx inputs (xxxx is the place holder for the specific input’s point number).

Coils

Think Binary outputs. Named coils after the coil in a relay which is activated to energize a circuit. The original PLC’s were relay replacement machines.
Also known as Outputs.
Also known as 0xxxx inputs (xxxx is the place holder for the specific input’s point number).


5 Digit VS 6 Digit Addressing

Friday, 2 March 2012

Helix Meters

These types of meters are made up of two radically pitched helical rotors which results in an axial liquid displacement from one side of the chamber to the other side. Both the rotors are geared together and there is a very small clearance between the rotors and the casing. 


Nutating-disk Meters

Thursday, 1 March 2012

Oval-gear Meters

These types of meters consist of two rotating, oval-shaped gears constructed with synchronized, close fitting teeth. In an oval gear meter, the rotation of gear shafts causes a fixed amount of liquid to pass through the meter. By monitoring the number of shaft rotations, one can calculate liquid flow rate. These types of meters prove to be very accurate when slippage between the housing and the gears is set very small. Turndown ratio of an oval gear meter gets influenced by the lubricating properties of the process fluid. 



Reciprocating Piston Meters