In the warehouse management system, the traditional method is to use detection equipment such as hygrometers and bimetallic measuring instruments for manual measurement, and then ventilate, dehumidify, and cool down the warehouses that do not meet the temperature and humidity requirements. This manual method is inefficient, has large errors, and random events are difficult to predict, so the quality of warehouse management cannot be well guaranteed. The system discussed in this article is a monitoring and management system for pharmaceutical factory warehouses. In addition to supervising and controlling the lower computer (MCS-51 single-chip microcomputer), the upper computer (PC) is also used to collect data transmitted by the lower computer for database management. In addition, the upper computer can also manage the warehouse drug entry, exit, validity period, transaction method and other information, and can be queried in the form of real-time curves and reports. The lower computer (MCS-51 single-chip microcomputer. We call the MCS-51 single-chip microcomputer and its peripheral equipment the warehouse computer) is responsible for collecting information such as temperature, humidity, smoke, etc. in the warehouse and transmitting it to the upper computer. This system allows office workers to monitor and manage warehouses hundreds of meters away while sitting in their offices. It not only frees office workers from heavy physical labor, but also makes warehouse management fast and accurate, improving the management level and office automation level of the enterprise.
2 System composition and working principle
The PC is installed with a warehouse management system written in VB6 as the front-end operating system. The database format of the system adopts the VB database format, also known as the local database. This type of database file uses the same format as MicroSoft Access. The data access uses the ADO control of VB6 through the MicroSoft Jet (Joint Engineering Technology) database engine, which is fast and efficient. This management system includes inquiries on incoming drugs, incoming dates, outgoing drugs, outgoing dates, and persons in charge, as well as reminders of expired drugs. In addition, the data transmitted from the warehouse machine is displayed in real time and stored in the local hard disk for query and printing. The background system is a communication system between a host computer and multiple slave computers. Multiple slave computers continuously collect temperature, humidity, smoke and other data from the warehouse and transmit them to the host computer. The PC displays them in real time and can set temperature, humidity, smoke and other parameters. The single-chip microcomputer controls the dehumidification, cooling and alarm systems in the warehouse according to the set parameters, so that the warehouse reaches the predetermined environment. If the environment in the warehouse does not match the set environment, the single-chip microcomputer will wake up the cooling and dehumidification equipment and lock the parameters in the warehouse within the predetermined range. If there is an accident such as fire or theft, the single-chip microcomputer will drive the fire and anti-theft alarm system and transmit the signal to the host computer for display on the screen.
3 Communication between PC and MCU
3.1 Implementation of communication method
Communication between PC and MCU is realized through serial port (as shown in Figure 2). Since the MCU system level is TTL level, which is incompatible with RS-232C, and considering the communication distance, we use Max485 chip produced by Maxim to convert TTL level into RS-485 standard, and then convert between RS-485 and RS-232, and then connect to the serial port of PC. This conversion method extends the communication distance, up to 1200 meters, and improves the feasibility of the system.
3.2 Communication protocol and program design ideas
Since this system consists of one host computer and multiple slave computers, a communication code must be set for the slave computer. For simplicity, any four between 0 and 255 can be used. When the PC wants to communicate with a single-chip computer, it sends a communication code to all single-chip computers. After receiving the code, the microcontroller checks it with its own code. If they are consistent, it responds to the PC and starts communication. Other microcontrollers continue to collect and transmit data.
3.3 Host Computer Programming
There is a control in VB6 specifically used for serial communication - the MSComm control. The most commonly used properties of the MSComm control are as follows:
CommPort property: sets and returns the communication port number, specifies the serial port used for communication on the PC
Setting property: sets and returns the baud rate, parity, data bits, and stop bits in the form of a string
PortOpen property: sets and returns the status of the communication port, used to open and close the port
Rthreshold property: The MSComm control sets the CommEvent property to ComEvReceive and generates OnComm before setting and returning the number of characters to be received
Input property: returns and deletes characters from the receive buffer, used to receive data
InputLen property: sets and returns the number of characters read from the receive buffer by the Input property
Output property: writes a character to the buffer, used to send data [page]
The VB6 communication initialization program for this system is as follows:
MSComm1.CommPort = 1; select COM1 as the communication port
MSComm1.Setting ="9600,n,8,1"; set the baud rate to 9600, no parity, 8 data bits, and one stop bit
MSComm1.OutBuffersize = 256 ;Set the output buffer size to 256 bytesMSComm1.RThreshold
= 3;When there are 3 characters in the input buffer, trigger the OnComm eventIf
Not MSComm1.PortOpen = True
Then MSComm1.PortOpen = True;Open the serial port and prevent the error of opening the same serial port at runtimeEnd
IfThe
above MSComm1 is the name (Name) of the system default MSComm control. After initialization,
send data through MSComm1.Output=OutputString, and OutputString is a defined character variable (Dim OutputString As String). Generally, the Timer event of the timer is used to send data regularly, and the timer is turned off after receiving the response character. The MSComm control can directly convert the string into binary data and send it, without us using algorithms to convert it in the program. It is best to close the serial port after each transmission. Use MSComm1.PortOpen=False to achieve this. The MSComm_OnComm event can capture errors that occur during communication and can also receive data. Since the attribute value of RThreshold is 3, when the input buffer is full of three characters, the MSComm_OnComm event is triggered. By judging the received characters, the direction of the main program branch can be determined.
3.4 Lower computer program design
When the single-chip microcomputer MCS-51 of this system communicates, timer T1 is used in timing mode 2 as a frequency generator, and a crystal oscillator of 11.0592 is selected. Since the baud rate is 9600, the initial value of timer T1 is 0FDH. Initialization also requires setting the control status register SCON used to control and monitor the serial port status. The initialization program is as follows:
MOV SCON, #0C0H; Communication mode 3
MOV PCON, #00H; SMOD=0
MOV TMOD, #20H; Timer T1, working in mode 2
MOV TL1, #0FDH; Set the baud rate to 9600 MOV TH1
, #0FDH
The single-chip microcomputer is always in a passive state, and only enters the interrupt service subroutine to send data and enter the communication state after receiving the communication command. When the PC communicates with the MCU, it first sends a call signal. After receiving the agreed call signal, the MCU sends a response signal to the PC, indicating that it is ready to receive. After receiving the response signal, the PC sends a communication code. The MCU receives the communication code and subtracts it from its own code. If it is 0, it starts to accept commands and set new parameters; if it is not 0, it continues to execute the program of collecting and sending data.
3.5 Design of the library machine
The design of the library machine is based on the MCU, equipped with EPROM, A/D conversion, digital display, photoelectric isolation and control circuits. The sensor converts non-electrical quantities such as temperature and humidity into electrical quantities, which are converted into digital quantities through A/D conversion, and then sent to the PC database for storage through the serial communication of the MCU. At the same time, the MCU compares the collected results with the set parameters. If it is not within the specified parameter range or the state quantity collected by the MCU is abnormal, the photoelectric isolation amplifier is driven. After a first-level amplification, the relay can be driven to open the cooling, dehumidification equipment and alarm system. Here, photoelectric isolation can effectively avoid the false operation of the relay and improve the anti-interference ability of the system.
4 Conclusion
The management and monitoring system introduced in this paper is based on the master-slave communication structure of VB6, which has good reliability and strong feasibility. Its hardware structure is simple, the software (VB6) programming environment is friendly, the interface is flexible, and it is easy to learn and use. This system can easily control the selection of communication objects, display the collected data in real time, and the human-computer dialogue is flexible and easy to operate. The application of this serial communication technology between the single-chip microcomputer and the database provides a new direction for the development of warehouse management.
Previous article:Temperature and humidity automatic detection system composed of AT89C51/55
Next article:Design of low power consumption and high precision snow melting measuring instrument based on single chip microcomputer
Recommended ReadingLatest update time:2024-11-16 19:54
- Popular Resources
- Popular amplifiers
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- Virtualization Technology Practice Guide - High-efficiency and low-cost solutions for small and medium-sized enterprises (Wang Chunhai)
- 2024 DigiKey Innovation Contest
- MCU C language programming and Proteus simulation technology (Xu Aijun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- FPGA and Digital Image Processing
- Score points! Tell us how you have prepared for the eSports tournament so far and what you think.
- Prize live broadcast opens up IoT society Nichicon's new power storage device
- What are the main parameters for selecting magnetic beads?
- Learn embedded development from engineers——Based on STM32 and μC/OS-III
- What is the output/input impedance value of CC2xxx?
- [TI recommended course] #[High Precision Lab] Operational Amplifier: 16 Fully Differential Amplifier#
- EEWORLD University Hall----Live Replay: Infineon & Intron Explanation- How to Choose a Suitable Automotive MOSFET
- Amway uses LT768 to realize TFT industrial serial port screen solution
- What are the methods of wireless bridge relay transmission?