madalin.todoran
Hi ! I have a problem with two function block which change values to same output variable.
I tried different combinations but I still didn't succeed. Only one FB work .

The FB control direction of a motor and with a function I need to write IN1, IN2 and pwm to the driver. I did this but with one function block. The problem is that I need to control 4 motors in different direction and with different speed.
Another problem that I observe is that MOVE function  don't retain the input value if the enable is 0 and force 0 value to the output constant and I can't change the value with another MOVE function .
To show the values I use Modbus Poll.
Results:
Capture.png  Capture1.png 

Screenshot 2018-05-24 14.22.07.png  Screenshot 2018-05-24 14.25.36.png 
Another implementation :
Screenshot 2018-05-24 13.50.48.png 
Screenshot 2018-05-24 14.28.23.png 
Reply 0 0
thiagoralves
Your logic is broken because you're failing to understand the concept of "enable" in the ladder logic language. Enable works the same way as the "custom-enable" function you created on the last pictures of your FB. Internally, the enable bit stays in series with whatever logic the block is performing. This means that when the enable bit is not activated, it will force the outputs of the block to be turned off as well. Some people misconceive this by thinking that when the enable bit is off it would skip the execution of the ladder logic block. This is not true. Every block in the ladder logic diagram is executed, even when the enable bit is off. Therefore, when a block has its enable bit off, it will still be executed, and the interpretation of that is that the outputs of the given block will be all false.

Therefore, on your little program, MOTOR1 is always rewriting whatever MOTOR0 is doing, since it is coming after. If MOTOR0 is enabled, it will write to the IN1out and IN2out variables the values you want. However, right after it, if MOTOR1 is not enabled, it will write false (or zero) to both of the variables since it is also attached to them. To solve this problem you need to use a selector (SEL) block, that will allow you to put one value or another on a variable depending on the condition you want. This post can help you get more insight on this concept:  https://openplc.discussion.community/post/problem-moving-data-to-a-register-8493297
Reply 0 0
madalin.todoran
Thank you very much ! I was blocked for two days with this problem and now I understand why it didn't work.
New FB :
Screenshot 2018-05-24 23.37.28.png The program looks more complicated, but it's doing the job
Screenshot 2018-05-24 23.37.32.png
Reply 0 0
Reply