Electrical – Arduino PID and AC controlling

arduinopid controllertriaczero crossing

I'm trying to make my own PID temperature controller using Arduino.
Arduino PID library outputs a PWM signal.
I need to control 230VAC using this PWM like a triac phase angle controlling.
If I use a triac phase angle method, I have to dedicate lot of processing power for zero-crossing detection for interrupt.

Is their any alternating way to do this?

Best Answer

Your application here uses PWM as the output from a PID library routine, I gather. If possible, your PWM period (inverse of frequency, of course) should be the same as the temperature sampling period.

Your sampling period should be as rock-solid repeatable as you can make it; with shorter sampling times being usually better, too. However, variability in temperature sampling translates immediately into poorer performance of the PID, so keep the repeatable nature of the sampling time to below about (in my book) 1:1000 or 0.1%, if possible. This means that if you sample temperature once per second, you want to make sure that you do so down to less than 1 millisecond of variation between samples and, hopefully, as close to zero drift over time as possible, too.

Only when your thermal mass is extremely small and your process is very fast should you consider using phase-angle firing -- because you have little choice about it, then. So in this case, with \$50\:\text{Hz}\$ mains AC say, you should be sampling temperature perhaps at \$100\:\text{Hz}\$ (once per half-cycle.) You'd then apply phase-angle firing and operate your PWM period to match your half-cycle temperature sampling period (also \$100\:\text{Hz}\$ with the PWM duty cycle determining the firing angle where "100%" would mean an immediate trigger going to the MOC3023 [which doesn't have a zero-cross circuit in it] and where "0%" would mean no trigger during that half-cycle.)

For slower thermal mass, which is far more likely I suspect, the PWM period can and should be much longer. Here, you absolutely do want to avoid phase-angle firing to avoid nasty levels of system noise. Here, you will want zero-cross firing that you get with the MOC3063, instead.

For zero-cross firing, the duty-cycle value technically should be an integer multiple of your AC half-cycle period. However, in your case using a library, you may not have any control over that. Instead, the PWM duty cycle duration may be near, but not exactly at, two different integer multiples of the AC half-cycles. This can be a problem, depending on how closely you need to control the temperature and how you set up your PID control parameters.

You could consider improving this integer multiple problem by applying a digital differential analysis, used to adjust each successive actual duty cycle such that the overall average over some successive grouping of them yields the PWM duty cycle average you want to achieve. This helps avoid degrading long-term precision. But I don't know if your library supports this. So that's just another issue to consider, but not necessarily a solution you can implement here.

You have specified very little about exactly what you are trying to achieve. I don't even know the frequency of your mains supply, for example, because you haven't said anything about it. Nor have you specified anything about your thermal mass or, really, anything much else. So this is all that I can offer.