Elevator MANUAL
Elevator MANUAL
Elevator MANUAL
Table of contents
INTRODUCTION
This LIFT Controller is implemented using PIC Microcontroller 16F877A of Microchip. It has three floors working model. Three request floor switch and three lift position sensor switch are interfaced to microcontroller. The microcontroller is programmed to control the servo motor in both the direction, ie to up or down the lift.All revalent terminals ie ports of microcontrollers to control the lift are brought out with marked. And all port status are indicated by LED. All lift operation status, postions are displayed in 16X2 LCD Display.
Technical specification;
1. Based on PIC Microcontroller 16F877A. 2. For display 16x2 LCD display is used. 4. All control ports used in the lift operation are provided as terminals and well marked. 5. All port status are indicated by LED . 6. Build in regulated 5v powr supply with ON/OFF switch. 7.Build in ICSP ( In-circuit serial programming) terminals provided.
Operating instructions
1. First connect the patch cords from lift control unit to lift working model, ie interconnect all identically marked terminals respectively. 2. Then apply power to woking model first. 3. Switch on the power supply to control unit. 4. The control unit will first do the self check and it locate the lift postion by moving the lift and brought the lift to ground floor. Till wait for that. If connections are not properly connected, it will message it.Then recheck the connection. 5. Now Lift is ready for the operation. 6. Press any floor request switch, then the lift will move to that floor. And the next request floor or operation is enabled only after the lift reaches the previously request floor. 7. Try different floors, and monitor the port status by LED. 8. IF any hang or halt or inoperation in control, then just switch off the unit, wait for few seconds, then switch on the unit, it wil work.
ALPHA
Manual for
( Sr. No:............................)
#include <16F877A.h> #fuses HS,NOWDT,PROTECT,NOBROWNOUT,PUT,NOLVP #use delay(clock=20000000) #define SELF_TEST_DOWN_TIME 30 #define SELF_TEST_UP_TIME 6 #define REQ_0_SW PIN_C7 #define REQ_1_SW PIN_C3 #define REQ_2_SW PIN_C4 #define PUL_0_SW PIN_C6 #define PUL_1_SW PIN_C0 #define PUL_2_SW PIN_C1 #define UP_LED PIN_B6 #define DOWN_LED PIN_B7 #define INTS_PER_SECOND 76 // (20000000/(4*256*256)) unsigned char seconds=0,int_count=0,gf_flag=0; unsigned char start_pos=0,end_pos=0; struct lcd_pin_map { BOOLEAN rs; BOOLEAN rw; BOOLEAN enable; BOOLEAN unused; int data : 4; } lcd; #byte lcd = 0x8 //0xF83 #define set_tris_lcd(x) set_tris_d(x) #define lcd_type 2 #define lcd_line_two 0x40 BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6}; struct lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; struct lcd_pin_map const LCD_READ = {0,0,0,0,15}; BYTE lcd_read_byte() { BYTE low,high; set_tris_lcd(LCD_READ); lcd.rw = 1; delay_cycles(1); lcd.enable = 1; delay_cycles(1); high = lcd.data; lcd.enable = 0; delay_cycles(1); lcd.enable = 1; delay_us(1); low = lcd.data; lcd.enable = 0; set_tris_lcd(LCD_WRITE); return( (high<<4) | low); }
void lcd_send_nibble( BYTE n ) { lcd.data = n; delay_cycles(1); lcd.enable = 1; delay_us(2); lcd.enable = 0; } void lcd_send_byte( BYTE address, BYTE n ) { lcd.rs = 0; while ( bit_test(lcd_read_byte(),7) ) ; lcd.rs = address; delay_cycles(1); lcd.rw = 0; delay_cycles(1); lcd.enable = 0; lcd_send_nibble(n >> 4); lcd_send_nibble(n & 0xf); } void lcd_init() { BYTE i; set_tris_lcd(LCD_WRITE); lcd.rs = 0; lcd.rw = 0; lcd.enable = 0; delay_ms(15); for(i=1;i<=3;++i) { lcd_send_nibble(3); delay_ms(5); } lcd_send_nibble(2); for(i=0;i<=3;++i) lcd_send_byte(0,LCD_INIT_STRING[i]); } void lcd_gotoxy( BYTE x, BYTE y) { BYTE address; if(y!=1) address=lcd_line_two; else address=0; address+=x-1; lcd_send_byte(0,0x80|address); } void lcd_putc( char c) { switch (c) { case '\f' : lcd_send_byte(0,1); delay_ms(2); break; case '\1' : lcd_gotoxy(1,1); break; case '\2' : lcd_gotoxy(1,2); break; case '\b' : lcd_send_byte(0,0x10); break; default : lcd_send_byte(1,c); break; } }
char lcd_getc( BYTE x, BYTE y) { char value; lcd_gotoxy(x,y); while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low lcd.rs=1; value = lcd_read_byte(); lcd.rs=0; return(value); } #int_rtcc void clock_isr() { if(--int_count==0) { int_count=INTS_PER_SECOND; seconds++; } } void main() { set_tris_c(0xff); set_tris_b(0x00); lcd_init(); int_count=INTS_PER_SECOND; seconds=0; set_timer0(0); setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT); enable_interrupts(INT_RTCC); enable_interrupts(GLOBAL); output_low(UP_LED); output_low(DOWN_LED); printf(lcd_putc,"\f EMBEDDED\2 LIFT CONTROLLER"); delay_ms(4000); seconds=0; output_high(DOWN_LED); while(seconds!=SELF_TEST_DOWN_TIME) { if(input(PUL_0_SW)) { gf_flag=1; seconds=0; output_low(DOWN_LED); break; } printf(lcd_putc,"\f SELF TEST\2 SELF CHECK:%02d",seconds); delay_ms(250); } output_low(DOWN_LED); if(gf_flag==0) { delay_ms(1000); output_high(up_LED); seconds=0; while(seconds!=SELF_TEST_UP_TIME) { printf(lcd_putc,"\f SELF TEST\2 SELF RECHECK:%02d",seconds); delay_ms(250); } output_low(UP_LED); delay_ms(1000); output_high(DOWN_LED); seconds=0; while(seconds!=SELF_TEST_DOWN_TIME) { if(input(PUL_0_SW)) { gf_flag=1; seconds=0; output_low(DOWN_LED); break; } printf(lcd_putc,"\2 SELF RECHECK:%02d",seconds); delay_ms(250); } if(gf_flag==0) output_low(DOWN_LED); printf(lcd_putc,"\fPLEASE CHECK THE\2WIRE CONNECTIONS"); }
else printf(lcd_putc,"\fLIFT ON G.FLOOR"); output_low(UP_LED); disable_interrupts(INT_RTCC); start_pos=0; while(TRUE) { while(!input(REQ_0_SW) && !input(REQ_1_SW) && !input(REQ_2_SW)); if(input(REQ_0_SW)) { end_pos=0; } else if(input(REQ_1_SW)) { end_pos=1; } else if(input(REQ_2_SW)) { end_pos=2; } if(end_pos>start_pos) { output_low(DOWN_LED); output_high(UP_LED); printf(lcd_putc,"\2MOVING UPWARD "); } else if(end_pos<start_pos) { output_low(UP_LED); output_high(DOWN_LED); printf(lcd_putc,"\2MOVING DOWNWARD "); } else { output_low(UP_LED); output_low(DOWN_LED); if(end_pos==0) printf(lcd_putc,"\2LIFT AT GNDFLOOR"); else if(end_pos==1) printf(lcd_putc,"\2LIFT AT 1stFLOOR"); else printf(lcd_putc,"\2LIFT AT 2ndFLOOR"); } if(end_pos==0) { while(!input(PUL_0_SW)) { if(input(PUL_0_SW)) { break; } if(input(PUL_0_SW)) printf(lcd_putc,"\1LIFT IN GNDFLOOR"); if(input(PUL_1_SW)) printf(lcd_putc,"\1LIFT IN 1stFLOOR"); if(input(PUL_2_SW)) printf(lcd_putc,"\1LIFT IN 2ndFLOOR"); delay_ms(200); } } else if(end_pos==1) { while(!input(PUL_1_SW)) { if(input(PUL_1_SW)) { break; }
if(input(PUL_0_SW)) printf(lcd_putc,"\1LIFT IN GNDFLOOR"); if(input(PUL_1_SW)) printf(lcd_putc,"\1LIFT IN 1stFLOOR"); if(input(PUL_2_SW)) printf(lcd_putc,"\1LIFT IN 2ndFLOOR"); delay_ms(200); }
} else if(end_pos==2) { while(!input(PUL_2_SW)) { if(input(PUL_2_SW)) { break; } if(input(PUL_0_SW)) printf(lcd_putc,"\1LIFT IN GNDFLOOR"); if(input(PUL_1_SW)) printf(lcd_putc,"\1LIFT IN 1stFLOOR"); if(input(PUL_2_SW)) printf(lcd_putc,"\1LIFT IN 2ndFLOOR"); delay_ms(200); } } if(end_pos==0) { printf(lcd_putc,"\fLIFT AT GNDFLOOR"); } else if(end_pos==1) { printf(lcd_putc,"\fLIFT AT 1stFLOOR"); } else { printf(lcd_putc,"\fLIFT AT 2ndFLOOR"); } output_low(UP_LED); output_low(DOWN_LED); start_pos=end_pos; } }