On Mon, 29 Sep 1997 11:52:46 -0000 Stephen Collister writes: >Hello All > >I am new to programming the Pic. Pic 16c84. >I have wrote a program that requires a pulse when mains is at zero. >I have used a small circuit using a comparator which does the job >but I have read a posting on here about using a 5 meg resistor >connected to the input from the mains to detect zero crossing. If the circuit is powered by a transformer, a current limiting resistor between an input port line and the transformer secondary will do the job and allow you to keep the circuit isolated from the power line. I used a 10K resistor from one end of a 24 VCT transformer (with the center tap grounded) to the INT input of a 16c74a. The INT was set to generate an interrupt on a negative edge, giving an interrupt just prior to a negative zero crossing. I timed out where the positive zero crossing would be and used this in a phase control dimmer. > >My questions are :- > >1) Is 5 meg ok with 240v I don't have the ap note here on vacation in this mountain cabin... Just have to look at the current limit on the input pin protection diodes, resistor power dissipation, and resistor voltage rating. > >2) Do I connect the Ov rail of cct to Neutral or will Earth be ok. I sure like transformer isolated circuits, BUT if you're running directly off the line, I think you should use neutral. There should be no current through the safety ground or earth connection other than fault currents or slight leakage currents (typically due to RFI filters). > >3) I gather I just test bit for being clear for zero crossing. Yes, or generate an interrupt, as discussed above. Since you are running motors in your application, I think it's important to make sure you are doing symmetrical phase control. If the timing or zero cross detection is off a little for one half cycle compared to the other, you can get some DC that an AC motor will not like. You can see how you're doing by driving a resistive load and measuring the DC component (just using a VOM or DVM set to DC) under various levels of phase control. A DC component will cause a current limited only by the coil resistance (instead of its reactance) and can lead to core saturation. I found out the hard way driving a transformer! Finally, note that when driving an inductive load with triacs, the triac turns off at the CURRENT zero crossing, which is after the voltage zero crossing. This results in a very sudden increase in voltage across the triac when it turns off. A snubber circuit is required to limit the speed of the voltage rise (dV/dt). Harold