Suchen Sie etwas anderes?
Scenario details:
- We want to read 12 modbus registers from a PLC
- 10 registers are binary and and the other 2 are word. It is necessary to use the modbus command 0x01 to read binary registers and the 0x03 modbus command to read word registers. Binary registers are in the addresses 10,11,12, … 17 and Word registers are in the addresses 100,101
- We want to inform the web platorm about about the register type. For this reason we will use the parameter MODBUS_custom. Data will be read every 60 seconds
- The web platform is protected with a Login and Password, so the Logger needs to be configured in security mode (LOGGER_serverLogin, Logger_serverPassword)
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: 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.8 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_serverLogin: miUsuario LOGGER_serverPassword: miPassword LOGGER_httpMode: getjson MODBUS_address: 1;1 MODBUS_start: 10;100 MODBUS_numwords: 10;2 MODBUS_period: 60 MODBUS_readCommand: 1;3 MODBUS_custom: BIN;WORD |
Serial port baud rate Number of bits No flow control No flow control 1 stop bit No parity APN GPRS provided by the GSM operator GPRS Login GPRS Password Modem is always GPRS connected SIM Card PIN Not using gateway 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 All phone numbers are authorized IP sent to phone which called or “on” SM Send commands to MTX by SMS Modem response to AT command with SMS Any IP will be able to connect to the modem Telnet is activated Telnet login Telnet password To connect to MTX from any IP 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 Web platform login The password of the web platform HTTP GET (JSON) mode ModBus addresses of sensors to be read Initial addresses of each meter Number of records read from each meter Frequency of readings in seconds Read commands 0x01 and 0x03 User custom strings |
Details:
- Examples of JSON received by the web platform:
- To read Words:
{“IMEI”:353234028104337,”TS”:”02/03/14 10:15:51”,”TYPE”:”MODB”,”C”:”WORD”,”A”:2,”ST”:100,”V1”:77,”V2”:88 }
- To read Binary:
{“IMEI”:353234028104337,”TS”:”02/03/14 16:32:00”,”TYPE”:”MODB”,”C”:”BIN”,”A”:1,”ST”:10,”NB”:10,”V1”:85,”V2”:3 }
- Note that in the case of reading binary registries these are returned grouped into byte-type registries (2 bytes, 8 bits, 2 bits). That is, the value of the binary register of address 10 would be in bit0 of V1, the value of the address registry 17 in bit 7 of V1, the address register 18 would be in bit 0 of V2 and the address register value 19 would be in bit1 of V2. In the previous case, the Custom variable is used to indicate that the records are of type Binary. Note that in the case of reading binaries also appears the variable NB, which indicates the number of bits read.
- Remember that the modem model used in this example has 2 serial ports. The main port (RS232) and the secondary port (RS232 or RS485) used in this example. To configure the secondary port as RS485 you must set the microswitch 2 “ON” as shown in Annex A of this manual