Writing on PLC S7 node works only 25% of the times

Hello every one! After digging about PLC conection, could find this "strange" problem here or in google. Thank you for taking the time to read!

I created a simple flow to control a PLC digital input (I0.0).
I use "inject" to enter the "true" value into the PLC. Works, but I need to press 3-4 times to make it work. Sometimes it will work at the first atempt. So it hard to investigate as it randomly works.
Im on win 10, PLC S/ 1200, ethernet direct connection, put/get allowed, disabled optimized access.
The code:
[{"id":"11e16088.8ea65f","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4a7fc439.439e2c","type":"s7 out","z":"11e16088.8ea65f","endpoint":"98c0118e.a1148","variable":"DIN1","name":"escritura_PLC_1200","x":860,"y":360,"wires":[]},{"id":"71217c4c.7c1c94","type":"inject","z":"11e16088.8ea65f","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":360,"wires":[["4a7fc439.439e2c","401f79be.d9d9a8"]]},{"id":"401f79be.d9d9a8","type":"debug","z":"11e16088.8ea65f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":560,"wires":[]},{"id":"b97d2639.d7c068","type":"inject","z":"11e16088.8ea65f","name":"RESET","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":420,"wires":[["d11c295a.59a6c8","401f79be.d9d9a8"]]},{"id":"d11c295a.59a6c8","type":"s7 out","z":"11e16088.8ea65f","endpoint":"98c0118e.a1148","variable":"Reset","name":"escritura_PLC_1200","x":860,"y":420,"wires":[]},{"id":"98c0118e.a1148","type":"s7 endpoint","z":"","transport":"iso-on-tcp","address":"192.168.0.192","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapterauto":true,"adapterport":"","busaddr":"2","adapteraddr":"0","cycletime":"500","timeout":"1500","verbose":"default","name":"plc_s7_1200","vartable":[{"addr":"I0.0","name":"DIN1"},{"addr":"I0.4","name":"Reset"}]}]

I attach a pic of the s7 node´s configuration
Any suggestions?

Hi,
actually it should never work. As far as I can see from your flow you are setting I0.0 and I0.4 which are Input addresses. Those address should be used only for reading purposes (not writing).
Once you command the PLC to set an Input to HIGH it will put the state of that address to HIGH but in the scan next cycle (which is just in a few milliseconds) the PLC will read the physical input value and set it to LOW.
If you are just starting to learn, try using M0.0 or even M1.0 as an address for your tests ;).

1 Like

Hello Tiago, its really nice to have you commenting my post :slightly_smiling_face:
I suspected that I should work with Memory yeah.
Yes , im 2 weeks in PLC and Edge stuff so far... Just trying to understand it, im more interested in the data analytics side.
The reason why it seldomnly works might be because of the latching:


Thank you!

Great and welcome to the forum!
Just please use this guide to share your flow next time How to share code or flow json :wink:

Thanks! actually I followed those indications, pasted the code, selected it and pressed </>
What am I missing?

Not sure what went wrong, but it should look like this:

[{"id":"11e16088.8ea65f","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4a7fc439.439e2c","type":"s7 out","z":"11e16088.8ea65f","endpoint":"98c0118e.a1148","variable":"DIN1","name":"escritura_PLC_1200","x":860,"y":360,"wires":[]},{"id":"71217c4c.7c1c94","type":"inject","z":"11e16088.8ea65f","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":360,"wires":[["4a7fc439.439e2c","401f79be.d9d9a8"]]},{"id":"401f79be.d9d9a8","type":"debug","z":"11e16088.8ea65f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":560,"wires":[]},{"id":"b97d2639.d7c068","type":"inject","z":"11e16088.8ea65f","name":"RESET","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":420,"wires":[["d11c295a.59a6c8","401f79be.d9d9a8"]]},{"id":"d11c295a.59a6c8","type":"s7 out","z":"11e16088.8ea65f","endpoint":"98c0118e.a1148","variable":"Reset","name":"escritura_PLC_1200","x":860,"y":420,"wires":[]},{"id":"98c0118e.a1148","type":"s7 endpoint","z":"","transport":"iso-on-tcp","address":"192.168.0.192","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapterauto":true,"adapterport":"","busaddr":"2","adapteraddr":"0","cycletime":"500","timeout":"1500","verbose":"default","name":"plc_s7_1200","vartable":[{"addr":"I0.0","name":"DIN1"},{"addr":"I0.4","name":"Reset"}]}]

Probably there were some line jumps in your flow and it caused the wrong format.

1 Like

You need to export it as "compact", not "formatted" to get the one line version. You can select that at the bottom of the export dialog.

1 Like

Thanks kuema,
I did use "compact" exporting, and after selecting and pressing </> no changes:


must be something else?

Ah, you need to use three backticks, in the screenshot I can see only one.

Like

```
(flow json as compact one-liner)
```

But the </> button should do exactly that. Strange. :thinking:

You have to click the button, then paste the code between the lines with backticks.

1 Like

Using M´s worked perfectly, thank you very much @machadotiago :wink:
In the other hand, @Colin, it worked, now I can post the one-lined code. Just so you know, I would rewrite the explanatory post, as it says to PAste, select code, and then press </>, will lead to error.
Thank you all!!!!

[{"id":"11e16088.8ea65f","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4a7fc439.439e2c","type":"s7 out","z":"11e16088.8ea65f","endpoint":"98c0118e.a1148","variable":"input 1","name":"escritura_PLC_1200","x":860,"y":360,"wires":[]},{"id":"71217c4c.7c1c94","type":"inject","z":"11e16088.8ea65f","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":510,"y":240,"wires":[["4a7fc439.439e2c","401f79be.d9d9a8"]]},{"id":"401f79be.d9d9a8","type":"debug","z":"11e16088.8ea65f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":560,"wires":[]},{"id":"b97d2639.d7c068","type":"inject","z":"11e16088.8ea65f","name":"true","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":400,"wires":[["401f79be.d9d9a8","4a7fc439.439e2c"]]},{"id":"6a99d2ab.f0faac","type":"s7 out","z":"11e16088.8ea65f","endpoint":"98c0118e.a1148","variable":"input 2","name":"escritura_PLC_1200","x":860,"y":420,"wires":[]},{"id":"98c0118e.a1148","type":"s7 endpoint","z":"","transport":"iso-on-tcp","address":"192.168.0.192","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapterauto":true,"adapterport":"","busaddr":"2","adapteraddr":"0","cycletime":"500","timeout":"1500","verbose":"default","name":"plc_s7_1200","vartable":[{"addr":"M0.0","name":"input 1"},{"addr":"M0.1","name":"input 2"}]}]

I would like to emphatize that you guys made me feel really good, this is my first post and got help in minutes , amazing people here, you rock. :kissing_heart:

4 Likes

I hadn't realised that you could do it that way, but I see you can. If you select a number of whole lines and then click the button it does add the backticks before and after it.
Are you saying that does not work for you?
I see in the example you posted that it has put single ticks in, which is what happens for me if you just select part of a line.
What browser are you using?

Im using updated Chrome on win10.

So the instructions say: "The easiest way to do that is to paste in your code or flow json, select it all, then click the 'Preformatted Text' button in the toolbar:"

So I was doing that, and then only 1 tick appears, even if hardwrote 2 more, would not work.
If you 1st press </>, then paste, it works fine.

1 Like

Can you post an image showing three backticks and it not working please? Are you definitely using backticks, not single quotes?

The select and click method works for me with Waterfox on Ubuntu, I don't use Windows so am unable to test it there.
Perhaps someone else can try it with Chrome on Win 10 and confirm whether they also see an issue there.

So if you follow the instructions, and paste the code, select , and then press </> you get the tick in the same line, therefore even if you put 3 ticks , wont work, beacause you dont have the line jump.
If you press enter to do a line jump, it will work.
Basically, it need to be clear that step one is pressing </>, and then paste the code, and not the other way around.

yes , I used backticks, as I just copied the auto-generated first tick.

I have just tried it with Chrome (83.0.4103.97) on Ubuntu and selecting then clicking the button works, so I guess it must just be a Windows issue, or the specific version of Chrome, or something particular about your system.

My version is 83.0.4103.97 (Build oficial) (64 bits)
Anyways, it works fine clicking then pasting.

I think the issue might be that the backticks need to be on separate lines.

Yes, but selecting multiple lines then clicking the button is supposed to put them in on separate lines (and does for me).