Mains dimming with arduino

I'm trying to do some home lighting automation and have no trouble with turning lights on and off an opto-isolated SSR gets that job done well. I'm having trouble figuring out a "cost effective" way to dim my incandescent lights with the PWM pins I haven't been able to find many off the shelf dimmers that accept PWM and the ones I have seen are pretty expensive. I currently have a few of these ICs LS7642 http://www.lsicsi.com/pdfs/Data_Sheets/LS7642_LS7642FO.pdf. It looks to be exactly what I need but I wonder if I wonder if I am missing something? If I build a circuit similar to the example in Figure 5 can I replace the R11 with some type of opto-coupler? It appears that I could directly hook a PWM pin from the Arduino up to the BCV pin but that would be unsafe. I have all the parts to build that circuit but I am unsure exactly what I should replace R-11 with. Below is the sample schematic for a halogen lamp with touch plate. I would eliminate the touch plate and transformer associated with the halogen lamp.

If the LS7642 is not the answer I'm open to any suggestions. I have been using X10 for the last few years and am pretty un-happy with its performance in my house. If the LS7642 is the right product for the job I can build it for about $5.00 per channel. I need 6 channels of dimming and can build the above circuit for about 5 bucks but if I could find a commercial solution for under $100.00 with at least 6 channels that would accept PWM or even serial then I would go for it.

Any thoughts or ideas would be appreciated. Thanks in advance!

You might be able to use an analog out pwm pulse and smooth it out into an analog signal using a DAC(digital to analog) converter, look at this thread for ideas on how to do that
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1216381158
connect this to BCV pin and connect the ground and +5 pins of the arduino to the Vcc and Vss of the chip, you would basically be using the arduino as a potentiometer, If you need to do alot of this you could look at a TLC5940 chip, this chip is used to dim leds, it baslically turns 1 PWM into 16 PWM signals. You could hook each PWM of the TLC5940 to a DAC then to the BCV input of the LS7642 your using, then control each one

I should add that the TLC5940 chip has an easy to use library for arduino, I am using 3 of the right now. the only drawback in your application is that it sinks current instead of sourcing it.

so it would be like this

arduino>>TLC5940>>up to 16 DAC >>up to 16 LS7642's

all of this would use approx 5 pins on your arduino

I don't think this chip is suitable for connection to an Arduino.

Resistance is not PWM. That being said, you can look up for electronic resistors from Maxim-ic.com, but I'm not too sure if you can use such voltages on it and of course, the chip will be almost microscopic. :expressionless:

I see now as bubulindo says it may not work well as i said above ( im sleep deprived) but yea if you use something like a digital resistor it should work fine, and bubulindo says he isnt sure it would work with this voltage, the control voltage is only +5V to 0V so it shouldnt be hard to find a proper digital resistor

Thanks for all the great info. I'm still learning thanks for bearing with me. I have a few of these analog opto isolators OPIA4N35 http://www.optekinc.com/datasheets/OPIA2110D.pdf I'm pretty sure this won't work as a direct replacement for the pot in R12 I'm a little shaky on my understanding of how a transistor would work in this situation. With the correct resistors would this effectively provide 0-5v to the BCV pin with a PWM pin controlling the brightness of the LED pin on the opto-isolator. Since I'm not space limited I'm tempted to go to Lowes and get a couple of cheap rotary dimmer switches and lash a servo to them and be done with it. It's a non elegant way that gives me both isolation and control.

You can use two of the 4N35s and an op amp to make one that is linear.

Put the LEDs in series so they both have the same current, and drive from op amp output.

Put both phototransistors on Arduino side thru 33k to +5V and a capacitor (just like VDD , R10 and C7, the phototransistor corresponds to R11) and feed one of them back to op-amp.

Add a RC from your PWM pin on Arduino to the other input of op amp.

NOW whatever voltage your Arduino makes with PWM, the op amp forces the optocouplers to reproduce that on their collectors. Both collectors shouyld closely follow the PWM.

So NOW disconnect the second 4N35 transistor and connect it to the mains side. Voila!

Well.. I built the circuit with the LS7642 It worked well. Unfortunately I stayed up to late working on it and accidentally forgot to unplug it from the mains to make an adjustment and completely blew up the LS7642 literally there is almost nothing left of it. Just a reminder to everyone working with High Voltage to BE CAREFUL. Luckily I didn't get hurt. So back to the drawing board I go.

Just a reminder to everyone working with High Voltage to BE CAREFUL.

I keep repeating this, but people carry on messing with what they don't know.