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?
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?
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.
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.
Update and further question:
I'm sensing the state of 6 LED's using the resistor approach which a great with 5 out of the 6 LEDs. I'm using a resistor of great enough value not to light the LED.
The problem with one of the LED is that the sensing is unreliable (sometimes it would read the LED coming on and sometimes it wouldn't). Using a meter I found that when the problem LED was on the voltage was ~1.2V at point 2 of the original diagram where the other 5 were at close to zero. It is strange because all 6 LEDs are in the same circuit. The issue appears to be that the PIC sees the ~1V as high which makes sense.
I did tried the lm78L05 to92 approach but couldn't stop it causing the LED to be illuminated when the LED was off.
Any ideas?
Last edited by Bdlhome; - 13th August 2011 at 13:35.
This forum is magic, I ask a question after spending hours trying to fix something and then within an hour I come up with an answer. The answer appears to be use a 5v zener diode is series with the resistor.
So my next question is what is next weeks lottery numbers?
The one I have![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Not expecting an answer from Steve because he should have collected his winnings by now
For everyone else; I want to track when a switch (which is in an existing circuit) is pressed and was hoping to use the same approach. The problem is the voltage is 0.7V when push to make switch is open and 0V when closed and that doesn't appear to be enough of a range.
ADC, comparator?!? Arwe you sure it's just not a sort of open collector output you have on hand? What if you attach a pull up resistor to it.
In meantime i'll count my millions![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Probably better for you to define track for your "0.7V" being presented to the PIC....
1. Immediately being notified when the switch is pressed? - use a comparator with PIC's comparator interrupt.
2. hopefully catching someone pressing a switch while polling the ADC Result very frequently? - use ADC and a tight main loop.
I have been using the resistor approach and sensing the voltage when the LED is off and then that drops close to zero when the LED is illuminated.
There are 6 LEDs in play and 5 out of the 6 work flawlessly but I'm having problems with one and it is driving me crazy.
Intermittently the PIC reads the input as positive even when the LED is illuminated just on that one LED. Further information to set the scene:
This circuit is in a car
When the engine isn't running it appears much more reliable (suggesting perhaps noise or voltage related)
With the engine running, turning on the courtesy light will sometimes correct the reading (falsely reading until the courtesy light is turned on and then it reads correctly). This again suggested voltage but turning on something else like the headlights does not have the same effect.
I've tried varying the resistor value and putting in capacitors but has no effect.
Anybody have any ideas? I'm pulling my hair out here.
To make matters worse (or maybe help diagnose) I went back to one of my earlier boards and it works perfectly..
On the newer boards (I have 3 that are all doing the same) that are having the problem, touching the resistor on the side before it enters the PIC makes it work. Is it the capacitance in my finger that is causing it to work?
The layout of the boards (old to new) is virtually identical, I moved a couple of components a little to make the board a little smaller (we are only talking 1/8-1/4 of an inch). The components are all the same values but some are different manufactures, but really clutching at straws at that point. I don't have a scope handy (although I will have access to one on Wednesday) so cant really see what is going on.
What PIC are you using? Also what specific pin are you using?
Shawn
Nothing specific to that pin that should cause an issue. Have you measured voltage at that pin? It sounds like it is floating, possibly due to a broken trace or a bad connection.
Shawn
Bookmarks