Maker Pro
Maker Pro

ATMega16 Interface with SSR

J

JoeyB

Hi All,

I've got a ATMega16 that is interfaced to a LM34 temperature sensor.
I'm using the ADC noise reduction (sleep) mode every second when I
sample my ADC. Based on the temp, I'm TRYING to drive a SSR directly
from the micro on Pin B0. The micro has a 300 ohm impedance that
should limit current to 16ma @ 5VDC. This is an acceptable load for
the micro. The only onther load is a LCD. I've done other projects
with this SSR and the mega16 albiet simpler - never a problem - the
Mega16 can source enough current to drive this particular SSR when it
is the only thing hooked to it. Now, when the micro determines that
it needs to turn on the SSR, it puts out 5VDC to the pin. With the pin
disconnected, no problem, 5VDC. When the pin is connected to the SSR,
the voltage on the pin is only 1 VDC. I put an ammeter in series with
the pin and the SSR and measured .1ma. So, it looks like the pin is
only sourcing 1 milliwatt of power...? According the the datasheet, it
should source 20ma@5Vdc.
Anybody have a clue? The micro is going into sleep mode and
taking measurements while it is trying to drive the SSR. Is this the
problem? Can the micro drive pins in sleep mode? I'm assuming my power
supply to the micro is sufficient because my VCC stays at 5VDC with
the pin at 1VDC. I've tried a couple of different SSRs. I'm pretty
sure they're ok. I've switched the output from Pin D0 to Pin B0, no
luck there. I've got the pins configured as outputs, DDRB, DDRD set to
1. I shouldn't have to worry about pullups when the pins are
configured to be outputs right? At least, that's what I'm getting
after reading the Mega16 datasheet. I've triple checked the circuit,
it's wired right...My last resort will be to re-design the circuit to
sink current rather than source it but - IN THEORY - what I have
should work. I can also spend some time taking the noise reduction
sleep mode stuff back out it that's the problem.

Any help is appreciated.
 
M

Martin Griffith

Hi All,

I've got a ATMega16 that is interfaced to a LM34 temperature sensor.
I'm using the ADC noise reduction (sleep) mode every second when I
sample my ADC. Based on the temp, I'm TRYING to drive a SSR directly
from the micro on Pin B0. The micro has a 300 ohm impedance that
should limit current to 16ma @ 5VDC. This is an acceptable load for
the micro. The only onther load is a LCD. I've done other projects
with this SSR and the mega16 albiet simpler - never a problem - the
Mega16 can source enough current to drive this particular SSR when it
is the only thing hooked to it. Now, when the micro determines that
it needs to turn on the SSR, it puts out 5VDC to the pin. With the pin
disconnected, no problem, 5VDC. When the pin is connected to the SSR,
the voltage on the pin is only 1 VDC. I put an ammeter in series with
the pin and the SSR and measured .1ma. So, it looks like the pin is
only sourcing 1 milliwatt of power...? According the the datasheet, it
should source 20ma@5Vdc.
Anybody have a clue? The micro is going into sleep mode and
taking measurements while it is trying to drive the SSR. Is this the
problem? Can the micro drive pins in sleep mode? I'm assuming my power
supply to the micro is sufficient because my VCC stays at 5VDC with
the pin at 1VDC. I've tried a couple of different SSRs. I'm pretty
sure they're ok. I've switched the output from Pin D0 to Pin B0, no
luck there. I've got the pins configured as outputs, DDRB, DDRD set to
1. I shouldn't have to worry about pullups when the pins are
configured to be outputs right? At least, that's what I'm getting
after reading the Mega16 datasheet. I've triple checked the circuit,
it's wired right...My last resort will be to re-design the circuit to
sink current rather than source it but - IN THEORY - what I have
should work. I can also spend some time taking the noise reduction
sleep mode stuff back out it that's the problem.

Any help is appreciated.
Next time take a deep breath and dont post too much info.
see
atmel doc2545, p330 ( wish it had an index)
shows that you can sink quite a lot of current .

How are you wiring the SSR, between 5V and the port pin. This is the
usual way

or between the port pin and ground?


martin
 
L

linnix

Next time take a deep breath and dont post too much info.
see
atmel doc2545, p330 ( wish it had an index)
shows that you can sink quite a lot of current .

Not in Noise Reduction Mode. The core and I/O module are shutdown in
NRM.
How are you wiring the SSR, between 5V and the port pin. This is the
usual way

or between the port pin and ground?

Either way should be fine, as long as the I/O module is active.
 
M

Martin Griffith

Not in Noise Reduction Mode. The core and I/O module are shutdown in
NRM.


Either way should be fine, as long as the I/O module is active.
Ah, the finer points of data sheets, thxs, just about to start with
avrs


martin
 
J

JoeyB

Thanks Linnix,

So dump the NRM stuff if I want to do any I/O. No I/O in any sleep
modes? I went back through the datasheet looking for anything about
the I/O modules being shut down in NRM and couldn't find any reference
to it. Thanks for the tip. Is there anything else I should be
reading?

I'll change my code around to skip NRM and let you know how it goes.
 
J

JoeyB

Update,

I just pulled the sleep mode stuff out - no dice. Still getting a 1
volt output on the pin with the SSR hooked up.

Any other ideas?

Thanks
 
A

Arlet Ottens

JoeyB said:
Update,

I just pulled the sleep mode stuff out - no dice. Still getting a 1
volt output on the pin with the SSR hooked up.

Any other ideas?

Thanks

Do you have a series resistor on the output pin ? Check the SSR spec for
forward voltage and turn-on current, and adjust a series resistor
accordingly. To verify the current, put a volt meter across the resistor.
 
J

JoeyB

Thanks Levente/Arlet

Levente, I went to your site. Interesting stuff. I saw how you had a
470 ohm resister in series with your SSR. I tried to get the software
file but it was corrupted when I tried to unzip it with Winzip. So, I
not sure how the pin was configured but I can guess.

Maybe I'm missing something simple: I've seen where people suggest
using E/I = R to determine the series resistance value to use but they
never consider the fact that the SSR is also in the circuit adding its
own resistance to the equation. Also, you need to take into
consideration the output impedance of the microcontroller. From
looking at the source current vs voltage table for the mega16, this
looks to be like a pretty non-linear output impedance. From the data
sheet, my ssr has a input impedance of 300 ohms. If I can't get
enough power to source it with no series resistance added, why would
adding a resistor fix anything? From the Mega16 data sheet, the output
impedance of the pin is close to 250 ohms at the desired voltage so I
should be close to impedance matched with no series resistor
whatsoever.

I'm going to swich the circuit so the Mega16 is sinking rather than
sourcing although I feel like I'm cheating because it SHOULD be able
to source this power according to the data sheets.

I'll report my findings.
Thanks.
 
J

JoeyB

Found it. I configured the port as a output in a function that was
never getting called. So, the port was never configured. Open
circuit,
it acted like it worked. Sending a 1 to it made 5V a zero, zero...
Under load however, no dice.

Stupid stuff can kick your (my) ass for days ! I guess it's all stupid
stuff once you find it.
 
L

Levente

Found it. I configured the port as a output in a function that was
never getting called. So, the port was never configured. Open
circuit,
it acted like it worked. Sending a 1 to it made 5V a zero, zero...
Under load however, no dice.

Stupid stuff can kick your (my) ass for days ! I guess it's all stupid
stuff once you find it.

Well it is allways like this. So you find it... good. I switch a 1kW heater
with that configuration. :) The stuff on my page is not zipped, rather gz-d
or bz2-d, which I don't know winzip can do anything about it... but PDFs
should work! :)

Best regards,
 
Top