Tunnel – PLC Modbus RTU periodically registers readings, sends them as a JSON object to webserver

¿Buscas alguna otra cosa?

Scenario details:

  • There is a Modbus RTU PLC. This PLC records some variables such as temperature, pulses, etc. in their register memory table from external devices connected to it. We need to read them and send them to a WebServer
  • MTXTunnel will connect every 15 minutes to the PLC serial port. The number for storing temperature is number 20. Pulse counters are stored in registers table number 21, 22 and 23
    respectively
  • MTXTunnel will get all data values and convert them to JSON objects in order to send them to a WebServer using HTTP GET procedure. In case the 2G/3G/4G network or server fails, it needs to store up to 1500 readings in MTX-Tunnel’s non volatile internal memory and then it can retry communicating later on
  • You also need to be able to access the PLC at any time in order to read the register values in real time or write/change any of PLC’s configuration parameters

Solution: MTX-Tunnel firmware + MTX-Java-IoT/MTX-Java-T/MTX-Java-T2

Config.txt configuration file:

Configuration Observations
COMM2_baudrate: 9600
COMM2_bitsperchar: 8
COMM2_autorts: off
COMM2_autocts: off
COMM2_stopbits: 1
COMM2_parity: none
GPRS_apn: movistar.es
GPRS_login: MOVISTAR
GPRS_password: MOVISTAR
GPRS_timeout: 0
MTX_PIN: 0000
MTX_mode: none
MTX_model: MTX-4G-JAVA-IOT-STD-N
MTX_portAux: modbusmaster
MTX_TPProtocol: ntp
MTX_TPServer: ntp.roa.es
MTX_TPServer2: es.pool.ntp.org
MTX_ping: 35
MTX_pingIP: 8.8.8.8MODBUS_period: 900
MTX_rssiLevel: 10
SMS_allPhones: on
SMS_sendIP: on
SMS_ATEnabled: on
SMS_ATResponse: on
FIREWALL_enabled: off
TELNET_enabled: on
TELNET_login: user
TELNET_password: 1234
TELNET_firewall: off
LOGGER_enabled: on
LOGGER_password: ID00001
LOGGER_server: www.miservidorWeb.com/json.asp?data=
LOGGER_registerSize: 300
LOGGER_numRegistersFlash: 1500
LOGGER_httpMode: getjson
MODBUS_address: 1
MODBUS_start: 20
MODBUS_numwords: 4
MODBUS_readCommand: 3
MODBUS_period: 900
Serial port baud rate
Number of bits
No flow control
No flow control
1 stop bit
No parity
APN GPRS from your network operator
GPRS Login
GPRS Password
Modem is always GPRS connected
SIM Card PIN
MTX-Tunnel mode
MTX modem model
AUXILIAR COM port used as master modbus
Time synch. protocol
Time server
Backup time server
Ping every 35 minutes without comms
IP address to ping
Coverage LED activated
All phone numbers are authorized
IP sent to phone which called or “on” SM
Remote AT commands by SMS enabled
Modem response to AT command with SMS
Any IP will be able to connect to the modem
Telnet is activated
Telnet login
Telnet password
Telnet port 20023
We enable the MTX Logger, to store the records
Password field can be used as ID device
Server URL, will receive JSON data
Register size
Maximum number of records in MTX
HTTP GET (JSON) mode
ModBus equipment address
ModBus register address to be read
Number of registers read
Reading command
Timing -seconds- read is repeated

Details:

  • MTX-4G-JAVA-IOT-STD-N modem is used if the PLC port is the RS485 type, but MTX-4G-JAVA-IOTSTD-N-RS232 terminals are more suitable if PLC has the RS232 port
  • Procedure:
    • Every 15 minutes the modem reads a series of PLC ModBus records. They are translated to JSON objects and sent to a WebServer. WebServer URL is configured in LOGGER_server parameter.
    • In the event of there being no coverage in GPRS link or the server is down, MTX-Tunnel stores data in the internal FLASH memory.
    • Using TELNET, it is possible to remotely access the system and read or write any PLC records, readings or configuration parameters. Use the AT^MTXTunnel=getmodbus and AT^MTXTUNNEL=setmodbus commands.
    • The JSON object data sent to the server has following syntax:
{“IMEI”:353234028103206,”P”:”ID00001”,”TYPE”:”MODB”,”A”:1,”TS”:”20/08/12 08:31:44”,”V1”:23,”V2”:275,”V3”:274,”V4”:32765}
IMEI Modem’s IMEI identifier
P Password user definable field
TYPE data type
A ModBus address
TS Timestamp
Vx Variables read

NOTE: You can also develop an easy modbusTCP/modbusRTU gateway as explained in example “Modbus TCP/Modbus RTU GPRS gateway