Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

save button state for elevator

Status
Not open for further replies.

mshh

Full Member level 6
Joined
May 30, 2010
Messages
349
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
usa
Activity points
3,871
how to use shift register to store the multiple push buttons status till needed for elevator requests?
 
Last edited:

Ah, shift registers are usually hardware components or coded in HDL for implementation on an FPGA, is this a specific microcontroller with a built in shift register or are you using a serial interface like SPI as a shift register?
 

I don't know if hardware shift register ( not built in microcontroller) could be used for this task or not?
if you have any suggestions for this problem please help.
for example if the car of elevator in the first floor and i pressed a button in the second floor then i pressed the fourth floor button. I want it to stop in the second floor and record the request of the fourth floor to go to it.
 
Last edited:

I can't understand how elevator algorithm related to shift register. It is a complex controller with real time system that controls everything. May be shift registers is used somewhere, but it is case we should start discussion from transformer or relay. Doesn't really make sense.
 

should I use a stack to store buttons requests then restore them back ? any suggestions?
 

INTERNAL. You might scan a column of buttons to detect input state with par. in and serial out (PISO), if you scan fast enough. Then output the indicated status using another register SIPO to the interior light indicator to acknowledge input.

EXTERNAL You might remote sense each floors button input by sampling to another PISO shift register if you have a an addressable communication bus instead of dedicated wires per floor. Then again a SIPO to latch detected button.

But to use a stack on button entries would not be effective, and should be register bits for each floor.p which are OR'd with updates or XOR'd with changes for each bit(floor)

The algorithm would only seek the consecutive floors in the direction it was going.

Start your design with user interaction & system requirements
.
Then a state diagram and consider faults, delays , setup time, transit time , anything else.


Do this before you even THINK of ANY implementation. Otherwise bad design method and you will end up tearing up your design many more times , till it's right.
 

this is the program for 5 story elevator using finite state machine. could you please explain more about (PISO) how to do it or give example.
Code:
#include <mega16.h>
#include <delay.h>
//////////////////////////////////
#define BUTTON_0  PINC.0
#define BUTTON_1  PINC.1
#define BUTTON_2  PINC.2
#define BUTTON_3  PINC.3
#define BUTTON_4  PINC.4

#define SENSOR_0  PIND.0
#define SENSOR_1  PIND.1
#define SENSOR_2  PIND.2
#define SENSOR_3  PIND.3
#define SENSOR_4  PIND.4
//////////////////////////
/////////////////////////////////
////////////////////////

 enum elevator_state {
  PARKED_0  = 0x10,
  PARKED_1  = 0x11,
  PARKED_2  = 0x12,
  PARKED_3  = 0x13,
  PARKED_4  = 0x14,
  
  UP_TO_1   = 0x21,
  UP_TO_2   = 0x22,
  UP_TO_3   = 0x23,
  UP_TO_4   = 0x24,

  DOWN_TO_3 = 0x43,
  DOWN_TO_2 = 0x42,
  DOWN_TO_1 = 0x41,
  DOWN_TO_0 = 0x40,

  UNKNOWN   = 0xff,
};

enum motor_state {
  STOP      = 0x00,
  MOVE_UP   = 0xc0,
  MOVE_DOWN = 0x80,
};




// global variables for state-machine state and motor control
// 
unsigned char state = PARKED_0;
unsigned char motor = STOP;

  
////////////////////////////////
void error(void) 
{
  motor = STOP;
  for(;;) {
     PORTB.5 = 1;
 
 }    
}
//////////////////////

void main(void)
{
PORTB=0x00;DDRB=0xFF;
PORTC=0x00;DDRC=0x00;
PORTD=0x00;DDRD=0x00;


#define MOTOR_ON  PORTB.7
#define UP_NDOWN  PORTB.6


  
  for( ;; ) {
      
      switch( state ) {
        case PARKED_0:
          if (BUTTON_1 | BUTTON_2 | BUTTON_3 | BUTTON_4) {
            state = UP_TO_1;
            motor = MOVE_UP;
          }
          else {
            motor = STOP;    
          }
          break;
          
      case PARKED_1:      
        if (BUTTON_2 | BUTTON_3 | BUTTON_4) {
          state = UP_TO_2;
          motor = MOVE_UP;
        }
        else if (BUTTON_0) {
          state = DOWN_TO_0;
          motor = MOVE_DOWN;    
        }
        else {
          motor = STOP;
        }                 
          break;

      case PARKED_2:      
        if (BUTTON_3 | BUTTON_4) {
          state = UP_TO_3;
          motor = MOVE_UP;
        }
        else if (BUTTON_0 | BUTTON_1) {
          state = DOWN_TO_1;
          motor = MOVE_DOWN;    
        }
        else {
          motor = STOP;
        }                 
          break;

      case PARKED_3:      
        if (BUTTON_4) {
          state = UP_TO_4;
          motor = MOVE_UP;
        }
        else if (BUTTON_0 | BUTTON_1 | BUTTON_2 ) {
          state = DOWN_TO_2;
          motor = MOVE_DOWN;    
        }
        else {
          motor = STOP;
        }                 
          break;
                 
      case PARKED_4:      
        if (BUTTON_0 | BUTTON_1 | BUTTON_2 | BUTTON_3) {
          state = DOWN_TO_3;
          motor = MOVE_DOWN;
        }
        else {
          motor = STOP;
        }                 
          break;
          
        case UP_TO_1:
          if (SENSOR_2 | SENSOR_3 | SENSOR_4) {
            error();
          }
          if (BUTTON_2 | BUTTON_3 | BUTTON_4) {
            state = UP_TO_2;
            motor = MOVE_UP;
          }
          else if (SENSOR_1) {
            state = PARKED_1;
            motor = STOP;    
          }
          else {
            motor = MOVE_UP;    
          }
          break;

        case UP_TO_2:
          if (BUTTON_3 | BUTTON_4) {
            state = UP_TO_3;
            motor = MOVE_UP;
          }
          else if (SENSOR_2) {
            state = PARKED_2;
            motor = STOP;    
          }
          else {
            motor = MOVE_UP;    
          }
          break;

        case UP_TO_3:
          if (BUTTON_4) {
            state = UP_TO_4;
            motor = MOVE_UP;
          }
          else if (SENSOR_3) {
            state = PARKED_3;
            motor = STOP;    
          }
          else {
            motor = MOVE_UP;
          }
          break;

        case UP_TO_4:
          if (SENSOR_4) {
            state = PARKED_4;
            motor = STOP;    
          }
          else {
            motor = MOVE_UP;
          }
          break;
          
        case DOWN_TO_3:
          if (BUTTON_2 | BUTTON_1 | BUTTON_0) {
            state = DOWN_TO_2;
            motor = MOVE_DOWN;
          }
          else if (SENSOR_3) {
            state = PARKED_3;
            motor = STOP;
          }
          else {
            motor = MOVE_DOWN;
          }
        break;

        case DOWN_TO_2:
          if (BUTTON_1 | BUTTON_0) {
            state = DOWN_TO_1;
            motor = MOVE_DOWN;
          }
          else if (SENSOR_2) {
            state = PARKED_2;
            motor = STOP;
          }
          else {
            motor = MOVE_DOWN;
          }
        break;

        case DOWN_TO_1:
          if (BUTTON_0) {
            state = DOWN_TO_0;
            motor = MOVE_DOWN;
          }
          else if (SENSOR_1) {
            state = PARKED_1;
            motor = STOP;
          }
          else {
            motor = MOVE_DOWN;
          }
        break;

        case DOWN_TO_0:
          if (SENSOR_0) {
            state = PARKED_0;
            motor = STOP;
          }
          else {
  	      motor = MOVE_DOWN;
  	    }
        break;
  		
      default:
        error();
          		
  	} // end switch(state)
 
  	
  	PORTB.5   = 1;
  	PORTB.5   = 0;
  	
  	PORTB = motor;

  }
	
}
 

Do you mean that i can use hardware shift register to store calls such as 47hc595 ? But how will it store calls it is shifting?
 

Hi,

why a shift register? Why not a simple flip flop?

I can´t see how a shift register can be useful.

Klaus
 

Hi,

Button press (for individual floor) --> sets the flip flop (for individual floor)
door open at this floor --> clears the flip flop

Klaus
 

Is that mean that i should use flip flop for each floor?
as I will program it to answer the call independently.
 

Hi,

Is there any alternative?

Klaus
 

Hi,

Is that mean that i should use flip flop for each floor?
Do you see any other solution?

I don´t. But I´m not into deep in the project. It is your project.

You talk about a shift register. I dont know why. And you don´t tell us / you don´t answer the questions.
But I aussme you will have your ideas.. and we can´t read your mind..so we don´t know about your ideas.

Klaus
 

when i talked about shift register , i was asking. as i saw it on some videos on youtube. I think it was used for seven segment or counter. flip flop is good solution for saving status i will try it.
thanks
 

I think the shift register hardware concept could be used this way, if you wish. Store 'next destination' in flip flops. Use as many as needed to create a unique binary number for each floor.

Each time the elevator closes its doors, check the 'destination' set of flip flops. If it contains a number, then send it to that floor. If it contains zero, let the elevator sit idle.

The shift register action is needed if you want to record every call for an elevator. Then you have several sets of flip flops, 'next destination', '2nd next destination', '3rd next destination'. After reading a floor number, you'll need to move them all up the line, using a shift register action (I think).

- - - Updated - - -

The whole process looks cumbersome. It may not be easy to construct, or make it work correctly.
 

Brad,

You're describing a FIFO memory, which doesn't account for the priority encoding necessary to avoid skipping floors...
e.g.
you get on a floor 1 and want to go to floor 10
call comes in on floor 5 up
while passing floor 2 a call comes in from floor 4 up
shift register design would pass floor 4 to pick up floor 5
floor 4 would have to wait until the elevator is going back up to pick up floor 4.

There needs to be a priority encoding of the floors (going in the current travel direction) so all floors that have their up (or down) button selected are stopped at. Shift registers can be used for implementing arbiters, which is sort of what is needed here.
 

- - - Updated - - -

Brad,

you get on a floor 1 and want to go to floor 10
call comes in on floor 5 up
while passing floor 2 a call comes in from floor 4 up
shift register design would pass floor 4 to pick up floor 5
floor 4 would have to wait until the elevator is going back up to pick up floor 4.
.

this problem happens now in the code #7. I don't know may be the stat machine needs to be modified
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top