16f18877 internal Zero Cross Detector

For general Flowcode discussion that does not belong in the other sections.
chipfryer27
Valued Contributor
Posts: 1929
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 421 times
Been thanked: 644 times

Re: 16f18877 internal Zero Cross Detector

Post by chipfryer27 »

Hi

Maybe not quite what you are after but you can reference pins directly, for example in a decision


Screenshot 2026-02-12 214622.jpg
Screenshot 2026-02-12 214622.jpg (87.23 KiB) Viewed 347 times
Regards

mnfisher
Valued Contributor
Posts: 1856
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 154 times
Been thanked: 876 times

Re: 16f18877 internal Zero Cross Detector

Post by mnfisher »

Possibly!

I suspect you might be able to do $PORTA0 = 1 in a calculation too?

Though - this is new to me - and I've not tried it...

chipfryer27
Valued Contributor
Posts: 1929
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 421 times
Been thanked: 644 times

Re: 16f18877 internal Zero Cross Detector

Post by chipfryer27 »

Hi

You can indeed reference ports/pins in calculations.

This calculation immediately turns on the inbuilt LED on a lolin-lite (pin 22, active low)

Screenshot 2026-02-13 051633.jpg
Screenshot 2026-02-13 051633.jpg (48.19 KiB) Viewed 319 times

Regards

alanwms
Posts: 152
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 8 times

Re: 16f18877 internal Zero Cross Detector

Post by alanwms »

See below
Last edited by alanwms on Mon Feb 16, 2026 1:50 pm, edited 1 time in total.

alanwms
Posts: 152
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 8 times

Re: 16f18877 internal Zero Cross Detector

Post by alanwms »

Maybe an easier method would be to simply connect a dual optical isolator via resistor directly to the micro controller transformer on the secondary ac side. Your open collector outputs will switch at every zero crossing.
That signal is connected to the hardware interrupt which services the routine.
If you need schematic help, I do have a working example.
Send me a note at aw@machineautomationproducts.net

Post Reply