pic microcontroller discussion list wrote: > Eisermann, Phil [Ridg/CO] wrote : > >> collector of optocoupler pulled to 5V via a 22k >> resistor. > > Or use the "weak pullup" and save a resistor... > that's a thought. >> To get a better reading of the actual zero crossing point, I would >> measure the typical pulse length before the application does >> anything. Half of the pulse length should get me pretty close >> to the true zero crossing point. > > So you'd detect the start of the zero-crossing, and then wait for > half of the the former calculated zero-crossing width ? Seem OK. > > Note that you can flip the INTEDG on each interrupt to capture > *both* edges using interrupts. > that's what I had in mind, actually. I would set INT to trigger on the rising edge. when the interrupt occurs, start TMR0. Flip INTEDG to trigger on falling edge. the next interrupt stop TMR0. half of TMR0 should be pretty close to the actual zero crossing. The problem I'm trying to address is that the interrupt pulse generated by the opto will start before the actual zero crossing and end after the zero crossing. the above described technique should allow me to determine how long after the interrupt the true zero crossing occurs. I hope I explained that correctly. >> >> The application will remain in service maybe 10 to 20 >> minutes before it is powered down. would the oscillator frequency >> remain stable enough during this point, > > Stable enough for what ? > Are you thinking on "free wheeling" during this 10-20 min period > without further zero-crossing detection ? No, i would still detect the zero crossing. But I would not re-calculate the length of the pulse. I would think the internal oscillator would not drift enough in this application to deviate more than a few usec. > For a Triac, you must at least wait until there is enough current to > hold the Triac conducting. > >> I do not need a large control range. > > What is "a large range" ? Or rather, what is "not a large range" ? > Well, that still needs to be fine-tuned, but initial calculations indicate a conduction angle range between 120 and 180 degrees. That means worst-case I would be firing 60 degrees from zero crossing. Phil Eisermann Electronics Engineer The Ridge Tool Company (440)329-4680 -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.