Time series of ds18b20

Source: Internet
Author: User
Time series of DS18B20


New users must make many mistakes in the reading and writing process of DS18B20. This article briefly describes how to use it.

1. Process 1 and 2 are the initialization process. Initialization is required for each read. Otherwise, 18b20 is in the STANDBY state and cannot be read successfully.

Process 1: lower the signal line 480-700us, reset it, then release the bus 15-60us, 18b20 will pull down the bus 60-240us,

Then it releases the bus. Therefore, a mark of successful Initialization is whether or not the 18b20 operating sequence is low and later.

(Note: The black part indicates host operation, and the blue part indicates 18b20 operation. After each host operation is completed, wait for 18b20

You must release the bus, such as setting Io to a high-impedance state. Otherwise, 18b20 cannot write the status online)

2. process 3 and 4 are 1bit Data Writing Processes. Process 3 is write 0, and process 4 is write 1. Process 3: Pull down the bus 60us and then lift

High bus 5us, complete. Process 4: Pull down the bus 5us and raise the bus 60us.

3. process 5 and 6 are 1bit read processes. Process 5 is read 0, and process 6 is read 1. Process 5, 6: Pull down the bus 5us, and then release

Put the bus and read the bus. If it is 0, read 0. If it is 1, read 1.

Time Series description of DS18B20

DS18B20 Control Process

According to the communication protocol of DS18B20, DS18B20 can only be used as the slave, while the single-chip microcomputer system is used as the host, and the machine is controlled

Three steps must be taken to complete a temperature conversion for DS18B20: resetting, sending Rom commands, and sending Ram commands. Each

Perform the preceding three steps to perform the operation on DS18B20.
The reset process is as follows: MCU pulls the data line down at least us, then releases the data line, waiting for 15-60us to make the DS18B20

Receives the signal. After DS18B20 receives the signal, it pulls the data line down by 60 to us. The host detects that the data line is low.

After the marker is successfully reset;

Send the ROM command: The ROM command indicates that the host is addressing all the DS18B20 received on the system to determine which

Or read the ROM serial number of a DS18B20.

RAM command: The RAM command is used by the microcontroller to operate on the internal RAM of DS18B20, such as reading the register value,

Or set the register value.
For specific RAM and RAM commands, see the data manual of DS18B20. The following is a brief introduction:

1. ROM Operation Command

DS18B20 uses the first-line communication interface. The ROM setting must be completed first because of the first-line communication interface.

And control functions will be unavailable. Once the bus detects the presence of a sub-device, it can issue the ROM operation of the device.

All ROM operation commands are 8-bit in length and mainly provide the following functional commands:

1) read ROM (script code 0X33 H): when there is only one node (device) on the bus, read the 64-bit

Serial number. If more than one node exists on the bus, this command cannot be used.

2) ROM match (script code 0X55 H): this command is followed by the 64-bit ROM serial number, which is only in this order on the bus.

The command is used to select a DS18B20 and then

Read/write operations.

3) ROM (instruction code 0XF0H): used to determine the number of DS18B20 connected to the bus and to identify all

64-bit ROM serial number. When the system starts to work, the bus host may not know the number of devices on the bus or

The 64-bit ROM serial number. The search command is used to identify all 64-bit ROM serial numbers connected to the bus.

4) skip ROM (instruction code 0 XCCH): this command is only applicable to only one node on the bus.

Allow the bus host to directly access RAM without providing a 64-bit ROM serial number to save operation time.

5) Alarm check (instruction code 0 XECH): this command is basically the same as the ROM search command, the difference is that only the temperature

The system responds only when the value of DS18B20 exceeds the set upper limit or lower limit. When the DS18B20 is powered on, an alarm is triggered.

The condition remains in the set state until another temperature measurement shows a non-alarm value, or changes the TH or TL settings.

So that the measured value is within the permitted range again. Triggers stored in the EEPROM are used for alarm.

2. RAM commands

DS18B20 has six RAM commands:

1) temperature conversion (instruction code 0X44 H): Start DS18B20 for temperature conversion, and save the result to the internal RAM.

2) read latches (instruction code 0 XBEH): Read nine bytes of content from the latencies of RAM.

(Byte 0) Start reading until nine bytes (byte 8, CRC value) are read. If you do not need to read

The host can send a reset signal at any time to stop the read operation.

3) write the temporary memory (instruction code 0X4EH): Write the upper and lower temperature alarm values and configuration data to the RAM

2, 3, 4 bytes. This command is followed by data that needs to be written to these three bytes.

4) copy the temporary memory (instruction code 0X48 H): copy the 2, 3, and 4 bytes of the temporary memory to the EEPROM, and use

Save as power loss.

5) re-call E2RAM (instruction code 0XB8H): restores the temperature upper and lower limits and configuration bytes in EEROM

2, 3, and 4 bytes of RAM, used to restore the previously saved alarm value and configuration bytes after power-on.

6) read Power Supply Mode (instruction code 0XB4H): Start the signal sent by DS18B20 in Power Supply Mode

To the master CPU. For the time slice for the first data reading after the command is sent to DS18B20,

The device will give its power signal. "0" indicates parasitic power supply. "1" indicates the external power supply.

The following is the operation procedure of DS18B20 summarized by the actual test.

1. DS18B20 Initialization

(1) first set the data line to "1 ".
(2) latency (the time requirement is not very strict, but as short as possible ).
(3) The data line is pulled to the low level "0 ".
(4) The latency is 490 microseconds (the time range of this time can be from 480 to 960 microseconds ).
(5) The data line is pulled to the High Level "1 ".
(6) latency wait (if Initialization is successful,

The returned low level "0 ". The status can be used to determine its existence, but note that it cannot be performed infinitely.

Wait, otherwise the program will enter an endless loop, so timeout control is required ).
(7) If the CPU reads the low-level "0" on the data line, the latency will also be delayed.

(Step (5) of the time) must be counted at least 480 microseconds.
(8) pull the data line up to the High Level "1" again and end.
  
2. write operation on DS18B20
This is my note: The following is the process of writing 0. If it is writing 1, the delay order will be different. For details, refer to the following time sequence diagram.
(1) The data line first sets the low level "0 ".
(2) The delay is determined at 2 (less than 15) microseconds.
(3) Send bytes in the order from low to high (only one bit is sent at a time ).
(4) The latency is 62 (greater than 60) microseconds.
(5) pull the data line to a high level with a latency of 2 (less than 15) microseconds.
(6) Repeat the operations from (1) to (6) until all bytes are sent.
(7) Increase the data line.

That is to say, when we write 1, we use the following sequence.
(1) The data line first sets the low level "0 ".
(2) The delay is determined at 2 (less than 15) microseconds.
(3) Send bytes in the order from low to high (only one bit is sent at a time ).
(4) latency: 2 (less than 15) microseconds.
(5) pull the data line to a high level with a latency of 62 (greater than 60) microseconds.
(6) Repeat the operations from (1) to (6) until all bytes are sent.
(7) Increase the data line. The specific time sequence of the program will be known.
3. DS18B20 read Operations

(1) Increase the data line to "1 ".
(2) latency: 2 microseconds.
(3) Reduce the data line to "0 ".
(4) latency: 2 (less than 15) microseconds.
(5) Increase the data line to "1" and the port should be in the input state.
(6) latency: 4 (less than 15) microseconds.
(7) The status of the read data line is 1 bit, and data is processed.
(8) latency: 62 (greater than 60) microseconds.

DS18B20 Sequence Chart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.