Design and test a control system for a service lift operating for four floors. The microcontroller (ATMega2560) is used to determine which contactor to provide power in order to activate the lift motor to move the lift up or down by checking the floor the lift is currently at. The control system should be also able to stop the power to the lift when it has reached the required floor. An integral safety factor should be implemented to always close the lift door before moving up or down. The control system is successfully able to determine which contactor needs to be powered in order to move the lift to the desired floor. The system is able to control the safety lift door motor in order to close the door when the lift needs to move and open the door automatically when it has reached the required floor.
A 3 phase motor is used in this application as this is requires a powerful motor which can handle a heavy load. The 3 phase motor is powered through the main 3 phase power. Power through the main’s runs through two main contactors. When the first contactor is switched on and the second contactor is switched off, power runs through the first contactor to the winding of the motor which moves the motor in the forward direction.
When the second contactor is switched on and the first contactor is switched off, power runs through the second contactor to the winding of the motor which moves the motor in the backward direction. Note that the wiring is different for the reverse direction.
In order to detect the floor the lift is currently at, a limit switch is used. As the lift moves up or down it closes and opens a limit switch on each floor. When the lift is at a particular floor the limit floor at that particular floor is closed indicating to the microcontroller the floor the lift is at. As the lift moves the limit switch opens indicating to the microcontroller that the lift is moving.
The transition from low to high signal produced by the limit switch when the lift moves through a floor happens in a fraction of a second and often too quick to be detected by the microcontroller. The limit switches are connected to a 5V DC supply and the output from the NO(Normally Open) terminal is connected to an IO pin of the microcontroller. Four limit switches at four floors send data to the microcontroller. This enables the microcontroller to determine the floor the lift is at by checking which pin went from low to high. The transition of a limit switch’s state is shown in the diagram below:
The tricky task is to enable the microcontroller to detect the transition from low to high. There are two methods to approach this issue. First method is to determine if a limit switch pin goes HIGH inside the loop function using an if condition. The program essentially while executing other code always checks if a pin goes HIGH. This takes up a lot of memory as the program is constantly looking for a HIGH signal from a limit switch pin. Another problem is that sometimes the program might miss this transition as the loop function was executing some other code while a transition occurs. In order to avoid these problems, Interrupts are used. Interrupts essentially pause the execution of code and execute a separate function when a specific interrupt condition is satisfied. This is ideal for the lift operation. When a limit switch pin goes from low to high an interrupt function is executed and this function checks if the lift is at the current floor and stops the lift or allow it to move further. Since the program is forced to execute the interrupt function when a limit switch is switched the system can ensure that the program does not deliberately skip detecting a floor. The microcontroller used for this application is the Arduino Mega 2560 which has 6 digital pins usable for interrupts which is ideal to use for the four floors. The first parameter to attachInterrupt is an interrupt number. Normally you should use digitalPinToInterrupt(pin) to translate the actual digital pin to the specific interrupt number. For example, if you connect to pin 3, use digitalPinToInterrupt(3) as the first parameter to attachInterrupt. It is also important to note that the delay() function won’t work inside the function executed by the Interrupt Service Routine(ISR).
The diagram above shows how the limit switches are connected to the MCU. The pins in the MCU are connected via a pull down resistor. This resistor pulls down the pin of the MCU to ground to ensure that a LOW voltage reading is read by the MCU when the limit switch is left open. The resistor configuration is shown in the diagram below.
Two 12V DC relays are used to switch AC power to the contactors of the motor which control its direction (either Up or Down). The circuit designed using Multisim is shown in the diagram below:
One end of the coil contactor of both the relay’s are connected to the 12V DC supply through a PNP transistor. The main reason of doing this is to ensure that the Motor is not provided power until the lift door is closed. Once the lift door is closed, the DoorSwitch output pin to the gate of the PNP transistor is pulled to ground ensuring that the PNP is turned on to provide the VCC power to both the relays. Therefore the relay is not turned on even if the MotorUp or MotorDown signal is HIGH. The other end of the relay coil is pulled to ground through a NPN transistor. The MotorUp signal is generated from the MCU. When the MotorUp signal is HIGH, the first NPN transistor is activated and it pulls the other coil contact to ground to complete the circuit to power the coil of the Up Relay to power the motor. The same method is used to activate the Down Relay. Reasons for using transistors to switch the Relays are:
- Both relays have 12VDC coils, therefore it is necessary to use a PNP transistor to switch the High side (12V) part of the coil as the MCU is only capable of producing 5V which is not enough to turn the relay coil on.
- Transistors can be used to switch on the relay by using minimal current from the MCU as little current through the base of the transistor activates it. This saves power in the MCU when it needs to switch the relays.
- It also isolates the MCU from any back current which can flow back to the pin of the MCU which can potentially damage the MCU.
A Flyback diode is installed across the coil contacts of the relay to ensure that the back current has a path to flow when the coil is switched on and off. Inductive loads such as a coil in the relay create sudden voltage spikes when the supply current is suddenly interrupted. This adds extra protection to the MCU. The diagram below shows how to connect a flyback diode across the coil contactors of the relay.
User controls the operation of the lift through floor buttons. There are four floor push buttons, when pressed indicates to the microcontroller that the lift needs to be brought to the desired floor.
A push button when pressed momentarily creates a HIGH signal and a then LOW signal when the user releases the button. The task of the microcontroller is to identify a HIGH signal from a floor button pressed by the user. This particular task need not be handled through an interrupt. As long as the user presses the button for a sufficient period of time the MCU is able to register the signal from the button. The next task of the microcontroller is to assess whether to turn the Up or Down motor depending on the user input and the current floor of the lift.
With smart programming through microcontrollers we can eliminate additional hardware that would have been required if a system is designed purely through logic and analog. The previous system for the lift required an additional directional switch as shown in the diagram below was used to enable the system to identify the direction the lift is travelling (Up or down).
But through designing an algorithm to hold the current floor of the lift in a variable and comparing it to the input from the user enabled the system to completely rid of the directional switches to determine the direction the lift should move in order to get to the desired floor. For example: In the Input and floor sense connections to MCU diagram shown above, the lift is indicating to the MCU that it is on the second floor through Pin 3. Then the user inputs by pushing the Fourth floor button. The MCU receives this command and compares the two inputs. Since the input from the user, “4” is greater than the input from the limit switch, “2” the MCU sends a signal through the MotorUp Pin to activate the transistor to power the Up relay.
As the lift moves up, the current floor variable in the program gets updated when it gets to the third floor. As soon as a limit switch is triggered it is compared to the input value from the user which in this case is “4” and again compares this value to the updated current floor to determine if the lift has approached the desired floor. Once the fourth floor limit switch is triggered, the MCU identifies that the lift has approached the fourth floor and sends a LOW signal through the Motor Up signal pin to stop power to the motor to prevent it from moving further.
Another important factor is to isolate the DC control side of the microcontroller from any AC interference that could affect the MCU through the inputs of the system. A problem I was faced since I did not have any isolation hardware installed initially, AC interference which originated from the metallic body of the lift was transferred to the MCU through the limit switches. Even though the limit switches operate on a separate DC supply, input from the limit switches are directly fed to the microcontroller, interference then occurs when the lift starts moving and due to this AC interference the MCU is not able to correctly identify the floor the lift is at. To counteract this issue an Optocoupler was used for each input to isolate the MCU from outside interference.
The purpose of the optocoupler is to transfer the input signal generated from the floor limit switch to the MCU via an LED and phototransistor. When the limit switch is closed the LED is powered up and the incoming light from the LED activates the gate of the phototransistor which then transfers a HIGH signal to the MCU successfully isolating the input from the outside and the MCU.