The temperature sensor DS18B20 the three position digital tube of the microcontroller with static di

Updated on number 2024-04-05
6 answers
  1. Anonymous users2024-02-07

    Here is the C51 procedure for DS18B20:

    Initialize 18b20

    uchar init18b20(void)uint i;

    bit no;

    ds=0;i=103;

    while(i>0)i--;

    ds=1;i=4;while(i>0)i--;

    no=ds;

    if(no==0)

    ds=1;i=100;

    while(i>0)i--;

    no=ds;

    if(no==1)

    not[1]=0;

    elsenot[1]=1;

    elsenot[1]=1;

    return (not[1]);

    bit tmpreadbit(void) reads one bit.

    uint i;

    bit dat;

    ds=0;i++;

    ds=1;i++;i++;

    dat=ds;

    i=8;while(i>0)i--;

    return (dat);

    uchar tmpread(void) reads one byte.

    uchar i,j,dat;

    dat=0;

    for(i=1;i<=8;i++)

    j=tmpreadbit();

    dat=(j<<7)|(dat>>1);

    return(dat);

    void tmpwritebyte(uchar dat) writes a byte to ds18b20

    uint i;

    uchar j;

    bit testb;

    for(j=1;j<=8;j++)

    testb=dat&0x01;

    dat=dat>>1;

    if(testb)

    ds=0;i++;i++;

    ds=1;i=8;while(i>0)i--;

    elseds=0;

    i=8;while(i>0)i--;

    ds=1;i++;i++;

    int tmp() ds18b20 temperature read.

    float tt;

    uchar a,b;

    ea=0;if(init18b20()==0)delay(1);

    tmpwritebyte(0xcc);

    tmpwritebyte(0x44);

    delay(10);

    init18b20();

    delay(1);

    tmpwritebyte(0xcc);

    tmpwritebyte(0xbe);

    a=tmpread();

    b=tmpread();

    temp=b;

    temp<<=8;

    temp=temp|a;

    c=b>>4;

    tt=temp*;

    temp=tt*10+;

    ea=1;return temp;

    elsenot[1]=1;

    ea=1;

  2. Anonymous users2024-02-06

    PIC did it two years ago, and the information is still there, haha.

  3. Anonymous users2024-02-05

    Hello dear and happy to answer your <>

    The DS18B20 is a digital temperature sensor that communicates with a single bus interface that can easily convert temperature data into a digital signal for transmission to the display. The specific steps are as follows:1

    Set up hardware connections: Connect the VDD pin of the DS18B20 sensor to the positive power supply, the GND pin to the negative power supply, and the Data pin to any IO port of the MCU. 2.

    Reading temperature data: The program is written in the programming language (e.g., C language) of the MCU to read the temperature data of the DS18B20 sensor. The DS18B20 communication protocol is required for specific operations, including sending reset signals, sending read temperature commands, and receiving temperature data.

    3.Processing temperature data: The temperature data taken from the DS18B20 reading Laoling is the original hexadecimal value, which needs to be converted to the temperature value at a common temperature scale such as Celsius or Fahrenheit using a calculation formula.

    4.Display temperature value: The converted temperature value can be displayed on the display by using a device such as a digital tube or LCD display on the MCU, and the temperature value read by the DS18B20 sensor can be seen on the display.

    It should be noted that in the process of hardware connection and program writing, it is necessary to follow the communication specifications and related technical documents of DS18B20 to ensure the normal operation of the sensor and the accuracy of the data. The above is mine, I hope it helps you and I wish you a happy life!

  4. Anonymous users2024-02-04

    First of all, the one-bit (1 bit) signal output by the DS18B20 cannot be changed into a bit by the single-chip microcomputer, one is a bit, and the single-chip microcomputer needs to read the one-bit signal output of the DS18B20 for many times in a row to synthesize the information it needs. For example, if the temperature output of DS18B20 is 16 bits, then the microcontroller will need to read 1 bit data 16 times.

    Read the temperature pseudo** (temperature is an integer variable that stores the temperature value):

    for ( i=1; i<=16; i++)

    onebit=function to read 1 bit of data ();

    temperature=temperature|onebit;

    if(i!=16)

    temperature=temperature<<1;

    Then, how does the microcontroller read a certain 1bit information output by DS18B20? Before the specifics, it is clear that this process must be completed within 15 microseconds (us) after the microcontroller pulls down the data line and initiates the data reading process, otherwise the correct data cannot be read (note: when initiating communication, the data bus is always pulled down by the microcontroller, and the data bus remains high when there is no communication).

    Let's talk about the specific process:

    1. The single-chip microcomputer pulls the data bus down;

    2. Delay 2us; (This time must be greater than 1us, otherwise DS18B20 will not be able to identify the pull down signal; It should also not be too large, more than 15us will not be able to read correctly. )

    3. Set the input and output direction of the IO port connected to the single-chip microcomputer and DS18B20 as input; (This step may also be that the single-chip microcomputer directly pulls the data cable higher, which varies depending on the chip).

    4. Delay 2us; (Give DS18B20 a certain time output signal).

    5. Read the level value on the data bus;

    6. Pull up the data bus, delay for a period of time and enter the next 1 bit reading.

    Note: The key to whether it can be read correctly here is whether the amount of delay is accurate enough, so before writing the DS18B20 program in C language, you need to find a delay function that you have enough confidence in the accuracy of the delay according to the single-chip microcomputer model and crystal oscillator frequency.

  5. Anonymous users2024-02-03

    DS18B20 Read Timing.

    1) Pull the data cable up "1".

    2) Delay of 2 microseconds.

    3) Pull the data cable down to "0".

    4) Time delay of 15 microseconds.

    5) Pull the data cable up to "1".

    6) Time delay of 15 microseconds.

    7) Read the status of the data line to obtain one status bit, and perform data processing.

    8) Time delay of 30 microseconds.

    It reads bit by bit, such as when the sensor is to send the data to the MCU 0x055, (0b001010101) (9bits) is sent to the MCU one by one, and then pieced together into 0x055 bits

  6. Anonymous users2024-02-02

    You read it out one by one, put the lower eight bits in a byte, put the upper eight bits in a byte, and then add it, there are many online programs.

Related questions
4 answers2024-04-05

The display temperature part is done, which means that you have completed the reading of the DS1820. In this case, you set a value in the program for comparison, greater than or less than a certain value output. >>>More

8 answers2024-04-05

The inlet air temperature sensor is broken, the starting is difficult, the idle speed is unstable, and the exhaust emission exceeds the standard; Unable to accurately transmit signals to the ECU. Injection cannot be accurately controlled. It will lead to an increase in the fuel consumption of the car. >>>More

14 answers2024-04-05

It is best to use an oscilloscope to observe the signal voltage change of the engine coolant temperature sensor, because the multimeter can only look at the voltage at one point in time, and the oscilloscope can see the voltage change trend. >>>More

7 answers2024-04-05

Not in the air flow. Right next to the throttle.