If a square wave, then the OUT bit is obviously going to set/clear right at the zero crossing. Square wave: If the waveform being checked for zero cross is a square wave, then the zero cross circuitry is obviously going to work. Section 21.2 states that the OUT bit is set when the current sink is active, and cleared when the current source is active. OUT bit: Section 21.2, page 316 of the PIC16F18856 datasheet clearly states that zero cross detection is gotten from the setting and clearing of the OUT bit. The schematic and LTspice sim of what we are doing is as attached. We are trying to do Zero Cross detection with the PIC16F18856. But with the AC Mains setup of the attached schematic and simulation, this situation is not prevalent…and therefore the resistor to ground is needed (ie from ZCDxIN pin to ground)…do you agree? PIC16F18856 datasheet Do you agree? The schematic in the PIC16F18856 datasheet shows a situation where the AC source and the microcontroller are both referenced to the same “ground”. As such, the resistor to ground (R5 in the attached schematic, is necessary for zero cross detection). If one never operates then there will be no zero cross detection. Section 21.2 of page 316 of the PIC16F18856 datasheet makes it clear that the zero cross detection needs both the internal current source, and also the internal current sink, inside the micro, to operate alternately.
![bipolar square wave ltspice bipolar square wave ltspice](https://s3.studylib.net/store/data/008302245_1-a81b6c14f9dac3d84300fb0463cb2de1-768x994.png)
![bipolar square wave ltspice bipolar square wave ltspice](https://people.utm.my/hanifah/files/2012/10/Bipolar-Square-Wave-Pulses-for-Liquid-Food-Sterilization-using-Cascaded-H-Bridge-Multilevel-Inverter-page-003.jpg)
If the resistor to ground is absent, then the current source internal to the PIC16F18856 will not operate, and therefore zero cross will not be detected…. Hello, Please can you confirm that the Zero Cross Detector inside the PIC16F18856 can only work with a mains input (as in the attached schematic and LTspice simulation) if there is also a resistor to ground from the ZCDxIN pin? (R5 in the attached schematic).