Design of a Warehouse Temperature and Humidity Monitoring System Based on CAN Bus
2026-04-06 07:38:40··#1
1. Introduction In warehouse goods management, environmental parameters such as temperature and humidity need to be monitored to ensure warehouse safety. As warehouse areas gradually expand, monitoring systems with strong transmission capabilities and long communication distances are required to effectively supervise warehouse goods. CAN (Controller Area Network) bus technology has advantages such as advanced multi-master network structure, long communication distance, low price, high reliability, large system capacity, convenient installation, low maintenance costs, and high cost-effectiveness. It is particularly suitable for monitoring large warehouses with large areas and dispersed warehouse locations. 2. System Hardware Design This system adopts a distributed monitoring network, mainly divided into upper-level and lower-level hardware. The upper-level hardware consists of a CAN communication adapter and an upper-level monitoring and management unit; the lower-level hardware consists of CAN nodes, field sensor groups, and temperature and humidity parameter controllers, as shown in Figure 1. Its working principle is that the lower-level nodes send messages containing data such as address, temperature, and humidity to the CAN bus at certain time intervals. The bus determines the highest priority data to be placed on the bus through its own arbitration, and then automatically arbitrates to send messages with relatively lower priority to the CAN bus in sequence. Since the CAN bus uses a broadcast access mode for information storage, messages can be sent to an idle bus by any node at any time. Each CAN bus node receives the message information appearing on the bus. Through message filtering and address settings of each node, the upper-level CAN node can receive the uploaded messages. After receiving the message information, the upper-level computer uses the KingSCADA software to monitor and record parameters such as warehouse temperature in real time. At the same time, the upper-level computer can send control information to the CAN bus at any time through the warehouse HMI, and the CAN bus nodes with matching addresses can receive the information. In this way, feedback control of parameters such as warehouse temperature can be realized. 2.1 Hardware Design of the Upper-Level Computer System The CAN communication adapter undertakes the data forwarding task between the upper-level computer and the CAN nodes, realizing communication between the upper-level computer and the lower-level computer. The key to realizing communication between the PC and SJA1000 using the EPP parallel port lies in implementing the SJA1000's read/write timing. There are two methods: software-generated read/write timing circuit and hardware-generated read/write timing circuit. This system uses hardware to generate the read/write timing circuit, using the time delay of logic gates to generate SJA1000 handshake signals. The circuit design is shown in Figure 2. 2.2 Hardware Design of the Lower-Level System The lower-level system includes a CAN node, a group of field sensors, and a temperature and humidity parameter controller. The CAN node mainly completes the configuration of CAN bus signals and CAN network communication. The field sensor group and parameter controller are mainly responsible for real-time monitoring of the temperature and humidity of various test points in the warehouse with the CAN node, as well as receiving commands from the upper management machine, transmitting data and providing feedback control according to the requirements of the upper management machine. The lower-level system structure is shown in Figure 3. 2.2.1 CAN Node The CAN node device mainly includes: an AT89S52 microcontroller, an SJA1000 CAN controller, and a PCA82C250 CAN bus transceiver. (1) CAN Controller SJA1000 The working mode of SJA1000 is selected by the CAN mode bit in its internal clock divider register CDR. The default mode during hardware reset is BasicCAN working mode. SJA1000 is equivalent to a storage-image I/O device relative to the microcontroller. Its address field consists of a control segment and an information buffer segment. During the download initialization, the controller can be programmed to set communication parameters. Communication on the CAN bus can be controlled by the microcontroller through this segment. Some of the internal registers of SJA1000 are writable, while others are both readable and writable. Before the system is working normally, the microcontroller needs to initialize some registers to ensure that the various parts of the system can exchange data correctly. The contents of the CAN controller are all written by the microcontroller. Its read/write timing is shown in Figure 4. From the read/write timing diagram, the microcontroller operates on SJA1000 because the address information of the data that can be stored in SJA1000 is used. The field data acquisition and control layer is responsible for acquiring data from the field and sending it to the bus in the format of the CAN protocol, and performing real-time control and monitoring of the field devices as needed. After the system is powered on, the microprocessor first initializes itself and SJA1000, and transmits the data to the CAN bus or directly displays and controls the data on-site via SJA1000; the information from the CAN bus is transmitted via an interrupt. The system generates an interrupt every time it receives a frame of information, which triggers the microprocessor to enter the interrupt service routine, reads the frame of information and transmits it to the field. (2) CAN transceiver PCA82C250 PCA82C250 is a CAN transceiver, which is the interface between the CAN controller and the physical bus. It provides the ability to drive and transmit the bus, the differential transmission capability of the CAN controller and the differential reception capability of the CAN controller. It has strong anti-interference and bus protection capabilities, and has three different working modes: high speed, slope control and standby. The power failure of a node on the bus will not affect the bus. It can achieve high-speed application within 40 m up to 1 Mb/s, and can connect up to 110 nodes. Pin 8 (RS) allows PCA82C250 to select three different working modes, as shown in Table 1. The specific circuit of the CAN node, as shown in Figure 5, is drawn based on the structural block diagram above. 2.2.2 Temperature Detection Section: The system uses the DS18B20 single-wire intelligent temperature sensor manufactured by Dallas Semiconductor. This sensor belongs to the new generation of intelligent temperature sensors adapted to microprocessors. The DS18B20 has two main operating modes: parasitic power supply mode and external power supply mode. This system uses the external power supply mode (as shown in Figure 6). 2.2.3 Humidity Detection Section: Humidity detection uses the HS1101 humidity sensor. The HS1101 is a varactor relative humidity sensor manufactured by Humireel, employing a unique process design. The HS1101 measures humidity by placing it in a 555 timer oscillation circuit, converting the capacitance change into a voltage frequency signal, which can be directly acquired by the microprocessor. The designed circuit is shown in Figure 7. The 555 chip is connected to external resistors R20 and R19, forming a charging circuit for the HS1101. Pin 7 is short-circuited to ground via an internal transistor to create a discharge circuit for the HS1101. Pins 2 and 6 are connected to an on-chip comparator, forming a multi-harmonic oscillator. R20 must be very small relative to R19, but must not fall below a minimum value. R18 is a short-circuit protection resistor. The HS1101 acts as a variable capacitor, connected to pins 2 and 6. Pin 3 serves as the short-circuit pin for R20. The equivalent capacitance of the HS1101 charges through R19 and R20 to its upper limit voltage (approximately 0.67 VCC, time T1). At this point, pin 3 of the 555 timer changes from high to low, and discharge begins through R19. Because R20 is short-circuited to ground by pin 7, it only discharges to the trigger threshold (approximately 0.33 VCC, time T2), at which point pin 3 of the 555 timer goes high. The continuous charging and discharging of the sensor through the two resistors R19 and R20 generates a square wave output. It can be concluded that there is a certain linear relationship between relative humidity and the output frequency of the 555 chip. Table 2 shows the typical frequency-humidity relationship (reference point: 25℃, relative humidity: 55%, output frequency: 6.660 kHz). The frequency of the 555 chip can be acquired by a microprocessor, and then the relative humidity value can be obtained by looking up the table. In order to improve the measurement accuracy, a lower-level computer will be used to acquire the frequency and send the frequency value to the upper-level computer for segmented processing. 2.2.4 Temperature and Humidity Control Section In the monitoring system, in addition to real-time detection of parameters such as temperature and humidity, it is also necessary to control these parameters. When the measured parameters such as temperature exceed the user-set value range, the relevant control equipment will be activated; otherwise, the control equipment will be shut down. The system uses relays to control the activation of ventilation, dehumidification and other equipment. The specific circuit design is shown in Figure 8, where J1 is used to control the ventilation equipment, and J2 and J3 are used to control humidity. 3 System Software Design The monitoring system software design is divided into the software design of the upper-level computer system and the software design of the lower-level computer system. The software of the upper-level computer system includes the monitoring and management software and the CAN adapter software. The on-site monitoring and management section primarily utilizes KingSCADA software to simulate on-site measurement points in the warehouse, collect and analyze on-site data, automatically calculate the highest, lowest, and average temperatures within the warehouse, and also calculate the highest, lowest, and average temperatures for each floor, providing real-time alarms for exceeding limits. It also enables operation and control of on-site equipment, such as activating ventilation, dehumidification, spraying, and safety protection devices, triggering alarms, and cutting off power. It automatically generates various reports and charts, establishes and stores warehouse storage history archives, and provides printing functionality. The remote monitoring and management section mainly handles remote warehouse status queries, report printing, and remote control. The CAN adapter software is developed using VB language in a Windows environment. Due to Windows protection, VB cannot directly read and write parallel ports; a separate program module is needed to achieve direct reading and writing of parallel ports. The WINIO module is used to handle VB's parallel port read/write functionality. Furthermore, since the WINIO module does not support system interrupts, a thread needs to be written in VB to query the SJA1000 interrupt status. The lower-level system software includes the CAN node software and temperature and humidity detection and control software. The software design adopts a modular approach. The main programs in the software include SJA1000 initialization, message sending, message receiving, CAN bus error handling, and the acquisition of field parameters in conjunction with sensors. 4. Conclusion This design successfully introduced the CAN bus as a communication network in the overall warehouse structure design. The lower-level computer used the AT89S52 microcontroller and SJA1000 to complete the CAN node design, while the upper-level computer completed the design of the CAN communication adapter. The upper-level computer used the VB high-level language and EPP protocol to control the SJA1000, greatly improving the system's internal speed and real-time performance, and offering advantages such as fast processing speed and low cost.