[clug] More info, please - was Re: Tridge's coffee contraption - photos

Alastair D'Silva alastair at newmillennium.net.au
Mon Nov 30 23:46:18 MST 2009

> -----Original Message-----
> From: linux-bounces at lists.samba.org [mailto:linux-
> bounces at lists.samba.org] On Behalf Of Paul Mackerras
> Sent: Tuesday, 1 December 2009 5:05 PM
> To: Alastair D'Silva
> Cc: 'Felix Karpfen'; linux at lists.samba.org; hugh at blemings.org
> Subject: Re: [clug] More info, please - was Re: Tridge's coffee
> contraption - photos
> Alastair D'Silva writes:
> > You can achieve the zero cross detection with an
> > optocoupler and a resistor divider network.
> I would be interested to see a circuit that can reliably detect the
> zero-crossings (to within a few microseconds), doesn't need any
> high-power resistors, and only uses a few components.

Theres a good example on AVR's site:


The example is for a mains coupled microcontroller (likely powered by a
capacitive supply from the mains) - since we want isolation, I would add an
optocoupler, and clamping diodes (the example uses the internal diodes of
the microcontroller).

At 1mOhm, the maximum current you would have through the resistor is 0.3mA,
dissipating around 0.1W, so high power resistors are not needed. You do
however need to ensure the resistors are suitably rated for that voltage
(plus some breathing room) though, and the easiest way to do that is to
uprate the power rating. Even so, the end result is cheaper, lighter and
less bulky than using a transformer.

While there is some lag to reach the trigger voltage of the micro's input,
it will be similar to the lag that a detector connected to a transformer
would show (probably less actually, since a transformer adds a phase shift
dependant on the impedance of the load). The optocoupler will add a fixed
amount of lag, which can be taken from the data sheet and accounted for in

I'm not too sure where the microseconds figure is coming from, given that
you are detecting a on a 50/60Hz signal. In order to have that resolution on
your switching, you would need a PWM with at least 14 bits of resolution.
The project is using an 8 bit PWM, which is an order of magnitude less than
the resolution required for microseconds to be a problem.

Alastair D'Silva           mob: 0423 762 819
Networking Consultant      fax: 0413 181 661
New Millennium Networking  web: http://www.newmillennium.net.au
skype: alastair_dsilva     msn: alastair at d-silva.org
blog: http://alastair.d-silva.org

More information about the linux mailing list