Shop OBEX P1 Docs P2 Docs Learn Events
Prop-controlled light dimmer — Parallax Forums

Prop-controlled light dimmer

Spork FrogSpork Frog Posts: 212
edited 2007-12-25 16:59 in Propeller 1
Recently, I've been working on a project involving the Propeller microcontroller. My goal is to be able to eventually make a computer-controlled music-synchronized light controller, similar to Light-O-Rama boards, but hopefully with a lower cost.

Here I have my interface circuit. It's basically just a triac and opto-isolator, with a few resistors and caps in there as well. I can currently toggle the light on or off, and I'm working on a PWM routine so that I can control the brightness of the light.

Post Edited (Spork Frog) : 12/3/2007 10:01:02 PM GMT
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-13 16:06
    With AC, conventional PWM doesn't work as well as it might with a DC light. I suggest you get a zero-crossing detector. Jon Williams posted some messages recently about one he uses in EFX-TEK's FC-4 fader/dimmer.

    With AC, you switch on the triac sometime after each zero-crossing. The triac turns off automatically on the next zero-crossing. The amount of time the triac is on for each half cycle of the AC roughly determines the light intensity. Actually, you have to figure in the height of the AC waveform at the time which is approximated by a sine function and the power delivered to the load is a function of the square of that. For incandescent lamps, the resistance varies with the filament temperature (brightness and color) which complicates things even further if you want to specify the brightness rather than the voltage or power to the load.
  • Spork FrogSpork Frog Posts: 212
    edited 2007-08-13 16:35
    freaked.giffreaked.giffreaked.gif

    Ok, this will be more complex than I anticipated.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-13 16:48
    The nice thing with a computer controlling the triac is that you can use a lookup table to translate the desired brightness to a time delay from the zero-crossing. The table you could make with a spreadsheet program and a few sample points. The actual code would be a simple cog routine you could do in Spin ... Wait for zero-crossing (with waitpne), lookup value in table for desired brightness, wait for that time (do a waitcnt), turn on optocoupler and turn it off after a few microseconds, repeat.

    For test purposes, you could just fill your table with times linearly chosen with 100% = no delay and 0% = just a little less than 1/120 sec delay (to allow for "slop").
  • hippyhippy Posts: 1,981
    edited 2007-08-13 19:35
    Spork Frog said...
    Ok, this will be more complex than I anticipated.

    Are you sure you even have the basic knowledge necessary to be doing this safely ?

    In your diagram for triac control you have the load wired between "Hot" and "Ground".
  • parts-man73parts-man73 Posts: 830
    edited 2007-08-13 20:04
    turn.gif Maybe this is a magic smoke generator! tongue.gif

    Sorry, I couldn't resist after the forums recent "heated" discussion on the subject of magic smoke
  • Spork FrogSpork Frog Posts: 212
    edited 2007-08-13 20:47
    @hippy: This schematic is the same as the one the datasheet for the opto-isolator suggests. And, no, I'm not sure I have all the knowledge, but I know people who do who have graciously helped me thus far. It also works so far as is (I can turn the light on and off by pulling an I/O pin on the Propeller high or low.)

    @Mike Green: ok, that's not so bad. But I have seen other circuits, namely circuits for light dimmers, which control the triac by simply changing the frequency of an oscillator... I'm looking into it to see what I can do.

    Post Edited (Spork Frog) : 8/13/2007 9:02:05 PM GMT
  • hippyhippy Posts: 1,981
    edited 2007-08-13 23:38
    @ Spork Frog : If that's how the datasheet shows it I am truly appalled. I suspect your circuit works because you have not wired it as per the diagram. If you have, disconnect it from Ground and connect the load circuit between Live/Hot and Neutral.

    Also add a suitably rated fuse at the very minimum, preferably use a proper RCD or some form of current leakage breaker.

    Your triac driver breadboard also leaves a lot to be desired, in terms of mains and control signal separation and insulation in general - I'm not talking about the opto-isolator, but the apparent lack of insulation on the copper track side, mains wires which can break off, touch something else, damage/destroy you or the Propeller.

    There's no neon or other indicator to let you know mains is on even if the lamp isn't ( quite a likely scenario while trying to get your dimmer working ), and picking the board up while mains powered is an accident waiting to happen.

    I would strongly recommend getting that side of things sorted out properly and into an insulated / earthed box as soon as possible.

    Once you've got a safe environment in which to work, there's plenty of fun to be had with digital controlled light dimming. Let's just do it safely, on a project you live to see the end of smile.gif
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-13 23:51
    Do have a look at the EFX-TEK boards, the RC-4 and the FC-4. They're both good examples of how to make a microcontroller board that controls AC loads.
  • Spork FrogSpork Frog Posts: 212
    edited 2007-08-14 12:36
    @Hippy: Oh... that's what you meant... No, in reality, I do have the return connected to ground, I just accidentally mis-labeled it on my schematic. I know what you mean though: that definetly would not be smart to do.

    And I did shock myself yesterday when working with this by accidentally putting my finger underneath the board... but good suggestions for all things. I'll look into finding a suitable box for this thing.

    @Mike Green: Ok, the FC-4 is basically what I'm trying to do right now except already completed. Interesting little board. Thanks for the pointer.

    Post Edited (Spork Frog) : 8/14/2007 12:44:01 PM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-01 17:01
    Spork Frog have you made any progress with your prop based dimmer? If so are you at a point where you might be willing to share some code? The reason I ask is in the coming months I plan on creating a prop based dimmer also. The goal of my project is to create a dimmer object that does not only forward phase dimming (which is what you are doing) but also reverse phase dimming. I have a fair amount of experience with dimming but I'm new to the prop, your code might be the springboard I need to get going.

    BTW if you are interested in DIY dimming you may want to check out two other forums. There are several people who have created dimmers on these forums and they are more than willing to help. I'm a member of the first one listed below and I'm spearheading the prop based dimmer project.

    http://www.christmasinshirley.com/forum/
    http://computerchristmas.com/

    Post Edited (DynamoBen) : 12/1/2007 5:07:46 PM GMT
  • DroneDrone Posts: 433
    edited 2007-12-02 15:38
    Hi Spork Frog,

    Just a thought... Why not use some standard home light dimmers with knobs on them. Perhaps the knob is connected to a simple potentiometer. Replace (or switch-out) the potentiometer with a digital pot. Have a look at this digital pot product selector page at

    www.maxim-ic.com/products/digi_pot/.

    Advantages of a modified commercial dimmer may be that (at least in the U.S. and/or EU) it is vetted for safety compliance and spurious noise (at-least in its unmodified form). Also, the code may be simpler if the digital pot is relatively easy to talk to. Some of these digital pots seem to have programmable volatile or EEPROM memory, addressability, multiple pots per package, lin or log, 2 or 3-wire serial interface (SPI, I2C or parallel). If you need to connect the dimmers far from the propeller, a serial interface can go a decent distance as well.

    Some disadvantages with this approach may be cost (reduced by reverse engineering the dimmer?), size, additional hardware complexity (the digital pot). Of-course opening and modifying a commercial dimmers voids warranties and certainly opens you up to liability as well. These digital pot parts may be expensive in small quantity, $5 USD up each. They seem hard to find too, especially in DIP packages (although DIPs are listed for some parts). You might want to keep on eye on pot tolerance over temperature range with these devices too.

    Example: Maxim/Dallas DS1803E-010, Digikey P/N DS1803E-010+-ND (no DIP stock avail.), unit stock 14-TSSOP available at $6.86 USD ea., Maxim 1K price approx. $2.10 USD ea.

    search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=DS1803E-010%2B-ND

    DS1803 Description:

    The DS1803 addressable dual digital potentiometer features two independently controlled 256-position potentiometers. Device control is achieved through a 2-wire serial interface. Three address pins allow up to 8 DS1803's to share the same 2-wire interface. The exact wiper position of each potentiometer can be written or read. The DS1803 is available in a 16-pin DIP, 16-pin SO, and 14-pin TSSOP package. The device is available in three standard resistance values: 10kΩ, 50kΩ, and 100kΩ and is specified over the industrial temperature range.

    As an alternative you might want to look at using a MOSFET as a digital pot via a 3-wire D/A from the propeller. But this is more complex and doesn't provide the isolation that (likely) these digital pot chips do.

    Regards,

    David
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-02 15:53
    David,
    The digital pots don't provide any isolation although they make it easier since you can drive them with an optoisolator.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-02 15:58
    As an alternative, for both safety and ultimate flexibility, consider X10 route. (Yeah, I know: hideous, totally annoying website!) They have a pretty good deal on a computer-controlled dimming set here, or you can mix and match components a la carte. Parallax has an app note for the X10 "firecracker" module interfaced to a BASIC Stamp here. It should be easy enough to adapt the information to the Propeller.

    -Phil
  • Spork FrogSpork Frog Posts: 212
    edited 2007-12-02 16:06
    Thanks all for the suggestoins, but I'm sticking with my original route, I believe.

    I've done a lot more research recently on the whole thing, and now I feel like I understand better exactly what needs to be done and the risks involved. Also, Nuts and Volts Magazine posted an article doing more or less exactly what I want to do using an SX controller, with schematics and code examples. Between those and other information found here, I'm going to adapt those for use with a Prop.
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-02 16:36

    X10 doesn't work well in an application like this it is way to slow and can be inconsistant. Spork is on the right track. While the alternatives are interesting they all fall short of his (and my) end goal. The goal is to create a dimmer pack. The pack would be driven by a computer. In my case all the packs I have made in the past were driven by DMX. Yes there is a risk of getting hurt but it’s not difficult to create the required isolation.


    For reference this is basically what he and I are building. http://wolfstone.halloweenhost.com/RemoteControl/dmxint_DPDMX20L.jpg
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-12-02 16:41
    (are any others relieved that Spork Frog can reply in November after his August's "I did shock myself yesterday when working with this by accidentally putting my finger underneath the board... "?)
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-02 16:46
    After years of working in 400A 3-phase dimming cabinets, I guess AC doesn't scare me anymore. Once in a while you get "nipped", goes with the territory. freaked.gif
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-03 00:57
    For those interested on how AC dimming works go here:

    http://www.dv-fansler.com/Computer%20Lights/dimmers.htm
    ·
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-12-03 01:37
    Frog: Your circuit is fine but has already been mentioned you are missing the zero-cross detector from which you can derive your timing to control the intensity. Some circuits are live and don't need optocouplers to drive the triac and in these it is an easy thing to detect the zero cross point (when the AC waveform crosses the zero volt point).

    For a fully isolated circuit perhaps the best way is a standard opto feeding back from the mains so that the photo-transistor's collector goes to a prop input via a pullup. When the AC goes very close to zero the prop input will go high and then you can start timing from there as to when to turn the triac on. A brief pulse is all that is needed to turn the triac on after which you can turn the opto off. The triac will turn off automatically when the AC current drops close to zero (Inductive loads can fool the triac which is why you need that RC snubber across it). At 60Hz you have up to 8.33ms before the end and start of the cycle. Maximum power is achieved by leaving the opto on or pulsing it at the start of the cycle. Half power is achieved by turning on half-way through the cycle etc (non-linear but).

    If your circuit is powered from the mains via a transformer and if you have access to the AC secondary then you can simply run something like a 1M resistor from there to a prop pin. The signal is a little different but still suitable for deriving timing.

    Many of us have been bitten by mains and it's only those of us still alive that can say that (serious). Make sure your circuit is on an earth-leakage circuit breaker (ELCB) but that won't help you if you place your hand across the tracks so if you don't have a case then simply tape a thin plastic sheet to the board. Be aware then your wife or a child might inadvertently touch this board when you just ducked out to get a coffee. Be safety conscious not just for yourself but others also.

    Demo software is a simple "wait-for-zero,time then trigger" loop. Depending upon the type of load whether it is a lamp or a fan etc you may have to add in some calculations or table lookup to make the response linear.

    *Peter*
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-12-03 03:37
    DynamoBen said...
    After years of working in 400A 3-phase dimming cabinets, I guess AC doesn't scare me anymore. Once in a while you get "nipped", goes with the territory.



    1)I presume you meant '400V 3 phase' as opposed 400A 3 phase - using the value you stated would mean that the 'cabinet' would be > 220KW !!?? EDIT: 3ph voltage level stated as 208v in later thread·so 115W in that case

    2)To say that it doesn't scare you anymore is fine - but it is important to have a healthy respect for it - IMHO

    3)If you were to be working in the 'High Tension' side of·the·business·- 'Once in a while you get "nipped", - means death.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 12/3/2007 5:19:47 AM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-03 04:48
    No I meant what I said 400A 3-phase (120/208V). I've worked around high power for a number of years. BTW high power is relative; I did work on a site that had 96000V substations in the building.
    ·
    If you want to get technical a person can be killed at just about any voltage.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-12-03 05:09
    Ben,
    Just·a question - what was a 115KW··dimming cabinet doing exactly ? Massive studio lighting ? or some form of high intensity discharge lighting ?

    If so - how did it affect power factor over varying load? - Did this require dedicated automated PFC (power factor correction) panels? What·Kvar PFC was required ? Just wondering as I want to run parallel tests on a power factor correction panel using·a propeller - to compare values and perhaps enhance reaction time for·switching in and out cap. banks·- just have to trial suitable CT's ..·then perhaps look at the harmonics ... the third harmonic distortion is measuring ca. 2.2-2.5% - at this site .. over 3% and there will be issues - so I had better look at load balancing ! fifth harmonic distortion·is surprisingly low at this site@ approx 1.1% - even though there is a lot of SMPSU and computer loads. Substantial savings can be made by the customer if these are addressed and the PF·brought as·close to unity as possible.

    Just noticed you·mentioned 208V 3 Phase so KW rating is about 115KW ....for your cabinets
    we use (220VAC single phase)/(380-415VAC) 3 PH 50 Hz here ..at these levels we would be talking·min. 220KW·at that·current.

    John

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 12/3/2007 7:00:26 AM GMT
  • Ziggy252Ziggy252 Posts: 32
    edited 2007-12-03 05:18
    I too am looking at microcontroller dimming.

    The attached circuit is based on an IGBT, controlled by a PWM input at 20-40KHz. By varying the duty cycle from 0 to 100%, you can vary the output to the load. The arrangement of Rshunt (0.1 Ohms) and Radj (10k Ohms) will trigger the SCR if the current drawn by the load goes beyond a chosen limit, which should provide overload protection. The choke on the load output smooths out the chopped-up waveform and gives a reasonable sinewave output.

    Keep in mind this circuit is still theoretical and is yet to be built. You will have to choose suitable components. I will be running this circuit past an electrical engineer friend before I attempt to build it.

    I accept no responsibility should your use of this circuit cause injury, death, cats and dogs living together, or whatever.

    Theory behind it is here:www.parlights.com/parlights/Downloads_files/strand/Dimming/Sinewave%20Dimmer%20Technology.pdf
    1346 x 717 - 16K
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-03 15:40
    I don't want to hijack the thread. I'm referring to large incandescent theatrical and studio dimming systems. You do have to use a K-rated transformer to reduce the third harmonic distortion·caused by the dimming.
    IGBT is a great way to do it allows you to do reverse phase dimming. lets use 50% intensity as an example. With forward phase dimming (triac) when a zero cross is sensed a timer starts. At 50% of that cycle the micro turns on the triac, at the next zero cross the triac automatically turns off and the whole process starts again. With reverse phase dimming when the zero cross is sensed the IGBT is turned on and a timer is started. At 50% of the cycle the micro turns OFF the IGBT. The advantage to reverse phase dimming is the lamp isn't "slammed" on which can shorten its life.
    Altering the duty cycle will work if you are interested in dimming DC loads. However this won't work for AC dimming, you need to sense the zero cross point and perform one of the two above dimming methods. BTW there is an open source dimming project that has a great IGBT circuit, the project is called Semitone (listed at sourceforge.net).
  • Christof Eb.Christof Eb. Posts: 1,161
    edited 2007-12-03 18:23
    Hello, Spork Frog and others,

    some time ago I have posted some light dimmer code that should work with your initial schematic.
    This can be found at the completed projects.
    "Propeller based Alarm clock, that wakes me up with light - includes light dimmer AC phase control "
    http://forums.parallax.com/forums/default.aspx?f=21&m=176650

    It is not completely perfect, because it generates some flickering, the spin code is perhaps not fast enough.

    Please be careful.
    Christof
  • AleAle Posts: 2,363
    edited 2007-12-03 20:02
    For the purpose of security in low voltage, as EE will call 110/220 VAC circuits, or for us electronics, high voltage, I'd recommend you make your circuit and main testing under less dangerous conditions. i.e. a car lamp, or one of those halogen @ 12 VAC. The current involved can be as high as you want, but a 22 W lamp is enough. You have all the problems involved with zero-cross detection, and you have the safety of 12 V. After that, you can bring your circuit, with proper components, dimensions and isolation to higher voltages. I got several electrical shocks during my early years, I mean as a kid, to really want to mess with that again, (As I learned how people stupidly, as the situation, not the people, died of electric shock, I was just lucky). If you are really interested in higher voltages, a safety course can be very handy, one can never be careful enough.

    You are having live 220 VAC over your desk, full of things. Under that board seems not to be any insulation. If you knock off that cable... the circuit and lamp fall to the floor. I'd suggest you remove that photo (is a bad example for untrained fellows, and you change it with one of a properly done setup. For instance, fix the board with screws to a 20x20 piece of wood, can be plywood. Fix the main cable there with a header, add a fuse! and a main switch, and fix the lamp's receptacle also to the wood. A setup like that will be easier to handle and safer.
  • DynamoBenDynamoBen Posts: 366
    edited 2007-12-03 20:56
    I·spoke with·Sprok via PM about testing at lower voltages. In the past I do all my initial testing with 12V AC. Once everything is sorted and working I move up to 120V. You are correct many of the challenges in dimming can be figured out with lower voltages.
  • AleAle Posts: 2,363
    edited 2007-12-03 21:54
    Fantastic.
  • Spork FrogSpork Frog Posts: 212
    edited 2007-12-03 21:57
    Picture removed. Yeah, probably not a good idea to have that up there.

    I was only working with 120v, but still I know it's dangerous.
  • Ziggy252Ziggy252 Posts: 32
    edited 2007-12-03 23:26
    Ben,

    The circuit described should work for an AC load. By running the IGBT at high frequency, you can avoid using it in its linear region (ie where it gets hot), but still get a gradual turn-off (which is one of the advantages of reverse-phase). There is no need to worry about the zero crossing, as we chop the waveform up all along its length.

    The PDF I linked to previously has a fairly good explanation of all three types of dimmer (forward-phase/TRIAC, reverse-phase/IGBT and sinewave).
Sign In or Register to comment.