Barely an hour between complete confusion and WOW! it works!!
Good job, I bet that feels good. I know it does for me when I figure something out... especially after "banging my head on the wall".
congrats!
Barely an hour between complete confusion and WOW! it works!!
Good job, I bet that feels good. I know it does for me when I figure something out... especially after "banging my head on the wall".
congrats!
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
We all know what you mean, that's for sure. If your walls are located too far away... here's a portable solution...
Should also grab one of these
------========------
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Thanks for the head banging kit, I have a feeling I will got a lot of use out of it while trying to get up to speed.
If you guys don't mind I have another probably very fundamental question, but my basic knowledge of electronics and programming is probably dangerous
For my first Pic project I want to sense the current state of an existing piece of electronics and then be able to control it based on the current state and other inputs that are not part of the existing circuit.
Below is the basics of the existing circuit.
I've measured the current (flowing between 3 and 4) when the switch is closed and it is only a few mA so I think I can happily pull point 4 to ground to emulate the switch being pressed.
For the sensing of the existing circuit and whether the LED is lit, can I just attach point 2 to an input and read a low (using internal pull up resistors)? I didn't know if that would interfere with the existing circuit. For the switch side of things I know I could use a relay or something to completely isolate the two circuits (mine from the existing), but wasn't sure about reading the state of the LED.
The existing hardware isn't cheap, so I don't want to experiment too much.
Any help or advice appreciated.
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.
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.
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.
Archangel: That's a neat trick, thank you.
Indeed I did, sorry about that.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?
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.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.
Bookmarks