Ds18b20 temperature measurement principle and logic timing

Source: Internet
Author: User

Ds18b20 Temperature Measurement principle:

The low temperature coefficient of the crystal oscillator oscillation frequency is limited by the temperature, used to generate a fixed frequency pulse signal to the subtraction counter 1, the high temperature coefficient crystal oscillator with temperature changes its oscillation frequency significantly change, the resulting signal as a subtraction counter 2 pulse input,

The low temperature coefficient oscillator inside the ds18b20 is an oscillator with a small oscillation frequency with a temperature variation, providing a stable counting pulse for counter 1.

The high temperature coefficient oscillator is a temperature-sensitive oscillator with an oscillating frequency that provides a count pulse with a temperature change for counter 2.

Initially, the temperature register is pre-set to 55 ℃, each time the counter 1 starts from the preset count to 0 o'clock, the temperature registers the temperature value increases 1 ℃, this process repeats, until the counter 2 counts to 0 o'clock stops.

The DS18B20 work process generally follows the following protocol: Initialize--ROM operation Command--memory Operation command--process data

① initialization

All processing on a single bus starts with the initialization sequence. The initialization sequence consists of a bus host issuing a reset pulse, which is then sent by the slave device to the presence pulse. The presence of pulses allows the bus controller to know that the DS1820 is on the bus and is ready to operate.

②rom Operation Commands

Once the bus host detects the presence of the slave device, it can issue one of the device ROM operation commands. All ROM operation commands are 8 bits long. The list of these commands is as follows:

Read ROM (reading ROM) [33h]

This command allows the bus host to read Ds18b20 's 8-bit product family encoding, a unique 48-bit serial number, and a 8-bit CRC. This command can only be used if there is only one ds18b20 on the bus. If there are more than one slave device on the bus, there will be a data conflict when all attempts are sent simultaneously from the slice (open drain will produce the result of the line).

Match ROM (ROM compliant) [55h]

This command is followed by a 64-bit ROM data sequence that allows the bus host to address specific ds18b20 on the multipoint bus. Only ds18b20 that are strictly compatible with the 64-bit ROM sequence can respond to subsequent memory operation commands. All slave slices that do not match the 64-bit ROM sequence will wait for the reset pulse. This command is available in the case of a single or multiple devices on the bus.

Skip ROM (skip ROM) [CCh]

In a single-point bus system, this command saves time by allowing the bus host to access memory operations without providing 64-bit ROM encoding. If more than one slave device exists on the bus and a read command is issued after the skip ROM command, data collisions occur on the bus due to multiple simultaneous sending of data from the slice (the effect of the line is generated by the open drain drop).

Search ROM (searching ROM) [f0h]

When the system starts to work, the bus host may not know the number of devices on the single-wire bus or its 64-bit ROM encoding. The search ROM command allows the bus controller to identify the 64-bit encoding of all the slave machines on the bus with the exclusion method.

Alarm Search (alarm finder) [ECh]

The process for this command is the same as the search ROM command. However, Ds18b20 only responds to this command in the event of a recent temperature measurement warning. The condition of the alarm is defined as temperature higher than th or below TL. As soon as the Ds18b20 is on, the alarm condition remains in the set state until another temperature measurement shows a non-alarm value or changes the setting of th or TL so that the measured value is again within the allowable range. The trigger value stored in the EEPROM is used for alarms.

③ Memory Operation Command

Write Scratchpad (writes the staging memory) [4Eh]

This command writes data to the DS18B20 's scratchpad, starting at address 2. The next two bytes written will be saved to address locations 2 and 3 in the scratchpad. A reset command can be issued at any time to abort the write.

Read Scratchpad (reading temporary memory) [BEH]

This command reads the contents of the scratchpad. The read starts from Byte 0 and continues until the 9th (byte 8,CRC) byte is read. If you do not want to finish reading all the bytes, the controller can issue a reset command at any time to abort the read.

Copy scratchpad (copy scratch memory) [48h]

This command copies the contents of the scratchpad into the E2 memory of the DS18B20, i.e. the temperature alarm trigger byte is stored in the nonvolatile memory. If the bus controller follows this command with a read gap, and Ds18b20 is busy copying the scratchpad to the E2 memory, DS18B20 outputs a "0" and Ds18b20 outputs "1" If the copy ends. If a parasitic power supply is used, the bus controller must start strong pull-up immediately after this command is issued and maintain a minimum of 10ms.

Convert T (temperature change) [44h]

This command initiates a temperature conversion without additional data. The temperature conversion command is executed, and then the DS18B20 remains in the waiting state. If the bus controller after this command to emit a read gap, and Ds18b20 busy to do time conversion, DS18B20 will be on the bus output "0", if the temperature conversion is completed, then output "1". If a parasitic power supply is used, the bus controller must start strong pull-up immediately after issuing this command and maintain 500ms.

Recall E2 (readjust E2) [b8h]

This command re-E2 the value stored in the temperature trigger to the scratch memory. This re-recall operation also occurs automatically when power is on the Ds18b20, so as long as the device is power-up, there is valid data in the staging memory. After this command is issued, for the first read data time slice emitted, the device outputs the ID of the temperature conversion busy: "0" = Busy, "1" = ready.

Read power supply [b4h]

For the time slice of the first read data emitted after this command is sent to DS18B20, the device gives a signal of its power mode: "0" = parasitic power supply, "1" = external power supply.

④ processing Data

Ds18b20 's high-speed staging memory consists of 9 bytes, which are assigned 3. When the temperature conversion command is released, the converted temperature value is stored in the No. 0 and 1th bytes of the high-speed staging memory in two-byte complement form. Single-chip microcomputer can be read through the single-wire interface to the data, read low in front, high in the rear.

Ds18b20 temperature measurement principle and logic sequence

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.