node-red -LOGO!

Ara comunicarem el LOGO!, amb node-red sense la intervenció de cap nodeMCU. L'objectiu és controlar determinades accions de forma paral·lela al programa de l'autòmat.

Programem el PLC amb aquest programa IoT-logo-03.zip. Després necessitem instal·lar el node node-red-contrib-s7. Suposant que el PLC està connectat a la IP 192.168.1.70, importem aquest flow:

[{"id":"43eeed69.d01594","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q1","name":"","x":507,"y":161,"wires":[]},{"id":"7833fad2.1e4ffc","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":193.5,"y":153,"wires":[["43eeed69.d01594"]]},{"id":"4afe213.b09cd6","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":195,"y":197,"wires":[["43eeed69.d01594"]]},{"id":"94cd9c57.c1ff4","type":"s7 endpoint","z":"","address":"192.168.1.70","port":"102","rack":"0","slot":"2","cycletime":"500","name":"","vartable":[{"addr":"DB1,B105","name":"q1"},{"addr":"DB1,B106","name":"q2"},{"addr":"DB1,B107","name":"q3"},{"addr":"DB1,B108","name":"q4"},{"addr":"DB1,B120","name":"A0"},{"addr":"DB1,B10","name":"I0"},{"addr":"DB1,DW20","name":"C002"},{"addr":"","name":""}]}]

Comproveu el funcionament.

Segim amb aquest:

[{"id":"43eeed69.d01594","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q1","name":"","x":507,"y":161,"wires":[]},{"id":"8632ca68.38b318","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q2","name":"","x":523,"y":288,"wires":[]},{"id":"6dc5cf0e.e2e6b8","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q3","name":"","x":520,"y":357,"wires":[]},{"id":"9b833362.f36b9","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q4","name":"","x":520,"y":428,"wires":[]},{"id":"7833fad2.1e4ffc","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":193.5,"y":153,"wires":[["43eeed69.d01594"]]},{"id":"4afe213.b09cd6","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":195,"y":197,"wires":[["43eeed69.d01594"]]},{"id":"c3eb6395.03c8a8","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":192,"y":299,"wires":[["8632ca68.38b318","6dc5cf0e.e2e6b8","9b833362.f36b9"]]},{"id":"67762529.0da614","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":193.5,"y":386,"wires":[["8632ca68.38b318","6dc5cf0e.e2e6b8","9b833362.f36b9"]]},{"id":"94cd9c57.c1ff4","type":"s7 endpoint","z":"","address":"192.168.1.70","port":"102","rack":"0","slot":"2","cycletime":"500","name":"","vartable":[{"addr":"DB1,B105","name":"q1"},{"addr":"DB1,B106","name":"q2"},{"addr":"DB1,B107","name":"q3"},{"addr":"DB1,B108","name":"q4"},{"addr":"DB1,B120","name":"A0"},{"addr":"DB1,B10","name":"I0"},{"addr":"DB1,DW20","name":"C002"},{"addr":"","name":""}]}]

I ara aquest:

[{"id":"43eeed69.d01594","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q1","name":"","x":507,"y":161,"wires":[]},{"id":"8632ca68.38b318","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q2","name":"","x":523,"y":288,"wires":[]},{"id":"6dc5cf0e.e2e6b8","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q3","name":"","x":520,"y":357,"wires":[]},{"id":"9b833362.f36b9","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q4","name":"","x":520,"y":428,"wires":[]},{"id":"7833fad2.1e4ffc","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":193.5,"y":153,"wires":[["43eeed69.d01594"]]},{"id":"4afe213.b09cd6","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":195,"y":197,"wires":[["43eeed69.d01594"]]},{"id":"c3eb6395.03c8a8","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":192,"y":299,"wires":[["8632ca68.38b318","6dc5cf0e.e2e6b8","9b833362.f36b9"]]},{"id":"67762529.0da614","type":"inject","z":"f38c6ab8.ad8808","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":193.5,"y":386,"wires":[["8632ca68.38b318","6dc5cf0e.e2e6b8","9b833362.f36b9"]]},{"id":"12358435.1f764c","type":"s7 in","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","mode":"single","variable":"I0","diff":true,"name":"","x":160.5,"y":550,"wires":[["199decf1.0e3ecb"]]},{"id":"fe312362.9bb4c","type":"debug","z":"f38c6ab8.ad8808","name":"","active":true,"console":"false","complete":"payload","x":533.5,"y":620,"wires":[]},{"id":"cb920e2a.c50788","type":"s7 in","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","mode":"single","variable":"C002","diff":true,"name":"","x":161.5,"y":621,"wires":[["fe312362.9bb4c"]]},{"id":"199decf1.0e3ecb","type":"debug","z":"f38c6ab8.ad8808","name":"","active":true,"console":"false","complete":"false","x":534.5,"y":553,"wires":[]},{"id":"94cd9c57.c1ff4","type":"s7 endpoint","z":"","address":"192.168.1.70","port":"102","rack":"0","slot":"2","cycletime":"500","name":"","vartable":[{"addr":"DB1,B105","name":"q1"},{"addr":"DB1,B106","name":"q2"},{"addr":"DB1,B107","name":"q3"},{"addr":"DB1,B108","name":"q4"},{"addr":"DB1,B120","name":"A0"},{"addr":"DB1,B10","name":"I0"},{"addr":"DB1,DW20","name":"C002"},{"addr":"","name":""}]}]

Analitzeu el funcionament.

Si ara afegim aquest flow:

[{"id":"12358435.1f764c","type":"s7 in","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","mode":"single","variable":"I0","diff":true,"name":"","x":166.86370849609375,"y":610.9091186523438,"wires":[["2445ff36.6ef1a"]]},{"id":"2445ff36.6ef1a","type":"s7 out","z":"f38c6ab8.ad8808","endpoint":"94cd9c57.c1ff4","variable":"q1","name":"","x":507.27276611328125,"y":612.7272338867188,"wires":[]},{"id":"94cd9c57.c1ff4","type":"s7 endpoint","z":"","address":"192.168.1.70","port":"102","rack":"0","slot":"2","cycletime":"500","name":"","vartable":[{"addr":"DB1,B105","name":"q1"},{"addr":"DB1,B106","name":"q2"},{"addr":"DB1,B107","name":"q3"},{"addr":"DB1,B108","name":"q4"},{"addr":"DB1,B120","name":"A0"},{"addr":"DB1,B10","name":"I0"},{"addr":"DB1,DW20","name":"C002"},{"addr":"","name":""}]}]

Com funciona?

Ara aquí tenim u recull de flows per jugar:

Intermitència

[{"id":"3afc790c.119316","type":"trigger","z":"3490053.d9c057a","op1":"1","op2":"0","op1type":"num","op2type":"str","duration":"5","extend":false,"units":"s","reset":"","name":"","x":371.12115478515625,"y":180.4342803955078,"wires":[["2821199.f6758e6"]]},{"id":"c21a258b.a4f1e","type":"inject","z":"3490053.d9c057a","name":"DISPARA","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":214.2322998046875,"y":181.21205139160156,"wires":[["3afc790c.119316"]]},{"id":"78119ef9.140e2","type":"comment","z":"3490053.d9c057a","name":"INTERMITÈNCIA Q1, 5'' on- 5'' off","info":"","x":259.9595947265625,"y":137.27272033691406,"wires":[]},{"id":"2821199.f6758e6","type":"s7 out","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","variable":"q1","name":"","x":541.8182983398438,"y":180.90904235839844,"wires":[]},{"id":"94cd9c57.c1ff4","type":"s7 endpoint","z":"","address":"192.168.1.70","port":"102","rack":"0","slot":"2","cycletime":"500","name":"","vartable":[{"addr":"DB1,B105","name":"q1"},{"addr":"DB1,B106","name":"q2"},{"addr":"DB1,B107","name":"q3"},{"addr":"DB1,B108","name":"q4"},{"addr":"DB1,B120","name":"A0"},{"addr":"DB1,B10","name":"I0"},{"addr":"DB1,DW20","name":"C002"},{"addr":"","name":""}]}]