Reasons and Solutions of Temperature Runout Change in GX18B20 Temperature Measurement




In the GX18B20 button setting upper and lower temperature alarm system, the biggest problem encountered is that the temperature will occasionally jump tens or hundreds of Baidu in the process of temperature measurement. The reason is that the interruption program used in the system, 18B20 has a strict reading and writing sequence, and can not be interrupted in the process. Otherwise, the above data will appear.

The solution is also simple: just turn off the interrupt at the reading temperature and turn on the interrupt after reading.


Reason analysis:

1 Initialization Bus Sequence

The manual only gives the shortest time 480us for the single chip computer to pull down the bus. Note that the maximum time is not given here, so there is no need to turn off the interrupt in the 480us time. Even if it is interrupted, it only prolongs the pull down time.

The next section is the time from releasing bus to 18B20 pulling down bus as response, 15 ~ 60us. This section is about interruption (in fact, if the interrupt function execution time is very short, such as 3us, it is also possible without interruption).

The next section is waiting for 18B20 to release the bus without interruption.

2 read bus

The minimum time to read the bus is 60us. In fact, as long as the single chip microprocessor sampled, it can be interrupted. The rest of the time is not so strict.

3 write the bus

The minimum time to write the bus is also 60us. In order to ensure that 18B20 can read the correct data, it must be interrupted during this period.

In summary, in fact, in the process of bus operation, the longest interruption time is 60us, the rest of the time do not need to be interrupted. This can satisfy the requirement of high real-time application such as dynamic scanning of digital tube.

Next:This is the last one
Prev:This is the first article