DS18B20 1 wire communication, LED temperature display 7

Today we are all going to learn chip DS18B20 temperature.
I Characteristics:
The specification of the sensor DS18B20 can mention briefly as follows:
• Use a wireless interface should just have one leg out to the media.
• It is possible to measure the temperature in the range of -55 -> +125 oC.Voi temperature range -10 ° C to + 85 ° C, the accuracy of ± 0.5 ° C.Co temperature warning function sweeping away the value given.
• Voltage: 3 - 5.5 V, you can configure multiple encryption level from 9-12 bits
The greater the number of bits precision hon.Thoi conversion time is 750ms maximum temperature for 12 bit encryption
• Current consumption in sleep mode tiny.
• Each sensor has a unique identification code stored in memory 64-bit on-chip ROM (on chip), binary values ​​are laser engraved.
• If configured for DS18B20 under 9,10,11,12 bit precision, we have respectively: 0.5 ° C, 12:25 ° C, 0125 ° C, 0.0625 ° C.Theo default manufacturer if they It is not configured mode, it will automatically switch configuration is 12 bits.
When temperatures begin converting the DQ pins are pulled low and the conversion finished, at cao.Nhu so we will be based on this phenomenon to determine when the conversion is complete temperature.
DS18B20-pinout
DS18B20-pinout

II.Instruction sets of DS18B20 

- READ ROM (33h)
Lets read the 8 byte code in ROM laser engraving, including the 8-bit code name components (10), 48-bit serial number, 8-bit CRC check. This command is only used when on the bus with one sensor DS1820, if not on the bus conflict due to all the slave devices respond.
- MATCH ROM (55h)
This command is sent with the next 64-bit ROM, allowing the controller bus pick out only a specific DS1820 sensor on the bus when there are multiple sensors connected to the DS1820. Only DS1820 ROM that has 64 bit on 64 bit string matching medium has been sent to the new response to the command of the next memory. And the DS1820 sensor with 64-bit ROM mismatch will continue to wait for a reset pulse. This command is used both in the case of a sensor wire, both in the case of multiple sensor wire.
- SKIP ROM (CCH)
This command allows the device to control access memory directly to the command of the DS1820 without sending a 64-bit ROM code sequence. This will save time waiting but only effective when fed on only one sensor.
- SEARCH ROM (F0h)
This command allows the bus controller can detect the number of members being connected to the bus I and the specific value of their 64-bit ROM with a detection cycle.
- ALARM SEARCH (ECH)
The process of this command is identical to the Search ROM command, but only DS1820 sensors respond to this command when alarm conditions occur during the final temperature measurements. Conditions of warning here is defined as the measured temperature value is greater than the value is less than the value of TH and TL are the highest temperature value and the lowest temperature was recorded on the memory stick Sensor.
After the master device (typically a microcontroller) using the command ROM to the address for a wireless sensors are connected to the bus, device owners will give the command DS1820 functions. By the command function device owner can read and write to memory Draft (scratchpath) sensor DS1820. initialized transition temperature values ​​measured and determined mode voltage supply source. The command function can be briefly described as follows:
- WRITE Scratchpad (4Eh)
This allows you to record 2 bytes of data in the memory of the DS1820 Draft. The first byte is written to the register TH (2 bytes of memory Draft) was the second byte is written to the register TL (3 bytes of memory Draft). The data transmitted in the first sequence is the most significant bit and the next bit is the significant decline. Both byte must be written before the master device outputs a reset pulse or when no data is present.
- READ Scratchpad (BEH)
This command allows the host device to read the contents of memory draft. The process begins reading from significant bit of byte 0 and dance continues until 9 Rhu byte (byte 8 - CRC). Equipment owners can generate a reset pulse to stop the process at any time reading if only part of the data in memory to be read drafts.
- COPYSCRATCHPAD (48)
This command copies the contents of two registers TH and TL (byte 2 and byte 3) in EEPROM memory. If the sensor is used in power supply mode l start the measurement.
- CONVERT T (44h)
This command launch a process of measuring and converting temperature values ​​into numbers (binary). After converting the resulting value is stored temperature on the temperature registers 2 bytes of memory Draft Conversion time not to exceed 200 ms, while in transition if the command reads the values ​​read that are equal to 0.
- READ POWER SUPPLY (B4h)
A read command following this command will indicate DS1820 is used mode power supply, how to read the value to 0 if powered by the main data path and is equal to 1 if the power supply via a separate path.
III. LED temperature display 7 application.
Code read DS18B20
Init_DS18B20 void (void)
{
unsigned char x = 0;
DQ = 1;
delay_18B20 (8);
DQ = 0;
delay_18B20 (80);
DQ = 1;
delay_18B20 (14);
x = DQ;
delay_18B20 (20);
}
unsigned char ReadOneChar (void)
{
unsigned char i = 0;
unsigned char dat = 0;
for (i = 8; i> 0; i-)
{
DQ = 0;
dat >> = 1;
DQ = 1;
if (DQ)
dat | = 0x80;
delay_18B20 (4);
}
return (dat);
}
void WriteOneChar (unsigned char dat)
{
unsigned char i = 0;
for (i = 8; i> 0; i-)
{
DQ = 0;
DQ = dat & 0x01;
delay_18B20 (5);
DQ = 1;
dat >> = 1;
}
}
ReadTemp void (void)
{
unsigned char a = 0;
unsigned char b = 0;
unsigned char t = 0;
Init_DS18B20 ();
WriteOneChar (0xCC);
WriteOneChar (0x44);
delay_18B20 (100);
Init_DS18B20 ();
WriteOneChar (0xCC);
WriteOneChar (0xBE);
delay_18B20 (100);
a = ReadOneChar ();
b = ReadOneChar ();
nhiet_thuc = b << 4;
nhiet_thuc + = (a & 0xf0) >> 4;

Comments

  1. Thanks for providing such a helpful information Very nice I like a lot of these topics, it was part of my area.

    health and safety display

    ReplyDelete

Post a Comment

Popular posts from this blog

Using the TLP250 Isolated MOSFET Driver - Explanation and Example Circuits

N-Channel MOSFET High-Side Drive: When, Why and How?

[Sharing] Assembly Code for Led Cube 8x8x8 using 8051 Micro-controller