1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Input For PIC uC

Discussion in 'Microcontrollers' started by mesamune80, Apr 30, 2008.

  1. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    Hi all,

    i am using a comparator ic and LM393 ,configured it as windows detector circuit with the output go to LED and pic uC pin.
    But i could not read any high logic from the ic output pin when the pin is goes high. i am using a 1k pull up resistor for the power (12v) to LED which is parallel to uC pin as well which i want the uC to detect it is logic high.
    Any problem with my configuration?
     
  2. Gayan Soyza

    Gayan Soyza Active Member

    Joined:
    Oct 23, 2006
    Messages:
    1,821
    Likes:
    19
    Location:
    Colombo
    Remove the comparator part from the uC & check the comparator whether it is working correctly?

    Can you see the LED goes on when input logic = 1 (in between your range)?

    What input did you feed the input?Inverting pin or for the non inverting pin?

    Note that its output open collector type.
     
    Last edited: Apr 30, 2008
  3. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ya,my LED lit but i could not get any signal to my uC pin.
    my circuit is look like this with the VrefA and VrefB to my pic uC pin (input pin)
    Is there anything i need to add so that my uC can detect logic 1 and 0 respectively?
     

    Attached Files:

  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK

    Remove the LED's, they are stopping the outputs going high!.
     
  6. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    i see ,thanks nigel ,but i need some indication for that? (high and low limit indication)
    can i do it in a different way? or any alternative for that?
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Use a transistor to feed the LED.

    Or, more crudely, put a resistor in series with the LED - but this will still restrict the output of the comparator from going fully high, and reduce the LED's brightness.
     
  8. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    Hi Nigel,
    Just noticed he is using a +12V supply to the LM393...:eek:
     
  9. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    It seem like i got not much choices,either a transistor or a dim LED =_="
    what transistor is suitable for this i can use 2N222?
     
  10. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    anything wrong with 12V? @_@"
     
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Not as long as you have a current limiting resistor feeding the PIC.
     
  12. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    okay i'll try it out ,thanks guys.
     
  13. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Or you can use 3.3V 250mW zener diode in series with each LED.
     
  14. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    You could do it this way.

    I have modified the top LED, I'm assuming a Red LED about Vfwd=2V

    The LM393 is open collector output, also the PIC analog is a high impedance.
     
    Last edited: Jul 7, 2008
  15. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    Thanks for all the replies,really thanks for all of you.
    i think i might choose either zener or voltage divider method to power up both my LED and also signal to my uC. =)
     
  16. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    Can i put it this way? so that i can adjust untill the voltage to my uC is about 5V at the same time i also can light on my LED.
    Or any better idea i can use? at the moment i have 10k adj resistor and 1k resisitor.
     

    Attached Files:

    Last edited: May 4, 2008
  17. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    i had thried the above mothod which is proposed by ericgibbs .i found that the voltage go to my uC is about 2.71. is this voltage enough for my uC to detect as high?
     
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    You have used the method I suggested, BUT you have not used the resistor values I calculated.
    You still have a 1K0 to +5V from the OPA ouput and the 10K adjustable is not a good idea.

    The 2.7V is only marginal, its not high enough for reliable operation, I would suggest at least 3V.
     
  19. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    i see,so u mean i have to use 700 (can i really get this from the market?what i got is 680ohms) and 300 (this can be obtained)
    And how could you manage to calculated those value?
    can u show the method to as well.From what i know is by using voltage divider but why must 700 and 300? the ratio would be 3/10 X12V =3.6V ?
    is this what you mean how about the LED voltage?
     
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    A 680R and 330R would be fine, if the PIC pin voltage is still a little too low use a 330R in place of the 270R.
    The original values were base on about a 10mA current from the +12V supply, this would be enough to light the LED [ I assume its a Red LED.?}

    The 3.6V would be acceptable

    Do you follow.?
     
  21. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ya i am using a red and a green LED,so you what you mean is 680 and 330 .And check the voltage output whether it is enough or not if not replace 330 with 270R right?hope there is no problem after this.
    ya one question here,what PIC programmer do all of you using?
    i need a USB programmer now,and dunno which one to choose >_<"
    Any recommendation?
     

Share This Page