FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    DS18B20 digital thermometer ----- DS18B20 DIGITAL THERMOMETER

     

    "1.DS18B20 basic knowledge DS18B20 Digital Temperature Meter is 1-Wire produced by Dallas, ie a single bus device with simple lines and small size. So use it to form a temperature measurement system, which has a simple line, in a communication line, can hang a lot of such a digital thermometer, which is very convenient. 2, characteristics of DS18B20 products (1). Communication can be implemented only for a port. (2). There is a unique serial number on each device in DS18B20. (3). There is no need to measure the temperature in the actual application. (4). Measure the temperature range in -55. C to +125. C between C. (5). Digital thermometer resolution users can choose from 9 to 12 bits. (6). Internal temperature, lower limit alarm settings. 3, DS18B20 pin introduction The pin arrangement of the TO-92 packaged DS18B20 is shown in Figure 1, and the pin function description is shown in Table 1. 4. How to use DS18B20 Since the DS18B20 uses a 1-Wire bus protocol mode, that is, the two-way transmission of data is implemented in a data line, the hardware does not support the single-bus protocol on the hardware, so we must use the software method to simulate A single-bus protocol timing to complete access to the DS18B20 chip. Since DS18B20 reads and writes data on one I / O line, there is a strict timing requirements for read-write data bits. The DS18B20 has a strict communication protocol to ensure the correctness and integrity of the data transmission. The protocol defines a timing of several signals: initialization timing, read timing, write timing. All timings are from the host as a master, a single bus device as a slave device. Each command and data transmission are started from the host, and if the single bus device is required to return data, the host needs to start the read order completion data reception after the write command is required. The transfer of data and commands is low in the first. DS18B20 reset timing DS18B20 read timing Two processes are divided into read 0 timing and read 1 timing for DS18B20. The read time slot for the DS18B20 is to release the single bus within 15 seconds from the host, so that the DS18B20 is transmitted to the single bus. DS18B20 is completing a read sequential process, at least 60 su is completed. DS18B20 writing timing The write timing of the DS18B20 is still divided into two procedures for writing 0 timing and write 1 timing. For DS18B20 writing 0 timing and write 1 timing requirements, when to write 0 timings, single bus is pulled low to at least 60 rupture, ensuring that the DS18B20 can correctly sample "0" electricity on the IO bus between 15Us to 45Us. Flat, when you want to write 1 timing, after the single bus is pulled, the single bus is released within 15 us. 5. Experimental task The temperature measuring system is constituted by a DS18B20, and the measured temperature accuracy reaches 0.1 degrees, the measured temperature ranges between -20 degrees to +100 degrees, and is displayed in an 8-bit digital tube. 6. Circuit schematic 7. System board hardware connection (1). Connect the P0.0-P0.7 in the "MCU system" area to the ABCDefgh terminal in the "Dynamic Digital Display" area with an 8-core line. (2). Connect the P2.0-P2.7 in the "MCU system" area to the S1S2S3S4S5S6S7S8 terminal in the "Dynamic Digital Display" area with a 8-core line. (3). Insert the DS18B20 chip into any of the "four-way single bus" area, pay attention to the power supply and the ground signal should not be reversed. (4). Connect the corresponding DQ terminals in the "four-way single bus" area to the P3.7 / RD terminal in the "MCU system" area. 8. C language source program #include #include Unsigned char code displaybit [] = {0xFE, 0xFD, 0xFb, 0xF7, 0xef, 0xDF, 0xBF, 0X7F}; Unsigned char code displaycode [] = {0x3f, 0x06, 0x5b, 0x4f, 0x66,0x6d, 0x7d, 0x07, 0x7f, 0x6F, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x00, 0x40}; Unsigned char code dotcode [32] = {0, 3, 6, 9, 12, 16, 19, 22, 25, 28, 31, 34, 38, 41, 44, 48, 50, 53, 56, 59, 63, 66, 69, 72, 75, 78, 81, 84, 88, 91, 94, 97}; UNSIGNED Char DisplayCount; Unsigned char displaybuf [8] = {16, 16, 16, 16, 16, 16, 16, 16}; UNSIGNED CHAR TIMECOUNT; UNSIGNED Char ReadData [8]; SBIT DQ = P3 ^ 7; Bit sflag; Bit RESETPULSE (VOID) { UNSIGNED Char i; DQ = 0; For (i = 255; i> 0; I -); DQ = 1; For (i = 60; i> 0; I -); Return (DQ); For (i = 200; I> 0; I -); } Void WriteCommandtods18B20 (unsigned char command) { UNSIGNED Char i; UNSIGNED Char J; For (i = 0; i <8; i ++) { IF ((Command & 0x01) == 0) { DQ = 0; For (j = 35; j> 0; j -); DQ = 1; } Else { DQ = 0; For (j = 2; j> 0; j -); DQ = 1; For (j = 33; j> 0; J -); } Command = _ CROR_ (Command, 1); } } Unsigned char readdatafromds18b20 (void) { UNSIGNED Char i; UNSIGNED Char J; UNSIGNED CHAR TEMP; TEMP = 0; For (i = 0; i <8; i ++) { TEMP = _CROR_ (TEMP, 1); DQ = 0; _Nop_ (); _Nop_ (); DQ = 1; For (j = 10; j> 0; j -); IF (dq == 1) { TEMP = TEMP | 0x80; } Else { Temp = TEMP | 0x00; } For (j = 200; j> 0; J -); } Return (TEMP); } Void main (void) { TMOD = 0x01; TH0 = (65536-4000) / 256; TL0 = (65536-4000)% 6; ET0 = 1; EA = 1; WHILE (resetpulse ()); WriteCommandTods18B20 (0xcc); WriteCommandtods18b20 (0x44); Tr0 = 1; While (1) { ; } } Void T0 (Void) Interrupt 1 Using 0 { Unsigned char x; Unsigned int result; TH0 = (65536-4000) / 256; TL0 = (65536-4000)% 6; IF (DisplayCount == 2) { P0 = displaycode [DisplayBuf [DisplayCount] | 0x80; } Else { P0 = displaycode [DisplayBuf [DisplayCount]]] } P2 = displaybit [displaycount]; DisplayCount ++; IF (DisplayCount == 8) { DisplayCount = 0; } Timecount ++; IF (timecount == 150) { Timecount = 0; WHILE (resetpulse ()); WriteCommandTods18B20 (0xcc); WriteCommandtods18b20 (0xbe); ReadData [0] = ReadDataFromDS18B20 (); ReadData [1] = ReadDataFromDS18B20 (); FOR (x = 0; x <8; x ++) { DisplayBuf [x] = 16; } Sflag = 0; IF ((ReadData [1] & 0xF8)! = 0x00) { Sflag = 1; ReadData [1] = ~ readdata [1]; ReadData [0] = ~ readdata [0]; Result = readdata [0] +1; ReadData [0] = Result; IF (Result> 255) { ReadData [1] ++; } } ReadData [1] = readtata [1] << 4; ReadData [1] = readdata [1] & 0x70; X = readdata [0]; X = x >> 4; X = x & 0x0f; ReadData [1] = readdata [1] | x; X = 2; Result = readdata [1]; While (Result / 10) { Displaybuf [x] = result; Result = Result / 10; X ++; } Displaybuf [x] = result; IF (sflag == 1) { DisplayBuf [x + 1] = 17; } X = readdata [0] & 0x0f; X = x << 1; Displaybuf [0] = (Dotcode [x]); DisplayBuf [1] = (Dotcode [x]) / 10; WHILE (resetpulse ()); WriteCommandTods18B20 (0xcc); WriteCommandtods18b20 (0x44); } "

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us