This thread has been very useful. I am not sure about one thing - for a 110vAC fan control circuit do I need to use the transformer to get 12V-0V-12V or is there a way I can use the AC supply directly into the optocoupler to drive the MCU. I believe I saw a schematic snap shot which shows AC supply connected directly to OC and then OC talking to the MCU.
I dont know how much you already know about triggering a triac for dimming or speed control so i’ll outline it here.
In order to get away without a transformer, you can use half wave rectification to create the DC supply for the circuit. That way you can ‘ground’ one side of the AC.
Note that this can be dangerous. The pot you use for adjustment should have a plastic shaft not metal so it cant conduct to the hands.
The triac works the same in each half cycle of the line voltage, just with opposite polarity. The circuit senses the zero cross of the line, then waits a predetermined time, then sends a pulse to the triac gate to turn it on. So the load only sees part of each half cycle rather than the full half cycle for each half cycle and that is what ‘dims’ the load.
The predetermined time is set by the user by turning the shaft of the pot, and the circuit detects how many degrees the shaft has been turned and changes the predetermined time delay as required. The delay can be anything from close to zero to a little less than one half cycle time. If the delay is close to the half cycle time then the triac never turn on, so that would be for max dimming.
Some dimmer switches you buy at the store work with fans. Maybe all modern dimmers work with fans but i havent tested them all.
Please note that this kind of circuit can be dangerous because part of the circuit is connected directly to one side of the line voltage. Two prong plugs are often plugged in backwards, and sometimes the outlet is not wired right either so you cant depend on using the neutral lead of the line wire because it might become live for numerous reasons.