Andrey Posted December 21, 2011 Report Share Posted December 21, 2011 I have a simple project (see attachment). I do not understand why variable "int var 1" is always equal to 1. Please explain to me. P.S. Win7 64bit, Vision ver 9.3.1.build 0, V570-57-T20 (Hardvare rev: E, OS ver: 3.4 (16)) with lasts updates P.S.2: а по русски тут говорят? Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted December 22, 2011 MVP 2023 Report Share Posted December 22, 2011 Because you are always setting the value of "int var 1" to 1 in network 1. This overwrites the outcome of the logic in network 2 - it's value will go to 2 for one scan, but be written back to 1 again the next scan. You'll never see it in Visilogic because it's happening too fast. Joe T. Link to comment Share on other sites More sharing options...
Andrey Posted December 22, 2011 Author Report Share Posted December 22, 2011 Thanks that have started to answer my question. I hurried up and not the correct example has made. In attachment the correct example. Why the variable "int var 1" is always equal to "1". Link to comment Share on other sites More sharing options...
Emil Posted December 22, 2011 Report Share Posted December 22, 2011 The first condition in your rung is DW1 = 0. If this is true, than you add 100 to it. If in this moment MI1 = 0, you will increase it and it will be equal to 1. The next scan DW1 will not be equal to 0 anymore (it will be equal to 100!) and the condition ot increase MI1 will be false. About Russian - you can send me mail to support@unitronics.com in Russian, but the answer anyway will be in English. Link to comment Share on other sites More sharing options...
Andrey Posted December 22, 2011 Author Report Share Posted December 22, 2011 [quote name='Emil' see my correct example in attachmet I have a same question. Link to comment Share on other sites More sharing options...
Emil Posted December 22, 2011 Report Share Posted December 22, 2011 If the subroutine is scanned always and there is no other logic to affect MI1, you need ot see it on lyne always 2. Link to comment Share on other sites More sharing options...
Andrey Posted December 22, 2011 Author Report Share Posted December 22, 2011 This example finished, more isn't present other program items. I think that the variable "int var 1" should increase on 1 every second. But it does not happen. Why? If to change procedure RUN (net 1) so that the condition (MI1 > 0) was processed parallely with (DW1 = SDW 43 + 100) all works. I can't load more pictures (or projects) on a forum to show it. Link to comment Share on other sites More sharing options...
Andrey Posted December 23, 2011 Author Report Share Posted December 23, 2011 Emil, Joe Tauser please see to example. In these examples the variable MI1 should be increases on 1 every second. In example (ex2.jpg) it work. In example (ex1.jpg) don`t work. Why? Link to comment Share on other sites More sharing options...
AlexUT Posted December 25, 2011 Report Share Posted December 25, 2011 Andrey, I suggest you the next modification. It works and doing everything as you wants. Link to comment Share on other sites More sharing options...
Andrey Posted December 28, 2011 Author Report Share Posted December 28, 2011 Problem not that I can't make something..... After summation of an operand with the timer (sdw 43), operators of conditions don't work. Link to comment Share on other sites More sharing options...
AlexUT Posted December 28, 2011 Report Share Posted December 28, 2011 Andrey, It does not work because you changed DW 1, and logic say that if you want to compare MI 1 to Zero if DW 1 is Zero - it is not Zero already. Attached is other example which works in accordance to your logic rules. Link to comment Share on other sites More sharing options...
Damian Posted December 28, 2011 Report Share Posted December 28, 2011 Andrey, It does not work because you changed DW 1, and logic say that if you want to compare MI 1 to Zero if DW 1 is Zero - it is not Zero already. Attached is other example which works in accordance to your logic rules. I agree that the series connection isn't working because DW1 gets modified while the network is being processed. I completely DISAGREE that it should be evaluating the ladder like this. Each instruction in a rung should only be executed ONCE. This means that once the comparator is evaluated, it should retain the state of that decision until the rung has been completely finished executing. What is really happening is the rung is going back and re-evaluating the comparator for subsequent conditions. Looking at the STL generated for the rung, you can see that Visilogic is not properly translating the ladder as written. It is clearly evaluating the first comparator instruction TWICE. It should not be. This is not in line with any other translator that I have ever seen. It is completely unintutitive, and breaks from the "left to right" execution convention that everyone expects. Link to comment Share on other sites More sharing options...
Andrey Posted December 28, 2011 Author Report Share Posted December 28, 2011 AlexUT I think that for procedure "run" net 1 (from ex1.jpg, post #8) the equivalent C code is: if (DW1 == 0) { DW1 = 100 + SDW43; if (MI1 > 0) { MI1 ++; } } You say that the equivalent C code is if (DW1 == 0) { DW1 = 100 + SDW43; } if (DW1 == 0) { if (MI1 > 0) { MI1 ++; } } But this code is equivalent to two nets. I am in confusion... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now