Constant voltage regulator followed by resistor current limiter

One simple idea is to use for example 7805 regulator to generate constant +5V output and then use a resistor calculated for +5V operation between the +5V IC output and the LED. The circuit needs input voltage in range 7-35 V to operate correctly.

     +====+     R1
+----|7805|----/\/\/\----+   +----
+Vin +====+             1|   |6      
        |               +=====+      
        |               |     | TRIAC
        |               |     | Driver
        |               +=====+       
        |               2|   |4       
+-------+----------------+   +----         
Ground


You calculate the value for R1 using following formula:
R1 = 3.7V / ledcurrent

The formula is based on the fact that the diode will have around 1.3V voltage drop in it, so the resistor has to dissipate 5V-1.3V=3.7V.

True constant current regulator circuit

Another possible circuit is to wire a constant voltage regulator IC as true constant current source. The following circuit operates at voltage range of 5-35 V and used LM317 adjustable voltage regulator IC as current source.

     +=====+   R1   
+----|LM317|-/\/\/\--+---+   +----
+Vin +=====+         |  1|   |6      
        |            |  +=====+      
        +------------+  |     | TRIAC
                        |     | Driver
                        +=====+       
                        2|   |4       
+------------------------+   +----         
Ground                      

LM317 regulator has 1.25V reference voltage. So the regulator tries to keep the voltage over R1 constantly at 1.25 V so limiting the current to value I = 1.25V / R1. You can calculate the value for R1 using the following formula:
R1 = 1.25V / ledcurrent

For more details LM317 datasheet is available at http://mot-sps.com/books/dl128/pdf/lm317lrev1f.pdf. Circuits with zero voltage starting semiconductor relay

MOC 3041 information

The MOC3041, MOC3042 and MOC3043 device consists of gallium arsenide infrared emitting diodes optically coupled to a monolithic silicon detector performing the function of a Zero Voltage Crossing bilateral triac driver. They are designed for building semiconductor relays, industrial controls and consumer appliances.

Features

    * Simplifies logic control of 115 Vac power
    * Zero voltage crossing
    * dv/dt of 2000 V/us typical, 1000 V/us guaranteed 

Recommended applications

    * Solenoid/valve controls
    * Light controls
    * Static power switches
    * AC motor drives
    * Temperature controls
    * E.M. Contactors
    * AC motor starters
    * Solid state relays 

Maximum ratings

    * Infrared emitting diode
          o Reverse voltage: 6 V
          o Forward current: 60 mA
          o Total power dissipation: 120 mW (at 25C) 
    * Output driver
          o Off-state output terminal voltage: 400 V
          o Peak repetive surge current (100 us): 1 A
          o Total power dissipation: 150 mW (at 25C) 
    * Total device
          o Isolation surge voltage: 7500 V
          o Total power dissipation: 250 mW (at 25C)
          o Juction temperature range: -10C to +100C 

LED trigger currents

Device   LED trigger current (max)

MOC3041    15 mA
MOC3042    10 mA
MOC3043     5 mA

Typical LED forward voltage is 1.3V (maximum 1.5V).

Example circuit from datasheet

     R1                       R2
                              360              
+---/\/\/\----------+   +----/\/\/-------------+------------+----------> 240V
+Vin               1|   |6                     |            |            Hot
                   +=====+ IC1                 | MT2        | 
                   | MOC | TRIAC              +-+           |
                   | 3041| Driver           G | | TRIAC     |
                   +=====+                   /| |           |
                   2|   |4                  / +-+           |
+-------------------+   |                   |  | MT1        \
Ground                  +-------------------+  |            / R3
                                            |  |            \ 39
                                            \  |            /
                                      R4    /  |            |  C1
                                      330   \  |           --- 10 nF
                                            /  |           --- 400..600V
                                            |  |            |              Neutral
                                            +--+------------+----o    o--> 240V
                                                                  load

The resistor R3 and capacitor C1 are for snubbing of the triac and may or may not be necessary depending upon the particular triac and load used.

MOC3041 based semiconductor relay circuit

     R1                       R2
                              56                
+---/\/\/\----------+   +----/\/\/-------------+------------+----------> 230V
+Vin               1|   |6                     |            |            Hot
                   +=====+ IC1                 | MT2        | 
                   | MOC | TRIAC              +-+           |
                   | 3041| Driver           G | | TRIAC     |
                   +=====+                   /| | TIC226D   |
                   2|   |4                  / +-+           |
+-------------------+   |                   |  | MT1        \
Ground                  +-------------------+  |            / R3
                                            |  |            \ 39
                                            \  |            /
                                      R4    /  |            |  C1
                                      330   \  |           --- 10 nF
                                            /  |           --- 400..600V
                                            |  |            |              Neutral
                                            +--+------------+----o    o--> 230V
                                                                  load
                                                                Max. 1750W

IC1 MOC 3040 or MOC 3041 TRIAC TIC 226D (use 600V model TIC 226M for indictive loads) R1 330 ohm (for 12V control voltage and MOC 3040).

MOC3041 enables construction of simple semiconductor relay: the ICs have internal zero crossing detector and provide 7.5 kV isolation. The output of IC is photodiac type (100 mA / 400 V at 25 celsius). MOC 3040 need 30 mA control current and MOC 3041 needs 15 mA control current. This means that for 12V input control voltage R1 must be 330 ohms for MOC 3040 and 680 ohms for MOC 3041. For other input voltages calculate correct value for R1 using formula:
R1 = 1000 * ( Uinput - 1.3) / controlcurrent

The circuit can handle currents up to 8 A if the thyristor is properly cooled.

Source: 302 Circuits, Elektor Electronics Publishing, pages 14-15

MOC 3020 based semiconductor relay circuits

Technical information about MOC3020 optodiac

MOC 3020 is an optocoupler IC designed for triggering TRIACS. This component is very widely used an can be quit easily obtained from many sources. The following information is taken from MOC3020 THRU MOC3023 OPTOCOUPLER/OPTOISOLATORS Data Sheets by Motorola (this documents contain only selected parts of the technical specs). Nowadays those former Motorola components are supplies by QT Optoelectronics.

Specifications

    * 250 V Phototriac Driver Output
    * Gallium-Arsenide-Diode Infrared Source and Optically-Coupled Silicon Triac Driver (Bilaterla Switch)
    * UL Recognized (File Number E65085)
    * High Isolation: 7500 V Peak
    * Output river Designed for 220 V ac
    * Standard 6-Terminal Plastic DIP
    * Directly Interchangable with Motorola MOC3020, MOC3021, MOC3022 and MOC 3023
    * Direct replacemen for:
          o TRW Optron OPI3020, OPI3021, OPI3022 and OPI3023
          o General Instrument MCP3020, MCP3021 and MCP3022
          o General Electric GE3020, GE3021, GE3022 and GE3023 

Absolute maximum ratings

    * Input output peak voltage: 7.5 kV
    * Input diode reverse voltage: 3 V
    * Input diode forward current (continuous): 50 mA
    * Output repetitive off-state voltage: 400 V
    * Output on-state current (50-60 Hz AC total RMS): 100 mA (Ta=25C), 50 mA (Ta=70C)
    * Output driver nonrepeative peak on-state (10 ms): 1.2 A
    * Maximum power dissipation:
          o Infrared-emitting diode: 100 mW
          o Phototriac: 300 mW
          o Total device: 330 mW 
    * Operating juction temperature range: -40C to 100C 

Input trigger current

Component   Current
            Typical Max
MOC3020     15 mA   30 mA
MOC3021      8 mA   15 mA
MOC3022      5 mA   10 mA
MOC3023      3 mA    5 mA

The forward voltage drop at the the optocoupler LED is typically 1.2V (at 10 mA current, 1.5V maximum).

Pinout

          _____
   ANODE |o    | MAIN TERMINAL
  CATODE |     | TRIAC SUBSTRATE (do not connect)
      NC |_____| MAIN TERMINAL
    

Selected example circuits from datasheets

Resistive load circuit

     R1                       R2
                              180                          Load
+---/\/\/\----------+   +----/\/\/-------------+-----------o   o-------> 220V
+Vin               1|   |6                     |                         Hot
                   +=====+ IC1                 | MT2         
                   |MOC  | TRIAC              +-+           
                   |3020 | Driver           G | | TRIAC     
                   +=====+                   /| |                      60 Hz
                   2|   |4                  / +-+           
+-------------------+   |                   |  | MT1        
Ground                  +-------------------+  |            
                                               |            
                                               +-----------------------> 220V
                                                                         Neutral

Inductice load with sensitive gate triac (Igt =< 15 mA)

        
      R1                      R2       R3
                              180      2.4k       load 
+---/\/\/\----+-----+   +----/\/\/-+--/\/\/\---+--o   o-----> 220V
              |    1|   |6         |           |              Hot
              |    +=====+         |           | MT2
              |    | MOC | TRIAC   |          +-+
              |    | 3020| Driver  |        G | | TRIAC
              |    +=====+         |         /| |
       T1     \    2|   |4         |        / +-+
+-------------------+   |          |        |  | MT1
                        +--------- | -------+  |
                                   |           |
                             C1    |           |
                            100nF ---          |
                            500V  ---          |
                                   |           |
                                   |           |             Neutral
                                   +-----------+-----------> 120V

For non-sensitive TRIACs (15 mA < Igt < 50 mA) change the resistor R1 to 1.2 kohm and C1 to 200 nF.

Circuit from 302 circuits book

This is circuit without zero crossing detector, so this can be used as part of a light dimmer circuit. The circuit is only designed for driving non-inductive loads (light bulbs). You should use 3.15A fuse to protect the output triac.

     R1                       R2
     180                      1K                
+---/\/\/\----------+   +----/\/\/-------------+------------+-----------> 230V
                   1|   |6                     |            |             Hot
                   +=====+ IC1                 | MT2        | 
                   | MOC | TRIAC              +-+           |
                   | 3020| Driver           G | | TRIAC     |
                   +=====+                   /| | TIC226D   |
                   2|   |4                  / +-+           |
+-------------------+   |                   |  | MT1        |
                        +-------------------+  |            |
                                            |  |            |
                                            \  |            |
                                      R4    /  |            |  C1
                                      1K    \  |           --- 100 nF
                                            /  |           --- 400V
                                            |  |            |              
                                            |   )           |
                                            |  (   L1       |
                                            |   ) 50..100   |
                                            |  (    uH      |
                                            |  |            |              Neutral
                                            +--+------------+----o    o--> 230V
                                                                  load

IC1     MOC 3020 or OPI 3020

The circuit is based on the main switching section of constant light source circuits shown at: 302 Circuits, Elektor Electronics Publishing, pages 296-298.

Another MOC 3020 based circuit

This circuit is a part of Velleman light organ kit (taken from Velleman-kit K5202 3-channel soundlight manual). The circuit controls up to 2A of AC current (440W load) and takes 12-15V input control voltage. The circuit is very typical triac control circuit using MOC 3020 (or compatible) optodiac and typical TRIAC. The circuit has a radio frequency interference filter built from L1 and C1.

     R1                       R2
     330                      470                               Load     Hot
+---/\/\/\----------+   +----/\/\/-------------+-------------+--o   o--> 230V
+                   |   |                      )             |  440W Max
                    |   |                     (   L1         |
                    |   |                      )  50 uH      |
                    |   |                     (   6 A        |
                   1|   |6                     |             |           
                   +=====+ IC1                 | MT2        --- C1
In                 |MOC  | TRIAC              +-+           --- 100 nF
12-15V             |3020P| Driver           G | | TRIAC      |  250 VAC
                   +=====+                   /| | Z0409      |  500 VDC
-                  2|   |4                  / +-+ Q6004      |      
+-------------------+   |                   |  | MT1         |
                        +-------------------+  |             |
                                               |             |
                                               +-------------+---------> 230V
                                                                         Neutral

The kit does not normally include the filtering components L1 and C1. The circuit is not normally built without it. The circuit looks very simple without the filtering components:

     R1                       R2
     330                      470                          Load
+---/\/\/\----------+   +----/\/\/-------------+-----------o   o-------> 230V
+Vin               1|   |6                     |           440W Max      Hot
                   +=====+ IC1                 | MT2         
In                 |MOC  | TRIAC              +-+           
12-15V             |3020P| Driver           G | | TRIAC     
                   +=====+                   /| | Z0409, Q6004, ...   
                   2|   |4                  / +-+           
+-------------------+   |                   |  | MT1        
Ground                  +-------------------+  |            
                                               |            
                                               +-----------------------> 230V
                                                                         Neutral

NOTE: If you plan to use filtering you must install both L1 and C1 or you will damage the TRIAC.