Input question from a newbe


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Input question from a newbe

    Hi,
    Since the external circuit operates on 12V the voltage at (2) will be 12V when the LED is off, if you connect that to an input of your PIC, which operates from 5V, current will flow from +12V, thru the resistor, LED and into the PIC's input pin, up thru the internal clamp diode and into the 5V supply line of the PIC and the LED will turn on (with less intensity since the total voltage is 7V instead of 12V).

    Use a high(ish) value resistor between point 4 and your PIC input (say 47k or something). That will limit the current into the PIC to safe level and stop the LED from glowing.


    Same thing with (4) really, if the voltage at (4) is 12V when the button is not pressed and you connect your PIC output (which toggles between 0 and 5V) to (4) it's likely that the external circuit will think the button is pressed no matter if the output is high or low. As you say, a relay or transistor switch should do the trick.

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


    Did you find this post helpful? Yes | No

    Default Re: Input question from a newbe

    One little trick I have always liked is to use a lm78L05 to92 cased regulator to feed your input, then you only flow 5v into the pic and it is small as a transistor and cheap too.
    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.

  3. #3
    Join Date
    Jul 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Input question from a newbe

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Since the external circuit operates on 12V the voltage at (2) will be 12V when the LED is off, if you connect that to an input of your PIC, which operates from 5V, current will flow from +12V, thru the resistor, LED and into the PIC's input pin, up thru the internal clamp diode and into the 5V supply line of the PIC and the LED will turn on (with less intensity since the total voltage is 7V instead of 12V).

    Use a high(ish) value resistor between point 4 and your PIC input (say 47k or something). That will limit the current into the PIC to safe level and stop the LED from glowing.


    Same thing with (4) really, if the voltage at (4) is 12V when the button is not pressed and you connect your PIC output (which toggles between 0 and 5V) to (4) it's likely that the external circuit will think the button is pressed no matter if the output is high or low. As you say, a relay or transistor switch should do the trick.
    HenrikOlsson: Thanks, your answer is very helpful and informative. Just to be sure though, when you said point 4 above (for the high value resistor) did you mean point 2?

    With the switch that makes sense, before starting on this I was originally thinking that there was high low and open but as you say it is either 0 or 5V.

    Quote Originally Posted by Archangel View Post
    One little trick I have always liked is to use a lm78L05 to92 cased regulator to feed your input, then you only flow 5v into the pic and it is small as a transistor and cheap too.
    Archangel: That's a neat trick, thank you.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Input question from a newbe

    Thanks, your answer is very helpful and informative. Just to be sure though, when you said point 4 above (for the high value resistor) did you mean point 2?
    Indeed I did, sorry about that.

    With the switch that makes sense, before starting on this I was originally thinking that there was high low and open but as you say it is either 0 or 5V.
    Actually, you can, instead of switching the output between high and low switch the pin between output (high or low) and input (high impedance). But in this case you'll end up with the same problem as with the LED. When the pin is an input current would flow thru whatever "feeds" the switch, into the PIC pin, up thru the clamp diode and into the 5V rail making the voltage at (4) around 5.5V which might fool the external circuit into thinking the button is pressed. Obviously all this depends on what is actually inside that black box.

  5. #5
    Join Date
    Jul 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Input question from a newbe

    I created a simulation of two LEDs using a breadboard and and using the 47K Ohm resistor approach it work, I could sense which LED was on or if neither were on.

    However, sometimes it seems to get confused and misread, it is as if there is some interference or noise being picked up. I check all the connections and tried varying the resistors but it still happens.

    Any thought?

    I'm also going to pick up some lm78L05 to92 and give that approach a try as well.

    Thanks again for the help and continued education

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Input question from a newbe

    I would suggest trying a lower value resistor but it seems you've already done that.

    What is the voltage at the pin (on the PIC) when the LED is on and off? Are you running the PIC on 5V?

  7. #7
    Join Date
    Jul 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Input question from a newbe

    Quote Originally Posted by HenrikOlsson View Post
    I would suggest trying a lower value resistor but it seems you've already done that.
    I think I found the problem, although not entirely sure why it did what it did. The initial LED circuit had one LED and when I added the second (in haste) I shared the same dropping resistor (based on the fact that that both LEDs would never be on at the same time). Giving each LED its own resistor appears to have solved the problem.

    Quote Originally Posted by HenrikOlsson View Post
    What is the voltage at the pin (on the PIC) when the LED is on and off? Are you running the PIC on 5V?
    The voltage at the pin is 5.6V Off and 0V (0.5mv on my meter) On

    The PIC is running on 5V (via 7805) but both circuits are fed from the same 12V supply, that is how it will be with the final circuit.

    thanks again.

Members who have read this thread : 0

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