plclearner
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.

Screenshot from 2018-04-11 13_46_46.png 
‘Industrial STOP/START’ I found in Wikipedia:
https://en.wikipedia.org/wiki/Ladder_logic
Reply 0 0
thiagoralves
Graphically your program looks correct, but when I opened it with the editor, I saw that the wiring was wrong. In fact, this kind of wiring is tricky with the editor. The easiest way to fix this is to remove the FLAG entirely. You don't need the FLAG to keep your lamp on. There are two ways to do this:

1. You can change the lamp contact to be of type "Set". Just double click on the contact and change the modifier. A Set contact will be true forever, until another rung with the contact on type "Reset" is activated.

OR

2. You can remove your FLAG coil in the output and change the parallel FLAG contact to be associated with your lamp variable. Therefore the lamp will hold itself true. Something like this:
Capture2.png 

If you still want to have your diagram with the FLAG, you will have to change it slightly. The problem is that your parallel FLAG coil at the end is only wired to the button, and not to the association of button+FLAG. To fix this, you need to put a dummy contact in the middle, that basically act as a node that concentrates your wiring. Like this:
Capture.png 
Reply 0 0
plclearner
thiagoralves wrote:
Graphically your program looks correct, but when I opened it with the editor, I saw that the wiring was wrong. In fact, this kind of wiring is tricky with the editor. The easiest way to fix this is to remove the FLAG entirely. You don't need the FLAG to keep your lamp on. There are two ways to do this:

1. You can change the lamp contact to be of type "Set". Just double click on the contact and change the modifier. A Set contact will be true forever, until another rung with the contact on type "Reset" is activated.

OR

2. You can remove your FLAG coil in the output and change the parallel FLAG contact to be associated with your lamp variable. Therefore the lamp will hold itself true. Something like this:
Capture2.png 

If you still want to have your diagram with the FLAG, you will have to change it slightly. The problem is that your parallel FLAG coil at the end is only wired to the button, and not to the association of button+FLAG. To fix this, you need to put a dummy contact in the middle, that basically act as a node that concentrates your wiring. Like this:
Capture.png 



Thanks for your astonishingly quick reply. You helped me a lot.
I've tried methods you mentioned, but there are still some problems.

1. Thanks for your kind advise but for some special reasons I can't use Set coil😉
2. As for method 2, in fact, I did what you said before I use FLAG. I have tried to use 'lamp' to hold itself but it didn't work. As soon as the program was uploaded and compiled successfully, 'lamp' goes TRUE immediately and it never goes FALSE. In fact, ‘lamp’ was supposed to be FALSE before I connect ‘button’ to ground. Please check the picture pasted below and project named 'light20180411-1.xml'. 
Screenshot from 2018-03-23 10-13-43.png 
3. Apparently I don't know why do we need to add a 'dummy contact'(Do other PLCs including commercial PLC products need to do this?) but I think I can understand what you said. I've tried to add a dummy contact between 'lamp' and 'button' to connect them(see picture pasted below and project named 'light20180411-2-dummy.xml') but it didn't work either. The phenomenon is exactly the same as 'light20180411-1.xml' above.
Screenshot from 2018-03-23 10-14-19.png 
Reply 0 0
thiagoralves
Both programs you sent me are logically equivalent. Latching the output using the lamp or using the FLAG is the same. The problem with your program is probably related to your hardware. For some reason, it seems that for the first cycle of the ladder logic, it is reading your button as false (logic zero), which for a negated contact means that it will make the rung true. You can try to fix this by putting the button's initial value as 1 on the variables list. This will force the button to be read as true at least for the first cycle.

If that doesn't work than probably OpenPLC is reading your button as false for more than one cycle. This will be hard to fix. One possible solution would be to put a timer in series with the button that will only enable the rung after a few seconds (that might be needed for the hardware to stabilize).
Reply 0 0
plclearner
thiagoralves wrote:
Both programs you sent me are logically equivalent. Latching the output using the lamp or using the FLAG is the same. The problem with your program is probably related to your hardware. For some reason, it seems that for the first cycle of the ladder logic, it is reading your button as false (logic zero), which for a negated contact means that it will make the rung true. You can try to fix this by putting the button's initial value as 1 on the variables list. This will force the button to be read as true at least for the first cycle.

If that doesn't work than probably OpenPLC is reading your button as false for more than one cycle. This will be hard to fix. One possible solution would be to put a timer in series with the button that will only enable the rung after a few seconds (that might be needed for the hardware to stabilize).


Thanks for your quick reply and patient guide. As a matter of fact, I have thought about hardware instability before I came to seek help.

I've tried to put the button's initial value as 1 on the variables list but it didn't work. And 'lamp' will be TRUE as soon as program begins to run. It seems that OpenPLC read 'button' as FALSE for more than one cycle when it begins to run.

Then I add a TON after the button, and set T#250ms(see the picture pasted below). This time, 'lamp' does't go TRUE automatically after OpenPLC begins to run. When I connect 'button' to ground(for more than 250ms, of course), 'lamp' goes TRUE and it is able to hold itself. It seems that your guess about hardware instability is right.
Screenshot from 2018-03-23 10-50-40.png 

Thanks for your patience. I am afraid I have to check my hardware devices then. 
Reply 0 0
Reply