I have created a circuit that uses an ATTiny to control a transistor that switches a relay. This board will be the power management center for a high-current device.
I have code that simply has the ATTiny mirror the switch's state into the transistor's state. That way the switch should control the relay.
When the switch is off, everything works fine. However, when the switch is on, the LED connected to the power rail and the LED connected to the 'off' position simply dim, and the fact that they are behaving the same way tips me off that something is wrong (Also the blue LED should simply turn off, with no change to the power rail LED, and I should probably hear the relay switching). I was wondering if someone could take a peek at the schematic I made based on the circuit I built and try to see if anything is amiss.
Thank you so much! This helped a ton. The problem is almost solved.
The device now works perfectly when no load is attached. However, when a load is attached and the power is turned on, the relay clicks very rapidly as if it is oscillating. Not only does the relay click, but the transistor pin flashes repeatedly with the clicking.
To me this would mean that when the relay is turned on, it somehow polarizes the switch and causes itself to turn off again rapidly, but I can't see how that could be possible.
UPDATE:
So what's interesting here is that if a load is attached when turned on, the flickering occurs.
However, if I turn it on and then attach a load, everything works perfectly.
ANOTHER UPDATE:
These results aren't reliably reproducible. It's hit-or-miss, here.
Perhaps I need to toss in a cap somewhere? Any insights would be greatly appreciated.
When the relay activates, +5 is connected to BAT+. Is that what you wanted? I don't why you'd do that. Or does +5 represent your load? If so, can the battery supply enough current? How much current is drawn?
A 0.1uF cap from pin 8 to pin 4 would certainly help.
+5 represents my load. I didn't really know the proper marking for that on a schematic.
The power source is actually a wall wart spitting out around 5.5V with a 3A max current. I'm using the relay to switch that power to the other boards I'm powering, and splicing the power cable so that the ATTINY always gets power, but when the relay is on, the route for the heavy current doesn't go through the little guy and fry it.
In total I'd suspect the current draw will be 2A, but I'm testing the load with my little Arduino, so currently no more than a few milliAmps.
I'll add a cap and get back to you. I really, really appreciate both your knowledge and patience. Thank you.
P.S: By pins 4 and 8, I'm assuming you mean ground and vcc. What is the purpose of this?
UPDATE:
I added the capacitor between the VCC and ground pins, 10uF. Now the Arduino will power itself on perfectly with none of the craziness. When I test it with the RPi though, the clicking still occurs. Perhaps a higher-capacity capacitor is in order?
UPDATE 2:
I switched the capacitor to 470uF. The device works flawlessly with smaller loads like the Arduino, but still freaks out with an RPi or higher-draw boards. Now the relay will flip and deliver power to the board for about a second before my entire circuit just loses power and reboots. Then it flips the relay again and dies again, repeating forever. The wall wart I have can handle 3A, so I don't see what the problem is here.
A 0.1uF from VCC to Gnd will supply high frequency current surges the chip needs for internal switching. It is called a decoupling cap. 10uF is good for big, slow current surges, but you need the 0.1uF to 0.22uF for the high frequency stuff.
How does the RPi fit in? Is the circuit connected to the RPi Gnd also?
Okay, that makes sense, and good to know! I have definitely read about decoupling caps before but never really understood what they were supposed to do. I'll see if I have any lower-farad caps around.
The 'load' in the schematic is actually just power wires extending from a board that are spliced into the regular USB Micro B power cable for the Pi.
UPDATE: A lower capacitor value (1uF) once again works well with the Arduino, but also once again fails when used in tandem with a higher current-draw board. It honestly appears like the circuit is 'running out' of power...
Are you at all interested in the fact that your schematic does not conform to standard format convention with respect to orientation of symbols ? (leds, battery, gnd, +5V, Vcc, transistor)
Basiclly, out of your entire schematic, the ONLY components that are shown correctly are the uC and the diode.
Everything else is either 90 degrees or 180 degrees rotated from what it should be. In short, all of your components are sideways or upside down except the arduino and the diode. (of course resistor don't count)
If you had any capacitors, they would probably be upside down or sideways as well.
You should take a few moments to actually learn the correct orientation of schematic symbols.
Obviously, none of the above has any relevance to the whether the circuit is electrically correct.
Yes I am absolutely interested in the correct orientation and method of creating schematics. Thank you for the advice!
Tom: That is much, much more readable. I love it.
My load is just power and ground with some pretty thick cable. It splits into both a barrel jack connector for powering an LCD (5v) and a micro USB (power only) cable for powering the Pi.
The board looked like it was running out of power, so I went back and re-did my split cable much more carefully and with good insulation. Now I'm happy to say the LCD works as expected, but anything connected to the microUSB will cause that infernal clicking.
I find this odd because the RPi definitely draws less current...
Almost there, guys. Thanks for the help so far!
(P.S: I definitely used an electrolytic cap. Why must it be ceramic?)
Hi,
Can you measure the current in the 5V supply when you have no fault and fault conditions.
I don't know much about the Pi, but if it has a switching supply on board then there will be a surge current before it starts up.
How long is your lead from the relay and the ATtiny45 and the PI?
An electrolytic cap is made a bit like two long sheets of foil with a wet paper towel (the electrolytic) between. To make it fit on the circuit board, the sheets are rolled up tightly in a spiral. Another component that is made as a spiral is called an inductor. The electrolytic cap actually has a measurable inductance (the opposite of capacitance) at high frequencies. It stops acting like a capacitor as the frequency increases.
A ceramic cap is made with a porous ceramic that is like a sponge coated with metal. It has a much lower inductance.
Electrolytics are cheap/easy to make in high values. So they are used as bulk capacitance in power supplies. Ceramics are used where the inductance must be so low that even a few millimeters of PCB track make an unacceptably large inductance, so they are placed very close to the chips that need this decoupling.
Tom: Just to be clear, you're asking for the current coming out of the power supply, right at its initial connection with my power circuit, with and without a load? The lead is about 4-5 inches in length.
Morgan: Okay, that makes a lot of sense, and your analogy clears up the rest. I'll try and find a low-microfarad ceramic cap laying around. Luckily the trace up to the cap from pin to pin isn't more than a few millimeters in length.
Thanks so much guys. I'll update this post with my results.