Connect with us

Specifying a relay to control lights etc.

Discussion in 'Electronic Basics' started by scouselad, Oct 22, 2007.

Scroll to continue with content
  1. scouselad

    scouselad Guest

    Hi,

    I'm doing a project on home automation and, as you might expect, I'd
    like to control a lighting circuit (standard filament bulbs, most
    likely) via a digital light sensor and a micro-controller. Obviously,
    to control the mains supply, I'll need some sort of relay. However,
    I'm not sure how I could emulate a "dimmer" control in this way. For
    example, I considered using PWM (which my micro-controller can produce
    automatically), but I'm not sure if a relay can respond that fast. I
    understand that solid-state relays (SSRs) respond much faster than
    electromagnetic and electromechanical relays, so I'd like to use an
    SSR if possible.

    Basically, I'd like a device that I can give some variable input so
    that it will vary the amount of AC mains voltage across my light bulb
    (or heater, or fan, etc.). It would be nice if there was something
    that will take digital input (perhaps PWM) but all I've found so far
    in that department is the Crydom MCTC range, which are a little too
    expensive (~£80/$160) compared to small SSRs (~£4-10/$8-20). However,
    I'd be happy with something that takes analog input if it saves me a
    lot of money.

    Thanks for reading,
    Allan Lewis.
     
  2. default

    default Guest

    Trying to use a SSR for pwm to control lighting is iffy at best.
    They, generally speaking, don't react fast enough and 50-60 cycles is
    rather slow. One can usually detect 20+ cycles of flicker in
    incandescent lamps. (halogen may be somewhat better because of a
    relatively thick hot filament - but no telling if that would interfere
    with the halogen cycle - some low wattage 120 VAC halogen lamps in
    the US have diodes in them to halve the voltage - further complicating
    dimming)

    With SSRs they frequently incorporate a circuit to slow the operation
    to prevent the SSR from half-cycling or fault conditions in the signal
    which might cause the load to self destruct from fast on-off operation
    - like induction motors.

    What does work very well is a resistive optical coupler added into a
    lamp dimmer in place of the control potentiometer to vary the phase
    angle of the triac firing.

    For lamp dimming with an isolated low voltage signal . . .

    Some time ago there were incandescent lamp coupled to photocells to
    arrive at a linear optical coupler - these days one of the led to
    mosfet OC's might be a choice. The linear couplers are still around
    in the incandescent form - but mostly as repair parts and somewhat
    costly. Very easy to construct also.

    You would need an analog signal to drive the coupler, but that is easy
    enough if you have pwm - to analog is just a matter of adding a cap
    and diode to integrate the signal, or many pics already have D/A built
    in.

    You don't mention how fast you want to modulate the light output - I'm
    assuming home automation means setting a lighting level and leaving it
    more or less constant for a period of time.
     
  3. scouselad

    scouselad Guest

    Ok, so I'll either need a controller on the (AC) output of the SSR to
    reduce the voltage across the lamp, or just ditch the SSR and try
    something else.
    Yes, the light would be pretty constant over at least several minutes,
    often for several hours.

    Anyway, thanks for the reply, I'll do some more research and see what
    I come up with.

    Anyone else...?
     
  4. scouselad

    scouselad Guest

    <snip>

    "Resistive optical coupler"? I've heard of optical couplers/opto-
    couplers but what do you mean by "resistive" in this context? Anyway,
    I thought that they were limited to ~50V, something confirmed by a
    quick search on Farnell - I'm using UK mains voltage (220-240V).

    Please clarify...
     
  5. John Fields

    John Fields Guest

    ---
    From your description I assume that you want to be able to set, and
    have the device keep the ambient light level constant in, say, a
    room, regardless of the effects of external light streaming in
    through windows or from adjacent rooms.

    That is, if there was no external light streaming into the room the
    lamp would be at its brightest, but as more and more external light
    illuminated the room the lamp would dim in order to compensate.

    Is that right?
     
  6. scouselad

    scouselad Guest

    Exactly. I have already bought a light sensor (an Intersil ISL29003)
    with I2C output that I intend to control from a Microchip 16F877 or
    similar - setting up that system is really another task entirely. What
    I'm looking for is something that I can give a variable input (either
    PWM or some digital input - I2C would be nice - or just an analogue
    voltage level) causing it to adjust the power delivered to the light.
    I know I can do this by adjusting the firing angle of a triac, but I'm
    not sure of the circuitry involved to make to control fully
    electronic. I've found lots of similar "dimmer" circuits on the net,
    mostly using triacs, but they all have a large potentiometer to
    control the dimming. What I want to do is use a circuit like that but
    with an electronically-controlled potentiometer. Again, I know that
    digital pots exist, but I don't think they will take UK mains voltage
    (220-240V).

    I hope that's clarified things.
     
  7. John Fields

    John Fields Guest

    ---
    Since you're going to use a µC, you could use something as simple as
    a pushbutton or two to ramp the setpoint up and down, and the output
    of the sensor to cause the µC to servo about that point.

    For example, let's say that you have one pushbutton which causes the
    light to get brighter, another which causes the light to grow
    dimmer, and that you've held one of them down (or repeatedly pressed
    and released one of them) until the illumination in the room is at
    the level you want.

    Now, when you release the pushbutton and the illumination in the
    room changes because of, say, the sun shining into the room through
    a window, later, the output from the sensor will increase and the µC
    will dim the light until the output from the sensor is as it was
    when the pushbutton was released.
     
  8. scouselad

    scouselad Guest

    I'm not quite clear about what your saying, and I'm not sure that it
    addresses my problem.
    I'm already planning a control panel (cf. your push buttons) to adjust
    the setpoint, which will be a combination of the ambient light and
    that provided electrically. However, what I need is a way to control
    the electric light level from the PIC. It should be pretty simple to
    work out an algorithm to decide how much power to put into the light
    bulb (or how much voltage across it - could be done several ways) but
    that's not what I need help with: what I'm asking is how to control
    the level of the bulb using an output from the PIC. Ideally, this
    would be a digital output, but I'm happy to do use a DAC if necessary.

    Perhaps you could clarify a little...
     
  9. default

    default Guest

    The optical coupler isn't intended to directly modulate the mains
    voltage, just to provide an isolated way to control a variable
    resistance.

    Check out http://www.fairchildsemi.com/ds/H1/H11F1M.pdf

    This was in the design newsgroup. An optical coupler that varies
    resistance from 100 ohms to 300 megohms with an isolated low voltage
    input - this would go inside a lamp dimmer circuit in place of the
    potentiometer that would normally be used to vary brightness. It is
    a component, not a complete solution for what you want.

    The diac normally used in a lamp dimmer fires at about 30 volts (even
    with 220 circuits) so a 60 volt coupler would be plenty.


    H11F1M, H11F2M, H11F3M
    Photo FET Optocouplers

    Features
    As a remote variable resistor:
    ¦=100 to =300M
    ¦=99.9% linearity
    ¦=15pF shunt capacitance
    ¦=100G I/O isolation resistance
    As an analog switch:
    ¦Extremely low offset voltage
    ¦60 V pk-pk signal capability
    ¦No charge injection or latch-up
    ¦t on , t off =15µS
    ¦UL recognized (File #E90700)
    General Description
    The H11FXM series consists of a Gallium-Aluminum-Arsenide
    IRED emitting diode coupled to a symmetrical
    bilateral silicon photo-detector. The detector is electri-cally
    isolated from the input and performs like an ideal
    isolated FET designed for distortion-free control of low
    level AC and DC analog signals. The H11FXM series
    devices are mounted in dual in-line packages.
     
  10. default

    default Guest

    On Mon, 22 Oct 2007 13:16:00 -0700, scouselad

    http://ourworld.compuserve.com/homepages/Bill_Bowden/page4.htm#pumpkin.gif
    Shows a basic lamp dimmer circuit - where the potentiometer is you use
    a resistive optical coupler

    Someone has already put it all together:

    Shows an idea for taking a standard manufactured lamp dimmer and using
    the pwm output from a basic stamp controller to set the brightness.

    The little circuit shown converts the pwm signal to a varying DC
    voltage and tells you what dimmer to use and where to get parts.

    http://www.epanorama.rackhost.net/schematicsforfree/Lights/An_AC_Dimmer_for_Use_with_the_Stamp.PDF
     
  11. John Fields

    John Fields Guest

    ---
    Sure.

    You'll need one register (lets call it 'RSET') to store the value of
    the setpoint, another ('RINT'), to store the value of the intensity
    sensor, another ('RDLY') to store the value which will be loaded
    into another ('DCNT') used as a down-counter which will trigger a
    TRIAC when it times out, controlling the light. You'll also need
    either a hardware or software zero-crossing detector.

    The way the thing works is that you use the zero-crossing detector
    to load the value of the setpoint into SREG and the value of the
    sensor into IREG, then you compare the values.

    If SREG is > IREG, then decrement RDLY, load that value into DCNT,
    and start counting down. When DCNT gets to zero, send a pulse to
    the TRIAC to trigger it and wait for the next zero crossing to start
    the cycle again.

    If SREG is < IREG, then increment RDLY, load that value into DCNT,
    and start counting down. When DCNT gets to zero, send a pulse to
    the TRIAC to trigger it and wait for the next zero crossing to start
    the cycle again.

    If SREG = IREG, then load the contents of RDLY into DCNT, and start
    counting down. When DCNT gets to zero, send a pulse to the TRIAC to
    trigger it and wait for the next zero crossing to start the cycle
    again.

    One thing you'll need to do to make the counter work properly is to
    make sure that its maximum count can't quite get to 180°. That's to
    make sure that at low brightness it won't trigger the TRIAC at the
    beginning of the next half-cycle, making it as bright as it can be.

    Let's say that the counter is 8 bits wide and that your mains
    frequency is 60Hz. That means that the time per half-cycle will be:


    1 1
    t = ---- = ------- = 0.00833...s = 8.33ms
    2f 120Hz

    Now, if your timer is 8 bits wide and is set to hex ff when it
    starts counting, that means that each increment of time it counts
    down until it gets to zero will be:


    8.33E-3s
    t = ---------- ~ 3.27E-5s ~ 32.7 microseconds
    255

    if it starts counting at one 60Hz zero crossing and stops at the
    next.

    Depending on how long it takes for your capture-compare-load-trigger
    routine to run, you'll have to decrease that time in order to keep
    from running into the next half-cycle and false-triggering the
    TRIAC.

    Alternately, if you could accept the increase in granularity, you
    could truncate some of the high end of the counter and use a lower
    frequency 'tick'.

    Do you know how to set up a software timer?
     
  12. scouselad

    scouselad Guest

    John and "default", thanks to both of you - I think I have what I need
    now :D
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-