Page 3 of 3
Re: 16f18877 internal Zero Cross Detector
Posted: Thu Feb 12, 2026 9:57 pm
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 (87.23 KiB) Viewed 474 times
Regards
Re: 16f18877 internal Zero Cross Detector
Posted: Thu Feb 12, 2026 10:05 pm
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...
Re: 16f18877 internal Zero Cross Detector
Posted: Fri Feb 13, 2026 5:22 am
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 (48.19 KiB) Viewed 446 times
Regards
Re: 16f18877 internal Zero Cross Detector
Posted: Mon Feb 16, 2026 1:46 pm
by alanwms
See below
Re: 16f18877 internal Zero Cross Detector
Posted: Mon Feb 16, 2026 1:48 pm
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