Go Down

Topic: Solid state relay, PWM sync with zero crossing detection (Read 31742 times) previous topic - next topic

raxz

Hello.
I have a project, where I need to use solid state relays(SSR) as light dimmer.
I have 8 SSRs of them and I need to drive them with PWM signal.
Mains voltage 230V, 50Hz.
I know that I need to know zero crossing and sync my PWM output with it.
I already have schematic for ZC detection and tomorrow I am going to buy parts I need.
Arduino is Mega1280.
What would be the easiest code for that?
I have been looking for different code examples, but they look complicated.
Do I need to sync internal timers, or can I use some easier way?

Grumpy_Mike

Quote
have 8 SSRs of them and I need to drive them with PWM signal.

No you don't.
It will do you no good if you do.

Once a SSR is turned on you can't turn it off until the end of the cycle, so a PWM signal is of no use to you.

All you need to do is to give a pulse on the gate after a delay once the zero point is reached. The length of that delay determines for how much of the cycle the SSR conducts and hence the power in your load.

raxz

When I get my zero crossing signal, how should I send a pulse? And how long delay should be?
And I can't use delay() function, because it halts all the code.
What would be the options?

jwatte


I have a project, where I need to use solid state relays(SSR) as light dimmer.


First, there are zero crossing type, and non-zero-crossing type SSRs.

If you want to delay for a known amount of time before getting an interrupt, you should use one of the timers (such as timer2 of the atmega328.) You can set the timer to count from 0 to 255 in 0.5/60 seconds (about 8 milliseconds) and then set the timer count target to the delay you want, and set it up to stop and interrupt when it reaches the compare target. Check out the data sheet:
http://www.atmel.com/dyn/resources/prod_documents/doc8025.pdf (chapter 18)
I don't think there's a direct Arduino-style library to do this, but it's not that hard to set up with the registers directly.

Third, perhaps you should try a pair of MOSFETs instead? They will happily switch on and off no matter where on the waveform you are. You can even run PWM at a rate other than the line rate.

Outgoing stock is 85 cents each: http://search.digikey.com/us/en/products/STP13NK50Z/497-7504-5-ND/1852503
Current models are about 1.37: http://search.digikey.com/us/en/products/AOT10N60/785-1191-5-ND/2353856

Note that you need two coupled head-to-head, because a FET will conduct like a diode in the "non-switched" direction.
You need heat sinks to get to the rated amperage -- but typically, that's the same for a SSR.

raxz

I already have random-fire SSRs.
Can I use 1 timer for 8 output?
Which timer on Mega1280?
Any code example?

Grumpy_Mike

Quote
Can I use 1 timer for 8 output?

Only if you want all channels to be at the same power.

Quote
Third, perhaps you should try a pair of MOSFETs instead?

On mains AC!!!

Most people use an SSR that contains a phase angle delay circuit, that you can feed with PWM as all it does is alter the brightness of the LED feeding the phase angle delay circuit.

raxz

How can I use 8 SSRs on different levels? I need 8 timers? Does Arduino have that many?

What it I convert AC to DC. It should be okay for tungsten lamps. Then, can I feed SSRs with pure PWM signal?

Grumpy_Mike

Quote
How can I use 8 SSRs on different levels? I need 8 timers? Does Arduino have that many?

You need 8 different delays, one way to get a delay is with a timer. The arduino only has three timers.
One way to get a delay is to use a timer to generate an interrupt. The ISR (Interrupt Service Routine) increments a counter and checks which of the 8 delays matches the current count. If one (or more) is equal then that pin is set high, if not it is set low.
As you said:-
Quote
I have been looking for different code examples, but they look complicated.

Maybe you are beginning to understand why.

Quote
What it I convert AC to DC. It should be okay for tungsten lamps. Then, can I feed SSRs with pure PWM signal?

DC at such a high voltage is dangerous because the electric shock it produces paralyses you and you feel it sticks to your hand unable to draw it away. You will also need smoothing capacitors that can handle the voltage and ripple current, these will be very big and very expensive. In short, don't go there.

Why not just use a proportional SSR you can feed PWM directly into and forget trying to do a DIY zero crossing detection.

raxz


Why not just use a proportional SSR you can feed PWM directly into and forget trying to do a DIY zero crossing detection.

I already have Crydom cxe480d5r SSRs. But maybe there is some little schematic that can be used? Maybe You can find something. I don't know what to look for. It would be much easier, sure.

Grumpy_Mike

#9
Jan 23, 2012, 05:00 pm Last Edit: Jan 23, 2012, 05:18 pm by Grumpy_Mike Reason: 1
Quote
I already have Crydom cxe480d5r SSRs.

Then you will have to go with what I said.

Quote
maybe there is some little schematic that can be used?

Anything you can implement in software you can implement in hardware, but you will end up spending more that if you just got the right component in the first place.

See this for what you are trying to do:-
http://en.wikipedia.org/wiki/Phase_fired_controllers

raxz


See this for what you are trying to do:-
http://en.wikipedia.org/wiki/Phase_fired_controllers

That's not easy thing to do as I see. There are no example schematics.
It's probably easier to measure zero crossing with Arduino and find some code to do the dimming.
I think I can't write it all by myself.
I bought optocouplers today, so I can send AC waveform to Arduino and start using is as interrupt. But what comes next... I don't know...

PeterH


I bought optocouplers today, so I can send AC waveform to Arduino and start using is as interrupt. But what comes next... I don't know...


Can I suggest that you figure out how it's going to work before you spend money on components? That way you won't find yourself with the wrong components and unwilling / unable to spend more money on the right components.

Grumpy_Mike

Quote
But what comes next

Use the zero crossing signal to trigger an interrupt.
Make that ISR reset a counter - that is all.

Use timer 3 to trigger an interrupt as fast as you need it. For example if you want 256 steps of control and you are in a 50 Hz area for mains then you need an interrupt every 1 / (256 * 100) seconds. It is 100 and not 50 because you do this every half cycle.

In this ISR you increment your counter. Then compare the value of the counter with your power request value (from 0 to 255). If it is equal you set your SSR driving pin, otherwise you clear it.

The smaller your power request value is, the sooner the mains cycle turns on and the more power you have. So all you main sketch has to do is to set this value and the phase angle will be adjusted to match.

Make sure the counter and the  power request value variable are declared as volatile and as global variables.

raxz


Can I suggest that you figure out how it's going to work before you spend money on components? That way you won't find yourself with the wrong components and unwilling / unable to spend more money on the right components.

But how should we learn if not from own experience? :)
It's not that big money and I'm doing it for own fun not offering anybody service.

Grumpy_Mike, many thanks! I try to write code for your description later tomorrow. If I do not succeed, I come back here. :)

jwatte


Quote
Third, perhaps you should try a pair of MOSFETs instead?

On mains AC!!!


Yes, why not? The power controller ones do voltage and current (both forward and reverse) just fine. From what I understand, the main issue is to design the gate->source voltage correctly when the source is shared with mains. If you have other concerns, I'd love to learn!

Go Up