Suchen Sie etwas anderes?
Scenario details:
- 2 sensors need to be monitored. An analog 0-10V sensor and a digital dry contact sensor
- The modem has 2 PLCs with Modbus RTU support connected to its RS485 port. One has the Modbus RTU @ 1 address and the other has the Modbus RTU @ 2 address.
- When changing the state of the dry contact sensor, which is connected to a digital input of the modem, the modem must write a value “1” in register 10 of the PLC @ 1 and PLC @ 2 in case the input and a “0” in case input is disabled
- When the analog sensor has a value> = 5000mV, the modem will write to register 20 of PLC @ 1 and PLC @ 2 a value of “2”. In case the analog input is <= 1000mV it will write a “0” in both registers and otherwise (between 1000mV and 5000mV) it will write a “1” in the Modbus registers of both PLCs
- In each digital event, the value of the digital and analog input must be sent to the MQTT broker
Solution: MTX-Tunnel firmware + MTX-IoT-S [4-N]
Configuration example (config.txt file) for the indicated scenario:
Details
- The configuration of the digital GPIO0 (where it is connected to the dry meter sensor) as “at; AT ^ MTXTUNNEL = EXECUTE, digitalon.txt; AT ^ MTXTUNNEL = EXECUTE, digitaloff.txt” indicates the following. Remember that all parameters are separated by semicolons ;
“At”> The input is configured to execute an AT command every time it changes state
“AT ^ MTXTUNNEL = EXECUTE, digitalon.txt”> The second parameter indicates the AT command that will be executed when the digital input is activated. In this case, the AT command script file is located in /atscripts/digitalon.txt
“AT ^ MTXTUNNEL = EXECUTE, digitaloff.txt”> The third parameter indicates the AT command to be executed when the digital input is deactivated. In this case, the AT command script file is located in /atscripts/digitaloff.txt
The file “digitalon.txt” will have the following content
The file “digitaloff.txt” will have the following content
The first two lines of this file write in register 10 of the PLCs with address @ 1 and address @ 2 a value of “1” in the first case (when the input is activated) and a “0” in the second case (when input is disabled).
The third line in both files executes an AT command that allows an MQTT message to be sent to the broker. NOTE that MTX-Tunnel substitutes the tags [GPIOx], [ADCx] and [COUNTERx] for ANY COMMAND AT with their corresponding values. In this case a JSON with the value of GPIO0 and current ADC0 is sent to the MQTT broker. - The configuration of the analog ADC0 (where it is connected to the 0-10V analog sensor) as “at; 1000; 5000; 100; AT ^ MTXTUNNEL = EXECUTE, analoglow.txt; AT ^ MTXTUNNEL = EXECUTE, analoghigh.txt; AT ^ MTXTUNNEL = EXECUTE, analognormal.txt ”indicates the following. Remember that all parameters are separated by semicolons;
“At”> The input is configured to execute an AT command when a certain condition occurs
“1000”> Minimum value from which the AT command of minimum value reached will be executed. In this case 1000mV
“5000”> Maximum value from which the AT command of maximum value reached will be executed. In this case 5000mV
“100”> Hysteresis. 100mV
“AT ^ MTXTUNNEL = EXECUTE, analoglow.txt”> AT command to be executed when the analog input is less than or equal to 1000mV. In this case, the AT command script file is run in /atscripts/analoglow.txt
“AT ^ MTXTUNNEL = EXECUTE, analoghigh.txt”> AT command to be executed when the analog input is greater than or equal to 5000mV. In this case, the AT command script file is located in /atscripts/analoghigh.txt
“AT ^ MTXTUNNEL = EXECUTE, analognormal.txt”> AT command to be executed when the analog input returns to a normal state between 1000V and 5000mV. In this case, the AT command script file is located in /atscripts/analognormal.txt
The file “analoglow.txt” will have the following content
The file “analoghigh.txt” will have the following content
El fichero “analognormal.txt” tendrá el siguiente contenido
These files write in register 20 of the PLCs with address @ 1 and address @ 2 a value of “2”, “0” or “1” according to the statement in this example - Note that MTX-Tunnel substitutes the tags [GPIOx], [ADCx] and [COUNTERx] for ANY COMMAND AT with their corresponding values. For example, the current value of the sensor connected to the ADC0 could be written to the PLCs @ 1 and @ 2. To do this, simply replace the value to write with the tag [ADC0], as shown in the following file: