Gateway module for serial network Example Setup
The GATEWAY Module for serial network uses a script for data exchange to a partner Gateway. This article shows how to put this device into operation with an example setup.
GATEWAY Module for serial network
Articlenumber: 100068
GATEWAY Module for Modbus TCP
Articlenumber: 100088
Instructions
Download and install the following software
KUNBUS Scripter: https://www.kunbus.de/downloads.html
(or see attached ZIP)
PuTTY: https://www.putty.org/
QModMaster: https://sourceforge.net/projects/qmodmaster/
Connect the USB-PiBridge Plug with the Serial Gateway
Connect the 24V power supply. The power led should light green
Connect the PiBridge Plug via USB to your PC
Open the Scripter and load the script “ScriptExample_64Registers.pbs” see top of the page.
Go to File → Settings and enter the serial connection details
Download the script
//
// KUNBUS GmbH
// 07.08.2019
// Example Script for a Gateway Serial Rx Module.
//
// This script demonstrates how to receive and transfer
// a variable amount of up to 64 Registers (2Bytes) to a partner
// Gateway Module.
//
// We define a serial protocol as follows
//
// Byte | 1 | 2 | 3 | ... | 129 |
// -----+-----------+--------+--------+-----+----------+
// Desc | Registers | Byte 1 | Byte 2 | ... | Byte 128 |
//
// On the Partner Gateway Modbus-RTU the data is mapped as follows
//
// Reg. | 1025 | 1026 | 1027 | ... | 1091 |
// -----+--------+-----------+---------+-----+---------+
// Desc | Status | Registers | Word 1 | ... | Word 64 |
//
// Attention: Command "setMBReg(address, parameter);" writes
// the value in parameter in the register address. The parameter
// can be a constant, variable or an array. If the parameter an array is,
// must be the number of occupied bytes a multiple of 2.
SECTION_CONFIG;
configPort(115200, even, 1, 8); // Configrue the serial interface
// Baudrate, parity, StopBits, DataBits
setBigEndian(); // One register consists of two bytes big endian
decl(cRegisterCount, 1); // 1-byte variable as register counter
decl(cRxCnt, 1); // 1-byte variable as byte counter
declArray(aRxBuf, 128); // An array may consist of up to 128 bytes
decl(cStatus, 1); // 1-byte variable as cStatus
// '10' : no error
// '20' : the value of 'cRxCnt' is > 128
// '30' : an error occured and the execution jumps to SECTION_ERROR
// '40' : a fatal error occured and the execution jumps to SECTION_FATAL
SECTION_INIT;
if cStatus==0