Keyboard and alarm control card for digital video monitoring system based on 89C51 single chip microcomputer

Publisher:心灵舞动Latest update time:2012-12-22 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The keyboard is one of the most important input devices in the digital video surveillance system and an important part of the human-machine interface. The commonly used industrial control computer keyboard is not much different from the PC keyboard except that it is equipped with an electronic lock switch to prevent illegal keyboard input. This keyboard not only has many keys and is inflexible to operate, but is usually only used as an input device, and the host cannot communicate with the peripherals through the keyboard. Based on the analysis of the communication mode of the PC keyboard, this paper designs a digital video surveillance system keyboard and alarm control card with the 89C51 single-chip microcomputer as the core. The card has two functions: keyboard communication and input and output alarm. It adopts the structure of a standard PCI card but does not occupy the hardware resources of the host. Among them, the alarm part has 4 inputs and 4 outputs, which can be connected to standard alarm sensors; the keyboard part has 16 keys, and the communication mode is fully compatible with the PC. The use of this control card can not only save the dedicated alarm decoder commonly used in the video surveillance system, but also realize two-way communication with the peripherals without occupying the hardware resources of the host. Using this feature, the abnormal situation of the system can be discovered and solved in time, thereby greatly improving the reliability of the digital video surveillance system based on the Windows operating system currently widely used.

1 Communication method between keyboard and host

The host communicates with the keyboard through the keyboard interface. The communication between the host and the keyboard is actually the communication between the keyboard interface and the keyboard. The PC keyboard interface uses the Intel8042 chip as a controller to receive keyboard scan codes and send commands to the keyboard. In addition to the power line and the ground line, there are two bidirectional communication lines between the keyboard and the host: the clock line and the data line. Using serial transmission, data is sent and received synchronously under the action of the clock pulse. It can send keyboard responses or keyboard scan codes to the host, and can also receive keyboard commands from the host. The host instructs the keyboard to send and receive data by setting the status of the data line and the clock line:

(1) The clock line is at a low level, prohibiting the keyboard from transmitting data.

(2) The clock line is at a high level and the data line is at a low level, notifying the keyboard to receive commands or parameters.

(3) Both the clock line and the data line are at high level, allowing the keyboard to transmit data.

1.1 The keyboard sends data to the host

Since keyboard input is asynchronous and real-time, the host system supports random input of key symbols in an interrupt mode. Whenever the keyboard interface receives the serial scan code sent from the keyboard, it sends a keyboard interrupt to the interrupt system. If the CPU responds to the interrupt, the keyboard interrupt program reads the scan code, converts it into a system scan code, and stores it in the keyboard buffer. When the keyboard sends data, the data line and clock line are controlled by the keyboard. The data format of a byte sent by the keyboard is shown in Figure 1.

The keyboard sends a byte of data format

The keyboard first detects the status of the clock line and the data line. When both are high, it starts to transmit data. The start bit, 8 data bits (low bit first), check bit and stop bit are transmitted in sequence. For each bit transmitted, the clock line generates a pulse synchronously. When the host receives the pulse, it sets the clock line to a low level and keeps it for a period of time, prohibiting the keyboard from continuing to send codes, so as to verify the correctness of the data, generate an interrupt, perform code conversion and perform corresponding operations. If the check is wrong, the resend command 0FEH is sent to the keyboard to request resending. The keyboard uses odd parity to send data to the host.

1.2 Keyboard receives host commands and parameters

The host first sets the clock line to a low level, then sets the data line to a low level, and after a delay of about 200μs, sets the clock line to a high level. When the keyboard detects this state, it starts to receive host commands, and the format of the received data is the same as that sent. The keyboard receives 1 start bit, 8 data bits, 1 check bit, and 1 stop bit in sequence. It is particularly noteworthy that when receiving keyboard commands or parameters, although the data is sent from the host to the keyboard, the clock pulse is generated by the keyboard. The host outputs a bit of data on the data line for each falling edge of a pulse received on the clock line. If the reception is correct, after both the clock line and the data line become high levels, the keyboard will send a response signal (0FAH) to the host, otherwise it will send a 0FEH signal to the host to request retransmission. After the host receives the 0FEH signal, it resends the data that it has just output. If this process continues for three times and the keyboard still cannot receive correctly, the host will give up transmitting this data and switch to executing the following program or display an error message. The host commands and parameters also use odd parity.

2 System Hardware Circuit Design

This system uses 89C51 single-chip microcomputer connected to PC keyboard interface. Figure 2 shows the principle of the system hardware circuit. P3.0 and P3.1 are connected to the clock line CLK and data line DATA of the host keyboard interface respectively, P2 port is connected to the 4×4 keyboard matrix, and P0 port is connected to the input and output alarm device after being driven. To ensure the reliable operation of the keyboard, the system is equipped with a watchdog circuit MAX813L. In addition, the system is also equipped with a buzzer, and there is a sound prompt every time a key is pressed.

System hardware circuit principle

3 System Software Design

The system software mainly consists of two parts.

3.1 The keyboard sends a scan code to the host

Compatible with PC standard keyboards, when it detects that a valid key is closed, the keyboard sends a connection code to the host, and when it detects that the closed key is released, it sends a disconnection code, that is, add 0F0H before the connection code. The system uses interruption to scan the keyboard every 10 ms. Taking into account the actual situation of the digital video surveillance system, unlike the standard PC keyboard, each time a key is pressed, no matter how long it takes, only one connection code is sent, and each time a valid key is entered, there is a sound prompt.

3.2 Keyboard receives host control commands and responds

The host control command includes two parts. One part is the control command sent by the standard PC to the keyboard, which is mainly used for the keyboard self-test. The other part is the control command added by this system, which is mainly used for two-way communication with peripherals to realize the input and output alarm function. The host will perform a self-test on the keyboard when it is turned on. The host's self-test of the keyboard is realized through the keyboard control command. The host requires the keyboard to use 0FAH as a response for each command received, and after sending the keyboard reset command 0FFH, the keyboard must send 0FAH and 0AAH as the correct response for the keyboard self-test. The control command added by this system is to notify the peripherals to send out sound and light alarm signals when dynamic alarm signals and system abnormalities are detected. These control commands are realized by reading and writing the host keyboard interface status register (port address 064H) and data register (port address 060H). Figure 3 shows the keyboard processing interrupt service subroutine flowchart.

Keyboard processing interrupt service subroutine diagram

4 Conclusion

This system uses the PC keyboard interface to achieve two-way communication with peripherals without occupying the host hardware resources. The designed digital video surveillance system keyboard and alarm control card have the advantages of few keys, simple operation and high reliability. It has been successfully applied in actual digital hard disk video surveillance systems, proving that the design method is feasible and can be widely used in industrial monitoring systems.

Reference address:Keyboard and alarm control card for digital video monitoring system based on 89C51 single chip microcomputer

Previous article:Three major intelligent fields to explore the potential market of SDI optical transceivers
Next article:A brief analysis of the application of NVR equipment in bank video surveillance system

Latest Security Electronics Articles
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号