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

Paul Mackerras paulus at samba.org
Tue Dec 1 04:19:53 MST 2009


Alastair D'Silva writes:

> Theres a good example on AVR's site:
> 
> http://www.atmel.com/dyn/resources/prod_documents/doc2508.pdf
> 
> 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).

So, 1Mohm resistor from active to the photodiode anode, neutral to the
photodiode cathode, with a diode across the photodiode - is that the
idea?

I'm afraid that won't work very well at all.  The current through the
photodiode will rise gradually from 0 to about 0.34 mA as we go
through the first quarter-cycle (5ms).  If we assume a 4N25, it has a
typical current-transfer ratio of 0.7 at 10mA photodiode current (0.2
min), but that drops by a factor of about 5 once we get down to
0.5mA.  So that means that we'll get a maximum of about 50uA of
collector current at the quarter-cycle point when the voltage is at a
maximum.  Around the zero-crossing, we won't get enough collector
current in the phototransistor to detect the zero-crossing with any
reliability.

We could reduce the resistor a bit, but what we really need is to get
at least 1mA of current through the photodiode within about 100us of
the zero-crossing.  That means a 10k resistor, which will end up
dissipating about 6W, which I don't consider acceptable.

> 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.

Actually I can in principle control the position of the turn-on pulse
with 1us resolution.  I should have said "tens of microseconds" rather
than "microseconds", though.  I would like to do it in under 100us,
and certainly in under 300us, since that is the point at which there
is enough voltage to turn on the triac reliably.

Paul.


More information about the linux mailing list