-->
Page 1 of 1

quasi pwm sync to mains 50hz.

PostPosted: Sun Jan 24, 2016 7:07 am
by Roffey
ESP8266 standalone .....
What I thought would be simple phase control related to a mains frequency signal, turned out to be 'not so simple'. Ok. trigger an interrupt on change on an input pin receiving the zero cross., store current time, then after a timeout trigger an output.
No! Timer timeouts, millis(), micros(), Ticker etc would just not do it. Beat frequency effects, sporadic pulses .... Whatever I did, or removed (yes, other things going on as well), had no effect.
In the end I tried analogWrites .... setting the pwm frequency just a fraction lower than 50Hz, (or the lowest frequency expected to prevent next cycle issues ), doing an analogWrite(pin,0) in the interrupt, then setting analogWrite(pin,'nnn') sync'd it nicely. Simple.
I used 50Hz since I only needed a phase control pulse in one cycle.
Maybe useful to someone?