Switch sensor vs. switch PIC pin


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579

    Default Switch sensor vs. switch PIC pin

    I made one thermometer with LED display for my car. I intend to use two DS18B20 sensors. Which method it's better : 1.using a switch for sensor-and a single pin of 16F628A (picture 1); 2.switching between sensor from one port of PIC (figure 2).
    The distance from PIC to switch are about 40 cm and from PIC to sensors are about meters. Thanks in advance for reply !
    Attached Images Attached Images   

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    Hi Fratello,

    Why not just put them on the same bus with no switch?

    According to the data sheet, you can talk to them both separately:
    Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area.
    It looks like you have enough digits in your display to represent A or B for each temp, so you can tell them apart.
    Last edited by ScaleRobotics; - 5th April 2011 at 15:52.

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    Thank for reply !
    The reading of temperature is ...chaotic ! Sometimes I want to see the temperature of outside, sometimes -the temperature of inside ! Without any rule !
    So, I need one switch... OK, the ideea to use both sensor on the same bus it's good, but...i need to read the serial number of each sensor and keep this serials in eeprom ?! It is one simply way to do this with PBP commands ? I made once one termometer using 1-wire commands and I remember it's not so easy ...

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    You could have your Main loop check the status of a switch, not in your sensor loop, if closed it jumps to a sub routine to check one and if open it goes to a different sub routine. the DS18B20 temp sensors never get switched, they are always on, so no noise problem.
    In the sub routines use your owout / owin and jumps to display refresh routine with pertinent data.
    You could even have the main loop read both sensors every loop and have your subs just display the variables your data is stored in.
    Last edited by Archangel; - 6th April 2011 at 06:04.
    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.

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    So the second variant it's better ?!

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    Hi Fratello,
    Well your complaint was noise interfered with data when you switch the device in /out. If you leave it "in circuit" all the time it eliminates that possibility. By using a separate input to detect a switch the noise is confined there. You might also consider using a pin that has an interrupt available, so it changes in "real time", instead of waiting for a loop to get around to it.
    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.

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    So...This is correct ?
    Code:
    ...
    If portA.7= 1 then
    valoare=temperature
    semn=sign
    else
    valoare=temperature2
    semn=sign2
    Endif
    
    Gosub Selectie
    Gosub Display				' B for Common CATOD;without B for Common ANOD
    
    Goto Main
    
    '======================================================================================       
    Selectie :
    
    IF semn ="-" then					
        DIGIT_3="-"
        else
        DIGIT_3=" "
    ENDIF
     
    IF valoare DIG 2 = 0 THEN
        DIGIT_2 = " "
        ELSE
        DIGIT_2 = valoare dig 2
    ENDIF
    
        DIGIT_1 = valoare dig 1
        DIGIT_0 = valoare dig 0
    
    RETURN
    '======================================================================================       
    Display:					' For Common ANOD
    for i=0 to 4
        TEMP = DIGIT_3 : gosub segments
        COMMON_3 = 1 : PAUSE 1 : COMMON_3 = 0
    
         
        TEMP = DIGIT_2 : GOSUB segments
        COMMON_2 = 1 : PAUSE 1 : COMMON_2 = 0
       
        TEMP = DIGIT_1 : GOSUB segments
        COMMON_1 = 1 : DP = 0 : PAUSE 1 : COMMON_1 = 0 : DP = 1
      
        TEMP = DIGIT_0 : GOSUB segments
        COMMON_0 = 1 : PAUSE 1 : COMMON_0 = 0
    next i
    RETURN
    Thanks for support !Name:  ttt.jpg
Views: 1168
Size:  165.5 KB

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    One of my DS18B20 it's about 4 meters from PIC. What is the smaller value of resistor used for this sensor ? Can I try with 1k ? Thanks !

  9. #9
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    I have used 15m cable and pull up resistor 680 ohms. Resistor value depends greatly on the capacity of cable. And the capacity of the cable depends on the length.

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    With 5 meters of cable from PIC to DS18B20, no need to decrease value of R (still 4k7). Thanks for support !

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


    Did you find this post helpful? Yes | No

    Default Re: Switch sensor vs. switch PIC pin

    ...but, in some cases, I decrease the value to 3k9...for the same lenght of cables !

Members who have read this thread : 2

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