NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Basic Electronics » PC4 not working?!
October 30, 2010 by Eddie |
Okay so I've been messing around with simple LED circuits just to get some practice on how to use multiple ports. This morning I set up 6 LEDs in a row(PC5 through PC0) I wanted to see if I could get them to light up one at a time from left to right. Anyway by modifying the led_blink code I was able to do this(And I was happy lol) I was modifying the code and uploading it over and over because I kept making minor changes to the code; I wanted to try different combinations of LEDs etc. One of the times it just got stuck at "Connecting to programmer". And after that I just kept getting this error: buffered memory access not supported. Maybe it isn't a butterfly/AVR109 but a AVR910 device? I looked around in the forum and followed people's advice to just rewire everything to make sure there were no loose cables. And I guess that was the problem because it all works now :) EXCEPT for PC4! I tried running the original led_blink code and it just wont work. I tried using other ports and the LED blinks with any other port. I tried troubleshooting everything that comes to mind but everything leads me to think that port just went bad? is that possible? :( I even tried hooking up an LEDs cathode to GND and directly touching its anode to the pin(which worked when i tried with other pins) but still nothing. P.S. sorry for the long post, I just want to give as much detail as possible |
---|---|
October 30, 2010 by Rick_S |
First and foremost, I what to give you kudos for actually searching the forum to find an answer to your programmer issue! Now to the topic at hand: It sounds as if you may have damaged that output pin. This can happen innocently enough by a static discharge, or accidental pin overload. (I once shorted a 12v supply to a pin and damaged it's output) An overhead photo may help but it sounds like you've covered the bases. One other thing, and this just may be me, I always use a current limiting resistor between an output on the micro-controller and an LED. I know the guide states that the "effective resistance of the MCU pin makes the pin voltage drop because of the current" and tells you do connect the LED directly between the pin of the MCU and the ground rail, but while I'm sure that is true, I don't know how many watts of power the internal resistance of the chip can dissipate before failure. I haven't been able to see that in the datasheet. So I figure if I put in a resistor that I know will drop the current with a known power handling ability, I'll protect the more important part... the MCU. I do know every design I find on the web uses current limiting resistors for LED's. So to sum up the long paragraph, if you do have to get a replacement MCU, you can't hurt anything by placing a resistor in series with an LED. JM2C Rick |
October 31, 2010 by Eddie |
Thanks for the response Rick. Yes I'm now convinced that the pin is damaged, I will order a new MCU right now actually. I will definitely take your advice of using a resistor in the future. One question though, what resistor should I use? I tried looking around but I'm a bit confused. I found several calculators to help find the right resistor for an LED but I'm not sure of what to input as the -Source voltage -diode forward voltage -diode forward current I'm assuming the Source voltage would be 5 since thats what we brought it down to from the 9V battery. Then I found this: Voltage drop is usually 1.9~2.1V for AlGaInP, 3.1~3.5 for InGaN and 1.2V for Infrared. Current is usualy 20mA, for UFO LEDs current is: 30mA for InGaN and 50mA for AlGaInP. Supply Voltage - depends what you have at disposal. Usuall is 6V or 12V source. So I input this into the calculator: Source voltage: 5V Diode Forward Voltage: 2(because of: Voltage drop is usually 1.9~2.1V) Diode forward current: 20(again: Current is usualy 20mA) And it recommended "a 1/2W or greater 390 ohm resistor". Would this be correct? |
October 31, 2010 by Eddie |
Okay I guess I need to look at an LED's data sheet to find out its forward voltage and current rating. But for now what would these numbers be with the resistors that came with the kit? |
October 31, 2010 by Eddie |
Sorry with the *LEDs that came with the kit? |
October 31, 2010 by Rick_S |
The resistance you came up with would be fine... Honestly, I often just go with 1k resistors because I have a bunch on hand and the LED's are plenty bright with them. 1/2 watt is way overkill. The formula for power is P(Watts)=I(current)*V(voltage) so in this situation, say you did have 5V driving your circuit with a full 20mA (.02A) your wattage use would be 5*.02 or .1W In reality, I'd probably run the LED between 15 - 17mA and that drops the power even more. You could use a 1/8W - 1/4W with no problems. Rick |
November 01, 2010 by bretm |
The guide does show an example using an LED without a limiting resistor, but this is a bad idea and should only be done if using battery power. The example should be changed. If you do this using a lab bench supply or wall-wart or some other higher-powered supply, you'll observe far too much current going through that pin, well over the limits listed in the datasheet. When it tried this it even changed the timing of the blink program. The chip was clearly under the weather. |
November 04, 2010 by hapshetsut |
I notice that this thread is probably stale by now, but i had a thought. If you're sure that everything is configured correctly in the code, and you're wiring is good, I would then suggest getting a multimeter out and looking at the voltage output of the pin. if you see that there is no voltage at PC4 high, then it's probably just bad, but if you see something weird, like an output 'high' that can't drive enough current to light an LED, you might just have a damaged (but not ruined) pin, so you could try running the output to a transistor switch, if you wanted to salvage it. If you just want to be done with it, I'd gladly take it off your hands :). Another (possibly irrelevant) question: Does it work as an input pin? I just hate to see a decent MCU go unused. |
Please log in to post a reply.
Did you know that SPDT stands for "Single Pole, Double Throw"? Learn more...
|