Microcontroller interfacing with Triac

Go To Last Post
48 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are there any problems or restrictions for making common ground between 220V AC and an AVR microcontroller for Triggering triac?

there is a better way to trigger a Triac with a microcontroller please tell me, thank you all.smiley

Ahmed Aassem

Last Edited: Mon. Jun 11, 2018 - 09:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An optoisolator is commonly used between a microcontroller and a triac.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely, this is a General Electronics question - not specific to AVR?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are many problems and restrictions - mainly safety related. If you wanted to directly drive the triac, then you would connect the AVR 0V to the mains active -but this makes the AVR circuit ‘live’ and potentially dangerous to work with. The usual solution is to use opto couplers to isolate the circuit.

For your own safety i would implore you to learn about electrical safety and the electrical regulations for your country. Learning the hard way usually involves screams and smoke.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the micro is completely buried inside the circuit, no opto isolation part is really needed.  For example, if the AVR is just going to blink the triac on/off.  Isolation can also help protect line noise from getting into the avr, though other means work too.

If the micro has some control lines, switches, or signals to the outside world, then isolation is usually needed.   

Lack of isolation means the avr power supply should not be isolated (since the isolation would be wasted).

Conversely, if the AVR is desired to be isolated its supply must also be an isolated type (otherwise the opto only prevents line noise from entering the avr, but it provides no safety protection)

Of course a non-isolated AVR connected to your PC for programming may cause damage when line voltage is applied (or at least present a shock hazard at the PC)--so care is needed.

 

Bottom line --opto isolation not always needed, but may add a few hurdles and require paying extra attention (safety wise) to what you are doing.

 

 

 

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
If the micro is completely buried inside the circuit, no opto isolation part is really needed.

You missed a very important caveat there: no isolation is really needed in operation.

 

But, as Kartman pointed out in #2:

this makes the AVR circuit ‘live’ and potentially dangerous to work with

Image result for danger of death sign

 

Kartman also wrote:
 Learning the hard way usually involves screams and smoke.

and the smell of burning flesh - probably your own!

 

surprise

 

Live mains is not to be trifled with!

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

balisong42 wrote:
An optoisolator is commonly used between a microcontroller and a triac.
Similar is an opto-isolated gate driver into back-to-back depletion mode NFETs to get enough current to drive the triac.

IXYS

Integrated Circuits Division

Application Note AN-500

Depletion-Mode Power MOSFETs and Applications

http://www.ixysic.com/home/pdfs.nsf/www/AN-500.pdf/$file/AN-500.pdf

(page 10 of 10)

Figure 10 FDA217 used with CPC3980 FETs to create Normally Closed Solid State Relay

similar in

Microchip

AN-D66

Depletion-Mode MOSFET: The Forgotten FET

By Bill Chen, Field Application Engineer

http://ww1.microchip.com/downloads/en/AppNotes/AN-D66.pdf

(page 4)

Figure 7. Normally-On Solid State Relay

via https://www.microchip.com/wwwproducts/en/DN2540

 


http://ixys.com/PartSearchResults.aspx?searchStr=fda217 (Optically Isolated Gate Drivers)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
Of course a non-isolated AVR connected to your PC for programming may cause damage when line voltage is applied (or at least present a shock hazard at the PC)--so care is needed.
Olimex has an isolated AVRISP STK500v2.

debugWIRE can be isolated; maybe likewise for UPDI though UPDI is symmetric impedance whereas debugWIRE isn't.

 

www.olimex.com

Olimex

AVR-ISP500-ISO

https://www.olimex.com/Products/AVR/Programmers/AVR-ISP500-ISO/

Microchip Technology Inc

Microchip Technology

Application Notes

AN_8112 AVR077: Opto Isolated Emulation for the DebugWIRE

http://www.microchip.com/wwwappnotes/appnotes.aspx?appnote=en591572

via https://www.microchip.com/wwwproducts/en/ATmega328PB

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You missed a very important caveat there: no isolation is really needed in operation.

Not missed, but most certainly worth mentioning several times: 

 

Of course a non-isolated AVR connected to your PC for programming may cause damage when line voltage is applied (or at least present a shock hazard at the PC)--so care is needed.

 

An isolation transformer is a good investment when experimenting with line powered designs

 

These are also pretty good for isolating your programmer from the pc (wireless link would be even better) (though not UL rated)

 

https://www.ebay.com/itm/USB-Iso...

When in the dark remember-the future looks brighter than ever.

Last Edited: Tue. Jun 12, 2018 - 01:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
[ADUM3160] (though not UL rated)
the IC has UL, CSA, and VDE

http://www.analog.com/en/products/interface-isolation/isolation/usb-isolators/adum3160.html

It might be in Olimex's USB isolator :

https://www.olimex.com/Products/USB-Modules/USB-ISO/resources/USB-ISO.pdf

(page 3)

SAFETY AND REGULATORY APPROVALS:

The USB isolator component used in USB-ISO have the following regulatory approvals:

(UL, CSA, VDE pending)

via https://www.olimex.com/Products/USB-Modules/USB-ISO/

https://www.mouser.com/ProductDetail/Olimex-Ltd/USB-ISO?qs=sGAEpiMZZMsyM1rGGtQxrO1HI6bIq7Ze

 

Edit : Mouser

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Tue. Jun 12, 2018 - 02:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

[ADUM3160] (though not UL rated)

I meant the isolator module you purchase didn't seem to have any UL or CE marks..... who knows who/how the PCB was laid out (we've seen a few doozies)...I might trust it to protect my PC...not sure I'd stand in a puddle & grab the output cable while the input side is plugged into a "live/hot" circuit.  At least until I open it & inspect to my satisfaction (did factory man decide to add some jumper wires!!??!)

 

That train of thought also makes me wonder...how good are knockoff/possibly counterfeit generic optoisolators???  Haven't heard anyone screaming.

 

 

When in the dark remember-the future looks brighter than ever.

Last Edited: Tue. Jun 12, 2018 - 04:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahmedasem22 wrote:
Are there any problems or restrictions for making common ground between 220V AC and an AVR microcontroller for Triggering triac? there is a better way to trigger a Triac with a microcontroller please tell me, thank you all

IF you have to ask this question, YOU DO NOT HAVE THE SKILLS NEEDED FOR THIS PROJECT, Please seek out those around you with the skills, working with LINE VOLTAGE is HAZARDOUS to your LIFE!

 

Jim

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is it me or are we seeing an increasing number of these threads expressing a suicidal death wish involving mains voltage in the hands of neophytes?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, I think the rate is about steady - so there must be dynamic equilibrium going on ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, thank you all, I read all of your replies...
I was mainly asking to know whether there would be noise at the 220V AC GND terminal that might cause the GND voltage of the household higher than that of the Vcc terminal of the AVR, because I know that would cause problems and damage the AVR..
But if there is no possibilty for that so no problem, as I know the GND is about 0V, so the potential difference between the GND of the AVR and the GND of the household source would not be something considerable, in case that I connected the AVR to a power supply..

is that correct?
 

I am just asking about the condition of 220V AC household electricity, because I am not sure about that, so I would like to learn more..

And I am not going to implement any projects unless I am aware of the needed information, that's why I am asking. :)
And another point is that I am not going to connect the AVR to any PC without taking it out of the circuit. :)

 

All Regards.

Thank you all.

Ahmed Aassem

Last Edited: Tue. Jun 12, 2018 - 08:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahmedasem22 wrote:
I am just asking about the condition of 220V AC household electricity, because I am not sure about that,

Please up date your profile to include your location, as AC wiring standards may be different then in the US.

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that's almost certain ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahmedasem22 wrote:
is that correct?
No as ground-faults and mis-wiring are possible.

Nearby lightning strikes will cause a voltage difference between ground and neutral.

The design of the power supply should limit the hot-to-neutral voltage difference with a typical lifetime (due to EFT and lightning)

ahmedasem22 wrote:
And another point is that I am not going to connect the AVR to any PC without taking it out of the circuit. :)
Then your discipline is better than mine; was reminded of the power of 120Vac when I forgot a step (remove power) during a test and debug cycle due to my eagerness to solve an issue.

Safer to correctly isolate the PC.

 


https://www.osha.gov/SLTC/etools/construction/electrical_incidents/gfci.html (Ground-Fault Circuit Interrupters)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am in Egypt, we usually have just two terminals, 220V .

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there a specific range that ground-faults do not usually exceed, so that I can use a specific diode to prevent the current flow in the opposite direction?

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ground-fault implies ground; if only hot and neutral then no ground.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, we have just two terminals, Hot and Neutral, I confused the Neutral with the Gorund..

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, so the main issue is that there would be faults that will make the voltage of the Nuetral wire high for some moments which could do harms, isn't it?
If no, please provide me with the issue, Thank you :)
I would like to learn more about the topic, but I am not eager to learn the mathematical formulae, time domain, frequency domain etc at the moment.
I've watched a video where someone triggerd the Triac directly with a DC battery, and here is the circuit diagram,
and this is the link to that video https://www.youtube.com/watch?v=...
I noticed he is using a fuse, so if I used a fuse and connected the GND of the AVR with the Neutral wire, what would the problem be?
Many thanks to the contributors, thank you, guys.

Attachment(s): 

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your neutral may not be exactly 0V! If it's not, then there might be smoke.  Personally, I'd think twice before doing what that youtube vid is doing - and I spent years designing light dimmers. I've been electrocuted and had things blow up in my face, so I speak from experience. With mains, when things go wrong, there's sparks and smoke.

 

Use optocouplers and you can work a bit safer without having to worry too much about blowing up your computer or anything else. Or, you could just ignore our advice and find out for yourself. Inshallah.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahmedasem22 wrote:

I am in Egypt, we usually have just two terminals, 220V .

 

So where does your ground connection come from?

 

Is your supply type TT, TN-S or TN-C-S?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

hence the suggestion in #12 to seek advice/assistance from properly competent local people - who know what the local rules & practices are ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

ahmedasem22 wrote:
, I confused the Neutral with the Gorund..

All the more reason to NOT DO THIS PROJECT!

 

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 so if I used a fuse and connected the GND of the AVR with the Neutral wire, what would the problem be?

 

By the time the fuse blows, your AVR or PC are blown to bits  (unless those inputs are mov/transorb protected)...Full Line power is like lightning to a 5V circuit. 

 

Why not save your life & do something else?  Make a nice AVR game or robot.

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

hehe

 

In High School, we used to build light blinking circuits and chasers and the like by soldering SCRs to the screws of ceramic light fixtures and running them from our 4000 series "COSMOS" logic on solderless breadboards or glued to blocks of wood "dead bug" style powered by 6.3v transformers, diodes and capacitors.

 

"Careful, this makes your whole circuit hot."

 

Was helpful to have LEDs for getting your circuit right, THEN connecting the light bulbs.

 

277,232,917 -1 The largest known Mersenne Prime

Measure twice, cry, go back to the hardware store

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lovely People, I am not doing an educational project, I just have some knowledge and worked on a home automation project with relays, and after I knew about Triacs I liked to know how to implement the same idea using Triacs.
And again, I am not going to take any risks, I will not do it without being completely aware of what I am doing, that's why I am asking.

Many thanks : )

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am definitely not ignoring your advice, what made me basically ask is that I know anything goes wrong with 220V AC connection can cause serious problems, one can die from such a voltage..

If I were to ignore your advice, I wouldn't even come here to ask!!

Yes, optocouplers will isolate it, I know about that :D But I would like to know more about the nature of AC sources, because it seems some of what I know was incorrect as expected..
But I would like to know, it may not be exact zero, yes, but would it be too high? I mean would it not be close to 0V?

 
And if implemented that, I will not operate the circuit with the computer connected to the AVR of course, I will program the Chip, unplug the programmer and disconnect it from the Chip then operate it.. That's in case I impelemented it..

 

Many Thanks..

Ahmed Aassem

Last Edited: Sat. Jun 16, 2018 - 12:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahmedasem22 wrote:
... I am not doing an educational project, ...

Necessity is the mother of invention.

Some of us have the fortune of inventions off-the-shelf and ready-to-go; you might not.

ahmedasem22 wrote:
... and worked on a home automation project with relays ...
Have you considered AC solid state relays (SSR) instead of triacs?

No because are too expensive and/or not available are common and valid answers.

 

Take care!

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am looking that up, :D
Thank you.

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The problem is we really don’t know what level neutral is. It depends on your wiring and other factors out of your control. Therefore connecting your computer to circuits connected to neutral can be dangerous.
Of course, if you do not connect your computer, then the AVR doesn’t care if it 0V connection is neutral or active. You just need to ensure the voltages the AVR is exposed to is within its ratings.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Here are 3 very nice Triac articles for your research...again without isolation, such circuits must be considered HOT & dangerous, especially if there are any external user accessible-items (Switches, knobs, connectors, leds, etc)

 

http://www.mouser.com/catalog/specsheets/stevalill004v1.pdf

http://www.ti.com/lit/an/slaa043a/slaa043a.pdf

http://www.nutsvolts.com/magazine/article/triac_principles_and_circuits_part_1

 

 

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great!, thank you very much..
And there will not be user-accessible items, all will be wireless.. In case of that I did it :D

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I think the safest way is to isolate the AVR circuit from the Triac circuit by using Optocopulers...
I have got another question, Are Triacs more practical than relay?
and Are Optocopulers more pratcial than relays?
I mean are they supposed to live more?

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes, I got to know them recently, after I started searching about Triacs, and I put them on to-search list, thank you..
I don't really know what they are, but yes, I will probably search soon.

Ahmed Aassem

Last Edited: Sat. Jun 16, 2018 - 05:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahmedasem22 wrote:

yes, I got to know them recently, after I started searching about Triacs, and I put them on to-search list, thank you..
I don't really know what they are, but yes, I will probably search soon.

 

Depends on what you want to achieve.

If you simply want to switch a circuit, then relays are the simplest choice - you get isolation as part of the deal. They also handle moderate overloads without failure.

 

You would normally use triacs if you wanted phase control- ie light dimming. More likely to fail from overload as compared to a relay.

 

As for optocouplers vs relays, again it depends on the application. If you were doing phase control with a triac, then you'd most likely use an optotriac device like a moc3021. 

 

 

One thing to consider with a triac is that they don't turn off completely. The have what's called 'leakage' that lets a small amount of current through. A relay doesn't suffer from this issue.

 

Tell us what you want to do and we can make a recommendation.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

In the past and for about 2 decades, I used designing and producing various light (220Vac bulbs) controllers; mainly for outdoor panels and moving message signs. Lately and in this field, I had to focus on controlling LEDs instead.

 

Since these old controlling boards were out of reach (not supposed to be touched by the user when running), there was no need of any isolation on them.

But on my side and in order to test/verify such boards, I supply them via 1:1 isolating transformer, so that if I touch one of its two floating terminals it becomes at earth (body) voltage.

Of course, I have to be very careful not to touch both of them or short them via the two scope probes in case they have a common ground.

Fortunately, I was able, about 10 years ago, to get a scope with independent floating probes (Fluke 190).

 

Although my work may not be suitable for your application, I prepared for you a typical schematic (LightControllerOnAC220V.pdf attached) of my today’s low-cost bulb controllers (sometimes they are requested for very old panels having bulbs).

 

Kerim

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great! Thank you very much. : )

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No light dimming, it's supposed to work just as a switch, like plugging and an plugging a lamp, a device etc..
One of the things that made me look for another device other than the relay was that it draws a relatively high current, even when I bought the module where transistor are used for the coil, so the AVR is just applying signal to activate the transistor so that the power supply activates the relays.
I was not able to connect more than 8 relays, when I did they suddenly dropped off for they draw current more than the AVR can bear..
 

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you used transistors to drive the relays, then the problem would be more likely to be the power supply rather than the AVR.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For instance, referring to "LightControllerOnAC220V.pdf", switching on-off the output triacs or varying (dimming) the light is determined by the AVR code.

Each triac is driven by narrow pulses (100 Hz, one for each half-cycle). The pulse width depends on the load; resistive or inductive and heavy or light (relative to the triac holding current), also its phase delay (after zero-crossing). Its range could be from 50us to 300us for example. The pulse amplitude depends on the triac gate sensitivity; 100mA usually works.

 

Back to "LightControllerOnAC220V", the current consumption of each triac when on is

(5V-0V7)/1K8 + 100mA*300us/10,000us = 2.4 + 3 = 5.4 mA

If necessary this value could be decreased by:

- increasing 1K8 of the driver and in case Vce is no more saturated, the output resistor (15R) could be adjusted to maintain the 100mA peak (LED is just for signalling, it can be removed).

- decreasing the pulse width

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But the power supply we used supports up to 10A!
That was strange in fact, and I remember that we measured the current supplied by the AVR and it was more than 500mA.

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Something was not right then! 500mA is way past the AVR’s maximum spec, so there was something wrong with your circuit.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you.

At some moments the current will be 100mA so if I connected the controller to 5 units of this it will be at its maxium current supply, correct?

I am pretty confused with this :D Excuse me.

Ahmed Aassem

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From what I can recall, you can expect to source/sink 20mA for each port pin with a maximum of 200mA for the chip. Of course, you should refer to the chip's datasheet for the actual figures. 

If we look at a common relay - https://www.ia.omron.com/data_pd...

 

The coil current is 43.2mA at 12V dc. The AVR port pin cannot switch this for two reasons - 12V is above the specs of 5V and the current of 43.2mA is above the port pin current. So we would use a transistor, mosfet or a power ic to do this. This means the AVR port pin only needs to source/sink a few milliamps at most and the actual switching is done by the other device. Therefore, we stay well within the maximum specs for the AVR. Depending on the actual device added for the switching, the AVR could reasonably control 100's of Amps for a number of channels.

 

If you used a device like the ULN2003 which it common, then the AVR can comfortably switch 7 relays. Obviously, the maximum current the ULN2003 can switch is detailed in it's datasheet which is around 200mA per channel but there is a limitation on the total current as it has a thermal limitation. Using the Omron G2R relay, then the ULN2003 could control 7 of these at 12VDC comfortably as the total current would be 300mA or so.

 

There's plenty of examples using the Arduino on the interwebs. As the Arduino is just an AVR on a circuit board, the examples equally apply.