# Lightintg Analog Details

Is there a magic incantation to make mathematics render correctly?

The theory of operation is to integrate -V_ac from about 4 volts at the beginning of a a cycle down to about 0.8 volts near the end of the cycle. Six comparators compare the integrated signal, V_out and turn on their corresponding triac as soon as its control voltage is greater than V_out.

Opamp #2 and Q2 reset the charge on C2 to 4 volts every time the AC input gets close enough to zero. D1 along with R8 and R9 ensure that the voltage at C2, V_out never goes below about 0.5 volts.

The interesting part of the circuit is opamp #3 and Q1. In this mode, Q1 behaves like a (nonlinear) transresistance device controlled by the output of the opamp. Applying the opamp rule:

<math> V_+ = V_- </math>, but, <math> V_- = I_R_13 * R_13 </math>. When Q2 is off and the voltage on C2 is above 0.5 volts, there's nowhere else for its current go so, so <math> V_out = 4.0v - \frac{1}{C_13} * \int{0}{t}I_R13 * dt </math>

Combining, we have: V_out = 4.0v - \frac{V_+}{C_13 * R_13} \int{0}{t}V_+ dt </math>

The voltage divider on opamp #1 divids the 12Vrms input signal by 10. (With R14 providing fudge factor) So we end up with:

<math> V_out = 4.0v - k \int{0}{t}V_ac * dt </math>

Whith K = 45.4hz. When V_ac is a perfect 12Vrms sin wave, the integral evaluates to 3.2volt seconds. The output will look like a cosine wave going from 4.0 volts to about 0.8 volts, 120 times a second.