I am using PLCOpenEditor and tring to build an OpenPLC project for test purpose. Because I am new to PLC, I am trying to imitate 'Industrial STOP/START' I found in Wikipedia. Please check the LD program pasted below(forget the 'STOP' button, I did't use it).
I think this LD program will do such things: when I upload .st file generated from this LD program and OpenPLC begins to run, ‘button’ will be TRUE(due to my physical hardware setting. All input pins on my hardware will be set to TRUE unless I connect them to ground), therefore 'lamp' and ‘FLAG’ will become FALSE. Then, I connect 'button' to ground(in order to set 'button' to FALSE), 'button' becomes FALSE and ‘lamp’ & 'FLAG' will become TRUE. Next, I disconnect 'button'(in order to set it to TRUE), 'button' will become TRUE. For the reason that 'FLAG' remains TRUE, ‘lamp’ will still be TRUE. No matter how many times I connect 'button' to ground or disconnect ''button,'lamp' is supposed to be always TRUE.
However, the fact is that when I upload the st file generated from this LD program, 'lamp' becomes FALSE(it seems okay). When I connect 'button' to ground, 'lamp' becomes TRUE(it seems okay too). Then I disconnect ‘button’(in order to set it to TRUE as I said before), 'lamp' becomes FALSE(it seems wrong now). I connect 'button' to ground, ‘lamp’ goes TRUE. I disconnect 'button', ‘lamp’ goes FALSE. It seems that there is no difference with 'FLAG' or without 'FLAG'.
I don't know whether I have made some mistakes(I am new to PLC, sorry) or there is something going wrong. I have asked some people near by but found no solutions, so I have to seek help. English is not my mother language, please ignore mistakes in grammar or vocabulary.
‘Industrial STOP/START’ I found in Wikipedia:
https://en.wikipedia.org/wiki/Ladder_logic