pascal Posted September 1, 2014 Report Share Posted September 1, 2014 I have the following problem : In net 1, I read a column of a data table in MI100 ... MI 109 in the same net (net 1) I search a certain value in the MI100...MI109, with a CALL subroutine that returns a returnvalue. Is this allowed, or should I search this value in another net ? Because sometimes (not always) I don't have the correct returnvalue ? program look likes this : read column and write to MI 100...MI 109 // search value into MI 1 // call subroutine for searching where MI 1 is in MI 100...MI 109 // put return value into MI 2 ( all this is place in one net ! ) or should it be like this ? net 1 : read column and write to MI 100...MI 109 net 2 :search value into MI 1 net 3 : call subroutine for searching where MI 1 is in MI 100...MI 109 net 4: put return value into MI 2 before I change my program, I want to know if this is the problem of bad readings ! Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted September 1, 2014 MVP 2023 Report Share Posted September 1, 2014 It is bad programming practice to put instructions together in the same ladder rung that aren't conditional. The only real exception would be when you have a coil that must be activated by multiple situations, since coils should always only exist in a single net. When you have an unnecessarily complex net, you run the risk of unpredictable results due to the compiler organizing the instruction differently than you might have expected. Link to comment Share on other sites More sharing options...
Eyal Koren Posted September 2, 2014 Report Share Posted September 2, 2014 I have the following problem : In net 1, I read a column of a data table in MI100 ... MI 109 in the same net (net 1) I search a certain value in the MI100...MI109, with a CALL subroutine that returns a returnvalue. Is this allowed, or should I search this value in another net ? Because sometimes (not always) I don't have the correct returnvalue ? program look likes this : read column and write to MI 100...MI 109 // search value into MI 1 // call subroutine for searching where MI 1 is in MI 100...MI 109 // put return value into MI 2 ( all this is place in one net ! ) or should it be like this ? net 1 : read column and write to MI 100...MI 109 net 2 :search value into MI 1 net 3 : call subroutine for searching where MI 1 is in MI 100...MI 109 net 4: put return value into MI 2 before I change my program, I want to know if this is the problem of bad readings ! Hi Pascal, Flex 727 is right. In ladder programming, the compiler can change the order of commands execution (in a single net) which may cause unexpected results. It is recommended to separate your code into simple structures - or one rung per net. This will also make your code more readable. Link to comment Share on other sites More sharing options...
pascal Posted September 2, 2014 Author Report Share Posted September 2, 2014 Ok, I think this will be the problem ( bad programming of me ! ) But 1 question about this issue : is the order of commands execution always the same, or can it change in time. The most of the time, I get "good" values, but suddenly I get a wrong one ! Or is the time needed for an read data table column and put the values into the MI's taking some time, so this is sometimes slower and I get "bad" result. this is because I want to explain my customer why the PLC sometimes gives the "wrong" values. Link to comment Share on other sites More sharing options...
Eyal Koren Posted September 2, 2014 Report Share Posted September 2, 2014 Ok, I think this will be the problem ( bad programming of me ! ) But 1 question about this issue : is the order of commands execution always the same, or can it change in time. The most of the time, I get "good" values, but suddenly I get a wrong one ! Or is the time needed for an read data table column and put the values into the MI's taking some time, so this is sometimes slower and I get "bad" result. this is because I want to explain my customer why the PLC sometimes gives the "wrong" values. Pascal, Once the code has been compiled and downloaded to the PLC, it will always be executed in the same order. Getting an occasional "wrong" value is probably a problematic logic. If you are not sure why this happens, you are welcome to send the application to support@unitronics.com including details related to the issue, and we will point it out. Link to comment Share on other sites More sharing options...
pascal Posted September 8, 2014 Author Report Share Posted September 8, 2014 Ok, thanks first, I will replace the "bad" program with the "correct" one and test it. If there are still problems, I will send you a copy of the program so you can check where the problem can be. I'll keep you informed about my results. Link to comment Share on other sites More sharing options...
pascal Posted October 16, 2014 Author Report Share Posted October 16, 2014 Hi, I rewrote my program, so I divided the large rungs into more rungs. But still I have a question and problem. Is it possible that the PLC reads a bad value from the datatables while the data tables are updated with " remote access " ? Every cycle I read the data table, but the customer changed the values of the data table and suddenly he had wrong values ? I checked the program, but couldn't find any wrong programming. Link to comment Share on other sites More sharing options...
cantcliff Posted October 20, 2014 Report Share Posted October 20, 2014 Are you sure they are uploading the changes to the data table? How are they using remote access? Maybe it's a communications issue? 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