yassineee
Newbie
General description of the system
A freight elevator is a mechanical device used to move goods or
equipment between several levels of a building (factory, warehouse, etc.). The size and capacity of the
cabin vary depending on the specific needs of the application. The lifting system
uses an electric motor that provides the energy needed to move a load
maximum depending on the needs of the application. In general, the system also integrates
several safety devices such as those linked to not exceeding the maximum load,
and safety relating to closing doors.
System Composition
A freight elevator control system serving 2 levels (ground floor + 1st floor) is built
around a PIC16F877 microcontroller operating at a frequency of 4 MHz, and includes the
following external devices:
- Motors controlled via L293D circuits (motor driver)
o 1 motor to raise and lower the cabin
o 2 motors to open and close the two cabin doors.
- Sensors
o A weight sensor (analog) to be connected to the ADC module of the PIC16F877
o A presence sensor at the doors (digital)
o 2 end-of-stroke sensors (digital) allowing precise stopping at the level
of the desired floor
A control panel serving as a Human-Machine interface and comprising:
- Push buttons
o 2 Up/Down control buttons to raise or lower the cabin.
o A button for monitoring the good performance of workers.
- An LCD screen to display messages.
- Indicator lights for visual signaling:
o Red: presence of obstacle near the cabin doors.
o Green: cabin in race.
- A buzzer for sound signaling
System operation :
When powered on, if the goods lift is not on the ground floor, an action on the motor
allows it to be lowered, the doors are open, the LCD screen displays the message
“Ground Floor” and all the lights are off.
An action on the “Up” or “Down” buttons ensures that:
o If no obstacle is present, the cabin doors close.
o The cabin goes up or down. The LCD screen then displays the message “UP” or
“Down” and the green light is on.
o If the end of travel is detected, the cabin stops, the green light goes out and
the LCD display shows “First Floor” or “Ground Floor” depending on the floor.
o Sliding doors open to allow loading or unloading
unloading, and the buzzer activates for 4 seconds.
Closing the doors to continue the treatment described above is not
possible in the following two cases:
o detection of the presence of an obstacle in which case the LCD screen displays the message
“OBSTACLE” and the red light flashes
o exceeding the maximum authorized weight of the goods/equipment, at which
In this case, the “OVERLOAD” message is displayed and the red indicator light comes on.
In both cases, the buzzer is activated for 2 seconds.
Cabin overloading directly affects productivity within the
the factory due to delays caused by untimely additional loading and
partial unloading obligatory in order to respect the maximum weight constraint.
Furthermore, a low load multiplies the round trips and leads to a loss of
time and energy. To control the work of workers, the system records
EEPROM memory:
o The number of overload attempts
o The number of strokes with a load less than 80% of the maximum load
An action on the “Monitoring” button allows you to view for 10 seconds, these 2
performance indicators. For example :
“Overload: 2” and “Underload: 3” on the 1st and 2nd line of the LCD screen, respect.
These two indicators can be initialized at any time by a prolonged action
on the follow button.
Required work
Session n°1 (week 9): Basic version of the project
A. Study of the architecture of the PIC16F877:
Draw up a comparison table showing the difference between the PIC16F84 and the PIC16F877
in terms of
The number of Ports,
The memories used, program and data, with their storage capacities
Sources of interruptions
Additional hardware resources
B. Development and simulation of the main program without the interrupt mechanism:
Considering the operation of the freight elevator in suitable conditions (without
take into account no detector or the use of the EEPROM module)
Create an ISIS assembly including the PIC16F877 microcontroller, and the resources
necessary auxiliaries.
Write the C code for the main function including the three configuration parts,
initialization and the main loop allowing:
React following the action of one of the “Up” and “DOWN” buttons
Control: the 3 motors, the LCD screen, the green indicator light, and the buzzer.
Note: At this stage of the project, activate:
the motor moves the cabin for 10 seconds to simulate a race
complete between the 2 floors.
Door motors for 3 seconds for opening/closing.
Session #2 (week 10): Implementation of the interrupt mechanism
Incorporate limit switches into your system simulation model
(LOGICSTATE) by choosing the correct I/O pins.
Also incorporate a presence sensor to secure the closing of the doors
sliding, and a red LED
Modify code C to take into account the presence of these new sensors.
(interrupt configuration, main loop update and routine
interrupt)
Session #3 (week 11): Using the ADC module
To protect the system against the risk of deterioration caused by excess weight,
incorporate a sensor to measure weight, at a suitable pin of the PIC.
This sensor can be simulated by a potentiometer.
Update the interrupt routine.
I do the editing and the code until session 2 but the work of session 3 does not work I have a problem at the ADC interrupt level so can you correct my code please and thank you.
this is all the details of the project .
A freight elevator is a mechanical device used to move goods or
equipment between several levels of a building (factory, warehouse, etc.). The size and capacity of the
cabin vary depending on the specific needs of the application. The lifting system
uses an electric motor that provides the energy needed to move a load
maximum depending on the needs of the application. In general, the system also integrates
several safety devices such as those linked to not exceeding the maximum load,
and safety relating to closing doors.
System Composition
A freight elevator control system serving 2 levels (ground floor + 1st floor) is built
around a PIC16F877 microcontroller operating at a frequency of 4 MHz, and includes the
following external devices:
- Motors controlled via L293D circuits (motor driver)
o 1 motor to raise and lower the cabin
o 2 motors to open and close the two cabin doors.
- Sensors
o A weight sensor (analog) to be connected to the ADC module of the PIC16F877
o A presence sensor at the doors (digital)
o 2 end-of-stroke sensors (digital) allowing precise stopping at the level
of the desired floor
A control panel serving as a Human-Machine interface and comprising:
- Push buttons
o 2 Up/Down control buttons to raise or lower the cabin.
o A button for monitoring the good performance of workers.
- An LCD screen to display messages.
- Indicator lights for visual signaling:
o Red: presence of obstacle near the cabin doors.
o Green: cabin in race.
- A buzzer for sound signaling
System operation :
When powered on, if the goods lift is not on the ground floor, an action on the motor
allows it to be lowered, the doors are open, the LCD screen displays the message
“Ground Floor” and all the lights are off.
An action on the “Up” or “Down” buttons ensures that:
o If no obstacle is present, the cabin doors close.
o The cabin goes up or down. The LCD screen then displays the message “UP” or
“Down” and the green light is on.
o If the end of travel is detected, the cabin stops, the green light goes out and
the LCD display shows “First Floor” or “Ground Floor” depending on the floor.
o Sliding doors open to allow loading or unloading
unloading, and the buzzer activates for 4 seconds.
Closing the doors to continue the treatment described above is not
possible in the following two cases:
o detection of the presence of an obstacle in which case the LCD screen displays the message
“OBSTACLE” and the red light flashes
o exceeding the maximum authorized weight of the goods/equipment, at which
In this case, the “OVERLOAD” message is displayed and the red indicator light comes on.
In both cases, the buzzer is activated for 2 seconds.
Cabin overloading directly affects productivity within the
the factory due to delays caused by untimely additional loading and
partial unloading obligatory in order to respect the maximum weight constraint.
Furthermore, a low load multiplies the round trips and leads to a loss of
time and energy. To control the work of workers, the system records
EEPROM memory:
o The number of overload attempts
o The number of strokes with a load less than 80% of the maximum load
An action on the “Monitoring” button allows you to view for 10 seconds, these 2
performance indicators. For example :
“Overload: 2” and “Underload: 3” on the 1st and 2nd line of the LCD screen, respect.
These two indicators can be initialized at any time by a prolonged action
on the follow button.
Required work
Session n°1 (week 9): Basic version of the project
A. Study of the architecture of the PIC16F877:
Draw up a comparison table showing the difference between the PIC16F84 and the PIC16F877
in terms of
The number of Ports,
The memories used, program and data, with their storage capacities
Sources of interruptions
Additional hardware resources
B. Development and simulation of the main program without the interrupt mechanism:
Considering the operation of the freight elevator in suitable conditions (without
take into account no detector or the use of the EEPROM module)
Create an ISIS assembly including the PIC16F877 microcontroller, and the resources
necessary auxiliaries.
Write the C code for the main function including the three configuration parts,
initialization and the main loop allowing:
React following the action of one of the “Up” and “DOWN” buttons
Control: the 3 motors, the LCD screen, the green indicator light, and the buzzer.
Note: At this stage of the project, activate:
the motor moves the cabin for 10 seconds to simulate a race
complete between the 2 floors.
Door motors for 3 seconds for opening/closing.
Session #2 (week 10): Implementation of the interrupt mechanism
Incorporate limit switches into your system simulation model
(LOGICSTATE) by choosing the correct I/O pins.
Also incorporate a presence sensor to secure the closing of the doors
sliding, and a red LED
Modify code C to take into account the presence of these new sensors.
(interrupt configuration, main loop update and routine
interrupt)
Session #3 (week 11): Using the ADC module
To protect the system against the risk of deterioration caused by excess weight,
incorporate a sensor to measure weight, at a suitable pin of the PIC.
This sensor can be simulated by a potentiometer.
Update the interrupt routine.
I do the editing and the code until session 2 but the work of session 3 does not work I have a problem at the ADC interrupt level so can you correct my code please and thank you.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 #include <stdio.h> #include <string.h> //int adcValue; //int tmp; // Define LCD Connections sbit LCD_RS at RC0_bit; sbit LCD_EN at RC1_bit; sbit LCD_D4 at RC2_bit; sbit LCD_D5 at RC3_bit; sbit LCD_D6 at RC4_bit; sbit LCD_D7 at RC5_bit; sbit LCD_RS_Direction at TRISC0_bit; sbit LCD_EN_Direction at TRISC1_bit; sbit LCD_D4_Direction at TRISC2_bit; sbit LCD_D5_Direction at TRISC3_bit; sbit LCD_D6_Direction at TRISC4_bit; sbit LCD_D7_Direction at TRISC5_bit; #define LCD_RS PORTC.RC0 #define LCD_EN PORTC.RC1 #define LCD_D4 PORTC.RC2 #define LCD_D5 PORTC.RC3 #define LCD_D6 PORTC.RC4 #define LCD_D7 PORTC.RC5 // Define Motor and Door Connections #define MOTOR_UP_DOWN_IN1 PORTD.RD0 #define MOTOR_UP_DOWN_IN2 PORTD.RD1 #define MOTOR_DOOR_LEFT_IN3 PORTD.RD2 #define MOTOR_DOOR_LEFT_IN4 PORTD.RD3 #define MOTOR_DOOR_RIGHT_IN5 PORTD.RD4 #define MOTOR_DOOR_RIGHT_IN6 PORTD.RD5 //Define sensors #define capteur_pos PORTA.RA1 // Define Button and LED Connections #define BUTTON_UP PORTB.RB0 #define BUTTON_DOWN PORTB.RB1 #define LED_GREEN PORTA.RA2 //chpin0->2 //#define LED_BLUE PORTA.RA0 #define LED_YELLOW PORTA.RA1 #define BUZZER PORTB.RB2 void configureIO() { // Configure ports for output as needed TRISD = 0 ; TRISC = 0; // TRISB = 0b10000011; // TRISA = 0b00000100; // interruption INTCON.GIE=1; ADIE_bit = 1; PEIE_bit = 1; //NTCON.INTE=1; //OPTION_REG.INTEDG=1; INTCON.RBIE=1; INTE_bit=1; } void initialize() { //affichage de test Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,"Hello World"); //initialisation : Led - buzzer LED_GREEN = 0; BUZZER =0; //init motors //m1 MOTOR_UP_DOWN_IN1 = 0; MOTOR_UP_DOWN_IN2 = 0; //m2 MOTOR_DOOR_LEFT_IN3 = 0; MOTOR_DOOR_LEFT_IN4 = 0; //m3 MOTOR_DOOR_RIGHT_IN5 = 0; MOTOR_DOOR_RIGHT_IN6 = 0; //sensors //capteur_pos=0; } /* void adc_init() { ADCON1 = 0b10001110; ADCON0 = 0b10000001; //ADCON1 &= 0x0F; ADRESH = 0x00; ADRESL = 0x00; } */ /* int adc_read() { // Start ADC conversion GO_DONE_bit = 1; // Attends la fin de la conversion while (GO_DONE_bit); // Retourne la valeur convertie return (ADRESH << 8) | ADRESL; } void adc_interrupt() { if (PIR1.ADIF) { int adc_value = adc_read(); if (adc_value > 512) { MOTOR_DOOR_LEFT_IN4 = 0; MOTOR_DOOR_RIGHT_IN5 = 0 ; BUZZER = 0; delay_ms(1000); BUZZER = 1; delay_ms(20000); BUZZER = 0; MOTOR_DOOR_LEFT_IN3 = 1; MOTOR_DOOR_RIGHT_IN6 = 1; } PIR1.ADIF = 0; } } */ /*void interrupt() { //if(RB0_bit==1) if((INTCON.RBIE==1)&&(INTCON.RBIF==1)) { // si cause par rb7 if(PORTB.RB7==1) { MOTOR_DOOR_LEFT_IN3 = 0; MOTOR_DOOR_RIGHT_IN6 = 0; //activation buzzer BUZZER = 1; delay_ms(2000); BUZZER = 0; MOTOR_DOOR_LEFT_IN3 = 1; MOTOR_DOOR_RIGHT_IN6 = 1; } INTCON.RBIF = 0; } if(INTF==1) { } } */ /*void operateDoors() { // affichage ouverture Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "Ouverture"); // Moteur mode: ouverture MOTOR_DOOR_LEFT_IN4 = 1; MOTOR_DOOR_RIGHT_IN5 = 1; delay_ms(3000); // Open doors for 3 seconds MOTOR_DOOR_LEFT_IN4 = 0; MOTOR_DOOR_RIGHT_IN5 = 0; BUZZER = 1; delay_ms(5000); BUZZER = 0; // Stop doors for 5 seconds //affichage fermeture Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "Fermeture"); //Moteru mode : fermeture MOTOR_DOOR_LEFT_IN3 = 1; MOTOR_DOOR_RIGHT_IN6 = 1; delay_ms(3000); // Close doors for 3 seconds // interruption si sensor détécte obstacle // MOTOR_DOOR_LEFT_IN3 = 0; MOTOR_DOOR_RIGHT_IN6 = 0; }*/ /*void MonterFloor() { Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "Up"); MOTOR_UP_DOWN_IN1 = 1; LED_GREEN = 1; delay_ms(10000); MOTOR_UP_DOWN_IN1 = 0; LED_GREEN = 0; if( MOTOR_UP_DOWN_IN1 == 0) { capteur_pos=1; delay_ms(3000); } else { capteur_pos=0; } } */ /*void DescendreFloor() { Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "Down"); MOTOR_UP_DOWN_IN2 = 1; LED_GREEN = 1; delay_ms(1000); MOTOR_UP_DOWN_IN2=0; LED_GREEN = 0; if( MOTOR_UP_DOWN_IN2 == 0) { capteur_pos=1; delay_ms(3000); } else { capteur_pos=0; } }*/ /*unsigned int ADC_Read_RA2() { unsigned int result; ADCON0 = 0b10001001; // Configuration pour RA2 (AN2) en mode ADC ADCON1 = 0b10000000; // Référence de tension VCC et VSS Delay_us(20); // Délai pour la stabilité de la tension de référence GO_DONE_bit = 1; // Démarre la conversion while (GO_DONE_bit); // Attends la fin de la conversion result = (ADRESH << 8) + ADRESL; // Combine les registres ADRESH et ADRESL return result; }*/ char txt1[]="hello"; char txt2[]="nomFic"; char tension[5]; int i; int main() { configureIO(); initialize(); ADC_Init() ; //ADCON0=0b10010001; ADCON1 = 0b00001110; //Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Hello"); Lcd_Out(2,5,txt2); // tmp = ADC_Read(0); // Read analog value from channel 24 //Lcd_Cmd(_LCD_CLEAR); // Efface l'écran LCD //RB7_bit=0; /*adc_init(); adc_interrupt(); */ while (1) { i=ADC_Read(0); IntToStr(i,tension); Lcd_Cmd(_LCD_CLEAR); delay_ms(1000); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,4,"hello"); Lcd_Out(2,4,tension); delay_ms(1000); } return 0; }
this is all the details of the project .
Last edited by a moderator: