Design of a temperature detection node based on CAN bus
2026-04-06 05:59:01··#1
In testing electronic ignition modules, to simulate the real operating conditions of the electronic ignition system, the modules are often placed in an environment above room temperature to obtain ignition parameter data closest to real automotive operating conditions. Due to the heat generated by the electronic ignition module itself, the temperature of its core components becomes a crucial factor affecting the module's performance; additionally, whether the ambient temperature meets the requirements for simulating real operating conditions must also be considered. This paper introduces a design scheme using an LM35 temperature sensor and a PICMicro temperature detection node to detect the core module temperature and ambient temperature of the electronic ignition module during simulated automotive electronic ignition. The module structure, working principle, and sampling value quantization method will be explained. Node Principle and Structure The temperature detection node consists of a sensor circuit, a signal conditioning circuit, a microcontroller application system, and a CAN bus interface. The basic working principle of the circuit is as follows: the sensor circuit outputs the sensed temperature signal as a voltage to the signal conditioning circuit. After conditioning, the signal is input to the A/D sampling circuit, where the ADC sends the digital value to the microcontroller system. The microcontroller system monitors the real-time temperature. When the temperature exceeds the warning and danger thresholds, the microcontroller will proactively send a warning message to the host computer to remind the operator to check. The module logic structure is shown in Figure 1. Figure 1: Logic Structure of the Temperature Detection Node. The sensor circuit uses an LM35 temperature sensor, powered by 15V DC, with an operating current of 120mA. It has extremely low power consumption, and the current change is minimal across the entire temperature range. The voltage output uses a differential signal, directly output from pins 2 and 3. The LM35 output signal passes through an LP filter composed of RC circuitry to filter out high-frequency noise interference. The core MCU of this node is the PIC16F87x, a low-power 8-bit microcontroller from Microchip. The PIC16F87x has a simplified instruction set and an execution speed of 200ns. The CAN controller uses Microchip's MCP2510, the bus driver uses a PCA82C250, the bus isolation circuit uses an optocoupler 6N317, and the signal conditioning circuit uses an LF412. The hardware structure of the temperature monitoring module is shown in Figure 2. Figure 2 shows the hardware structure of the temperature monitoring module. The signal conditioning circuit mainly amplifies and limits the sensor signal, conditioning the DC voltage output of the sensor circuit, which is approximately 2V, to conform to the voltage range of the PICMicro's AD interface. This ensures that the signal does not exceed the AD sampling range while maintaining sufficient signal accuracy. The microcontroller acquires the sensor's temperature data through the A/D sampling channel and calculates the temperature range. The peripheral circuits are the necessary peripherals required for the operation of the PIC16F87x minimum system. The PIC16F87x exchanges data with the MCP2510 via the SPI bus, completing the sending and receiving of CAN bus data packets. Its interface circuit is shown in Figure 3. Figure 3 shows the interface circuit between the PIC16F87x and MCP2510. SCK is the SPI bus clock. The SPI interface of the PIC16F87x module connects to SI, SO, and SCK of the MCP2510. RA4 and RA1 control the chip reset and chip select of the MCP2510, respectively. INT accepts interrupt requests from the MCP2510. System Software Design 1. System Software Flow To avoid malfunctions due to interference, the software employs redundancy and fault-tolerance measures. When the A/D module processes sampled data, software filtering is used to remove potential spike interference from the circuit. The method involves sampling five times consecutively, comparing and removing the maximum and minimum values, summing the remaining three values, and taking the average. This average is used by the CPU to define the temperature range. Data packet parsing and encapsulation follow the CAN application layer protocol. The main program flow is shown in Figure 4. Figure 4: Main Program Flow When the CPU detects an abnormal temperature, it sends a temperature abnormality alarm to the host computer based on the abnormal temperature range. This is the only data frame actively sent by the CPU to the host computer at this node. The node's temperature-related data is stored in a buffer. When no data request is received from the host computer, the data in this buffer is continuously refreshed with new data to ensure the real-time performance of the node's data. The interrupt flow is shown in Figure 5. Figure 5: CAN Receive Interrupt Flow 2. Quantization Method of Sampled Values Accurate quantization of sampled values is crucial for the normal operation of the temperature control circuit. The following conversion method is used for quantization. Let the voltage after signal conditioning be Ui, then -10V Ui = -10V + ΔT·Kt = -10V + 55℃ × 0.111V/℃ = -3.895V. After Ui is converted into a digital quantity, each digital quantity corresponds to a voltage value of 19.531mV, denoted by Ks. The correspondence between the digital quantity change and the temperature change can be obtained: Kt/Ks = (0.111V/℃) / (19.531mV/digital quantity) = 5.683 digital quantity/℃. The digital quantities corresponding to other temperatures can also be calculated using the above method. 3. SPI Interface Communication The PIC16F87x exchanges data with the MCP2510 through the SPI interface. The MCP2510 is designed to connect directly to the Serial Peripheral Interface (SPI) of many microcontrollers. External data and commands are transmitted to the device through the SI pin, while data is transmitted on the rising edge of the SCK clock signal. The MCP2510 sends instruction bytes via the SO pin on the falling edge of SCK. Table 1 lists all the instruction bytes for the operation. Taking the PIC16F87x sending a read instruction to the MCP2510 as an example, the SPI interface communication process is illustrated. At the start of the read operation, the CS pin is set to low. Subsequently, the read instruction and the 8-bit address code (A7~A0) are sequentially sent to the MCP2510. After receiving the read instruction and address code, the data in the specified address register of the MCP2510 is shifted out and sent via the SO pin. After each data byte is shifted out, the internal address pointer of the device is automatically incremented to point to the next address. Therefore, a read operation can be performed on the next consecutive address register. Data in any consecutive address register can be read sequentially using this method. The read operation can be ended by pulling the CS pin high, as shown in Figure 6. Figure 6 SPI Interface Communication Timing Conclusion The temperature control node developed based on LM35 has strong working stability, high reliability, and features small size, high sensitivity, short response time, and strong anti-interference ability. This node is low-cost, uses common components, and has high engineering value. It has a CAN interface, allowing it to function as a standalone testing system or as a key component of a distributed testing system. All upper-layer CAN protocols can be implemented in software, making the node's interface flexible and unrestricted by these protocols.