Hacker News new | ask | show | jobs
by sowbug 1227 days ago
Thanks (and thanks to petre down below). The Arduino PID libraries I found want to use PWM, but part of the appeal of the project was understanding PID in the first place, so perhaps I could adapt it to something like a 0.1Hz modulation rate and see where that gets me.

I assume it's hard to do proper AC PWM if you don't know when the AC sine wave's phase starts, preventing you from maintaining a consistent pulse amplitude over time. But I was hoping that something simple like a resistive heater wouldn't be too fussy about it.

And then there's the small matter of my home being constructed from flammable materials....

1 comments

You can do PID using a discrete output instead of analog/PWM. It's a common use case. I think I've seen an Arduino library that allows for this. Or, you can use whatever library you're already using and convert the PWM value to OFF or ON. Slow down the loop so you don't get a lot of chatter on the output; add hysteresis if necessary.

If you actually want to do AC "PWM" (it's not really PWM), use a triac as suggested by another poster, and make sure it does zero crossing detection.