Zero crossing detector hardware.

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

alanwms
Posts: 48
Joined: Tue Sep 16, 2008 2:09 pm
Location: Minnesota USA
Has thanked: 3 times
Been thanked: 17 times
Contact:

Zero crossing detector hardware.

Postby alanwms » Sat Nov 11, 2017 3:48 pm

If you want to pick up the zero point of the AC mains, a novel method (see attachment) is to use an opto isolator with two emitters reverse connected in parallel. The only time a positive signal is available, is when both LED emitters are not conducting (mains is at zero).
RB0 interrupt will be evoked every time the AC gets to a zero condition.

The main transformer uses a diode to supply the rest of you circuitry via the 5v regulator so no extra transformer is required.

Uses -
Light intensity control
Accurate timing (divide by 50 for 1 second action (60 USA)
Counting
Mains synchronizing (Grid inter-tie etc)
State programming - Allows an interrupt to gather I/O information. Could eliminate the requirement to use input icons making the program easier to read.
Zerocross.jpg
Zerocross.jpg (54.68 KiB) Viewed 1836 times


State Machine.jpg
State Machine.jpg (59.54 KiB) Viewed 1836 times
These users thanked the author alanwms for the post (total 4):
kersing (Sat Nov 11, 2017 3:53 pm) • jgu1 (Sun Nov 12, 2017 8:33 am) • leoo (Wed Dec 06, 2017 10:21 am) • acestu (Fri Dec 08, 2017 2:19 pm)
Rating: 22.22%
 

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Zero crossing detector hardware.

Postby kersing » Sat Nov 11, 2017 3:54 pm

It would be nice if you could attach a flowchart to complement the screen shots. Screen shots can be hard to read...
These users thanked the author kersing for the post:
jgu1 (Sun Nov 12, 2017 8:33 am)
Rating: 5.56%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

alanwms
Posts: 48
Joined: Tue Sep 16, 2008 2:09 pm
Location: Minnesota USA
Has thanked: 3 times
Been thanked: 17 times
Contact:

Re: Zero crossing detector hardware.

Postby alanwms » Sun Nov 12, 2017 1:26 am

Not sure if my particular code will add anything so I have increased the resolution for a partial look at the development of "states" in the interrupt routine which can be used to determine what to do in the main program.
Attachments
Flowcode state.jpg
Flowcode state.jpg (35.23 KiB) Viewed 1826 times
These users thanked the author alanwms for the post:
acestu (Fri Dec 08, 2017 2:20 pm)
Rating: 5.56%