Design of Temperature Detection Node Based on CAN Bus

In the test of the electronic ignition module, in order to simulate the real working condition of the electronic ignition system, the electronic ignition module is often placed in an environment above the normal temperature for electronic ignition experiments to obtain the ignition parameter data closest to the real vehicle operating conditions. . Due to the heating of the electronic ignition module itself, the temperature of its core components becomes an important factor affecting the performance of the electronic module; in addition, it is also necessary to consider whether the ambient temperature meets the requirements for simulating real operating conditions.

This article refers to the address: http://


This paper introduces a design scheme using the LM35 temperature sensor and PICMicro's temperature detection node to detect the core module temperature and ambient temperature of the electronic ignition module during the simulation of automotive electronic ignition. It will clarify the module structure, working principle and A method of quantifying sampled values.

Node principle and structure


The temperature detecting node is composed of a sensor circuit, a signal conditioning circuit, a single chip application system, a CAN bus interface, and the like. The basic working principle of the circuit is that the sensor circuit outputs the sensed temperature signal to the signal conditioning circuit in the form of voltage. After the signal is conditioned, it is input to the A/D sampling circuit, and the digital value is sent to the single-chip microcomputer system by the ADC. The MCU system will monitor the real-time temperature. When the temperature exceeds the warning value and the dangerous value, the MCU will send a warning message to the host computer to remind the operator to check. The logical structure of the module is shown in Figure 1.

Figure 1 Temperature detection node logic structure


The sensor circuit uses temperature sensor LM35, the supply voltage is 15V DC, the working current is 120mA, the power consumption is very low, the current change is small when working in the whole temperature range, the voltage output adopts the differential signal mode, and the 2, 3 pin is directly Output. The LM35 output signal passes through an LP filter consisting of RC to filter out high frequency noise interference.


The core MCU of this node is the PIC16F87x, which is a low-power 8-bit microcontroller from Microchip. The PIC16F87x has a reduced instruction set with an execution speed of 200ns. The CAN controller uses Microchip's MCP2510, the bus driver uses PCA82C250, the bus isolation circuit uses optocoupler 6N317, and the signal conditioning circuit uses LF412. The hardware structure of the temperature monitoring module is shown in Figure 2.

Figure 2 Temperature monitoring module hardware structure


The signal conditioning circuit mainly completes the function of amplifying and limiting the sensor signal, and the output voltage of the sensor circuit is changed to a DC voltage of about 2V, which is adjusted to meet the voltage range of the AD interface of the PICMicro, and cannot exceed the range of the AD sampling, but also There is considerable signal accuracy. The MCU collects the temperature data of the sensor through the A/D sampling channel and calculates the temperature range.


The peripheral circuitry is the necessary peripheral for the PIC16F87x minimum system operation. The PIC16F87x exchanges data with the MCP2510 through the SPI bus to complete the transmission and reception of CAN bus data packets. The interface circuit is shown in Figure 3.

Figure 3 PIC16F877 and MCP2510 interface circuit


Among them, SCK is the SPI bus clock, the SPI interface of the PIC16F87x module is connected to the SI, SO, SCK of the MCP2510, and RA4 and RA1 respectively control the chip reset and chip select of the MCP2510. INT accepts the MCP2510 interrupt request.

System software design

1 system software process

In order to avoid malfunction caused by interference, the software adopts some redundancy and fault-tolerant processing. When the A/D module processes the sampled data, software filtering measures are adopted to filter out spikes that may occur in the circuit.

The method is to continuously sample five times. By comparing and judging, the maximum value and the minimum value are removed, and the remaining three values ​​are summed and averaged. The average value is used as the effective data used by the CPU to divide the temperature range. The parsing and encapsulation of the data packets follow the application layer protocol of CAN. The main program flow is shown in Figure 4.

Figure 4 main program flow


When the CPU detects an abnormal temperature, it will issue a temperature abnormality alarm to the upper machine according to the temperature abnormal range. This is the data frame that the node CPU only actively sends to the upper computer. The temperature-related data of the node is stored in the buffer. When the host computer data request is not received, the data of the buffer is continuously refreshed by the new data to ensure the real-time performance of the node data, and the interrupt process is as shown in FIG. 5. Shown.

Figure 5 CAN Receive Interrupt Flow


2 Quantization method of sampled values


The accurate quantification of the sampled value is the key to the normal operation of the temperature control circuit. The following conversion methods are used for quantization. Let the signal-conditioned voltage be Ui, then -10V < Ui <10V, the temperature corresponding to -10V is known to be -55 ° C, the temperature corresponding to 10V is 125 ° C, and the proportional factor Kt = 0.111V / ° C is easily obtained. When the temperature is 0 ° C, ΔT = 55 ° C (corresponding to the amount of change at -55 ° C).


Ui = -10 V + ΔT · Kt = -10 V + 55 ° C × 0.111 V / ° C = -3.995 V.


After Ui is converted into a digital quantity, each digital quantity corresponds to a voltage value of 19.531 mV, which is represented by Ks. The correspondence between digital change and temperature change can be obtained: Kt / Ks = (0.111V / ° C) / (19.531mV / digital) = 5.683 digital / °C.


The digital quantity corresponding to other temperatures can also be calculated by the above method.


3 SPI interface communication

The PIC16F87x exchanges data with the MCP2510 via the SPI interface.

The MCP2510 is designed to interface directly with the serial peripheral interface (SPI) of many microcontrollers. External data and commands are transferred to the device through the SI pin, and data is transferred on the rising edge of the SCK clock signal.

The MCP2510 is transmitted on the SCK falling edge through the SO pin. Table 1 lists the instruction bytes for all operations.


The PIC16F87x sends a read command to the MCP2510 as an example to illustrate the SPI interface communication process.


The CS pin will be asserted low at the beginning of a read operation. The subsequent read command and 8-bit address code (A7~A0) will be sent to the MCP2510 in sequence. After receiving the read command and the address code, the data in the MCP2510 specified address register will be shifted out and sent through the SO pin. After each data byte is shifted out, the device's internal address pointer is automatically incremented to point to the next address. Therefore, the next consecutive address register can be read. This method can sequentially read the data in any one of the consecutive address registers. 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 stability, high reliability, small size, high sensitivity, short response time and strong anti-interference ability. The node is low in cost, the devices are conventional components, and have high engineering value. This node has a CAN interface that can be used as an independent detection system or as a key part of a distributed test system. The upper layer protocol of CAN can be implemented in software, which makes the interface of the node flexible, and is not restricted by the upper layer protocol.

T Shape

T Shape LED Bulb,T Shape LED Lamp,T Shape LED Bulb Light

Led Light Led Panel Co., Ltd. , http://www.yl-led.cn