Atcan Posted January 27, 2017 Report Share Posted January 27, 2017 Hello! This is my first post. Being a beginner in the subject, I am facing some troubles on doing a coding for a Samba PLC. I understood that the Main Routine always runs along with any other subroutine that was loaded by the "While Displayed" function in a loaded display. So, here coes my question: What if a subroutine is called from the Main Routine by the Call Subroutine (say Sub1) and, besides that, a new display is loaded and this displays contains a While Displayed subroutine (Sub2) that is not the same one that was called by the Call Subroutine? Would they run simultaneously? I mean, the three routines, Main, Sub1 and Sub2? Thanks for any help. Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted January 27, 2017 MVP 2023 Report Share Posted January 27, 2017 Yes, they'll all run in the same scan. If it would make you feel better assign a bit to be on while the display is active and then call Sub2 from the Main routine with a contact tied to that bit. Joe T. Link to comment Share on other sites More sharing options...
Atcan Posted January 27, 2017 Author Report Share Posted January 27, 2017 Thank you Joe. And can I assume that, while in the loaded display, the Main routine will run all the way from top to bottom? Antonio Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted January 27, 2017 MVP 2023 Report Share Posted January 27, 2017 I had to look this up. According to the Help, here is the detailed scan order: 1. Read Inputs 2. Solve ladder program, starting with Main 3. Write Outputs 4. Service HMI screen - update variables, run subroutines associated with display, process keyboard input 5. Process Communications Repeat So the subroutine associated with the display runs after the Main ladder program and its subroutines are solved. Good question. Joe T. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted January 28, 2017 MVP 2023 Report Share Posted January 28, 2017 21 hours ago, Joe Tauser said: If it would make you feel better assign a bit to be on while the display is active and then call Sub2 from the Main routine with a contact tied to that bit. Be sure to set the Powerup value to RESET for that bit. I've been burned by that and have learned my lesson. Link to comment Share on other sites More sharing options...
Atcan Posted January 29, 2017 Author Report Share Posted January 29, 2017 Thank you Joe T. and Flex727 for the tips. One more question, now about the SB33: If I have it in the Main Display subroutine, does it mean that it will not run at the CLP power up but will run upon its return from any other display when returning from subsequent subroutines? I will run your tips this Monday only as I don't have a CLP simulator, so I need to run it at the machine itself. Antonio Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted January 29, 2017 MVP 2023 Report Share Posted January 29, 2017 Note that SB33 is for a "Standard Vision". Translation: "Old PLC we still sell". SB33 does nothing in your Samba, which has the newer platform and is referred to as an "Enhanced Vision". Joe T. Link to comment Share on other sites More sharing options...
Atcan Posted January 30, 2017 Author Report Share Posted January 30, 2017 I was betting a lot on this SB 33, for those codes I wanted to run just once on certain subs. Is there any valid SB for the same function? Is there a list of all operand that are valid for the Samba? The list in the PDF ladder manual are not clear for me. Thanks Antonio Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted January 30, 2017 MVP 2023 Report Share Posted January 30, 2017 Just create logic to do the same thing. Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted January 30, 2017 MVP 2023 Report Share Posted January 30, 2017 Quote I was betting a lot on this SB 33, for those codes I wanted to run just once on certain subs. Antonio - how many PLC ladder programs have you written? Sometimes we get a long thread going without realizing we are catering to a new programmer who is trying to do something in what he thinks is the best way but is really something based on another language style. Often there are functions that simplify the task significantly. Please give us more specific detail on what you're trying to do. Joe T. Link to comment Share on other sites More sharing options...
Atcan Posted January 30, 2017 Author Report Share Posted January 30, 2017 Hi Joe T., You are absolutely right. I just checked my ladder program and realizad that in every rung I used the SB 33 would work at the same way even if it is not there. That's why it was running as expected even not being the SB 33 functional for the my enhanced PLC. So I just removed it and it sti working right. I don't consider my program a complex one. Just some few contactors and valves that must work synchronized by a number of timers and an analogic transducer for pressure. As there are various ways of working, I had to develop a number of displays and subroutines. Sorry but I am afraid to say that this is my first PLC ladder program. We are a family company (machine manufacturer) and currently use a very simple, locally made PLC, but some overseas customers are asking for a global system that would be found more easily so that they feel more confident in case a spare one would be needed. Actually, my biggest problem was to understand the ladder reading flow, that now became very clear thanks to your and Flex727's help. Antonio Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted January 31, 2017 MVP 2023 Report Share Posted January 31, 2017 If you wish to post your code we would certainly be happy to review it and make suggestions. Joe T. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted January 31, 2017 MVP 2023 Report Share Posted January 31, 2017 20 hours ago, Atcan said: Sorry but I am afraid to say that this is my first PLC ladder program. Do not be sorry. That's what we're here for. Link to comment Share on other sites More sharing options...
MVP 2023 Ausman Posted February 1, 2017 MVP 2023 Report Share Posted February 1, 2017 Hi & welcome Antonio, well done to all on this one, and thanks Antonio for the good responses and also your obvious investigating/learning/efforts prior to posting. We understand reluctance to post code, but if it is not too secret, it might help. There is a wealth of knowledge here and we all started with our "first PLC ladder program"!! One other last method to check your entire program....find the person amongst your friends/neighbours who is a total computer klutz, ie even gets confused using a mouse etc. Get them to run though your displays and operations to confirm that it all works as you want it to and is easily understood. If there is ever a way for you to find a sequence issue, or make something easier to follow, this is it. The main reason for this suggestion is to ensure that everything is perfect before you ship it as your "global system". Much easier to fix it before it goes out! cheers, Aus Link to comment Share on other sites More sharing options...
Atcan Posted February 1, 2017 Author Report Share Posted February 1, 2017 Hello Ausman, thanks for the nice words. I am still working on the program and, by the tests I've done so far, I almost there. Once I finish it I will follow your recommendations above and do the operation tests. I wonder if there is any available information about how to get to a good program, such as simple tips on making it a safe/reliable program? 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