How does the DS18B20 work?
The DS18B20 temperature measurement principle is shown in Figure 1.
In the figure, the oscillation frequency of the low temperature coefficient crystal oscillator is little affected by the temperature, and a pulse signal for generating a fixed frequency is sent to the counter 1.
The high temperature coefficient crystal oscillator changes its oscillation rate with temperature, and the generated signal is used as the pulse input of counter 2.
Counter 1 and the temperature register are preset to a base value corresponding to -55 °C.
Counter 1 counts down the pulse signal generated by the low temperature coefficient crystal oscillator. When the preset value of counter 1 is reduced to 0, the value of the temperature register is incremented by 1.
The preset of counter 1 will be reloaded and counter 1 will resume counting the pulse signals generated by the low temperature coefficient crystal.
This cycle until the counter 2 counts to 0, the accumulation of the temperature register value is stopped, and the value in the temperature register is the measured temperature.
The slope accumulator is used to compensate and correct the nonlinearity in the temperature measurement process, and its output is used to correct the preset value of the counter 1.
DS18B20 application circuit Ds1820_Bus = 0; //Generate falling edge, enter write timing (send data in 15us)
Ds1820_Bus = data_1820&0x01; //Send the number from the low position
Delay_X15us(3);//delay 45us, guarantee 18b20 sampled data
Ds1820_Bus = 1; // Pull high to complete the number
Delay_X15us(1);//Continuous delivery number should be at least 1us (15us here)
DS18B20 application circuit two
In order to get sufficient current supply for the DS18B20 during the dynamic conversion cycle, when the temperature is converted or copied to the E2 memory operation, the MOSFET can be used to pull the I/O line directly to VCC to provide sufficient current. After issuing any instructions that involve copying to E2 memory or initiating a temperature transition, the I/O lines must be converted to a strong pull-up state for up to 10μS. In the strong pull-up mode, the problem of current supply not being solved can be solved, so it is also suitable for multi-point temperature measurement applications. The disadvantage is that an I/O line is required to be used for strong pull-up switching.
The external power supply mode is the best way to work with the DS18B20. The work is stable and reliable, the anti-interference ability is strong, and the circuit is relatively simple, and a stable and reliable multi-point temperature monitoring system can be developed. Xiaobian recommends that you use an external power supply in development. After all, only one VCC lead is connected to the parasitic power supply. In the external power supply mode, the DS18B20 wide power supply voltage range can be fully utilized, and the temperature accuracy can be ensured even when the power supply voltage VCC drops to 3V.