Modbus Martem: Difference between revisions

From Phobos Wiki
Jump to navigation Jump to search
(Uus lehekülg: '== Addressing scheme == Telem Application Modbus function code enumeration: <pre> enum ModbusFunctionCodes { MODBUS_FN_UNSUPPORTED = 0x0, MODBUS_READ_COIL ...')
 
No edit summary
Line 1: Line 1:
== Addressing scheme ==
== Addressing scheme ==
=== Introduction ===
Modbus addressing scheme is separated in to the address and the function code.
=== Address ===
Modbus addresses are extracted from GWS column 'Obj. Addr. v' in the following way:
<pre>
if(100000 <= address)
    address %= 100000;
else
    address %= 10000;
</pre>
=== Function Code ===
==== Function Code enumeration ====


Telem Application Modbus function code enumeration:
Telem Application Modbus function code enumeration:
Line 18: Line 38:
</pre>
</pre>


Lower device addressing has small differences for input and output objects in Telem Application.
Function code extracting has small differences for input and output objects in Telem Application.
 
==== Input objects ====


Input objects function code is determined from the address in the following way:
Input objects function code is determined from the address in the following way:
Line 42: Line 64:
</pre>
</pre>


Note that ...
==== Digital output objects ====
 
Digital output function codes are determined by their 'SubType^' type in GWS:
 
<pre>
if( SubType^ == Single ) {
    return MODBUS_FORCE_SINGLE_COIL
} else {
    return MODBUS_FORCE_MULTIPLE_COIL
}
</pre>
 
 
==== Analog output objects ====
 
Analog output objects always use MODBUS_SET_SINGLE_REGISTER as function code.

Revision as of 06:18, 19 August 2016

Addressing scheme

Introduction

Modbus addressing scheme is separated in to the address and the function code.

Address

Modbus addresses are extracted from GWS column 'Obj. Addr. v' in the following way:

if(100000 <= address)
    address %= 100000;
else
    address %= 10000;


Function Code

Function Code enumeration

Telem Application Modbus function code enumeration:

enum ModbusFunctionCodes
{
    MODBUS_FN_UNSUPPORTED           = 0x0,
    MODBUS_READ_COIL                = 0x1,
    MODBUS_READ_INPUT               = 0x2,
    MODBUS_READ_HOLDING_REGISTERS   = 0x3,
    MODBUS_READ_INPUT_REGISTERS     = 0x4,
    MODBUS_FORCE_SINGLE_COIL        = 0x5,
    MODBUS_SET_SINGLE_REGISTER      = 0x6,
    MODBUS_FORCE_MULTIPLE_COIL      = 0xF,
    MODBUS_SET_MULTIPLE_REGISTER    = 0x10
};

Function code extracting has small differences for input and output objects in Telem Application.

Input objects

Input objects function code is determined from the address in the following way:

if(100000 <= address)
    fn_code = address / 100000;
else
    fn_code = address / 10000;

switch( fn_code )
{
case 0:
    return MODBUS_READ_COIL;
case 1:
    return MODBUS_READ_INPUT;
case 3:
    return MODBUS_READ_INPUT_REGISTERS;
default:
case 4:
    return MODBUS_READ_HOLDING_REGISTERS;
}

Digital output objects

Digital output function codes are determined by their 'SubType^' type in GWS:

if( SubType^ == Single ) {
    return MODBUS_FORCE_SINGLE_COIL
} else {
    return MODBUS_FORCE_MULTIPLE_COIL
}


Analog output objects

Analog output objects always use MODBUS_SET_SINGLE_REGISTER as function code.