Shop OBEX P1 Docs P2 Docs Learn Events
BasicStamp Dimmer with Triacs, flickering problem — Parallax Forums

BasicStamp Dimmer with Triacs, flickering problem

johnmademlisjohnmademlis Posts: 3
edited 2007-12-27 18:33 in BASIC Stamp
Hello,

i 've just finished a light controller that controls 5 220V lamps, using 5 pins of a BS2. Each pin drives a led and the gate of a triac, via a MOC3063 optotriac.

Switching on and off the lamps works perfect through PBASIC programming. The problem is when i try to dimm the lamps using PWM command. Although the leds dimm nicely, the lamps doesn't dimm but they have a flickering. Does anyone knows why the leds dimm while the triacs no?

Sincerely
John

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2007-03-27 17:36
    The implications are that the on/off cycle is slower than about 1/30th of a second. That is about the threshold at which the eye sees a flicker rather than a dimmer output.

    Obviously the solution is to increase the on/off cycle rate. It may be that with the higher voltage, internal capacitances and resistances play a role in creating a slower response - a time delay.

    Everything is guess work unless you actually put the output on an oscilloscope and see what it looks like. But sometimes guesswork can lead to an adequate solution.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-27 17:57
    Part of the problem is that the PWM statement is not intended for this use. It produces very short, narrow pulses such that the average % "on time" is that specified in the PWM. These are not synchronized at all with the power line frequency, so the "averaging" doen't work well. To get smooth dimming, you will need a more complex circuit that uses a zero-crossing detector to detect when the 220VAC cycle is at zero volts. Your program would delay a fraction of the cycle, then turn on the triac which would remain on for the rest of the cycle. I don't think a Stamp would be able to handle the timing well, so you may want to use an external timer controlled by the Stamp. You could use a 555 timer with a digital pot with perhaps 64 or 128 steps. The zero-crossing detector would reset the timer which would turn on the MOC3063 some time later (controlled by the pot).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-03-27 18:06
    Pulse width modulation is not a good way to drive a triac directly, unless it's synced to the AC line. The reason is that once a triac switches on, it stays on until the end of the AC cycle. You're seeing flicker because the triac is switching on at the first high it sees in the cycle, which can occur at seemingly random times. In order to use the PWM, you will have to modify your circuit to convert the PWM output to a DC voltage, then use the DC voltage to determine where in the AC cycle to switch on the triac.

    -Phil
  • metron9metron9 Posts: 1,100
    edited 2007-03-27 19:35
    I have a very nice paper (project from a grad student) on a triac dimmer complete project and parts list used in the project that I found while searching the web (I just happen to be working on the same thing) I will post it tonight, exactly as Mike says, it uses a zero crossing detector. I was trying to use a zero crossing ssr with pwm but that only allows on at crossing up and turns off for one cycle so the second level would be from 60hz to 30 hz then 15hz for three levels of brightness. I suppose a non sero crossing ssr could be used but I don't know.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • johnmademlisjohnmademlis Posts: 3
    edited 2007-03-27 19:38
    Thanks for your replies,

    i am aware about the zero crossing issue but the MOC3063 optoisolator i use between BS2 pin and TRIAC gate has embedded the zero crossing circuitry, thats why i didn't use another circuit for it. If i use a capasitor between the pin that drives triac and ground would i had better results?

    Except PWM, is there any other instruction that i could use for the same task? Maybe PULSEOUT?

    Sincerely

    John Mademlis
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-27 20:04
    I didn't realize that the optocoupler also includes a zero crossing detector. I don't think you can use this device for dimming, only on/off control. The zero-crossing detector delays the trigger until the next zero crossing to reduce the power dissipation of the triac. The net result is that you will get a lot of flickering and not much control of dimming.
  • metron9metron9 Posts: 1,100
    edited 2007-03-27 20:51
    I found my order for the parts I bought for my dimmer project. The triacs are 16amp

    The device I have information on uses the following components

    BTA216X-600B RAIL 3Q TRIAC 1.2 20 $24.00
    MOC3011M 6-Pin DIP 250V Random Phase Triac Driver Output Optocoupler 0.305 20 $6.10
    6N138 8-Pin DIP Single-Channel Low Input Current High Gain Split Darlington Output Optocoupler 0.72 20 $14.40

    The triac's have internal snubbers

    The 6n138 is used for the zero crossing detector

    The drivers are Random Phase so the triac can be turned on after the crossover point

    I will post the information I have when I get home

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • metron9metron9 Posts: 1,100
    edited 2007-03-27 22:37
    Here is the pdf file

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • johnmademlisjohnmademlis Posts: 3
    edited 2007-03-27 23:05
    Thanks metron for the pdf, i will study it.

    As i have seen, it utilizes a more advanced microcontroller with timers and interupts capablilities, something that lacks in Basicstamp. Maybe the solution is detecting zero crossing with external circuitry.

    John Mademlis
  • nowfalnowfal Posts: 2
    edited 2007-04-13 20:12
    can anyone help me out with wat may be causing my MCU to malfunction and then never work again??

    please visit :

    http://nowfal85.googlepages.com/home

    thank you
  • skylightskylight Posts: 1,915
    edited 2007-04-14 16:43
    Apart from the timing issues with synching to the mains supply have you got a mains side inline choke·before the triac this will help. Open loop dimmers are ok but not as good as closed loop dimmers with feedback which can handle varying loads.

    You couldn't go wrong reading this pdf: http://www.ortodoxism.ro/datasheets2/1/03pxx82cl7r9zp7fq65askzx89cy.pdf


    Post Edited (skylight) : 4/14/2007 4:48:29 PM GMT
  • Harrison.Harrison. Posts: 484
    edited 2007-04-15 23:19
    nowfal said...
    can anyone help me out with wat may be causing my MCU to malfunction and then never work again??

    please visit :

    http://nowfal85.googlepages.com/home

    thank you

    You shouldn't be reviving posts, especially when you are posting about a totally different processor. To answer your question: Why are you feeding AC into your processor's interrupt pin? That is not safe, you should at least put a single diode in between the processor and the transformer so you clip the bottom of the AC signal.
  • metron9metron9 Posts: 1,100
    edited 2007-04-16 05:40
    You have a 12V AC Voltage going to your uC Ground.

    Your switches when open are floating. You should pull them down with resistors or use the internal pullups and connect the switches to ground instead of +5 for an inverted signal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • nowfalnowfal Posts: 2
    edited 2007-12-27 18:33
    Thank you for all your help, the project has been completed. For more info please visit autolightcontrol.googlepages.com
Sign In or Register to comment.