Sign in to follow this  
Followers 0
devo.xx

PLC-5 subroutines

7 posts in this topic

Hey guys, I'm pretty new to programming AB controllers and don't know what limitations exist and where I have more freedom. (Background is with Mitsubishi) A while back I programmed using RSLogix5000 and it had a lot of power. However, this particular project is using a PLC-5 controller, so I must use RSLogix500. What I have are a bunch of "Trolleys" that drive along a track, from A-B, A-C, C-B, etc. They operate exactly the same way, drive until you are close, slow down, stop, open arms, drive away, grab another item.... In RSLogix5000, I could create a Subroutine and have Input/Return variables. So I could pass in the common "Drive to Destination" and a Structured Data Type that would handle all of the variables for the Trolley. In RSLogix500, I cannot just pass these variables in. One way I can see, is to do a bunch of "MOV" instructions to pass them in to the SBR. Then when the SBR gets executed (immediately after the "MOV" instr) it will perform the math/compares on these variables, then do a bunch of "MOV" instructions at the end. But this gets messy quick, and if anything changes inside the SBR, I need to remember to add/remove the necessary "MOV" instructions. I'd like to make my code as easy to debug and update as possible. So if I need to change the way the Trolleys handle their "Slow Down" zone (ie. maybe I want to add a "Medium Speed" zone later) I only want to have to add it ONCE. This negates having to copy/paste the new rungs in to the adjacent programs for Trolley A, B and C. Copy/Pasting has led me to miss changing one variable, or not copying one rung, etc. Is there a way to do this in Standard Ladder?

Share this post


Link to post
Share on other sites
A PLC-5 is programmed with RSLogix 5 not 500. RSLogix500 is used to program SLC500 controllers SLC5/01, SLC5/02, SLC5/03, SLC5/04, SLC5-05. What PLC do you have? PLC-5/11,PLC-5/20, PLC-5/30, PLC-5/40, PLC-5/60, PLC-5/80 or something else. (SLC-5/??) FYI, RSLogix 5 and a PLC5 do support passing parameters to a subroutine. Edited by Mickey

Share this post


Link to post
Share on other sites
1747-L551C 5/05 CPU So I guess an SLC-5/05? RSLogix500 is definitely correct :P

Share this post


Link to post
Share on other sites
To duplicate the passing of parameters I think your stuck with the "MOV" instructions. Hopefully someone else will have more to say. Edited by Mickey

Share this post


Link to post
Share on other sites
As a Maintenance Boss who jsut got rid of the last of our PLC 5 Parameter Passing nightmare machines. Please let me implore you to write the code out in long form and take the ease of troubleshoot route over the ease of writing the program {aka subroutines} route.
1 person likes this

Share this post


Link to post
Share on other sites
Well, there will be plenty of people who won't like this (will speak to it later), but here goes... Don't use MOV, use COP. If you have enough duplicate machines to justify this, you can very carefully arrange your database and I/O (plan for spares too). You arrange contiguous registers and structures (timers, counters, etc) so that each machine has the same structure. You also create a 'workspace' area of registers and structures on which your subroutine will operate; this workspace area will correspond to a typical data structure for a trolley. You may also have a common area within the subroutine for housekeeping, etc. Then for each trolley, map inputs to input trolly register, use COP to copy trolley registers to workspace use COP to copy trolly structures to workspace execute logic on workspace with subroutine return from sub and use COP to map back from workspace to trolley registers/structures map output register to trolley outputs next trolley This takes much planning and testing because field troubleshooting is more difficult should you do it this way. Don't do this if you don't plan on also incorporating extensive and comprehensive self-diagnostics to assist in normal troubleshooting. This includes alarming/messageing to tell the operator what the trolley may be waiting for, why it's interlocked, and what permissives are required, and which aren't set. When developing systems, try to do it so that after it's deployed someone doesn't have to look into the code to figure out why something isn't working. Edited by jamesau

Share this post


Link to post
Share on other sites
I think I'll stick with what BobLfoot said. They're just old PLCs working on the old standard. To map all my variables using "MOV" or "COP" will just be a nightmare.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0