Please help with code for DS18B20


Closed Thread
Results 1 to 40 of 110

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    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) ...

  2. #2
    Join Date
    Oct 2010
    Posts
    413


    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?

  3. #3
    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.

  4. #4
    Join Date
    Oct 2010
    Posts
    413


    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,

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    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

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 : 3

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