Go Down

Topic: Advice on a simple ATtiny relay circuit (Read 2480 times) previous topic - next topic

etatoby

Jun 05, 2012, 10:08 pm Last Edit: Jun 05, 2012, 11:39 pm by whatfireflies Reason: 1
Hi everybody!

I'd like to (try and) program an ATtiny from my Arduino and use it to control three light bulbs (incandescent.) I've done my homework, but I'd like to get some confirmation that I didn't make glaring mistakes, before I fry something :smiley-sweat:

Can you give a look at this circuit?



Did I forget anything?

Keep in mind the 5V will come from a recycled "wall wart" transformer of the cheapest kind.

Is my hunch right about using the unregulated line to drive the relays?

Jack Christensen

#1
Jun 05, 2012, 10:34 pm Last Edit: Jun 05, 2012, 10:36 pm by Jack Christensen Reason: 1
Greetings :)

I believe the right side of the relay coils should go to the +5V supply, not to ground. I'd measure the 5V unregulated supply just to make sure it's not far in excess of the relay coil specs. Also, if the 5V supply isn't filtered (or if I wasn't sure how filtered it was), I'd add a reasonably large electrolytic
on the input side of the regulator, maybe somewhere between 220µF and 470µF.

The relay and driver setup could be tested with the Arduino to prove that part of the circuit before moving to the ATtiny.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

etatoby

Oh my, you're right! I've fixed the diagram.
Of course I'll test everything on the Arduino before adding more complexity!

The supply measures 5.4V with no load (voltmeter straight to the DC connector) so I'll keep that in mind when I choose the relays.

The regulator's datasheet suggests a 100nF ceramic on the input. Does the large electrolytic go in parallel with it, as I've seen done many times? Do they have different functions?

Coding Badly


Is programming in-system part of the plan?

Jack Christensen

Yes, I usually use an electrolytic in parallel with a 100nF ceramic. The higher capacitance or the electrolytic provides the bulk of the filtering at lower frequencies, but the ceramic capacitor with its lower equivalent series resistance (ESR) and inductance is better at handling the higher harmonics, noise, etc. It's also common to see a 100nF ceramic cap placed physically near pretty much every logic chip, MCU, etc. to address the high-frequency noise generated by the switching in these chips. It's not unusual for an MCU to require multiple bypass capacitors, depending on package layout. Good reading here: http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

etatoby

Thank you!

I pried open the power supply. It has a 470µF on the output side, so I guess I can skip that. But I'll still put a 100nF ceramic physically close to my voltage regulator, even though I found the same component in the power supply too, in parallel with the electrolytic.

By the way, this tiny power supply has the strangest circuit! The mains goes straight into a 4-diode rectifier, then there's a power mosfet (K2185), two transistors, and a bunch of passive components. Only then does it go into the (small-ish) transformer. There's also a photocoupler (TLP421) spanning the high voltage / low voltage barrier, alongside the transformer! Do you know what kind of circuit is it? Tomorrow I'll try and draw the schematics. Maybe it's not as cheap as I thought!


Jack Christensen

No doubt a switching supply. In which case it may be regulated, many are. I'd probably add an electrolytic to the project anyway, maybe 10, 47, 100µF, something like that. Kind of like chicken soup. Can't hurt! XD
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

etatoby

#7
Jun 06, 2012, 01:00 am Last Edit: Jun 06, 2012, 01:02 am by whatfireflies Reason: 1
Awesome!

I'll post pictures and info as my project progresses. My masterplan is to turn a recycled traffic light into an animated light fixture ]:D



Is programming in-system part of the plan?


Not really. I'll try and program it on a breadboard. I'll hopefully load something like ard-core13 and use a sketch debugged and tested beforehand on my Arduino.

etatoby

#8
Jun 06, 2012, 01:53 am Last Edit: Jun 06, 2012, 01:54 am by whatfireflies Reason: 1
I updated my circuit to add a diode and a fuse (or PTC) to protect from supply polarity reversal and from over-current.

Again I ask for validation and advice. Are there other common protection schemes I should be using? What about the voltage spike from a failing power supply? That could cause damage without even blowing the fuse, wouldn't it?

Jack Christensen

#9
Jun 06, 2012, 02:12 am Last Edit: Jun 06, 2012, 02:13 am by Jack Christensen Reason: 1
I prefer to have the diode in series, this will block reverse polarity input yet not draw a large current in a reverse-polarity situation which might damage the power supply. I rarely fuse low-voltage, low-current projects, nor do I worry about power supply failures. It happens quite seldom (never, in my somewhat failing memory ;)), I'm not doing aerospace stuff or anything that life or limb depends on, and there's usually not much invested in the circuit itself. So I'm living right on the edge here XD

Below is a more-or-less typical supply circuit from one of my projects, meant to be powered from a wall wart. This particular example supplies both 5V and 3.3V.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/


Go Up