Motor soft starter based on single chip microcomputer AT89C5l

Publisher:和谐相伴Latest update time:2011-10-31 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Due to the rapid development of microcomputer technology and the complexity of control systems, the application of multi-machine communication is becoming more and more extensive, especially in the control of some industrial processes. Multi-machine communication has become the mainstream communication method in the field of communication control.
In view of the fact that the current single-chip microcomputer books (including textbooks) rarely introduce the implementation technology of multi-machine communication, this paper designs a traffic light control network system based on the traffic light control system, and uses this as an example to give a solution for single-chip microcomputer multi-machine communication.

1 Basic principles of single-chip
microcomputer multi-machine communication In addition to point-to-point communication, communication between computers also includes one-to-multiple or multi-machine communication, which constitutes a computer network. Among them, master-slave multi-machine communication is a more commonly used method. In the master-slave multi-machine communication system, there is only one host, but there can be multiple slaves. The information sent by the host can be transmitted to each slave or a specified slave. The information sent by the slave can only be received by the host, and the slaves cannot communicate directly with each other. The host is usually a PC, but it can also be a single-chip microcomputer (this article studies the use of a single-chip microcomputer as the host), and the slave is usually a single-chip microcomputer. Mode 2 and Mode 3 of the serial port of the MCS-51 microcontroller have multi-machine communication functions, which can realize a bus-type multi-machine distributed system composed of a host and several slaves. The connection method is shown in Figure 1.

a.JPG


In multi-machine communication, the multi-machine communication control bit SM2 of the MCS-51 microcontroller can be fully utilized. The SM2 of the microcontroller used as the host should be set to 0, and the SM2 of the microcontroller used as the slave should be set to 1. There are two types of data sent by the host and received by the slave: one is the address, which is used to indicate the address of the slave that needs to communicate with the host, and is marked by the 9th bit of the serial data being "1"; the other is the data, which is marked by the 9th bit of the serial data being "0". Since SM2=1 of all slaves, each slave can always receive the address sent by the host when RI=0 (because the 9th bit of the serial data is "1") and enter its own interrupt service program. In the interrupt service program, each slave compares the received slave address with its local address (assigned during system design). All slaves that are not equal in comparison exit from their respective interrupt service programs (SM2 is still 1), and only slaves with equal comparison addresses are the slaves addressed by the host for communication. The addressed slave sets SM2=0 in the program to receive the data or command (RB8=0) that follows. The above process can be further summarized as follows:
(1) The host's SM2=0, all slaves' SM2=1, are in the listening state (can only receive address frames) to receive the address sent by the host.
(2) When the host sends a frame of address information to the slave, 8 bits are the address, and the 9th bit is 1 to indicate that it is an address frame.
(3) When SM2=1, RB8=1 and RI=0, all slaves receive the slave address frame sent by the host, perform interrupt processing, enter the corresponding interrupt service routine, and compare with the local address to confirm whether it is the addressed slave.
(4) The addressed slave clears SM2 through instructions, sets SM2=0 to enter the data receiving state, can receive the data (including commands) sent by the host, and sends the received slave address back to the host as a response signal for the host to check, thus realizing the dual-machine communication between the host and the addressed slave; the non-addressed slave keeps SM2=1 and exits the interrupt service routine.
(5) Complete the data communication between the host and the addressed slave. After the communication is completed, the addressed slave resets SM2=1, exits the interrupt service program, returns to the listening state, and waits for the next communication.

2 Traffic light control network hardware circuit design
2.1 Hardware circuit
The urban traffic control system is a linkage system. The traffic light control systems of all intersections are controlled by a central host. When an emergency occurs at an intersection (such as traffic control, traffic jam, road maintenance, etc.), clicking the corresponding button of the central host can make all the red lights at the intersection light up and prohibit all ordinary vehicles from passing. This paper uses Proteus software to simulate and design
a master-slave multi-machine system in which one host controls two slaves. When implemented, it can be expanded to 253 hosts. The hardware circuit is shown in Figure 2. The single-chip microcomputer U1 is the host, U2 and U3 are slaves, representing the control machines of the two intersections, S1 and S2 are buttons, connected to P1.1 and P1.0 of U1 respectively. When pressed, the traffic lights of the two intersections are controlled to light up all red lights, indicating that an emergency occurs at the intersection. The two BCD digital tubes connected to the host U1 are used to display the response frame received by the slave, that is, the address number of the intersection where the emergency occurs. If an error occurs in the transmission of the received response frame and it is different from the address number sent by the host, the two digital tubes display FF. When S1 and S2 are not pressed, the two digital tubes also display FF.

b.JPG


Since the "0" or "1" transmitted during serial port communication is distinguished by the voltage relative to the "ground", when using serial port communication, the "ground" lines of the master and slave devices must be connected so that they have the same voltage reference point.

2.2 Communication Protocol
Multi-machine communication is a complex communication process. Communication protocols are necessary to ensure the operability and operation order of multi-machine communication and realize the response and coordination of both the sender and receiver. These communication protocols should at least include the address of the slave, the control command of the host, the response frame format of the slave, and the data communication format. The communication protocol of the traffic light control network system established in this paper is shown in Table 1.

c.JPG


3 Software Program Design
3.1 Host Program Design
The host is mainly responsible for calling the slave, sending control commands, receiving the slave response frame, displaying data, etc. In order to ensure the success of the handshake between the master and the slave, the host uses the query method to send and receive data, and the serial port working mode is set to mode 2, SMOD=0. The flow chart is shown in Figure 3.
h.JPG
e.JPG

f.JPG


3.2 Slave Program Design
The slave runs the traffic light control program in a loop. The traffic light control program uses timer/counter 0 to achieve timing. In order to communicate with the host normally, the serial port of the slave also works in mode 2, SMOD=0, to maintain the same baud rate as the host. Since the address frame and command frame sent by the host when calling the slave are not repeated, in order to make the program simple, this article does not use the ninth bit of data to determine whether it is an address frame or a command frame after the slave receives the data sent by the host. If the received data is equal to the local address, it indicates that it is an address frame, and immediately sends its own address to the host as a response signal; if it is a command, the relevant operation is performed according to the command (all intersections turn red or restore traffic light signals); if it is neither equal to the local address nor one of the two commands, it is considered that the data is not sent to the local machine, and the machine continues to monitor. The list of interrupt service programs for receiving and sending data from the serial port of slave U2 is as follows:
d.JPG
i.JPG

4 Conclusion
It is a relatively complicated process for a single-chip microcomputer to use a serial port for multi-machine communication. Therefore, most single-chip microcomputer books do not introduce this aspect or provide examples. This article discusses the multi-machine communication of the MCS-51 single-chip microcomputer. It is a good example to use single-chip microcomputer multi-machine communication to realize networked centralized control of the urban traffic light control system. Through Proteus simulation operation (its operation is shown in Figure 3), this solution is feasible.

j.JPG


Reference address:Motor soft starter based on single chip microcomputer AT89C5l

Previous article:Design of intelligent temperature control meter with communication port based on single chip microcomputer
Next article:A Clever Application of Large-capacity EEPROM in Single-chip Microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号