# Calculating the Current Setting Resistor for a TLC5916 LED Driver

The Official TI TLC5916 Datasheet is far more confusing on the subject of calculating the external current-setting resistor than it really needs to be.

The basic relations appear on page 17, but the detailed discussion on page 22 will make your head explode. Here’s how I see it …

VRext, the voltage across Rext, the reference resistor, is controlled by a 1.26 V band gap reference multiplied by VG, the voltage gain of a 7-bit DAC.

```VRext = 1.26 V * VG
```

The DAC produces VG from the HC (High Current) bit and the six CC0..CC5 (Configuration Code register) bits. HC selects a range and CC0..CC5 are a binary multiplier.

`VG = ((1 + HC) * (1 + CC/64) ) / 4`

The minimum VG value for HC = 0 is 1/4 and the max is 1/4 + 63/256 = 127/256:

`VG = (1 + CC/64)/4 = 1/4 + CC/256`

The minimum VG value for HC = 1 is 1/2 and the max is 1/2 + 63/128 = 127/128:

`VG = (1 + CC/64)/2 = 1/2 + CC/128`

The  absolute minimum VG = 0.25 happens when HG and CC0..5 are all zero. Conversely, absolute maximum VG = 0.992 happens when they’re all one.

That means VRext varies from

`VRext (min) = 1.26 * 0.25 = 0.315 V`

to

`VRext (max) = 1.26 * 0.992 = 1.25 V`

There’s a kink in the middle of that range, as shown in the graph on page 23, where HC shifts gears to the high range.

Rext then converts that voltage into Iref, the LED reference current:

```Iref = VRext / Rext
```

The CG (Current Gain) multiplies Iref to set the actual LED current. The CM bit controls CG. You can either use the weird exponential formula in the datasheet or just remember:

• CM = 0 selects CG = 5
• CM = 1 selects CG = 15

Sooo, finally, Iout (LED current) is just:

`Iout = CG * Iref`

Knowing all that, you can choose Rext so that the absolute maximum current doesn’t exceed the LED rating:

`Iout (max) = 20 mA = 15 * (1.25 V / Rext)`

Which tells you that Rext must be no less than

`Rext = (15 * 1.25 V) / (0.02 A) = 938 Ω`

Then you can find the minimum current through the LEDs:

`Iout (min) = 5 * (0.315 V / 938 Ω) = 1.68 mA`

Now, given that the chip’s specs seem to indicate that the minimum regulated current is 5 mA, I suspect that all bets are off as regards linearity and matching and all that. Given that my friend wants a really dim clock, I think this will work out just fine…

Memo to Self: For whatever reason (and it must be a real stinker), TI numbers the CC bits backwards. CC0 is the Most Significant Bit, CC5 is the Least Significant Bit.

And because CC5 is the first bit shifted into the TLC5916’s shift register, you must run the Arduino hardware-assisted SPI in LSB-first mode.