Current location - Education and Training Encyclopedia - Graduation thesis - Design of photoelectric counter based on single chip microcomputer!
Design of photoelectric counter based on single chip microcomputer!
The counting display circuit can finish counting and displaying the above pulse signals. Fig. 3 is a block diagram of a counting system composed of a single chip microcomputer.

The counting system is based on MCS-5 1 series single chip microcomputer 803 1. The program memory 27C256 and data memory WM00 16DRH are extended on the periphery of 80 13 single chip microcomputer. In addition, I/O port is extended to 8255, which also has clock unit, power-off protection, watchdog unit, communication unit and LED (light emitting diode).

1)803 1 single chip microcomputer and memory

803 1 contains 4kb EEPROM program memory, which has the characteristics of low power consumption and strong anti-interference ability and can be placed in the monitoring site. The data memory WM00 16DRH is a multifunctional nonvolatile SRAM, which has the following characteristics: high speed, high anti-interference and self-retention, no fear of power failure, no loss of data after switching on and off for millions of times, power failure protection valid for 10 years, continuous high-speed reading and writing, single byte operation at any address, no need to piece together pages, random reading and writing without waiting, immediate effect, and TTL/compatible input and output.

2) Counting and display

The pulses corresponding to the traffic volume of multi-lane vehicles are input to the P 1 port of 803 1 single chip microcomputer in parallel through photoelectric isolation coupling. The counting value is controlled by software and set by keyboard, and displayed by LED. There are two modes: automatic cycle display and fixed-point display, which can be switched at will [4].

When the installation position of the pyroelectric sensor is fixed, the pulse width and duty ratio of the input pulse depend on the speed and distance on the expressway (the pulse width corresponds to the time in the effective monitoring direction of the vehicle sensor, and the speed and distance are limited), and the duty ratio Q is less than 50%. In order to accurately pick up the traffic flow information, the software can realize that the reading period of each parallel input data is shorter than the pulse width, and calculate the data read in two adjacent reading periods of each channel (temporarily storing the data read in the previous period). Where 0 is the reading data of the last cycle, when the pulse is at low level, and 1 is the reading data of the next cycle, when the pulse is at high level, thus avoiding the omission and repeated counting of the pulse, and then adding the four readings once every cycle, the sum of the accumulations is the total traffic flow.

The timer/counter in 803 1 single chip microcomputer is set to the working mode of 1, forming a 16-bit binary counter [5], and the 5-bit decimal counter [5] is directly driven by dynamic scanning. The dynamic scanning mode is adopted to directly drive the 5-digit decimal LED display screen, and the maximum count value reaches 65,536, which can record the traffic volume of four vehicles and display the daily traffic volume in one month, and accumulate the total daily traffic volume of four lanes in one month, and the data protection time in the counter can reach one month. When the counter reaches the set value, it will give an audible and visual alarm, store the data and reset it manually.

3) Clock unit

DS 12C887 real-time clock chip has the function of displaying specific time information. If the adjustment and setting buttons are designed, the time can be easily adjusted and set, thus providing accurate time data for traffic statistics.

4) serial communication unit

Due to the limited data storage and data processing ability of the single chip microcomputer system and the high real-time requirement on site, the single chip microcomputer can only temporarily store and simply process the collected data. As for a large number of data storage and subsequent complex data processing, it can be handed over to the upper computer. Because the host computer has RS-232 standard serial port, data communication with the host computer can be realized through TTL level full-duplex serial port of 803 1 single chip microcomputer and additional RS-232 level conversion circuit MAX3232.

3 Software design

The counting system program mainly includes system self-checking program, system initialization program, keyboard scanning program, key processing program, display program and data acquisition processing program. Figure 4 shows the main program flow.

4 Installation and debugging