Sorry for the longer delay between posting some progress. I didn't have much time for continuing in this project. Of course there were some tryings and strugglings with zero-cross detection.
First idea was, to use for zero-cross detection basic external interrupt. I used signal generator for testing. Input signal was sinus @50Hz. When I connected the signal to MCU, there were some delay between reaching the zero level and interrupt itself. MCU was running with 8MHz internal oscillator. Delay was ~4ms, what is unacceptable (1/50Hz = 25ms). I have tested it on 8-bit MCU, to be sure, if there is something wrong. But results were the same. "Maybe there is a problem with internal oscillator". So I have decided to use external one, but without success.
So I have switched the input signal to square and it was working well. After some analysis (including datasheet) I have figured out, that is missing "Schmidt circuit" on MCU's inputs. The edge of input sinus signal is not so perpendicular as expectations. It means that, external interrupt mechanism can't reach this edge.
Finally I have the solution, how to fix this problem. I didn't want to use 4-way rectifier and stuff like that. So a comparator is the right way. But, which one to use, external or internal... . External has some advantages, so I decided to use this one.
I have made only simulation, but it should work ;)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
I have used an optocoupler with two diodes inside ( + pullup resistor and Schmitt trigger). In the software I detect the negative going edges and reset a timer in the interrupt. This timer has compare check against 4 offsets (zero crossing, mosfet switching, sine wave slicing [for T210] and peak).
Link: https://github.com/csatti/SolderingStation/tree/master/Resources/drawings
Are you sure? yes | no
Hi Attila!
I have modified my previously posted schematic. After adding opto-coupler and some additional required components. I have tested in on physical transformer and seems to be, that is working like expected. Don't have time to post some progress, unfortunately, ... :(.
Anyway, thank you for sharing your idea about ZCD ;). It's very similar to my version.
Are you sure? yes | no