Shop OBEX P1 Docs P2 Docs Learn Events
Incandacent Bulb — Parallax Forums

Incandacent Bulb

LightfootLightfoot Posts: 228
edited 2007-07-31 19:39 in General Discussion
I am making a circuit that uses a Solid State Relay that uses the PWM statement to control brightness of incandescent bulbs on the 110 line. I have my eyes on this relay www.mouser.com/search/refine.aspx?Ntt=653-G3E-220T-US12 for cost. The dimmer has 255 (1 byte) steps. What frequency does a filament best respond to?

PWM, rb, <what should the duration be?>

Or should I do something else?

Thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2007-07-28 13:04
    Lightfoot

    I look at this relay data sheet it dose not say any thing about being able to use this in a dimming mode so i do not know
    that you will be able to use it for what you want to with it

    If i have time latter i will see if i can find something that might work for you

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-28 13:27
    The PWM statement will not work very well for dimming on AC using an SSR. The SSR is designed to let through half cycles of AC to reduce transients and power dissipation, so after receiving a logic trigger, it waits until the next zero crossing (of the AC waveform) to turn on. A light dimmer will turn on part way through the AC half cycle (based on the dimmer setting) and stay on until the next zero crossing. The PWM statement puts out a high speed (hundreds of KHz) pulse waveform whose average time on is the value requested.

    You could do a little dimming by switching on the SSR for a variable number of half cycles in some period of time (like 1/10 second). It would give you a limited number of levels and the results wouldn't be anything like linear light levels, but it would be something.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-07-28 15:05
    Lightfoot -

    The easiest way to dim an incandescent lamp with a PBASIC Stamp is to use the X-10 lamps modules and employ the PBASIC XOUT command. You can find documentation and examples of the XOUT command in the PBASIC Syntax and Reference Manual, or in the PBASIC Help File. It really couldn't be simpler.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • LightfootLightfoot Posts: 228
    edited 2007-07-28 18:07
    I now plan on varying the duration each half-cycle is on (see picture). I would set the PWM frequency to 120Hz and vary the duty cycle between 0 and 255 (each representing a point for each half cycle). Will this give me good results?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Lightfoot) : 7/28/2007 8:46:38 PM GMT
    231 x 273 - 3K
  • LightfootLightfoot Posts: 228
    edited 2007-07-29 00:54
    Will using a MOC3010 optocoupler and a triac enable you to do AC dimming with an SX?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-29 01:03
    Yes, you can use an MOC3010 optocoupler and a triac to do AC dimming and an SX can handle the timing. You really do need a zero-crossing detector to keep the SX synchronized with the AC line. An easy way to do that is with another optocoupler, one with a phototransistor or logic output.
  • LightfootLightfoot Posts: 228
    edited 2007-07-29 01:27
    Is there a schematic or some material I can work off of? A zero cross circuit sounds simple, just need to know where it fits.

    Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-29 01:41
    Here's one example: www.discovercircuits.com/DJ-Circuits/60hzclk.htm

    You'd connect the logic output to an I/O pin. It would be delayed a little from the actual zero crossing because the LED has to have enough voltage to fire. You'll have to figure out that time delay and work it into your program if it's important.
  • LightfootLightfoot Posts: 228
    edited 2007-07-29 07:29
    1. I may be a bit confused here but won't that circuit only trigger on the positive-going half cycle?

    2. Does the zero cross circuit trigger the microcontroller to run the pulse width modulatation code?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Lightfoot) : 7/29/2007 7:35:08 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-29 13:36
    1) Yes, you're right. The easiest thing to do would be to use two optoisolators with the LEDs wired "back to back" and the phototransistors wired in parallel. That would trigger on both half cycles.

    2) Yes, the zero crossing detector gives the starting time. Simply delay for whatever fraction of a half cycle you want, then trigger the triac.
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-07-29 13:53
    You can use the H11AA1 to get a 120 Hz zero cross signal from your AC line. I found this in a lot of dimmer circuits and used it in the design of the FC-4 fader board.

    Post Edited (JonnyMac) : 7/29/2007 2:06:16 PM GMT
    532 x 384 - 33K
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2007-07-29 15:30
    JonnyMac
    Please let me know when these board are for sale because I want to buy one of them· FC-4 fader board········· Nice...idea.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • LightfootLightfoot Posts: 228
    edited 2007-07-29 18:47
    Would it work to connect the LEDs to the AC out of the transformer? It probably will. I feel more comfortable connecting a device like this to a low voltage source.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-07-29 19:03
    You'd have to reduce the 15K resistors to something that will let about 5 mA flow through the H11AA1 input LEDs. That said, if your goal is to dim a 120 VAC lamp then you're already connecting to 120 VAC. The 15K (0.5w) resistors limit the current to the H11AA1 and it's optically isolated from the 5v side -- it's as safe as your construction skills.

    FWIW, I've attached the FC-4 triac circuit schematic for your reference. The input to the MOC3023 is referenced from the zero-cross signal -- the longer the hold-off from ZC, the dimmer the lamp. The FC-4 uses an ISR that runs every 32.5 uS which gives 256 segments of each half cycle of the AC.
    660 x 244 - 30K
  • LightfootLightfoot Posts: 228
    edited 2007-07-29 20:28
    Will this code do it?

    plp_a = 0
    tris_a = %0001
    ra = 0
    
    
    DO
    
            DO UNTIL RA.0 = 1 'Zero cross is attached to RA.0, wait for it to fire.
    
            LOOP
    
            PWM RA.1, rb, 50 'Pulse width modulation value is read from RB port.        
    
    LOOP
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Lightfoot) : 7/29/2007 10:42:40 PM GMT
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-07-29 22:44
    My program uses an ISR and keeps two variables for each lamp: the brightness level (0 to 255) and an accumulator for triggering the triac. At the ZC point I turn the triac control pins off and then reload the accumulators with the desired levels. Then, each time through the ISR, I increment the accumulators, and when one rolls over to zero I activate the respective triac. So the lower the level the longer between ZC and triac triggering.

    ' Dimmer service runs every 32.5 uS (256 accs x 120 Hz)
    ' -- inspired by code from Phil Short
    '
    Dimmer_Service:
      ASM
        JNB         ZCross, Update_Ch1
    
    Zero_Cross:
        CLR         Lamps                           ' all triacs off
        MOV         acc1, level1                    ' reset dimming accumulators
        MOV         acc2, level2
        MOV         acc3, level3
        MOV         acc4, level4
    
    Update_Ch1:
        IJNZ        acc1, Update_Ch2                ' update timer
        SETB        Lamp1                           ' triac on when expired
    
    Update_Ch2:
        IJNZ        acc2, Update_Ch3
        SETB        Lamp2
    
    Update_Ch3:
        IJNZ        acc3, Update_Ch4
        SETB        Lamp3
    
    Update_Ch4:
        IJNZ        acc4, Dimmer_Done
        SETB        Lamp4
    
    Dimmer_Done:
      ENDASM
    



    You might be able to adapt this to high-level code like you're attempting, but you have to remember that when a triac is activated it can only be turned off by removing the gate and hitting zero-cross.

    Post Edited (JonnyMac) : 7/29/2007 10:52:21 PM GMT
  • LightfootLightfoot Posts: 228
    edited 2007-07-30 05:02
    This look good?

    plp_a = 0
    tris_a = %0001 'Triac is on pin RA.1, Zero cross detector is on RA.0.
    
    
    DO UNTIL RA.0 = 1 Wait until zero cross fires.
    
    LOOP
    
    DO
    
              RA.1 = 0 'Shut off triac.
    
              PAUSEUS RBC 'somewhere between 0us and 8333us, receive as a WORD.  RBC represents the off time.
    
              RA.1 = 1 'Turn triac on.     
    
              DO UNTIL RA.0 = 1 Wait until zero cross fires, triac will remain on until next zero cross.
    
              LOOP
    
    LOOP
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-07-30 05:13
    You need to turn the triac off right after you turn it on. If you wait until after the zero-crossing, it will stay on for the entire next half-cycle. (Translated: You can turn a triac on, but you can't really turn it off. As long as it's not being triggered, it will turn itself off at the next zero- crossing.) Also your upper time limit will be somewhat less than 8333uS, due to delays in the trigger and triac signals. If you get erratic behavior at your dimmest settings, you will need to shorten the maximum delay time.

    -Phil
  • LightfootLightfoot Posts: 228
    edited 2007-07-30 07:08
    My program removes the signal on the triac's gate at zero cross. It then waits for the off duration. After that I re-apply the gate signal. Isn't that correct?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-07-30 07:51
    No, it's not correct. If you do that, the triac will be on all the time. You just need a short pulse to trigger the triac. It will stay on by itself until the zero crossing.

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-07-30 08:03
    Lightfoot -

    An ISR is shorthand for Interrput Service Routine, a routine which is invoked whenever a (specified) interrupt occurs.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • LightfootLightfoot Posts: 228
    edited 2007-07-30 08:42
    1. First the program waits for the off duration. It then turns on the gate for a millisecond. After that the gate turns off. The program now waits for the next zero cross and starts over. This sounds better.

    2. Johnny, is your interrupt triggered by the zero cross detector? If this is the case perhaps I can put this code in the interrupt code block.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Lightfoot) : 7/30/2007 8:47:45 AM GMT
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-07-30 13:28
    My ISR is also handling serial UARTs so it actually runs 5x the 32.5 uS rate used by the dimming circuit. As you can see, the ZC input is polled.

    You might try something like this:

    Main:
      triac = IsOff
      IF ZC = 1 THEN
        acc = level
      ENDIF
      INC acc
      IF acc = 0 THEN
        triac = IsOn
      ENDIF
      PAUSUS 32.5
      GOTO Main
    



    Note that when using constant values with PAUSEUS, fractions are allowed. You might want to use a 20 MHz resonator to give yourself plenty of resolution with PAUSEUS.

    Post Edited (JonnyMac) : 7/30/2007 1:45:23 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-07-30 17:32
    You can probably get by with a narrower trigger pulse than 1mS. The narrower the pulse, the more you increase your dimming range at the lowest levels. This is because the pulse is not allowed to straddle the zero-crossing. So the narrower it is, the more you can delay it.

    -Phil
  • LightfootLightfoot Posts: 228
    edited 2007-07-30 19:19
    What is the smallest pulse I can use? Does the triac datasheet say?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-07-30 20:21
    The triac datasheet should have this info. You will also need to include any rise and fall times added by the optoisolator, then double it for good measure. Or ... you could just experiment to find the narrowest reliable pulse width.

    -Phil
  • LightfootLightfoot Posts: 228
    edited 2007-07-31 15:42
    Will I have a problem with the lights buzzing at low brightness?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-07-31 16:09
    Dunno. Electronics requires experimentation. Lots of it. Why not just build it and see what happens? Then come back here and report on your findings.

    -Phil
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-07-31 19:39
    Excellent point, Phil; a day of experimenting will yield far more than a week worth of Internet Q&A. FWIW, I have not noticed any buzzing with my circuit, and I have four lamps running side-by-side on a demo project.
Sign In or Register to comment.