Remote Lighting Control Box System Based on 51-chip Microcomputer

Publisher:忠正Latest update time:2011-12-30 Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Computers are the symbol of today's information age. Realizing remote real-time automatic control through computers is a trend of future development. There are usually many lighting devices in large shopping malls, restaurants, stadiums and entertainment venues. In the past, switch control and circuit breaker control often required staff to frequently visit the site for operation, or to pull a long 220V wire to the control room, which had poor real-time and safety. In order to enable staff in the control room to perform real-time and effective status control and status query on remote lighting equipment scattered in various rooms, the author developed a remote lighting control box system based on a single-chip microcomputer. The system is controlled by a PC host computer to control multiple remote lighting control boxes. The system transmits commands serially through the RS-485 bus, with a transmission distance of up to 1.2km, and enhances the formulation of serial communication protocols to reduce noise interference. One lighting control box can control 16 street lights. The SST89C58 single-chip microcomputer is selected in the lighting control box. Its convenient IAP function can download Hex files online and debug without using the programmer multiple times. 1 System structure and function

The structure of the remote light control box system is shown in Figure 1, where the PC host is placed in the control room and each light box is placed near the lighting equipment. The PC host sends control instructions and transmits the instructions serially to each remote light control box through the RS-485 bus, so that the switch can be controlled in real time in the control room and the status of each light can be queried. The RS-485 bus is selected from the aspects of transmission distance and cost performance. RS-485 is a balanced line that can realize long-distance and multi-node control. The focus of this design is the light control box. The following will take a light control box as an example to introduce the software and hardware design of the system.

2 Hardware Design

2.1 Main components

The design system uses the SST89C58 microcontroller with IAP (In-Application Programming) function launched by Silicon Storage Technology. It is fully compatible with the standard 8052 microcontroller in terms of instruction system, hardware structure and on-chip resources. At the same time, the capacity of the internal program storage Flash is increased to 36KB. Six special function registers related to Flash programming and two special function registers related to watchdog reset are added. The IAP function of SST89C58 is written using a general program [1], and Keil's μVision simulation software is used for programming simulation. The generated Hex file is directly downloaded from the PC to the microcontroller through the RS-232 serial port for operation and debugging. It is very convenient to use and shortens the development cycle. The ULN2803A device is a monolithic integrated high-voltage, high-current Darlington transistor array produced by TI. The array consists of 8 NPN Darlington transistors. Its characteristics are high current gain, strong load capacity (output current can reach 500mA), and high operating voltage (withstand voltage up to 50V). The selected device is X5045, which is a 4K SPI electrically erasable memory used to store the slave station number after power failure. Maxim's MAX485 is a universal half-duplex transceiver with a transmission speed of 9.6Kb/s and a transmission distance of up to 1.2km. It can realize serial asynchronous communication between the host computer and the microcontroller. 2.2 System Core Hardware


远程灯控箱系统的核心硬件图如图2所示,以SST89C58型单片机为核心,用P0口和P2口进行信号控制,注意P0口要加上拉电阻器。通过2个ULN2803进行电流放大,可驱动16路继电器。由于片内带有共阴极箝位二极管,可适应感性负载,故输出端可省去大量二极管。SST89C58驱动16路继电器,可控制16路灯信号。若要增加控制信号,可增加8255型器件扩展并行接口。用X5045保存RS-485网络从机站号。SST89C58单片机的P1.2引脚用来模拟X5045的时钟输入信号SCK,CS=0时,串行输出SO在时钟信号下降沿有效,串行输入SI在上升沿有效(WP=1)。具体操作还需要写入状态字。串口部分选用MAX485。其中,RE与DE接在一起由单片机的RD(P3.7)控制。拉低为接收有效,拉高为发送有效。该系统还具有上电自动复位和通电指示功能。设计PCB时应注意合理布线,对单片机电源进行滤波整流,并远离干扰源。

3 System Software Design

Using C language compiler to develop single-chip microcomputer has outstanding features such as easy use, high programming efficiency and easy simulation and debugging. There are many versions of C51. The software of this system is developed with Keil C51 compiler of Keil Software Company of Germany. This compiler is based on Windows platform integrated development environment, which can edit, compile and debug assembly language programs and C51 programs. It can also simulate I/O ports, timers/counters, serial ports and interrupts and other functional components unique to single-chip microcomputers. The software design of this system consists of main program, interrupt program, serial receiving subroutine, serial sending subroutine, X5045 read and write subroutine and several function realization subroutines. Among them, X5045 read and write subroutine needs to operate the clock accurately, which is written in assembly language, and the others are written in C language.

3.1 Main program design

In the main program, first initialize SST89C58 and X5045, and then wait for new commands. When NewData=1, it means that a valid command frame has been received, otherwise continue to wait. Then determine whether it is the local address. If so, determine the control command, otherwise continue to wait. The host computer sends the specified string, which represents commands such as turning on the light, turning off the light, querying, and setting. Through string comparison, the command instruction is determined and jumps to the corresponding entry subroutine; after the operation is successful, the subroutine is sent through the serial port to return the corresponding prompt. The specific process is shown in Figure 3. In this system, the human-computer interaction interface of the host computer is developed by C++Builder. Due to space limitations, it is omitted here.

3.2 Serial port interrupt program design

In order to enhance anti-interference and effectively distinguish noise from data for easy operation, the serial port interrupt program strengthens the formulation of the communication protocol [2]. The specific implementation method is to add a start flag and an end flag. Noise appears in the form of random bytes. Through testing and experiments, it is found that noise is not easy to occur when 0x00 is followed by 0xFF in this system. Therefore, the start flag is set to 0x000xFF, and the end flag is the carriage return and line feed 0x0D0x0A. If the command frame is received successfully, NewData=1 is set to indicate that the new command is valid. Considering error correction, the data is in short packet mode. Delay is used in the middle to ensure the reliability of the start bit. The serial port interrupt program flow is shown in Figure 4. Part of the program list is as follows.

//Serial connection function

INT8U ReUART(INT8U*ch)

{INTl6U delay=6000;

while(--delay) //delay

{if(RI), /Serial receive interrupt flag

{RI=0; //Receive interrupt flag software reset

、 *ch=SBU F=//Read data buffer

return 1; } // Return l if successful

}

return(0); //Return 0 if reception fails

)

//Serial interrupt handler

void UART_Inter(void)interrupt 4

{INT8U ii;

INT8U temp,templ;

ReUART(&temp,); //First receive 2 bytes continuously

ReUART(&templ);

//Start mark

if((temp==0x00)&&(templ==0xFF))

//Continuously receive a command frame

{for(ii=0;ii<12;ii++)

{if(ReUART(&buff[ii])==0)

goto Inter._end;}//Jump out of interrupt

if((buf[10]==0x0D)&&(buf[ll]==0x0A)), / end mark

NewData=l; //New command flag is valid

}

Inter_end:; //interrupt exit

}

4 Conclusion

The remote light control box system based on SST89C58 can realize a PC host computer to control up to 256 light control boxes, with a maximum transmission distance of 1.2km. Each light control box can control 16 street lights. It realizes the functions of centralized management and decentralized control. The system improves anti-interference through software and hardware, and has good scalability, simple structure, low investment, and practical application shows that it has strong practicality.

Keywords:MCU Reference address:Remote Lighting Control Box System Based on 51-chip Microcomputer

Previous article:Using Serial Port and Parallel Port to Implement Online Programming of 51 Single Chip Microcomputer
Next article:Implementing Chinese Input Method Using C51 Single Chip Microcomputer

Recommended ReadingLatest update time:2024-11-16 18:00

Incremental programming method for STM8 microcontroller
1 Open STVP 2 PROJECT/NEW, create a project with a random name 3 PROJECT EDITION, first select the chip in Configuration, the most important thing is to set it in SerialNumbering Check Enable Serial Number, enter the address you want to select, the starting value and the step value of the byte number 4After setting up
[Microcontroller]
Incremental programming method for STM8 microcontroller
51 single chip microcomputer dot matrix design
Before making a dot matrix, let's first understand the principle of the dot matrix and the process of dot matrix display. The dot matrix is ​​actually 64 individual LEDs arranged in 8 rows and 8 columns. ROW1-8 and COL1-8 control the 1-8 LEDs of the rows and columns respectively. When ROWx is high and COLy is low, th
[Microcontroller]
51 single chip microcomputer dot matrix design
51 single chip microcomputer automatic clothes drying source program circuit diagram and physical diagram
The circuit schematic is as follows:   The actual picture produced is as follows:     The microcontroller source program is as follows: #include REGX51.H #include intrins.h #include math.h       #include stdio.h         #define uchar unsigned char #define uint unsigned int sbit DATA=P1^0; sbit MOTOR_A_1=P2^5; //
[Microcontroller]
51 single chip microcomputer automatic clothes drying source program circuit diagram and physical diagram
A brief discussion on the application of C8051 single chip microcomputer in variable air volume air conditioning control system
1. Introduction: The variable air volume (VAV) air conditioning system is an air conditioning system that uses a variable air volume box to adjust the air volume and the fresh air return mixing ratio of the room, and adjusts the air volume or fresh air return mixing ratio of the air conditioning unit accord
[Microcontroller]
Multiphase multifunctional energy measurement meter based on ADE7758 and MCU
0 Preface     Like developed countries, my country is vigorously promoting time-of-use electricity prices to ease the current tight electricity supply situation as the marketization of electricity supply gradually deepens and computer networks are rapidly popularized and developed. Dual-rate electronic energy meters h
[Microcontroller]
Multiphase multifunctional energy measurement meter based on ADE7758 and MCU
AT89C51 microcontroller assembly language to write alarm signal program
Use P1.0 to output 1KHz and 500Hz audio signals to drive the speaker as an alarm signal. It is required that the 1KHz signal sound for 100ms and the 500Hz signal sound for 200ms, alternating between them. ; Use P1.0 to output 1KHz and 500Hz audio signals to drive the speaker ;Requires 1KHz signal to ring for 100ms
[Microcontroller]
51 MCU Development Series 4_LED Dot Matrix Scanning Display
LED dot matrix screen has strong luminous brightness and good indication effect. It can produce moving luminous pictures and texts, which are more likely to attract people's attention. It has a large amount of information and can be updated at any time. It has very good advertising and notice effects. Here, the author
[Microcontroller]
51 MCU Development Series 4_LED Dot Matrix Scanning Display
Detailed explanation of new energy vehicle controllers: VCU, ECU, MCU and battery BMS
The various controllers in new energy vehicles mainly include: vehicle control unit (VCU), engine control unit (ECU), motor control unit (MCU) and battery management system (BMS). The three electric technologies of new energy vehicles include battery, electric drive and electric control. The battery part
[Automotive Electronics]
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号