LED fixtures containing more than one LED sometimes combine half the wires into one. When the shared wire connects to the minus side of the LED’s, it is called “common cathode”. Two examples are found on this page:

  1. A railroad crossing sign. Two LED wires plus one common wire (3 wires total)
  2. A stoplight for a street intersection. Three LED wires plus one common wire (4 wires total)

The Details

For those interested in the details of common cathode operation, read on. For those wishing to jump right in and use the code, skip to the next sections.

There are two kinds of common wire. We prefer common anode, since we already have the plus (+) terminal for it, but can also work with common cathode:

  • Common Anode
    • Shared wire is anode or plus “+” side of each LED
    • Easy connection for the Morsel, since it already has plus “+” pins available
    • Works the same as individually wired LED’s

The remainder of this page is about common cathode wiring.

  • Common Cathode
    • Shared wire is cathode or minus “-” side of each LED
    • Requires a minus pin on the Morsel. We will create one with an LED Port
    • Brightness is inverted compared to individually wired LED’s (100% = off, 0% = on)

For various reasons, common cathode brightness is less by an equivalent 1 to 2 dim button steps. This is usually not a problem, since the lights have small surface area. They are viewed directly instead of illuminating a scene.

Wire connection:

  1. Connect common wire to a port of one phase
  2. Connect LED wires to Ports of the other phase
  3. Note: Port a is excluded from both lists.

Port phases.  Phase 1:  b, d, e, i      Phase 2: c, f, g, h

What happens if the phase 1/ phase 2 rule is not followed? No harm is done, but the LED may not turn off completely (dims to 0.4% instead of 0.0%). The same faint glow persists if true ground (the G pin) is used for the common wire. For best regulation, each fixture should use another LED port for the common wire.

Set brightness in this way:

  • Adjust brightness within the sequence, if needed, remembering that 100% is off and 0% is on
  • Keep the Dim button at 100%
  • Set the common terminal to 100%
  • If using Theme Designer, set scaling to 100% for all LED Ports of the fixture

All of these details are taken care of in the following examples.

Railroad Crossing (Common Cathode)

Export as a test sequence to the Morsel. The railroad crossing will appear on the following LED ports:

b (chn2):  LED 1
c (chn3):  Common
d (chn4): LED 2

//Railroad Crossing 
//Common Cathode Version
//LED's on chn2 and chn4, common is chn3

//best contrast when common comes from one phase and LED's from the other:
//  Phase 1:  b, d, e, i      Phase 2: c, f, g, h

// set common cathode pin to 100%
define commonCathode 100%

define fadeUpTime 120ms     //LED 0  Incandescent 80-150ms
define fadeDownTime 250ms   //LED 0  Incandescent 80-350ms

//remembering that brightness is inverted,
//uncomment one of the following to set brightness
define dimLevel 0%         //max 100% brightness
//define dimLevel 50%       //half brightness
//define dimLevel 75%       //quarter 25% brightness
//define dimLevel 87.5%     //eighth 12.5% brightness

//"off" is always 100%
define off 100%             //led turned off

//an external switch can turn off the RR Crossing effect in Theme Designer by 
//enabling "CC Fx" on all three pins, then pulling CC pin high (5V)
//start of code 
 chn3 = commonCathode //common wire. No harm repeating this statement in loop 

        //random starting point                                //random start
        go between start1 and start4
                                                                  start1
        chn4 = fade from off to dimLevel for fadeUpTime
        chn2 = fade from dimLevel to off for fadeDownTime
@0.5s
                                                                  start2
@1.0s
                                                                  start3
        chn4 = fade from dimLevel to off for fadeDownTime
        chn2 = fade from off to dimLevel for fadeUpTime
@1.5s
                                                                  start4
@1.99s
        //slight speed difference if more than one crossing used
        go to slightSlip with 50% chance
@+20ms  slightSlip

        go to start1       //repeats

Synchronized Streetlights (Common Cathode)

This sequence drives two streetlights delayed to be located a city block apart. Export as a test sequence to get the following LED Ports assigned. For a single streetlight, use only one set of channels.

b (chn2):  Green
d (chn4):  Yellow
e (chn5):  Red

c (chn3):  Common

f  (chn6):  Second street Green
g (chn7):  Second street Yellow
h (chn8):  Second street Red

i (chn9):  Second street Common

// Synchronized Streetlights (Common Cathode)
//
//1st streetlight: G-Y-R = chn 2, 4, 5. Common cathode chn3
//2nd streetlight: G-Y-R = chn 6, 7, 8. Common cathode chn9
//
//best contrast when common comes from one phase and LED's from the other: 
// Phase 1:  b d e  i     Phase 2:  c  f g h
//test chn:  2 4 5  9               3  6 7 8
//           G-Y-R  C               C  G-Y-R
// Street:   1 1 1  2               1  2 2 2
//

//brightness setting combined with fade
//for incandescent, fade should take around 100ms for full scale brightness swing
//fade-to needs more milliseconds for same fade if brightness range smaller
//uncomment one:
define dimLevel fade to 0% within 120ms    //fully on
//define dimLevel fade to 67% within 360ms   //one-third brightness
//define dimLevel fade to 90% within 1000ms  //one-tenth brightness

//fade-to needs more milliseconds for same fade if brightness range smaller 
//uncomment one to match the above fade speed: 
define off fade to 100% within 120ms 
//define off fade to 100% within 360ms 
//define off fade to 100% within 1000ms 

//which channels contain LED's
define Green chn2    
define SecondStreetGreen chn6      
define Yellow chn4
define SecondStreetYellow chn7
define Red chn5
define SecondStreetRed chn8

//speed of stoplights
//change if desired
define YellowTime @+2.5s    //default @+2.5s
//basic time unit used in stoplight speed define 
define BTU @+5s             //default @+5s

//Code starts here 

//Initial outputs off
         Green=off Yellow=off Red=off
         SecondStreetGreen=off 
         SecondStreetYellow=off
         SecondStreetRed=off 

//Common cathodes at 100%
         chn3 = 100%
         chn9 = 100%

        //start randomly
        go between start1 and start7

//times  //lights to turn on        //lights to turn off        //random starting point
                                                                      start1
        Green = dimLevel                Red = off
BTU                                                                   start2
        SecondStreetYellow = dimLevel   SecondStreetGreen = off
YellowTime                                                            start3
        SecondStreetRed = dimLevel      SecondStreetYellow = off
BTU                                                                   start4
        Yellow = dimLevel               Green = off
YellowTime                                                            start5
        Red = dimLevel                  Yellow = off
BTU                                                                   start6
        SecondStreetGreen = dimLevel    SecondStreetRed = off
BTU                                                                   start7

        //slight speed difference in case randomized timing is needed somewhere 
        go to slightSlip with 50% chance 
@+25ms slightSlip 
        go to start1  //repeats

 

 

 

Forward
Back