RSlogix - Simple 2 level Elevator with Subroutine

Here is a new print-out. For the old copies, I printed directly to a PDF file, which LogixPro does not always do very well. Now in LogixPro, I first "Save file as picture", then open the JPG file and print that to a PDF. That seems to get more readable resluts.

In the first rung MOV, the "295" is the value of the built-in LogixPro Elevator encoder when the elevator is on the first floor. By setting simulated analog input I:5 (elevator encoder position) to 295 on the FIRST PLC SCAN, that causes the elevator to show up in the simulator on the bottom floor, and always starts the program with the elevator at that location. You can see the encoder locations of all 4 floors by looking at the values in the LIM instructions on Rung 000, Subroutine 7- Track Car Movement. If your elevator does not have an encoder, you will either need to write a subroutine to simulate the encoder (I have one of those too - see attached file), or you will have to substitute limit switch inputs for each floor, and try to track the elevator using those position limit switches.

There are problems with using limit switches only. Elevators usually have cables that get shorter or longer with temperature, and the elevator brakes become worn over time. So the car may not stop exactly on a limit switch each time. Even using the encoder, the elevator often travels one number past the target. That is why using the LIM instruction is a good idea, because it allows you to target a RANGE or values, not just one point. That way, if the elvator stops close enough within a range of encoder values, then your position bit for that floor will still go ON.

The CLR instruction (Clear) only has one parameter, the address of the 16-bit word that is to be cleared or set to 0's.

You need to learn how to use your RSLogix Help file.

RSLogix CLR Instruction.JPG
 

Attachments

  • LogixPro 4-Floor Elevator - Subroutine 3 - First-Scan Initialization.pdf
    116 KB · Views: 124
  • LogixPro Simuated ELEVATOR ENCODER.ZIP
    512 bytes · Views: 73
Last edited:
Complete Student Guide for Modifying LogixPro 4-Floor Elevator to 2-Floor Elevator

Hi, Lancie, do you have any guidelines on how to shorten this program to a minimum for 2 floors?
Remove all inputs and complete rungs that have references to floors higher than 2.

I will write you a Complete Student Guide for Modifying 4-Floor Elevator to 2-Floor Elevator. When deleting rungs, start with the LAST rung for each file on your "list to be deleted". Otherwise, the rung numbers will change as you delete (move up), and you will lose track of which rung numbers to delete.

Complete Student Guide for Modifying LogixPro 4-Floor Elevator to 2-Floor Elevator
(2). Main Ladder File 2: Leave as is.
(3). Subroutine 3: Leave "as is" if you use an encoder. If not, change Rung 000 to turn on the limit switch input that will place the elevator on the 1st floor.
(4). Sub 4: Delete rungs 003 and 004, and 008 to 013.
(5). Sub 5: On rung 001, delete the 2nd and 3rd input branches for floors 3 and 4 (B3 bits and GRT insructions). On rung 002, delete the 3rd floor bottom rung branch.
(6). Sub 6: leave as is.
(7). Sub 7: Delete rungs 003 and 004. On rung 005, delete the "CAR ON 3rd" and "CAR ON 4th" rung branches.
(8). Sub 8: Delete Rungs 004 and 005.
(9). There is no 9. You are done, easy-peasy!

Have you begun to see the value of using subroutines in a program with many steps? The detailed steps can be overwhelming if you try to do all in one big ladder. Broken into logical process steps, the ladder logic becomes much easier. That is a justifiable reason for using subroutines
 
Last edited:
Here are excerpts from the original subroutine descriptions for the LogixPro Multi-Floor Elevator Student Exercise, for educational purposes as allowed by copyright law.
U2, Main Ladder:
These minimal rungs only call the subroutines as needed.

U3, Initialization Subroutine:
Each time you test your program, you should first reset the simulation using the selection in the simulations menu. This will ensure that elevator is back at the first floor and all the hardware is in its initial state. When you place your program into the run mode, U3 will be executed, and it is here where you should ensure that all flags etc are in their correct initial state. In particular, the "Do Next or Wait" flag should be latched true which will ensure that subroutine U7 (Next Request or Wait) will be actively scanned at this time.

U4, Catch Floor Requests:
This subroutine is where the logic that will detect, and react to the closure of the 4th floor wall switch should be placed. The lamp for this switch should be latched on, but this should only occur if the elevator is not already at the 4th floor. In later exercises, additional logic will be added for the other switches that can initiate a change in the elevator's location.

U5, Next Request or Wait:
This subroutine is where the decision to move the elevator will be made. The built-in lamps of the wall mounted switches may be used as a flag to initiate a move of the elevator car. For now it will only be necessary to monitor flag (lamp) O:2/11 and set the "Close and Go" flag in response. This in-turn invokes the "Close Door and Move" subroutine (U7) which will take care of getting the elevator underway.

U6, Close Door and Move:
In this subroutine, locate the logic to close the door, and then energize the motor to get the elevator underway. The desired direction is obvious in this case, but later you will most certainly require flags to indicate which direction to proceed in. Before exiting this subroutine, make sure that both the "Do Next or Wait" and the "Close and Go" flags are cleared (unlatched), and set the "Car is Moving" flag so that positioning of the car will be controlled.

U7, Track Car Movement:
Once the car is moving, this subroutine takes control, and is responsible for deciding where to stop the car. In this exercise, both the direction and destination are fixed (up, 4th floor), so you will only be required to determine when the car has reached the fourth floor. Once there, the car's location should be flagged by updating the appropriate floor indicator lamps, and the "Stop and Open" flag should be set (latched) which will in-turn invoke the "Stop and Open Door" subroutine. The car's vertical position can be determined by reading the motor's shaft encoder (I:5), and equating this reading to those you have gathered for the individual floors. It may take a little trial and error to initially gather these values, but the task can be made easier if you temporarily slow the LogixPro scan rate down somewhat.

U8, Stop and Open Door:
The first thing to do here is to stop the motor and reset (unlatch) the "Car is Moving" flag. You should also extinguish the built-in lamp of the wall mounted request switch. The floor indicator lamps above the door can be utilized to determine which lamp is to be extinguished. Lastly a small 2 second settling delay should be allowed for, followed by opening the door.
 
Last edited:
OK Lancie, thank you for all the details. However, I decided to start again from scratch that program after all the new knowledge I've gained during the last week.

Remember this is a very simple program (for students) and it has to stay that way. For this one I do not wish to push it to a practical program that could be used in a real life scenario (I'm running out of time).

Simply said, there is only these output required:

IP0 External Elevator call button
IP1 Elevator on level 2 sensor
IP2 Elevator on level 1 sensor
IP3 Internal Elevator button
IP4 Door obstruction sensor
IP5 Lift door closed sensor
IP6 Lift stuck alarm button

OP0 Elevator motor UP
OP1 Elevator motor DOWN
OP2 Elevator door motor OPEN
OP3 Elevator door motor CLOSE
OP4 Alarm

There is only 2 scenario possible for the car movement:

OPTION 1:
The elevator is 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.

OPTION 2:
The elevator is 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.

"GOING DOWN":
After the elevator go up to the second floor and the doors open from the previous subroutine, the doors are held up open for a period a time, then closes. After closing the elevator car goes back down and open it's door, waiting for the next user to press the internal car button.

I decided to divide the program in subroutine according to these options (3).

This is my first try for this second version...

Much appreciated,
Cheers.
 
For this one I do not wish to push it to a practical program that could be used in a real life scenario (I'm running out of time).
Do not worry about being too practical. None of the programs presented here could ever be used for a real-life elevator (no safety switches or emergency stop and other required controls).

I decided to divide the program in subroutine according to these options (3).
I am sorry that you have learned the wrong function of subroutines, and how to incorrectly divide a program into subroutines. Dividing according to your instructions is the exact wrong approach. You should divide according to the major steps required to PERFORM those options. For 1 and 2 of your 3 options, the elevator functions will be exactly the same routine. However, dividing by your Option 1 and Option 2, you will end up with two ladder programs artifically squeezed into 2 parts, like a fat woman split into 2 different girdles.

The only way I could help you with this misguided approach would be to write the program for you. Sorry, I am not going to help you learn bad programming with your planned method.

PS: What the heck, I hate to see you mess it up even worse. Here would be your Main Lad 2 File to call your 2 Option Subroutines as you stated. Really, these two would be only typical Going Up and Going Down functions, with most buttons crippled and the Going Down routine crippled so that it automatically returns to the first floor after door is closed automatically by a timer (instead of responding to the normal elevator button controls).

Mitureg's Elevator Main Lad 2 File.jpg
 
Last edited:
You do need to wait until the doors open before activating Sub 4, and seal in the Going Up and Going Down relays (inside each Sub).

Mitureg's Elevator Main Lad 2 File.jpg
 
Last edited:
You should divide according to the major steps required to PERFORM those options.

What would be the two major steps required in order to perform those options?
These one?

-Elevator on level 1, but needs to go up to level 2 (Going UP)
-Elevator on level 2, but needs to go down to level 1 (Going Down Automatically)

Cheers.
 
Really, these two would be only typical Going Up and Going Down functions, with most buttons crippled and the Going Down routine crippled so that it automatically returns to the first floor after door is closed automatically by a timer (instead of responding to the normal elevator button controls).

I could add the internal button to trigger Going Down instead of going down automatically.
 
Please, please, please do NOT program any unnecessary delays.....

Every day I use an elevator that waits 4 seconds after you have got in to it and pressed the button for the floor you want, before closing the doors. Why? What for? the door gap sensors are clear, and the passenger(s) have made a request to go to another floor.... so why does it wait 4 seconds!! beats me.

Then, when the doors have fully closed, there is another 3 second delay before the lift starts to move. Why? What for? doors have closed, lift knows it has to go somewhere else, so what is it waiting for!! beats me.

I'd offer to rectify the shoddy programming, but I doubt it's an Allen-Bradley PLC working it, being as it is, a German lift....
 
Then, when the doors have fully closed, there is another 3 second delay before the lift starts to move. Why? What for? doors have closed, lift knows it has to go somewhere else, so what is it waiting for!! beats me.

Good point. I'll remove the unnecessary delay.

Cheers
 
OK I got a new version.

Do I have to assume that the Call Button or Internal Button have to be held long enough to seal-in B3:0/0 (Going UP)?

I added an extra rung branch to bypass a delay "waiting to go down" before the door motor closes.

Cheers.
 
Here are my suggestions to fix it. There are so many changes that I wouldn't know where to start describing them. Be sure to Verify the Project to remove the edits.

Do I have to assume that the Call Button or Internal Button have to be held long enough to seal-in B3:0/0 (Going UP)?
Yes, but that only requies 1 PLC scan, about 1 split second.

I added an extra rung branch to bypass a delay "waiting to go down" before the door motor closes.
If you do not include the "short pause" as required by your problem instructions for both going up and going down, then you have not met the specifications for the program, and should receive a lower grade for not following instructions. I have included that by using a Short Pause timer for each travel direction. No time was specifed for the "short pause", therefore you COULD set these timers to 1 x 0.01 seconds and still meet the intent of the instructions. Technically, the way this instruction is written, the short pause must occur BEFORE the doors start to open.
After a short pause, the elevator doors should open via OP2.
This is good training for the real world, where your customers will often require unreasonable and illogical items in your programs. If you want to get paid, you can include those items, or stand on your principles, leave them out, and go hungry!

You should still refuse to do anything that violates safety rules, or causes danger or damage. All other harmless little quirky requests should be done according to the contract agreement.
 
Last edited:
Then, when the doors have fully closed, there is another 3 second delay before the lift starts to move. Why? What for? doors have closed, lift knows it has to go somewhere else, so what is it waiting for!! beats me.
Due to safety concerns, there is a lot of double-checking going on during those times. Before the elevator can move, the brakes have to be released. But if they are released and the cables are too tight, or too slack to overcome the new weight in the elevator, then the elevator may jump, fall downward, or snap the cables. All are unpleasent experiences for the passengers. So the steps are: Doors close, motor takes up slack in cables until weight on brake latches is 0 (cables supporting total weight but brakes still not released). Then double checks are made on all systems to make sure the motor can raise or lower the elevator. Only then are the brakes released. This is to prevent nasty surprises (such as maybe the cables broke while the car was stopped and latched into the shaft, or the motor failed and cannot hold the weight once the brakes release).

When those type of checks are not made, and the elevator is still allowed to run (as in the attched Excel spreadsheet "History" tab), then people can get stuck when the elevator stops with maybe only the bottom two feet of the elevator doors matched up with the top 2 feet of the shaft doorway. To get out then, you have to force the elevator door open, then crawl through the small gap and drop down to the floor below.
 
Last edited:
Rung 3:2

"(Use T4:1/DN to turn off relevent outputs BEFORE the GOING UP Subroutine 3 has ended. This is so no outputs ges stranded in ON state.)"

I do not understand what this is, could you explain it, is it a typo?
This is so no outputs ges stranded in ON state

I like the way you simplified the use of the B3 for the work flow with "FINISHED GOING UP" that triggers the "GOING DOWN" subroutine.

I didn't know we could use a SBR box as an input. That is a good trick to keep the routine active until finish. I think you understood that's what I was trying to do with B3s.

We're pretty down by now. Thanks again for your help Lancie.

I will let you know when I have finished my paper. I will send you a copy through email if you want, just drop you email in PM.

Cheers.
 

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,694
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,861
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,182
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,549
Back
Top Bottom