introduction
This article uses VHDL language to design a practical three-layer elevator controller . Its code has good readability and easy to understand. The source program is simulated by A1tera's MAX + plus II software, and the target device is CPLD device. Through the design of the three-story elevator controller, we can find that this design has a certain scalability, and can be used as the basis for the realization of more elevator controllers.
If you want to realize the control of the n-level elevator, you must first add all the buttons at the port, and the indicator light only needs to change the 3 in the vector to n. At the same time, you need to add other statements that trigger the indicator light in the key control process. In the elevator's lifting state, change 3 to n, in the elevator's door opening state, change 2 to n-1, in the door closing state, change posiTIon = 3 to posiTIon = n, the key is to modify the part of posiTIon = 2, if you follow the It is very cumbersome to list each layer, so you have to find the commonality of the judgment conditions of each layer. One of the solutions is to create a new global vector one as std-logic-veoter (n downto 3) should be rewritten to 0, and then stoplight and fuplight Vector comparison, if there is a higher level request, then stoplight or fuplight vector, if both stoplight and fuplight vector are less than one vector, it means there is no higher level internal ascent request, then compare fdnlight vector and one vector, if it is greater than It means that the high-rise has a descent request and the elevator must go up. If there is no request signal, the elevator stops, otherwise the elevator descends. This can greatly simplify the program, but it should be noted that the one vector must be updated in real time, as a basis for judgment, you can write another process and use buttonclk to trigger.
1 Functions to be realized by the three-story elevator controller
(1) There is an up and down request switch at the entrance of each floor elevator, and a stop request switch at the customer arrival level is provided in the elevator.
(2) Equipped with an elevator entrance position indication device and elevator operation mode (up or down) indication device.
(3) The elevator goes up (down) one floor every second.
(4) The elevator arrives at the floor with a stop request. After 1 second, the elevator door opens and the door opening indicator lights. After 4 seconds, the elevator door closes (the door opening indicator goes off) and the elevator continues until the last request signal is executed. Stay on the current level.
(5) All requests inside and outside the elevator can be memorized and responded in order according to the elevator operation rules. Each request signal is retained until it is eliminated after execution.
(6) Elevator operation rule 1: When the elevator is in the ascending mode, it only responds to the upstairs request signal higher than the position of the elevator, and executes one by one from the bottom up until the last request to go up is completed; Then go directly to the highest level requested by going downstairs, and then enter the descent mode. When the elevator is in the descent mode, it is opposite to the ascent mode.
(7) The initial state of the elevator is the first floor open state.
2 Design plan and demonstration
2.1 Design scheme of the controller
The functional modules of the controller are shown in Figure 1, including the main controller, sub-controller, floor selector, status display, decoder and floor display. The passenger selects the floor to be reached in the elevator, and the elevator starts to run through the processing of the main controller. The status display shows the running status of the elevator, and the number of floors where the elevator is located is decoded by the decoder to be displayed on the floor display. The sub-controller transmits the valid request to the main controller for processing, and at the same time displays the running status of the elevator and the number of floors where the elevator is located. Since the sub-controller is relatively simple, the main controller is the core part.
2.2 Design idea of ​​the three-story elevator controller
The elevator controller is implemented with a state machine, and the idea is relatively clear. You can think of every second that the elevator waits as well as opening and closing the door as an independent state. Since the elevator goes up or down by one layer every second, the state machine can be triggered by a uniform clock with a period of 1 second. According to the actual working situation of the elevator, the state machine can be set to 10 states, namely, "the elevator stays on the first floor", "door opening", "door closing", "door opening waiting for 1 second", "door opening waiting for 2 seconds" , "Wait for door opening for 3 seconds", "Wait for door opening for 4 seconds", "Up", "Down" and "Stopped state". The transition conditions between various states can be determined by the above design requirements.
3 Comprehensive design of the three-story elevator controller
3.1 The physical design of the three-story elevator controller
First consider the input port, an asynchronous reset port reset, used to return to the initial state when the system is abnormal; outside the elevator, there must be a lift request port, the first layer is the lowest layer, there is no need to have a descent request, and the third layer is the highest layer , There is no need to have an ascent request, there are ascending and descending request ports on the second floor; inside the elevator, there should be a request port for staying on each floor: an elevator clock input port, the input clock takes 1 second as a cycle for Drive the elevator to move up and down and open and close the door; there is also a key clock input port, the clock frequency is higher than the elevator clock.
The second is the output port. After there is a lift request signal, there must be an output port to indicate whether the request is responded. After there is a request signal, the output port outputs logic 'l'. After being responded, the logic 'O' is restored; similarly, there should be such an output port inside the elevator to show whether the stop of each floor is responded; outside the elevator, a port is needed to indicate where the elevator is now; the elevator opens and closes the door The output status can also be indicated by an output port; in order to observe whether the elevator is operating correctly, an output port can be set to indicate the elevator's lifting status.
ALLIN , https://www.nbdisplayapio.com