Suchen Sie etwas anderes?
Scenario details:
- We have a PLC Modbus RTU. In its internal memory this PLC contains a number of variables/registers (for example, one temperature and three counters,…) which should be read and sent periodically to Web server
- Therefore, MTX-Tunnel should request periodically (every 15 minutes) the PLC through a serial port in order to read the above mentioned registers. The registers to be read are temperature with register number 20, and the counters’ registers 21, 22 and 23 respectively
- After each reading MTX-Tunnel will send the register’s value to a Web server via HTTP GET using a JSON object, but it should be able, in case of 2G/3G/4G communications failure, to store in flash memory up to 1500 readings that will be sent off when the communications are restored
- At any moment it should be possible to establish a IP-RS485 gateway to directly access Modbus registers of PLC. Additionally this gateway will be used for updating the firmware of PLC when needed
Solution: MTX-Tunnel firmware + MTX-Java-IoT/MTX-Java-T/MTX-Java-T2
EXAMPLE of settings (file config.txt) for such scenario:
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: server 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.8 MTX_rssiLevel: 10 MTX_serverTimeout: 300 TCP_port: 0 TCP_port2: 20011 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_port: 20023 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 Gateway created 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 Socket closes if there’s no traffic in 300 secs. Disabled gateway Secondary serial port gateway active in 20011 SMS with commands can be sent from any phone Modem replies with its IP to a missed call or SMS 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 We enable MTX logger to store the records Field to identify the origin of the frames URL to send the JSON with data The size of internal registry of MTX Maximum number of records in MTX Sending mode HTTP GET (JSON) Modbus address to be read Initial modbus register address to be read N. of records read from each device Reading command Period in seconds within which a reading is done |
Details:
- This scenario is only recommended from firmware MTX-Tunnelv 9.18
- The process is as follows: MTX independently reads Modbus registers of the PLC every 900 seconds via RS485 port. After being read, the registers are stored in MTX modem’s internal memory.If there is 2G/3G/4G coverage, the modem will send the register to the configured Web server.If not, they will be sent later when there is 2G/3G/4G again
- Any moment it is possible to carry out a real-time reading of Modbus registers of the PLC from a Control PC, or update the PLC firmware. To do this task, a IP-RS485 transparent gateway is configured through TCP20011 port. When a connection to the port is established (and due to that the IP-RS485 is established), the internal process of MTX modem responsible for interval reading (every 900 seconds) of PLC Modbu registers will be temporarily suspended (to avoid collisions in RS485 bus). This way it is possible to access RS485 port of the PLC directly to carry out a real-time reading of the PLC registers or update its software. When the IP-RS485 gateway established in TCP 20011 is closed, the internal process of MTX modem is resumed, which allows again reading PLC registers every 900 seconds
- With the parameter TCP_port2: 20011 modem opens a socket server in the TCP port 20011 to be able to establish a IP-serial gateway of the secondary serial port of MTX modem; in this case it is RS485 port. TCP_port: 0 parameter does not configure any server socket associated with the main serial port, because we don’t need it
- It is strongry recommended to set a value in the configuration parameter MTX_serverTimeout for this example. Otherwise, if a gateway is established in the port TCP 20011 and when finished working it does not close the connection correctly (for example, unexpected connection failure because of the lack of power supply of the Control PC, Ethernet cable extraccion,..), the modem will not resume the reading process every 900 seconds. The timeout corresponding to 300 set in the parameter MTX_serverTimeout makes it possible that if gateway disconnection in the port TCP20011 goes wrong, the modem will close the connection in the port automatically after 300 seconds (5 minutes) without traffic, and the reading process will be resumed • Si desde el PC de control quiere realizar una pasarela Modbus TCP a Modbus RTU (en lugar de la pasarela Modbus RTU sobre TCP configurada en este ejemplo), puede añadir el parámetro MTX_gatewayModbus: on
- If you want to establish, from the Control PC, a Modbus TCP to Modbus RTU gateway (instead of Modbus RTU over TCP as show this example), you can add the parameter MTX_gatewayModbus: on
- JSON object sent to the URL specified in LOGGER_server is encoded the following way:
{“IMEI”:353234028103206,”P”:”ID00001”,”TYPE”:”MODB”,”A”:1,”TS”:”20/08/12 08:31:44”,”ST”:20,”V1”:23,”V2”:275,”V3”:274,”V4”:32765}
That means Web server receives a JSON object with modem’s IMEI, a password field (P) that can be also used to identify the device (if you do not want to use IMEI), device modbus address (A), time stamp (TS) of when modbus data was read, the initial address read (ST) and V1,V2,… with each variable read.
- Remember that the modem used in the given example has 2 serial ports: the main port(RS232) and the secondary port (RS232 or RS485). To configure the secondary port RS485 you should set miscroswitch 2 in “ON”, as it is shown in the Annex A of this manual