[PIC] three floor elevator programming

Status
Not open for further replies.

adnan namal

Junior Member level 3
Joined
Dec 17, 2013
Messages
26
Helped
3
Reputation
6
Reaction score
3
Trophy points
3
Visit site
Activity points
178
I am working on my FYP "controller for three storey elevator". The main problem is that i am not good in programming. I designed a prototype for my project, there is no door option and i used 4 limit switches one on 1st floor, two are on 2nd floor for up down call and one is at floor 3. There are three switches inside the lift for three floors. I am using pic16f877a micro-controller for my project and three light sensors to detect lift car. I need help how to program micro-controller using real traffic management system for lift. It is not possible to use only if, else statement, i saw on different forums, blogs and papers they used switch statement but i don't understand it. I will be grateful i someone help me to figure it out.
 

you might want to look into STATE functions. Use global variables to hold the states. You need two functions related to it. One to find the state, and another to set the state.

The state function(s) for the elevator might set/find: door open/closed, elevator moving up/down/stationary, and which floor it is or last at.

Another different state for elevator requests[the button pushed, up/down, destination].

As a floor request is made, you have to be able to determine where it goes in the stack of floor destinations. I.e. elevator is on 3rd floor and 1st button is pressed. Some-one on 2nd floor presses the down button, so that request should jump to the top of stack.

A switch statement is like a fancy if statement. If the value of the variable is this, then do these statements. If it is not, then go to the next test. https://www.cprogramming.com/tutorial/lesson5.html
https://www.codingunit.com/c-tutorial-the-if-and-switch-statement https://en.wikipedia.org/wiki/Switch_statement https://www.programiz.com/c-programming/c-switch-case-statement
 
kam1787 thanks for your reply..... I am working on same algorithm but i will be very thankful to you if you send me example (in microC pro syntax if possible) of code for above same situation and how to make these state as you mentioned... Thanks again
 

This project is very largely a software project, and a complex one at that. Have you discussed it with your professor? Maybe try to get a project that is more suited to your ability.
 
I only need the sample code. I stuck on programming part. After two months i have to submit the project. i am working on hardware part and i have lift prototype on which i will implement my circuits. Many thanks
 

You also need to store the states in internal eeprom. If there is a power failure then after power restore or generator ON the elevator should act depending upon the previous state read from eeprom.
 
Sir i have completed the hardware part of my project and basic programming using Hall buttons + Lift buttons. as well. Know i am stuck on some part of programming like i don't know how to store and serve the requests while lift is moving..
Know sir kindly add one thing in my code is to store one request when lift is moving from floor 0 to floor 2 and there is one request from floor 1 down hall call (to move down), lift continue to move up to floor 2 then it will move down to floor 1. By understanding this part i will be able to complete all other tasks.
 

Attachments

  • PROGRAM+proteus.zip
    68.3 KB · Views: 139

as mentioned previously

you can use a stack [or linked list] to hold the floor requests - - for every request and every state change you have to go through the stack and see if any requests can be fulfilled

using your example, when the [1,0] {request from floor 1 to go to floor 0} is first received, examine the stack which has only [0,2] so it won't be handled now, so add to the bottom of the stack.

when the lift reaches floor 2, re-examine the stack as there is a state change. The stack has [1,0] so that becomes active.
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…