TTL level control of 230V

Thread Starter

frankv

Joined Jan 23, 2010
5
Hi guys,

I'm new here, and I do have some electronics knowledge, but mostly limited to digital.

What I want to do is control my Christmas lights from an M16C microcontroller, which is a CMOS device (not sure of the significance of that vs TTL). I live in NZ which has 230V 50Hz mains supply.

I have lots of strings of lights and LEDs which all have the same 8-function control circuit. Photos of circuit board attached. There's some kind of integrated circuit on a daughterboard that reads clicks of the switch and changes the display mode. This daughterboard has 4 outputs, each of which drives a string of about 9 (LED+5Kresistor)s in series via a PCR 406 (Googling PCR 406 is what led me here!).

I've done some reverse-engineering of the circuit, and the 4 diodes at the bottom make up a full-wave (I think) rectifier, outputting about 220V DC. The outputs of the daughterboard are analog 0 - 0.6V, relative to 'ground' (which I guess is in reality is floating up and down +/-230V at 50Hz). 0V = LEDs off, 0.6V = bright LEDs. The output of the PCRs varies between 0V and 220V. The 220V DC supply is also fed out to the light strings. The third attachment on this post is a scan of my schematic.

I have an M16C development system (http://www.renesas.com/fmwk.jsp?cnt...p=/products/mpumcu/m16c_family/m16c60_series/) lying around, and I'm quite familiar with it, so I figure I might as well use it to control the lights. I'll maybe run a serial interface from my PC to it.

The bit I don't know how to do is to interface the M16C to the control board on the LED string.

My plan is to replace each of the daughterboard outputs with a CMOS 0/5V digital output from my M16C microcontroller, voltage-divided to 0.6V using a couple of resistors. That should allow me to turn on/off each string of LEDs from the uC, right? Or are these PCR406 devices controlled by current? In which case, I'd need a resistor/transistor pair in front of each one to provide the current needed? Or is there some other device that does what I want, but easier (and cheaper?)

The M16C board has an LM7805 regulator which can be supplied from a mains-powered wall-wart. Is there any issue with the 'ground' of the uC and the 'ground' of the control board? I guess I need to connect these two grounds together? Or should I not do that because it would blow the circuit boards to bits? Should I run the M16C from batteries instead?

If that all works, I think I'd also like to vary the brightness of the LEDs using PWM controlled by the uC. Is there a problem with this?

Is this feasible?
 

Attachments

Last edited:

3ldon

Joined Jan 9, 2010
82
yeah, run the uC from batteries or get yourself an isolated 220 volt power supply, hook a wall wart up backwards to another wall wart..

They are probably 400 volt transistors like any other, I would use a cmos chip to buffer the uC, and use a 1K resistor to send a 4mA currnent into the transistor, might need more than that, but how much current does the light string draw?
 

eblc1388

Joined Nov 28, 2008
1,542
What I want to do is control my Christmas lights from an M16C microcontroller, which is a CMOS device (not sure of the significance of that vs TTL). I live in NZ which has 230V 50Hz mains supply.
As you have probably found out, many of these LED controllers are NOT isolated from the mains, which means danger of live connections. It is not a problem with the unit because they are enclosed inside an insulating casing. Once you try to connect something to it, this electrical isolation is compromised.

I have lots of strings of lights and LEDs which all have the same 8-function control circuit. Photos of circuit board attached. There's some kind of integrated circuit on a daughterboard that reads clicks of the switch and changes the display mode. This daughterboard has 4 outputs, each of which drives a string of about 9 (LED+5Kresistor)s in series via a PCR 406 (Googling PCR 406 is what led me here!).
The part shown in your schematic is not correct.

PCR406 is not a transistor. It is a SCR, it will stay normally OFF but will conduct current in one direction after being triggered. It won't turn itself OFF as long as there is current flow in the device. The only way to turn it off is to remove the current on which there are several ways to achieve that. The most common is to use the natural AC current as power supply which returns to zero every cycle.

In view of the electrical isolation requirement I mentioned above, the component that you can possibly use from these daughter boards are the LEDs and the PCR406, apart from the bridge rectifier.

The method of electrical isolation I will comment below.

I have an M16C development system (http://www.renesas.com/fmwk.jsp?cnt...p=/products/mpumcu/m16c_family/m16c60_series/) lying around, and I'm quite familiar with it, so I figure I might as well use it to control the lights. I'll maybe run a serial interface from my PC to it.

The bit I don't know how to do is to interface the M16C to the control board on the LED string.
If you want to control these LEDs, you'll need to allow for one input signal and several output signals on your M16C. All these signals will be logical 0-5V level.

The input signal will be the zero crossing of the mains(230V) voltage of which the precise timing you will need to take into account. You will need a zero crossing pulse(ZCP)circuit connects to the mains to give you that. Obviously electrical isolation is also required for this zero crossing pulse circuit.

I trusted you know how to read the logic level on a port pin and set a port pin High/Low on your M16C, and this is enough to control the external circuit, provided a suitable interface is used.

The interface you'll need is simple. A MOC302x opto-siolated TRIAC, one for each PCR406 to control a single string of LEDs. The MOC302x is vital in offering electrical isolation between your low voltage M16C and the dangerous mains voltage. There is a LED+TRIAC inside the MOC302x. If you turn ON the LED, then the TRIAC will turn ON. The TRIAC itself will switch max. of 100mA. If this is the max. current of the LEDs string, then you can do away with the PCR406 too but you will need to use the PCR406 if you want up to 0.5A current.

With the input ZCP signal telling you when is the precise moment in the AC cycle, you simply turns ON the LED inside the MOC302x and in effect you have also turn ON the LEDs string via the PCR406 too. Another method is to use pulse transformer to drive the PCR406 but that would not be a good choice compares to the MOC302x opto-triac.

Remember, there must be electrical isolation between your M16C and LEDs or else you will risk electrocution.

The M16C board has an LM7805 regulator which can be supplied from a mains-powered wall-wart. Is there any issue with the 'ground' of the uC and the 'ground' of the control board? I guess I need to connect these two grounds together? Or should I not do that because it would blow the circuit boards to bits? Should I run the M16C from batteries instead?
You don't have these "ground or common" problem if the two circuits have no electrical connections. That's the reason of using opto-triac.

If that all works, I think I'd also like to vary the brightness of the LEDs using PWM controlled by the uC. Is there a problem with this? Is this feasible?
You cannot do PWM with the PCR406 but controlling the LED brightness is simple by switching ON the LEDs at the right moment.

By turning ON the LEDs half way or 3/4 way through the AC cycle, you will get half or 1/4 of the full brightness.

I have the datasheet of the PCR406 if you want to have a look at it.
 
Last edited:

Thread Starter

frankv

Joined Jan 23, 2010
5
Hi,

Thanks for the replies and the explanation of SCRs.

Obviously, the quick, cheap, easy solution I was hoping for :rolleyes: isn't going to work.

Lets ditch the SCRs and associated circuitry entirely, and look for a solution that more directly matches what I want to do... switch 230V on/off under uC control.

What device should I use for the switch? Obviously something that provides optical isolation for the control circuit from the uC.

Could I just use a transistor with an opto-isolated base? (Have I just described an SSR?) That would half-wave rectify the signal to the LED string. Which won't make any difference to the brightness of the LEDs, since they only light up when there's current in one direction. Or is there some problem with the voltage being below the base voltage for half the cycle?
 

bertus

Joined Apr 5, 2008
22,277
Hello,

As eblc1388 already told you isolation is a must.
I have attached the datasheet of the MOC30XX series.
On page 6 there are some schematics suitable for your application.

Greetings,
Bertus
 

Attachments

retched

Joined Dec 5, 2009
5,207
Lets ditch the SCRs and associated circuitry entirely, and look for a solution that more directly matches what I want to do... switch 230V on/off under uC control.
Sounds like a relay to me.

You then need a logic level relay coil, or you need to boost the logic level to the relay coil voltage.
Through an isolator.^^
Then the 230 in and out of the relay.
 
Top