Kikis Posted May 30, 2012 Report Posted May 30, 2012 Hello friends, I have made a lot of projects using jazz and M90/M91 controllers. However this is the first time i will be using a vision series model and i'm not familiar with programming using sub-routines. I'm writing a program for a Vision 570 PLC which includes 3 different modules and 15 sub-routines totally. Even though my program jumps from one sub-routine to another, i would like to have a timer that will work continously without being affected by a sub-routine change. The timer's working time will depend on a user's preset value. Therefore it may stop working in the 3rd subroutine or in the 5th and so on. Is it correct to use an accumulated timer in every subroutine? So when it leaves a subroutine it stops working and when is entering the next one begins to decrement from the retained value. I also need to have a cycle counter where i used 0.1 second pulse and included the code in every sub-routine of the project. Is this correct? Thanks in advance, kikis
Peter van Hoof Posted May 30, 2012 Report Posted May 30, 2012 hI kikis, I believe you think the concept of programming with subroutines works the way a linear programming language like basic or c does jumping back and forth at will but this is not the way it is intended. The idea behind it is that in every ladder scancycle the program always starts at the first net, in the main Subroutine, in the main Module (this is the one highlighted) and should end at the last net in this same subroutine All calls to different subroutines are supposed to end with a return. Do not for example program a wait loop jumping back 1 or more nets to wait for a certain condition as this would create a condition that would not update inputs and outputs and eventually trigger a watchdog timeout. Please look at the topic "Program Sequencing" in the helpfile. Following this general idea a part of the program that has a timer can be anywhere in the main subroutine OR in a subroutine that is ALWAYS called from the main subroutine (unconditional) Think of programming in subroutines as inserting a number of ladder rungs (nets) un your main program in a jazz controller, but keeping it neater. these rungs could always be executed (unconditional) or only under certain circumstances (conditional) but instead of actually putting these rungs (nets) there you have them neatly labled and stored in a subroutine. I hope this helps. Peter van Hoof
Kikis Posted May 30, 2012 Author Report Posted May 30, 2012 Hi peter, My main mistake is that i was thinking that the PLC couldn't scan 2 or more sub-routines simultaneously. Now everything is clear for me. Thank you very much for your support. It really helped me!!
Kikis Posted May 31, 2012 Author Report Posted May 31, 2012 I've got another one question and i hope that someone here could help me. Project optimizer found some duplicate coils in my program. My application demands manual, semi-auto and auto mode operation. Therefore certain Outputs are used several times in different subroutines. These sub-routines are called conditionally and they are never running simultaneously as the machine can't be in auto and manual mode at the same time. What's the problem with dublicated coils? Thanks, kikis
MVP 2023 Joe Tauser Posted June 1, 2012 MVP 2023 Report Posted June 1, 2012 The optimizer doesn't know that the subroutines won't run at the same time. The fact is they CAN run at the same time; you're just programming them so they won't. Using the same normal coil twice in a program is really bad form anyway. A better way is to have a separate coil for the same function in each routine and then OR them to the real output in another subroutine. This way of programming is so much easier to troubleshoot - you don't have to check which subroutine is active. Just look at the coil that's on and you'll know. The PLC doesn't weigh any more or the program run any slower if you use more coil addresses. One of the arts of programming is writing it so someone else can figure out what you've done in case a tree falls on you or the machine gets shipped across the country or halfway around the world and you're not there when something goes wrong. Or you have to go back two years later and figure out what you were thinking. Joe T.
Damian Posted June 1, 2012 Report Posted June 1, 2012 One of the arts of programming is writing it so someone else can figure out what you've done in case a tree falls on you or the machine gets shipped across the country or halfway around the world and you're not there when something goes wrong. Or you have to go back two years later and figure out what you were thinking.Joe T +10
Kikis Posted June 1, 2012 Author Report Posted June 1, 2012 Thanks again for the feedback. I have to say that the compiler and project optimizer are really helpful tools. It would be really great if Visilogic offered also a Project simulator that will run without connection to the PLC.
2rlp Posted June 4, 2012 Report Posted June 4, 2012 We are thinking about idea of simulator. A welcome move
MVP 2023 Flex727 Posted June 5, 2012 MVP 2023 Report Posted June 5, 2012 We are thinking about idea of simulator. Emil, users have been BEGGING for this, along with online edits, for many years now. Do you think the idea of a simulator will advance from the "thinking" stage to the "planning" stage anytime soon?
Emil Posted June 5, 2012 Report Posted June 5, 2012 Sorry, at this stage the information on this matter is clasified and I cannot share it.
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