RSlogix - Simple 2 level Elevator with Subroutine

mitureg

Member
Join Date
May 2013
Location
Canada
Posts
199
Hello everyone, thank you in advance for taking the time to read this post. All comments and advice are welcomed. I follow up on everybody in details.

I am pretty new at this and I am quite baffled with this new problem of mine.

Without further due let's get to it:

The operation of the elevator is as follows: Assuming that the elevator is at
level 1, (IP2 energised), there are two options;

The elevator could be called from level 2 by the external call button IP0 being pressed. The elevator doors should then close via OP3, once closed IP5 (doors closed sensor) should energise. At this point the elevator should start to move up via OP0 (elevator motor UP). Once the elevator reaches level 2, IP1 would energise and this should stop the elevator motor. After a short pause the elevator doors should open via OP2.

The elevator could also be operated from level 1 via the internal button IP3. The elevator doors would then close (OP3) energising IP5 (doors closed sensor). The elevator should then move up to level 2 via OP0. Once level 2 sensor IP1 energises, the elevator doors can then open via OP2.

Please have a look at my attempt with subroutines in attachment.



Much appreciated,
Cheers!

Elevator3B_1.jpg
 

Attachments

  • ELEVATOR_3b - Copy.zip
    16.3 KB · Views: 389
Here are a few comments.

Rungs 000 and 003: The Car Buttons (internal) and the Floor buttons (external) do the same jobs, so you can do one call to your Subroutine 7 using two parallel input branches. However, remember that elevator call buttons (both Car and Corridor buttons) are always the momentary-contact type (not maintained-contact). That means when you release the button, it goes off again. So when any elevator call button is pressed, you need to seal or latch it on, and also turn on an indicator light right on the button that shows it has been pressed and latched. Probably you should first latch in each button, for both floors 1 and 2, for both Car and Corridor (or Floor) buttons.

Here is the Main Lad 2 program for the LogixPro 4-floor elevator. The main is consists exclusively of JSR (Jumps) to the 6 subroutines. You could organize your elevator the exact same way. The only additional logic you might need to complete a simulated elevator would be a simulated encoder that tracks the position of the car (which fortunately is built into the LogixPro simulator version). I have a LogixPro version of the simulated encoder also (nothing but a timer and a CTU and CTD), that could easily be converted to RSLogix. You could use that to test your elevator logic. All real-world elevators now use some type of encoder or tracking device, as well as redundant limit switches on each floor. The position of the car MUST be known to the elevator controller (not usually a PLC) at all times.

ELEVATOR BASIC PROGRAM STRUCTURE.jpg ELEVATOR SIMULATED ENCODER.jpg
 
Last edited:
Hi Lancie,

I did what you requested, you can have a look (file in attachment):

Rungs 000 and 003: The Car Buttons (internal) and the Floor buttons (external) do the same jobs, so you can do one call to your Subroutine 7 using two parallel input branches. However, remember that elevator call buttons (both Car and Corridor buttons) are always the momentary-contact type (not maintained-contact). That means when you release the button, it goes off again. So when any elevator call button is pressed, you need to seal or latch it on, and also turn on an indicator light right on the button that shows it has been pressed and latched. Probably you should first latch in each button, for both floors 1 and 2, for both Car and Corridor (or Floor) buttons.

However, I think I have basics problem with JSR. I do not understand well how it works. Even though internal or external are sealed, the subroutine doesn't seems to go normally.

I am also confused with what to put on the first row of a subroutine in terms of inputs. Do I duplicate the input that is on the same rung that triggers the JSR on the main file?

The RSlogix version I have at the moment is the Micro Starter Lite version with the combo Emulate 500 and RSLinx Classic Lite. Should I upgrade, if yes, would you have a link for the instruction of an upgrade in order to get the LogixPro simulator version? Remember that I run all this in Windows 7.

Much appreciated,
Alex.
 
However, I think I have basics problem with JSR. I do not understand well how it works. Even though internal or external are sealed, the subroutine doesn't seems to go normally.

JSR simply does as it's name states, that is, it jumps to a subroutine specified by you.If nothing is placed in front of a JSR then it jumps to the subroutine every time the rung in which it is placed gets scanned.Placing any logic before JSR ensures that the subroutine get's executed only when the condition defined by the logic becomes true.It executes all the rungs in the subroutine prior to an "END" or "RET" instruction, then jumps back to the original routine and continues the execution of that routine from the rung after JSR.

I am also confused with what to put on the first row of a subroutine in terms of inputs. Do I duplicate the input that is on the same rung that triggers the JSR on the main file?

As you can see from the above explanation that doing that would make no sense.
 
Quote:
Originally Posted by mitureg
However, I think I have basics problem with JSR. I do not understand well how it works. Even though internal or external are sealed, the subroutine doesn't seems to go normally.
JSR simply does as it's name states, that is, it jumps to a subroutine specified by you.If nothing is placed in front of a JSR then it jumps to the subroutine every time the rung in which it is placed gets scanned.Placing any logic before JSR ensures that the subroutine get's executed only when the condition defined by the logic becomes true.It executes all the rungs in the subroutine prior to an "END" or "RET" instruction, then jumps back to the original routine and continues the execution of that routine from the rung after JSR.

Quote:
Originally Posted by mitureg
I am also confused with what to put on the first row of a subroutine in terms of inputs. Do I duplicate the input that is on the same rung that triggers the JSR on the main file?
As you can see from the above explanation that doing that would make no sense.
__________________

Does that mean that the first rung of a subroutine doesn't need any input?

CHeers.
 
The RSlogix version I have at the moment is the Micro Starter Lite version with the combo Emulate 500 and RSLinx Classic Lite. Should I upgrade, if yes, would you have a link for the instruction of an upgrade in order to get the LogixPro simulator version? Remember that I run all this in Windows 7.
No, LogixPro is a completely different simulator program, written by Mr. Bill Simpson from Canada, and also a PLCtalk.net member. You cannot replace (nor would you want to) replace your Micro Starter Lite with Logixpro. However, you can use LogixPro as an aid or addition to your tool box. You can upload a demo copy of LogixPro from thelearningpit.com.
http://www.thelearningpit.com/

If you decide to purchase (now $46 for the recommended CD version), schools can get a discount. You might get your instructor to order some copies, as many PLC training classes have done.

For the elevator, the advantage of LogixPro is that it has a complete layout of the elevator, showing control panel, working interactive buttons, limit switches, motor, encoder, and everything needed to run a RSLogix-type program in simulation mode. I will post a picture showing the LogixPro Elevator Simulator. The elevator PLC program has been discussed in many differnt threads on this site.

Does that mean that the first rung of a subroutine doesn't need any input?
No, the first rung of a subroutine should be thought of simply as the next rung after the last one in the ladder logic that called the subroutine (executed a JSR (Jump to Subroutine). The subroutine knows everything that your Main Ladder 2 files knows, so you do not have to pass information to it. In other words, your first subroutine rung should be constructed the same way that you build a rung in the main program. Traditionally, subroutines have a RET (Return instruction) as the last rung, but RSLogix has even made it so that if the RET is missing, the END instruction in a subroutine does the same thing as the RET.

One difference to be aware of:
Warning! Outputs controlled within a subroutine remain in their last state until the subroutine is executed again. Rockwell Software
In other words, if a subroutine is not "called", any outputs that occur only inside the subroutine will not change from their last state.

LogixPro Elevator Simulator.jpg
 
Last edited:
Some observations on your Elevator_3C - COPY program:

1. Why do you always put "COPY" at the end of your RSLogix file names? All RSLogix programs are only a copy. Any one program usually gets saved numerous times with at least 4 backup copies stored by RSLogix, and any number of other variations saved by the user. I find it best simply to add a date at the end of the file, or a revision number. Either is more useful than the "COPY" word, which does not say much about what is in the file.

2. It appears that you may be trying to put too much into your Elevator Main Lad 2 file. If you think of the Lad 2 file as merely the Table of Contents for the Chapters in a book, with an interactive link to the text of each Chapter, you will see that it is not necessary to put buttons and flags in the main file. At most, you only need one XIC bit in front of each JSR in the Elevator main ladder file. For the routine that looks for button pushes (which should be done on each and every scan of the main ladder), you do not need anything in front of that JSR, because it should be called on every scan to check for new button presses. I think your current Main Lad 2 file should mostly be moved to a "CATCH FLOOR REQUESTS" subroutine (except for the JSRs to U6, U7, and U8).

Try to think about how a real elevator operates, and how you can divide up its functions. Then make a list of those functions. Then make each function into a subroutine. You can do all that, but you should eventually arrive as similar categories in the above picture, even though your elevator only has 2 floors.

Here is the contents of Sub 4 for 4 floors. 2 floors should be very similar and about 1/2 as long.
 
Last edited:
Hi Lancie, could you post your full program for the 4 floor elevator? I need to understand how you did it as a whole. Thank you for the information on LogixPro, I will consider it.

Much appreciated,
Cheers.
 
It is already there. Tip: You may find a lot of help over in the Downloads section of this site. I see my old Elevator program has been downloaded over 8000 times.
 
I got the file, but it's an *.rsl file type. Is there any way to convert it to a .RSS ?
Congratulation on your 8000 hit on that elevator program btw.
 
Here is a LogixPro PDF print-out. It should be good student training to convert the addresses to your RSLogix MicroLogix PLC!
 
Hi Lancie, do you have any guidelines on how to shorten this program to a minimum for 2 floors? I got all the pdf reprogrammed in RSlogix and started to cut down the superfluous rungs.

Cheers.
 
Hi Lancie, I can't seem to be able to read the Elevator logic box or your pdf (LogixPro 4-Floor Elevator - Subroutine 3 - First-Scan Initialization.pdf) SBR 3 / Rung 000.

What are the variables in the MOV?

Cheers.

Car_Park_1c.jpg
 

Similar Topics

Good morning (EST), I am trying to implement the code below in on an S7-1200. It's barely half a dozen instructions, but I am stuck; I have not...
Replies
26
Views
5,696
Hello, I have a modicon background where there is a "Pulse" function that accepts an input for the deisred pulse time length. I effectively...
Replies
8
Views
2,061
Here is the rungs I have made for my school project: Basically I just press an associated Function Key (F1, F2, etc) on the PanelView to...
Replies
7
Views
1,863
I am learning Rslogix on my own when free time is available at home and have created several simple programs. My question now, is how to change...
Replies
4
Views
2,183
Hello everyone. I would like to thank anyone reading this post. I would appreciate any advice or thoughts on this program. I am a beginner. This...
Replies
28
Views
9,552
Back
Top Bottom