Jump to content

Subroutines and Displays


Recommended Posts

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

  • MVP 2023

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

  • MVP 2023
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

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

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

  • MVP 2023
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

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

  • MVP 2023

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...