Hello! I bring good news.
First I will answer:
- The idea I have when the bus goes into an error is to detect an error and set a waiting time to re-establish communication and to initialize again. I'm still working on this.
- I have the second bus already implemented and working. It is a new physical bus with a new USB-RS485 adapter.
Right now I have a bus that reads the 6 digital input modules at maximum speed and another bus in which I send a query every second. In addition, the second I use to activate relays.
The implementation of the activation of the relays, I'm working on it. What I don't like is that I have 128 relays and I have to attack them all separately. When I get this a bit advanced, I'll post.
[{"id":"209e05d933581382","type":"modbus-flex-getter","z":"3c3fa1ce28c0ce43","name":"Modbus Flex Getter - 1RS485","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"08eb64dc3971b8b1","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":true,"x":390,"y":220,"wires":[["30118cbab3c92f77","bb51eba97298343e","c137dda295101019","e1842eb601f14288","5e5d40d9a78cb6bd","897e047a478e3289","4a34ecc0f0856934","13fb93f070716b95"],[]]},{"id":"39dcb638ca6b4444","type":"inject","z":"3c3fa1ce28c0ce43","name":"begin","props":[{"p":"payload"},{"p":"queueUnitId","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":130,"y":380,"wires":[["0c5c2847fd3d0222"]]},{"id":"30118cbab3c92f77","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg modbus","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":200,"y":120,"wires":[]},{"id":"0c5c2847fd3d0222","type":"function","z":"3c3fa1ce28c0ce43","name":"","func":"if (!(msg.hasOwnProperty('payload'))) {\n return null;\n}\nvar count;\nif (msg.payload == \"\") {\n count = msg.queueUnitId + 1;\n} else {\n if (msg.modbusRequest.unitid < 6) {\n count = msg.modbusRequest.unitid + 1;\n }\n else {\n count = 1;\n }\n}\nmsg.payload = {\n 'fc': 2,\n 'unitid': count,\n 'address': 0,\n 'quantity': 16\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":380,"wires":[["209e05d933581382","1562a609b2da1bf5"]]},{"id":"1562a609b2da1bf5","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg function","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":500,"y":420,"wires":[]},{"id":"bb51eba97298343e","type":"debug","z":"3c3fa1ce28c0ce43","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"modbusRequest.unitid","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":120,"wires":[]},{"id":"c137dda295101019","type":"delay","z":"3c3fa1ce28c0ce43","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":170,"y":320,"wires":[["0c5c2847fd3d0222"]]},{"id":"dc4dba8ce161f3cd","type":"modbus-flex-getter","z":"3c3fa1ce28c0ce43","name":"Modbus Flex Getter - 2RS485","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"1d30ba62236b3eda","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":true,"x":250,"y":700,"wires":[["701f1c6b7856e43a","429761f113c4adb6","b94b862430a7c92e","8c57e745311051c8","6441e4ef2e6ac351","205fa9e97151872c","6e3172a083fca2a5","cdeaf13b136f4ddc","30f6c45f24961eae"],[]]},{"id":"701f1c6b7856e43a","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg modbus","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":540,"y":560,"wires":[]},{"id":"c3607d8d6f797d28","type":"function","z":"3c3fa1ce28c0ce43","name":"","func":"if (isNaN(msg.counter++)){\n msg.counter = 11;\n}\n\n//Incrementar comptador\nmsg.counter++;\n\n//Comprovació comptador dins de límits i ajustament\nif (msg.counter < 2) {\n msg.counter = 2;\n}\n\nif ((msg.counter >= 3) && (msg.counter < 11)) {\n msg.counter = 11;\n}\n\nif (msg.counter >= 16) {\n msg.counter = 2;\n}\n\n//Lectura inputs WELLPRO WP3082ADAM - Analògics\nif (msg.counter == 2){\n msg.payload = {\n 'fc': 3,\n 'unitid': msg.counter,\n 'address': 0,\n 'quantity': 8\n };\n}\n\n//Lectura sensors SHT20 (Temperatura i humitat)\nif ((msg.counter >= 11) && (msg.counter <= 15)) {\n msg.payload = {\n 'fc': 4,\n 'unitid': msg.counter,\n 'address': 1,\n 'quantity': 2\n };\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":880,"wires":[["dc4dba8ce161f3cd","5be9684544644059"]]},{"id":"429761f113c4adb6","type":"debug","z":"3c3fa1ce28c0ce43","name":"","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"modbusRequest.unitid","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":600,"wires":[]},{"id":"30f6c45f24961eae","type":"delay","z":"3c3fa1ce28c0ce43","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":180,"y":820,"wires":[["c3607d8d6f797d28"]]},{"id":"1efd5499a5b7c7ac","type":"comment","z":"3c3fa1ce28c0ce43","name":"Lectura inputs a baixa velocitat (sensors, relés, ...)","info":"","x":230,"y":560,"wires":[]},{"id":"ffdc63fbb4130d4c","type":"comment","z":"3c3fa1ce28c0ce43","name":"Lectura inputs a alta velocitat (pulsadors)","info":"","x":220,"y":40,"wires":[]},{"id":"6150ceeef4ee62b9","type":"inject","z":"3c3fa1ce28c0ce43","name":"begin","props":[{"p":"payload"},{"p":"counter","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":880,"wires":[["c3607d8d6f797d28"]]},{"id":"70081fa2f327012a","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg1","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":560,"wires":[]},{"id":"fc72bb501a3c1949","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg2","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":600,"wires":[]},{"id":"b94b862430a7c92e","type":"function","z":"3c3fa1ce28c0ce43","name":"get-Temp-n11","func":"if (msg.modbusRequest.unitid == 11) {\n var msg1 = {};\n var msg2 = {};\n msg1.payload = msg.payload[0];\n msg2.payload = msg.payload[1];\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":640,"wires":[["70081fa2f327012a"],["fc72bb501a3c1949"]]},{"id":"8c57e745311051c8","type":"function","z":"3c3fa1ce28c0ce43","name":"get-Temp-n12","func":"if (msg.modbusRequest.unitid == 12) {\n var msg1 = {};\n var msg2 = {};\n msg1.payload = msg.payload[0];\n msg2.payload = msg.payload[1];\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":680,"wires":[["7d3e8ecd36d04889"],["ad41f44073b2a36c"]]},{"id":"6441e4ef2e6ac351","type":"function","z":"3c3fa1ce28c0ce43","name":"get-Temp-n13","func":"if (msg.modbusRequest.unitid == 13) {\n var msg1 = {};\n var msg2 = {};\n msg1.payload = msg.payload[0];\n msg2.payload = msg.payload[1];\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":720,"wires":[["91eb46501a328c84"],["b77fe990b5e81867"]]},{"id":"205fa9e97151872c","type":"function","z":"3c3fa1ce28c0ce43","name":"get-Temp-n14","func":"if (msg.modbusRequest.unitid == 14) {\n var msg1 = {};\n var msg2 = {};\n msg1.payload = msg.payload[0];\n msg2.payload = msg.payload[1];\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":760,"wires":[["b88a0aa9a3340e0f"],["278b216f0fa39052"]]},{"id":"6e3172a083fca2a5","type":"function","z":"3c3fa1ce28c0ce43","name":"get-Temp-n15","func":"if (msg.modbusRequest.unitid == 15) {\n var msg1 = {};\n var msg2 = {};\n msg1.payload = msg.payload[0];\n msg2.payload = msg.payload[1];\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":800,"wires":[["06796e1aa2d5471a"],["b35d2db345465c62"]]},{"id":"7d3e8ecd36d04889","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg1","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":640,"wires":[]},{"id":"ad41f44073b2a36c","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg2","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":680,"wires":[]},{"id":"91eb46501a328c84","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg1","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":983,"y":719,"wires":[]},{"id":"b77fe990b5e81867","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg2","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":983,"y":759,"wires":[]},{"id":"b88a0aa9a3340e0f","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg1","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":800,"wires":[]},{"id":"278b216f0fa39052","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg2","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":840,"wires":[]},{"id":"06796e1aa2d5471a","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg1","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":880,"wires":[]},{"id":"b35d2db345465c62","type":"debug","z":"3c3fa1ce28c0ce43","name":"msg2","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":920,"wires":[]},{"id":"5be9684544644059","type":"debug","z":"3c3fa1ce28c0ce43","name":"","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":920,"wires":[]},{"id":"cdeaf13b136f4ddc","type":"function","z":"3c3fa1ce28c0ce43","name":"get-Analog-n2","func":"/*if (msg.modbusRequest.unitid == 2) {\n var msg1 = {};\n msg1.payload = msg.payload[0];\n return (msg1);\n}*/\n\nif (msg.modbusRequest.unitid == 2) {\n var msg1 = {};\n var msg2 = {};\n var msg3 = {};\n var msg4 = {};\n var msg5 = {};\n var msg6 = {};\n var msg7 = {};\n var msg8 = {};\n msg1.payload = msg.payload[1];\n msg2.payload = msg.payload[2];\n msg3.payload = msg.payload[3];\n msg4.payload = msg.payload[4];\n msg5.payload = msg.payload[5];\n msg6.payload = msg.payload[6];\n msg7.payload = msg.payload[7];\n msg8.payload = msg.payload[8];\n return ([msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8]);\n}","outputs":8,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":880,"wires":[[],[],[],[],[],[],[],[]]},{"id":"e1842eb601f14288","type":"function","z":"3c3fa1ce28c0ce43","name":"get-inputs-n1","func":"if (msg.modbusRequest.unitid == 1) {\n var arr = msg.payload;\n var byte1 = (arr[0] * 1) + (arr[1] * 2) + (arr[2] * 4) + (arr[3] * 8) + (arr[4] * 16) + (arr[5] * 32) + (arr[6] * 64) + (arr[7] * 128);\n var byte2 = (arr[8] * 1) + (arr[9] * 2) + (arr[10] * 4) + (arr[11] * 8) + (arr[12] * 16) + (arr[13] * 32) + (arr[14] * 64) + (arr[15] * 128);\n var msg1 = {};\n var msg2 = {}; \n msg1.payload = byte1;\n msg2.payload = byte2;\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":120,"wires":[["a535adb9eb67b31a"],["e4468ea70a523297"]]},{"id":"a535adb9eb67b31a","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs1.1","miniserver":"c04ca4d6caa1d5c9","control":"19f40e56-0072-ee50-ffff6fc206f2b7bf","x":980,"y":100,"wires":[]},{"id":"e4468ea70a523297","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs1.2","miniserver":"c04ca4d6caa1d5c9","control":"19f40e7b-0047-1d6c-ffff6fc206f2b7bf","x":980,"y":140,"wires":[]},{"id":"5283b5f6cd6c0016","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs2.2","miniserver":"c04ca4d6caa1d5c9","control":"19f41951-00b4-8dc5-ffff6fc206f2b7bf","x":980,"y":220,"wires":[]},{"id":"5e5d40d9a78cb6bd","type":"function","z":"3c3fa1ce28c0ce43","name":"get-inputs-n2","func":"if (msg.modbusRequest.unitid == 2) {\n var arr = msg.payload;\n var byte1 = (arr[0] * 1) + (arr[1] * 2) + (arr[2] * 4) + (arr[3] * 8) + (arr[4] * 16) + (arr[5] * 32) + (arr[6] * 64) + (arr[7] * 128);\n var byte2 = (arr[8] * 1) + (arr[9] * 2) + (arr[10] * 4) + (arr[11] * 8) + (arr[12] * 16) + (arr[13] * 32) + (arr[14] * 64) + (arr[15] * 128);\n var msg1 = {};\n var msg2 = {}; \n msg1.payload = byte1;\n msg2.payload = byte2;\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":200,"wires":[["d0f489a34622a3d5"],["5283b5f6cd6c0016"]]},{"id":"d0f489a34622a3d5","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs2.1","miniserver":"c04ca4d6caa1d5c9","control":"19f41950-001b-8672-ffff6fc206f2b7bf","x":980,"y":180,"wires":[]},{"id":"8d46a9ee02206c0e","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs3.2","miniserver":"c04ca4d6caa1d5c9","control":"19f41952-023c-9c74-ffff6fc206f2b7bf","x":980,"y":300,"wires":[]},{"id":"897e047a478e3289","type":"function","z":"3c3fa1ce28c0ce43","name":"get-inputs-n3","func":"if (msg.modbusRequest.unitid == 3) {\n var arr = msg.payload;\n var byte1 = (arr[0] * 1) + (arr[1] * 2) + (arr[2] * 4) + (arr[3] * 8) + (arr[4] * 16) + (arr[5] * 32) + (arr[6] * 64) + (arr[7] * 128);\n var byte2 = (arr[8] * 1) + (arr[9] * 2) + (arr[10] * 4) + (arr[11] * 8) + (arr[12] * 16) + (arr[13] * 32) + (arr[14] * 64) + (arr[15] * 128);\n var msg1 = {};\n var msg2 = {}; \n msg1.payload = byte1;\n msg2.payload = byte2;\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":280,"wires":[["29f33b03494ee7da"],["8d46a9ee02206c0e"]]},{"id":"29f33b03494ee7da","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs3.1","miniserver":"c04ca4d6caa1d5c9","control":"19f41951-02b4-951b-ffff6fc206f2b7bf","x":980,"y":260,"wires":[]},{"id":"611e447cc3908d9a","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs4.2","miniserver":"c04ca4d6caa1d5c9","control":"19f4197d-0316-0373-ffff6fc206f2b7bf","x":980,"y":380,"wires":[]},{"id":"4a34ecc0f0856934","type":"function","z":"3c3fa1ce28c0ce43","name":"get-inputs-n4","func":"if (msg.modbusRequest.unitid == 4) {\n var arr = msg.payload;\n var byte1 = (arr[0] * 1) + (arr[1] * 2) + (arr[2] * 4) + (arr[3] * 8) + (arr[4] * 16) + (arr[5] * 32) + (arr[6] * 64) + (arr[7] * 128);\n var byte2 = (arr[8] * 1) + (arr[9] * 2) + (arr[10] * 4) + (arr[11] * 8) + (arr[12] * 16) + (arr[13] * 32) + (arr[14] * 64) + (arr[15] * 128);\n var msg1 = {};\n var msg2 = {}; \n msg1.payload = byte1;\n msg2.payload = byte2;\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":360,"wires":[["7835a2118d42ff32"],["611e447cc3908d9a"]]},{"id":"7835a2118d42ff32","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs4.1","miniserver":"c04ca4d6caa1d5c9","control":"19f41953-0318-a3d0-ffff6fc206f2b7bf","x":980,"y":340,"wires":[]},{"id":"fe6f251a1b85df90","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs5.2","miniserver":"c04ca4d6caa1d5c9","control":"19f4197e-02b6-123a-ffff6fc206f2b7bf","x":980,"y":460,"wires":[]},{"id":"13fb93f070716b95","type":"function","z":"3c3fa1ce28c0ce43","name":"get-inputs-n5","func":"if (msg.modbusRequest.unitid == 5) {\n var arr = msg.payload;\n var byte1 = (arr[0] * 1) + (arr[1] * 2) + (arr[2] * 4) + (arr[3] * 8) + (arr[4] * 16) + (arr[5] * 32) + (arr[6] * 64) + (arr[7] * 128);\n var byte2 = (arr[8] * 1) + (arr[9] * 2) + (arr[10] * 4) + (arr[11] * 8) + (arr[12] * 16) + (arr[13] * 32) + (arr[14] * 64) + (arr[15] * 128);\n var msg1 = {};\n var msg2 = {}; \n msg1.payload = byte1;\n msg2.payload = byte2;\n return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":440,"wires":[["d9803f23d95ace50"],["fe6f251a1b85df90"]]},{"id":"d9803f23d95ace50","type":"loxone-control-out","z":"3c3fa1ce28c0ce43","name":"Inputs5.1","miniserver":"c04ca4d6caa1d5c9","control":"19f4197e-0084-0ad5-ffff6fc206f2b7bf","x":980,"y":420,"wires":[]},{"id":"08eb64dc3971b8b1","type":"modbus-client","name":"1RS485","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":true,"failureLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB1","serialType":"RTU","serialBaudrate":"38400","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"0","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"1d30ba62236b3eda","type":"modbus-client","name":"2RS485","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":true,"failureLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"0","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"c04ca4d6caa1d5c9","type":"loxone-miniserver","host":"192.168.2.9","port":"80","enctype":"0","active":true,"keepalive":"30000"}]
I will briefly explain what is done in the scheme:
-
RS485-1:
Signals from 6 digital input modules are received as fast as possible. The information of each module is divided into 2 bytes and sent to a controller.
*Here I have a problem. Now a lot of information is constantly being sent to the controller and sometimes it is not needed because there is no state change. That is, I would have to implement a comparator within the functions (where I convert the data) and in case of a change of state send that new information. What happens to me now is that I clutter the controller with a lot of new information.
How can I save the variables (bytes) and retrieve them in the next function input? -
RS485-2:
Every second a new query is made of the status of different sensors.
Here as a novelty, I have implemented a counter control within the function. The counter number is used to create the modbus message. Inside the function I check that it is not out of range.
Doing tests with the relays, I think that a read and a write have conflicted.
I have seen that the counter value was erased and with that information, I have used the "isNaN()" function to invoice and position the value again.
Finally I send the information to the controller. Same problem as above (controller saturation).
Attached is a screenshot of how I am attacking the resolution to activate relays.
Perhaps the counter is not the best solution. Suggestions welcome and I'm open to making changes.
Sorry if I overdid the explanations.