Yukkotete
Hello,

I am working with my UniPi board and I have a problem while running a simple program working with the analogical output.
Problema Analogicas.png 

As you can see, there is a simple MOVE block loading a value in the analogical output and it´s enabled by a contact which is refered to the digital input in the UniPi board.
The problem is that the MOVE block is only loading a value when the LAST NETWORK is enabled (when the digital input on the last network is equal to '1'), i have tried to change the order in the networks and the contacts but the program is still working with only the last network (the lower network).

I have also checked the .st file and nothing seems to be wrong there.

I would apreciate some help here. Thank you very much.
Reply 0 0
thiagoralves
That's the way ladder logic works. All lines are evaluated sequentially. When the MOVE block is false, it will move zero to your SalidaAnalogica. Therefore, since you have the same output for all ladder logic rungs (network), it will get overwritten so that only the last rung will prevail. For example, if the MOVE block on the first rung is true, it will move Valor1 to SalidaAnalogica, but right after it, the next rung will move zero to the same output if it is false, and so on.

You need something that will disable the rung if the contact is false. Check this post for some inspiration: https://openplc.discussion.community/post/problem-moving-data-to-a-register-8493297?pid=1295560855
Reply 1 0
Yukkotete
Thank you very much! Didn't know that the MOVE block was overwritting the output. All solved now for the moment.
Reply 0 0
jason.hsiao
Hello, 
  I am confused. Because  in CODESYS plc simulation , MOVE block not overwrite the output to 0 when EN is false . This logic is not same. 
PIC1.png 
Reply 0 0
thiagoralves
There are several interpretations of the standard. I’ll take a look on this again to make sure which one is the right one.
Reply 0 0
thiagoralves
Here is what the standard says about it:

2.5.1.2 Execution control
As shown in table 20, an additional Boolean EN (Enable) input or ENO (Enable Out) output, or both, can be provided by the manufacturer or user according to the declarations

VAR_INPUT EN: BOOL := 1; END_VAR
VAR_OUTPUT ENO: BOOL; END_VAR

When these variables are used, the execution of the operations defined by the function shall be controlled according to the following rules:
  1. If the value of EN is FALSE (0) when the function is invoked, the operations defined by the function body shall not be executed and the value of ENO shall be reset to FALSE (0) by the programmable controller system.
  2. Otherwise, the value of ENO shall be set to TRUE (1) by the programmable controller system, and the operations defined by the function body shall be executed. These operations can include the assignment of a Boolean value to ENO.
  3. If any of the errors defined in table E.1 for subclauses of 2.5.1.5 occurs during the execution of one of the standard functions defined in 2.5.1.5, the ENO output of that function shall be reset to FALSE (0) by the programmable controller system, or the manufacturer shall specify other disposition of such an error according to the provisions of 1.5.1.
  4. If the ENO output is evaluated to FALSE (0), the values of all function outputs (VAR_OUTPUT, VAR_IN_OUT and function result) shall be considered to be implementation-dependent.
As you see, all the standard says is that when EN is FALSE the function should not be executed. I will discuss with the maintainers of the MatIEC compiler what they think would be the best interpretation of this. Perhaps, writing zero to the variable connected to the MOVE block when EN is FALSE is actually executing something, right? So maybe this interpretation is in fact wrong. If they agree with me, we might change the behavior of this on the next releases.
Reply 0 0
jason.hsiao
Thanks for your instant reply, I'll wait for good news. ðŸ˜ƒ
Reply 0 0
skv
This isn't problem of MatIEC compiler, but the way how PLCOpenEditor converts FBD/LD code to ST.
This is already fixed in the latest PLCOpenEditor from Beremiz repository.
Reply 0 0
jason.hsiao
Thank you for your assistance, the problem has been solved. ðŸ˜ƒ
Reply 0 0
epgodoy
skv wrote:
This isn't problem of MatIEC compiler, but the way how PLCOpenEditor converts FBD/LD code to ST.
This is already fixed in the latest PLCOpenEditor from Beremiz repository.


So the PLCOpenEditor 1.3 version ("The source code for this installer is based on commit 52afa2d from August 16, 2018") on the OpenPLC project website is not the updated (last) version of the  PLCOpenEditor?
Thanks
Reply 0 0
thiagoralves
For the last version it is better to go directly to bitbucket and get the latest code. I like to test each new version before making it available on the website, and that takes time. That's why you won't find the latest code in there, but at least a tested and stable version.
Reply 0 0
Reply