Gloworm72
[203128%2F9674406%2Fmceclip0]
[203128%2F9674407%2Fmceclip0]How do I use boolean logic before the IN and after the Q if you can only type in a tag? I have a picture of v4 vs one I used to have in v3
Reply 0 0
thiagoralves
v4 tries to force users into writing less “spaghetti” code on ladder logic. Blocks must be connected by their top pins with Boolean logic and variables should be used to activate other pins in the blocks. You can essentially build the same logic by removing execution control from both timers, and then using FAST_FLAG in series with LED_STATE connected to IN on the first TON block.
Reply 0 0
Gloworm72
v4 tries to force users into writing less “spaghetti” code on ladder logic. Blocks must be connected by their top pins with Boolean logic and variables should be used to activate other pins in the blocks. You can essentially build the same logic by removing execution control from both timers, and then using FAST_FLAG in series with LED_STATE connected to IN on the first TON block.
Thank you for the quick response, that's what I attempted before:
[203128%2F9674414%2Fmceclip0]
[203128%2F9674413%2Fmceclip0]
 
Is there something else you think is the issue here?
Reply 0 0
thiagoralves
You cannot have two rungs controlling the same coil. A rung that evaluates to false will set the coil to false. So ultimately the last rung always wins as it will overwrite whatever the rungs above it did on that coil.
 
The right way to do this is to actually rename your “FastTime” variable to “BlinkTime” and then move different time values to it based on a condition (you can use MOVE blocks with execution control enabled for that).
 
If you want your output to blink fast, move a short time to “BlinkTime”. If you want it to blink slowly, move a long time to “BlinkTime”.
Reply 0 0
Gloworm72
You cannot have two rungs controlling the same coil. A rung that evaluates to false will set the coil to false. So ultimately the last rung always wins as it will overwrite whatever the rungs above it did on that coil.
 
The right way to do this is to actually rename your “FastTime” variable to “BlinkTime” and then move different time values to it based on a condition (you can use MOVE blocks with execution control enabled for that).
 
If you want your output to blink fast, move a short time to “BlinkTime”. If you want it to blink slowly, move a long time to “BlinkTime”.
Ok I think I understand! So something like this?
[203128%2F9676003%2Fmceclip0]
[203128%2F9676004%2Fmceclip0]
Reply 0 0
thiagoralves
That's correct! As you see, thanks to the new OpenPLC v4 ladder editor "restrictions" you managed to successfully transform this "spaghetti" code here
203128-9674407-mceclip0.png
 
into a beautiful, organized, and very much readable ladder here
203128-9676003-mceclip0.png
203128-9676004-mceclip0.png
 
I know the new ladder editor may seem a bit picky, but it is definitely for the better 🙂
Reply 0 0
Gloworm72
That's correct! As you see, thanks to the new OpenPLC v4 ladder editor "restrictions" you managed to successfully transform this "spaghetti" code here
203128-9674407-mceclip0.png
 
into a beautiful, organized, and very much readable ladder here
203128-9676003-mceclip0.png
203128-9676004-mceclip0.png
 
I know the new ladder editor may seem a bit picky, but it is definitely for the better 🙂
Thank you for the help! It does look much more clean!
 
Just to clarify, does the rule of never having the same coil in two separate rungs apply to every scenario? Or is that only if the coil is controlling a physical element like an LED? Even if it was just an internal tag acting as a flag that should be avoided as well?
Reply 0 0
thiagoralves
Yes, it applies to EVERY scenario, as this is fundamentally how ladder logic works, processing one rung after the other in sequence. The only "nuance" is if you use Set/Reset coils, as they actually operate by function (to set, or to reset) instead of by attribution (coil = True if rung is True / coil = False if rung is False). With a set/reset coil, if the rung is true, coil will be set (or reset). If the rung is false, nothing will happen (no function called). That's what makes set/reset coils safe to be used on multiple rungs.
Reply 0 0
Gloworm72
Yes, it applies to EVERY scenario, as this is fundamentally how ladder logic works, processing one rung after the other in sequence. The only "nuance" is if you use Set/Reset coils, as they actually operate by function (to set, or to reset) instead of by attribution (coil = True if rung is True / coil = False if rung is False). With a set/reset coil, if the rung is true, coil will be set (or reset). If the rung is false, nothing will happen (no function called). That's what makes set/reset coils safe to be used on multiple rungs.
Thank you for the clarification, that all makes sense now!
Reply 0 0
Kang
v4 tries to force users into writing less “spaghetti” code on ladder logic. Blocks must be connected by their top pins with Boolean logic and variables should be used to activate other pins in the blocks. You can essentially build the same logic by removing execution control from both timers, and then using FAST_FLAG in series with LED_STATE connected to IN on the first TON block.
 
Understand your intention for less "spaghetti" and limit the blocks top pins with line connection.
 
However, this rule means that the blocks' non-top pins can not have any line connections to Boolean logic, only variables is allowed, right? But single variable logic is usually not enough for ladder blocks.
If I understand correctly, I will need to add many transition variables to fill in non-top pins of blocks, which makes the ladder program more complex.
 
According to my knowledge of mainstream PLC brand, they all have similar limitations for top pins of blocks to make sure the ladder program is well organized. But they also allow the non-top pins to flexible connections(variables or Boolean line logic) . Otherwise, the ladder program is totally not friendly to users.  
 
I believe it is necessary to allow Boolean line connection to non-top pins, or correct me if I am wrong about your intention and design.
Reply 0 0
thiagoralves
I understand your point. Perhaps in the future we might think about a good way to add it without compromising code readability
Reply 0 0
Reply