Please help with code for DS18B20 - Page 3


Closed Thread
Page 3 of 3 FirstFirst 123
Results 81 to 110 of 110
  1. #81
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    ok,

    there is no problem with the DQ link.

    there is no bad component DS18B20. I have put two new DS18b20 that are working on a different circuit.

    How do i know the DS serial number? Do i need to get the serial number from my DS18b20 and place it to the code?

  2. #82
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Sorry for asking so many things, i just be so close to make it work.

    So do i need to read the serial number for each sensor and place it inside the code?

    do i need to follow that http://www.picbasic.co.uk/forum/cont...r-nine-of-them?

    and then get the serial number from the DS?

  3. #83
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Read first page of THIS topic !!!

  4. #84
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Every device on 1-Wire network has in its internal EEPROM a unique serial number that has to be known to the host.

    Otherwise the host can not find the device and communicate.

    On Maxim site there is an application note about a way to automatically find the devices on the local 1-wire network. SO every time your controller powers up, it makes an device scan and stores the found ID's or serial numbers.


    The second method is to find the serial numbers by your self and store them in the internl EEPROM of the controller.


    AN187, is the Note that describes the method

    Ioannis

  5. #85
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Fratello and Ioannis,

    thanks for your help.

    Now i understand. It is very similar to RFID serial number. You can retrieve the serial from the device.

    I will make a small program to retrieve the serial from the device and place it to the code.

    i will come back with my results.

    Best Regards,

  6. #86
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Quote Originally Posted by astanapane View Post
    I will make a small program to retrieve the serial from the device and place it to the code.
    It's in post #22. Enjoy !

  7. #87
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Hi Fratello,

    here we are step by step.

    i did retrieve the serial number from the DS18B20. I placed it to the code and worked.

    I put two sensors and now i have INT and EXT temp. I can say that they are really close the temp from two sensors.

    Now i would like to ask you if the code is for the temp only or the thermostat.

    I have place two LED on the porta.2 and porta.3, but i dont see any light.

    Do i need to configure anything else?

  8. #88
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Good job ! Keep it so !
    You need to add these lines :
    If V < TargetTemp - Hyst then ' Below Target temperature - Hysteresis
    PORTA.2=1 ' Activate Warm Output
    PORTA.3=0 ' Deactivate Cold Output
    EndIf

    If V > TargetTemp + Hyst then ' Above Target temperature + Hysteresis
    PORTA.2=0 ' Deactivate Warm output
    PORTA.3=1 ' Activate Cold Output
    EndIf
    just in front of
    GoSub SelectSign ' +/blank/- Sign
    GoSub DisplayTemp ' Temperature to LCD


    Goto MainLoop ' Do it forever

  9. #89
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Hi Fratello,

    your help is much appreciated.

    I will follow your instructions this afternoon. The code is working really well and the temperatures are very close to other circuits i have.

    Thanks a lot!!!

  10. #90
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    hi again,

    i place the code at your suggestion, and it is ok,

    the problem is that the low and high indications are flashing they are not stable on when they are activated.

    is that normal?

  11. #91
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    ok i found the problem,

    if i place small current LEDs they are flashing when the port is activated.

    If i place an LED more than 25mA then it stays light and stable.

    But!!! i have seen an other problem. The INT sensors seems to stack some times, and gets unstack if there is a rapid change on the EXT sensor.

    Have anyone noticed that? Do you think that this is Sensor problem?

    thanks.

  12. #92
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Ok after all i found out that it was the sensor problem.

    According to the outputs on the ports for high and low indication, the problem exists.

    Once i place a low current 10mA it does not light but flashing very low.

    If i place an led more that 20mA then it fully light up.

    I dont know if anyone has the same problem.

  13. #93
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    The function on thermostat it's made with R (4k7 - from PIC port), transistor (BC547), relay (from collector to plus).

  14. #94
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Thanks Fratello,

    i havent test with any transistor, because normally it works with an indication of LED. The ports can handle 100mA. I thought that would work like that.

    This week i will be in Vienna and then i will be in America for some Seminars. So i wont be able to test in my lab the code or a circuit.

    I will get 3 uLED 3,2 touch from Sparkfun and i will try to make and complete the circuit for RFID that i have started in addition to codelock circuit.

  15. #95
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Which display did you ordered? the 4D 3.2" touch screen?

    Ioannis

  16. #96
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20


  17. #97
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    i'm facing the same problem with the LED output pulses.

    Is there anyone has the same problem? I cannot fix it.

    Once the temp goes closer to the SET temp, the output seems to have pulses before it light the LED at its level.

    It looks like the PIC sends pulses at the very close set temp and once it comes to the action, lights the LED.

    To be more specific.

    Lets say we SET the TEMP at 22 C. and .10 C. the plus and minus from 22 C.

    If the display goes to 21.6 or 21.8 the indicator LED flashes very low with pulses.

    If the TEMP goes to 22.20 then the LED lights.

    Please let me know if anyone of you having the same problem. To program i use the PIC KIT 2.

    thanks a lot.

    I would like to say that i have test the circuit with Transistor also and Resistor 4,7K.

    But at the point close to the set TEMP the led keeps flashing, and once is reaching the (emaple 22.20 C) it goes stable active.
    Last edited by astanapane; - 8th December 2011 at 09:43.

  18. #98
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    The comparisson is done with the program code in post #88?

    Ioannis

  19. #99
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Hi Ioannis,

    Yes, i have added the lines Fratello told me in order to activate the outputs.

  20. #100
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    It should not do this. The code has some kind of hysteresis which prevents the play at he output.

    What if you increase this hysteresis?

    Ioannis

  21. #101
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    I made tens of this thermostat, for all my friends, relatives....without troubles. Maybe it's time to show us Your schematic !

  22. #102
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    May we ALSO see your FULL code ???

    ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  23. #103
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Yes sure, i will upload the code soon, and i will also make a small video if you want.

    On the output, i have done the following configurations.

    1) only an LED
    2) light the LED through resistor.
    3) light the LED through a transistor.

    In case number 1. the 3MM LED does not go ON but it flashes very low with some pulses, it is not noticeable. (the 5 mm goes on)
    In case number 2. the LED works just fine
    In case number 3. the LED works just fine

    My question is, if anyone understands why it does not light up straight from the PIC (pin) output with no transistor or resistor.

    thanks a lot and sorry for the trouble

  24. #104
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    I can only assume an overload with some kind of interference with something else around...

    I would never load directly PIC output pins.

    Ioannis

  25. #105
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    My opinion : MUST connect the LED trough resistor (R=U/I ; where U=5V and I depend on LED colour) ...

  26. #106
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    it is strange because most of the times PICs can directly drive loads until 100mA. The leds get something like 10mA or less. The thing is that it looks like some pulses coming up from the pin. Can i test the PIN without any load on it with an oscilloscope? IF i have pulses then can we identify what the problem should be?

  27. #107
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Quote Originally Posted by astanapane View Post
    it is strange because most of the times PICs can directly drive loads until 100mA. . . .
    Ok I took this comment out of context . . . 100 ma if all port pins have a load on them distributed across the entire port . . . 25ma max on a single output pin. . . unless I misread the data sheets.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  28. #108
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Fratello,

    i have changed your code a little bit, only a very simple thing in order to have two outputs.

    instead of this

    Code:
    If V < TargetTemp - Hyst then ' Below Target temperature - Hysteresis
    PORTA.2=1 ' Activate Warm Output
    PORTA.3=0 ' Deactivate Cold Output
    EndIf
    
    If V > TargetTemp + Hyst then ' Above Target temperature + Hysteresis
    PORTA.2=0 ' Deactivate Warm output
    PORTA.3=1 ' Activate Cold Output
    EndIf


    i used this

    Code:
    If V < TargetTemp - Hyst then ' Below Target temperature - Hysteresis
    PORTA.2=1 ' Activate Warm Output
    
    EndIf
    
    If V > TargetTemp + Hyst then ' Above Target temperature + Hysteresis
    PORTA.2=0 ' Deactivate Warm output
    EndIf
    
    If V2 < TargetTemp - Hyst then ' Below Target temperature - Hysteresis
    PORTA.3=0 ' Deactivate Cold Output
    EndIf
    
    If V2 > TargetTemp + Hyst then ' Above Target temperature + Hysteresis
    PORTA.3=1 ' Activate Cold Output
    EndIf
    and now i have two outputs. Very simple change but useful.

    Regards,

  29. #109
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    I used to manipulate the ports directly, but once I had a problem and suspicion have fallen on the technique among other things.

    So, I now only use HIGH and LOW commands even if these eat a little program memory just to be sure.

    If your code is small enough to fit in one page then you probably can use direct port control.

    Ioannis

  30. #110
    Join Date
    Apr 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Please help with code for DS18B20

    Quote Originally Posted by fratello View Post
    Thanks for support !!!!
    First code (post #18) return this result : 28 CA C6 48 1 0 0 A7
    Second code (post # 22) return : CA C6 48 01 00 00


    In the code that I write now I use something like this :
    "Init1
    OWOut DQ, 1, [$55, $28, $FE, $DA, $3E, $0, $0, $C1, $4E, $FF, $FF, $7F]
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $48]
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $B8]
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $BE]
    Pause 1000
    OWOut DQ, 0, [Temperature.Byte0, Temperature.Byte1, 0, 0, DS18B20_12bit]


    Init2
    OWOut DQ, 1, [$55, $28, $FE, $DA, $3E, $0, $0, $C1, $4E, $FF, $FF, $7F] 'SENSOR 2 !!!!!!!!! not reading yet !!!!
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $48] 'SENSOR 2 !!!!!!!!! not reading yet !!!!
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $B8] 'SENSOR 2 !!!!!!!!!
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $BE] 'SENSOR 2 !!!!!!!!!
    Pause 1000
    OWOut DQ, 0, [Temperature.Byte0, Temperature.Byte1, 0, 0, DS18B20_12bit]


    Main
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $44] ' Start temperature conversion Sensor 1

    WaitLoop:
    While not DQ
    Wend

    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $BE]
    OWIn DQ, 0, [Temperature.Byte0, Temperature.Byte1]
    GoSub Convert_Temp
    GoSub DisplayTemp

    Part2
    OWOut DQ, 1, [$55, $28, $CA, $C6, $48, $1, $0, $0, $A7, $44] ' Start temperature conversion Sensor 2

    WaitLoop2:
    While not DQ
    Wend"



    I hope it's good...will see !
    I try to read serial number in my DS18B20:
    first sensor 28D698D7400F8
    second sensor 28FED6D64002B
    third sensor 2880DC3C2009E

    but how I put it in the code with $ ?

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts