The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Category: Electronics Workbench

Electrical & Electronic gadgets

  • TLC5916 Configuration Code Setting

    TLC5916 Writing Config Code
    TLC5916 Writing Config Code

    The TLC5916 data sheet clearly shows that you write the configuration code (which controls the LED current) by shifting seven bits in, then raising LE during the 8th SCK pulse while simultaneously shifting the 8th bit.

    That makes no sense whatsoever: you couldn’t use standard SPI hardware in a chained configuration, because you’d have to blip LE while shifting.

    In fact, the chip doesn’t work that way. You set the config code in Special Mode just like you set the LED driver bits in Normal Mode: shift ’em all in, then blip LE to latch ’em into the parallel holding register.

    Here’s the code to make it happen…

    DisableSPI();                               // manual SPI control
    
     digitalWrite(PIN_DISABLE_DISPLAY,HIGH);    // initial condition
     digitalWrite(PIN_LATCH_DO,LOW);
    
     PulsePin(PIN_SCK);                         // 1
     digitalWrite(PIN_DISABLE_DISPLAY,LOW);
     PulsePin(PIN_SCK);                         // 2
     digitalWrite(PIN_DISABLE_DISPLAY,HIGH);
     PulsePin(PIN_SCK);                         // 3
     digitalWrite(PIN_LATCH_DO,HIGH);           //   sets Special Mode
     PulsePin(PIN_SCK);                         // 4
     digitalWrite(PIN_LATCH_DO,LOW);
     PulsePin(PIN_SCK);                         // 5
    
    //-- Send brightness level
    
     EnableSPI();                               // turn on SPI hardware
    
     SendRecSPI(Brightness);
     SendRecSPI(Brightness);
     SendRecSPI(Brightness);
     SendRecSPI(Brightness);
     SendRecSPI(Brightness);
    
     PulsePin(PIN_LATCH_DO);                    // latch new shift reg contents into drivers
    
    //-- put LED drivers back in Normal Mode
    
     DisableSPI();
    
     digitalWrite(PIN_DISABLE_DISPLAY,HIGH);     // initial condition
     digitalWrite(PIN_LATCH_DO,LOW);
    
     PulsePin(PIN_SCK);                          // 1
     digitalWrite(PIN_DISABLE_DISPLAY,LOW);
     PulsePin(PIN_SCK);                          // 2
     digitalWrite(PIN_DISABLE_DISPLAY,HIGH);
     PulsePin(PIN_SCK);                          // 3
     digitalWrite(PIN_LATCH_DO,LOW);             //   sets Normal Mode
     PulsePin(PIN_SCK);                          // 4
     digitalWrite(PIN_LATCH_DO,LOW);
     PulsePin(PIN_SCK);                          // 5
    
     digitalWrite(PIN_DISABLE_DISPLAY,LOW);      // turn the LEDs on again
    

    The SendRecSPI() function does exactly what you’d expect:

    byte SendRecSPI(byte Dbyte) {                // send one byte, get another in exchange
    
     SPDR = Dbyte;                      // assume it's OK to send a new byte
    
     while (! (SPSR & (1 << SPIF))) {   // wait for shift to finish
      continue;
     }
    
     return SPDR;                       // SPIF will be cleared
    }
    

    I don’t know. Maybe the chip also works the way they show in the datasheet, but I doubt it’s worth finding out.

  • TLC5916 LED Driver Current Monotonicity Hack

    TLC5916 Current Gain vs Config Code
    TLC5916 Current Gain vs Config Code

    I’m using Texas Instruments TLC5916 constant-current LED driver chips for my my friend’s Totally Featureless Clock. An 8-bit configuration value sets the output current, with the external resistor defining the maximum value as described there.

    The problem is that the current-versus-config-value curve has a non-monotonic discontinuity in the middle, where the Current Multiplier bit switches from 0 to 1. I don’t know in which alternate universe this design decision made sense, but right here and now…

    It. Does. Not.

    Why it’s a problem: the LED brightness tracks room illumination as seen by a CdS photoresistor, averaged over maybe half a minute. The brightness changes very slowly, so the jump when it goes from 0x7f to 0x80 is really eyecatching. At least to me, anyway.

    Eyeballometric measurement of the curve shows the current at 0x80 pretty much matches the current at 0x60, soooo let’s just shove the second quarter of the curve (between 0x40 and 0x7f) downward until it meets the high-current value at 0x80.

    This code does the trick:

    if ((Brightness >= 0x40) && (Brightness <= 0x7f)) {
     Brightness = 0x40 + ((Brightness & 0x3f) >> 1);
    }
    

    Basically, that maps 0x7f to 0x5f. The output current for 0x5f is pretty close to the current for 0x80, making the step pretty much a non-issue.

    You could, if you were fussy enough, work out the actual current mapping values from the data sheet equations and make the ends match up perfectly.

  • Photoresistors Aren’t Indestructable

    Delaminated photoresistor
    Delaminated photoresistor

    So while testing the routine that measures light intensity using the technique described there, I discovered that:

    • The conductive layer atop the photoresistor doesn’t bond well to the base layer
    • The transparent top coating isn’t armor plating

    I wanted to verify the extreme dark end of the response curve, where the resistance is the highest and the input voltage correspondingly the lowest. The fastest way to do that is to put a piece of black electrical tape across the photoresistor’s face; it worked perfectly.

    Unfortunately, peeling the tape off the photoresistor also peeled the coatings apart. The resistance was unchanged, but I suspect moisture inside the layers isn’t going to do them the least little bit of good.

    Drat & similar remarks…

  • Arduino Pro: Securing the Serial Connecor

    Epoxy backfill on Arduino Pro serial connector
    Epoxy backfill on Arduino Pro serial connector

    The surface-mount serial connector on an Arduino Pro board isn’t the most robust of devices; the FTDI USB interface and USB cable can apply far too much torque to those little pins. Even before the situation described yesterday, the pins were getting wobbly.

    The connector shell is a big part of the problem, as it doesn’t mechanically lock the pins in place. Installing and removing the FTDI USB board pushes and pulls the pins against their pads, which means the adhesive bonding the pads must handle all that stress.

    Eventually, the Reset and TX pin pads tore loose from the circuit board. At that point, they have no mechanical stability at all; you can bridge a solder blob from the pin to its trace, but the adhesive holding the copper pad in place has lost all strength.

    The fix is straightforward, if ugly.

    • Repair the pin-to-pad/trace connections with something better than a solder blob. I used small snippets of component leads.
    • Apply denatured alcohol and scrub away all the solder flux around the pads.
    • Apply enough epoxy to the back of the connector to bond it, the pins, and the circuit board into one mechanically stable unit. I worked the epoxy between the pins and slightly under the connector shell with a small screwdriver and toothpick.

    Even with this repair in place, the connector is not particularly robust. It’s much better than it was, so we’ll count it as a win.

    This Arduino Pro has survived several projects, hence the hideous solder blobs here & there. I suppose I should just throw the poor thing away, but … that’s not my nature.

  • Arduino Pro: Power Adaptation for FTDI Basic USB

    Arduino FTDI Basic on modified Arduino Pro
    Arduino FTDI Basic on modified Arduino Pro

    Some time ago, I bought a 5 V Arduino Pro board (about which you read earlier there) and a nominally compatible FTDI Basic USB-to-serial adapter. Turns out that they’re not quite a perfect match, although they do play nicely together in normal use.

    The FTDI Basic board produces a 3.3 V regulated output voltage that’s connected directly to the output of the Pro’s 5 V regulator. This doesn’t cause any particular problem, but one side effect is that you can’t shut the board’s power off: the USB power will keep the CPU alive, more or less.

    You should, of course, use a 3.3 V FTDI Basic board with a 3.3 V Pro, which would at least put two similar voltage sources head-to-head.

    The Pro is using a backup power supply that, for reasons that make perfectly good sense, backfeeds the Pro’s 5 V regulator: when the +12 V main supply Goes Away, the backup power supports VCC directly, rather than through the regulator. The regulator can take a joke like that, as witness the FTDI vs Pro situation; in my case, a diode isolates the two supplies in normal operation.

    For reasons that I don’t completely understand, some combination of voltage to the Pro regulator and the (diode isolated!) backup support voltage caused the FTDI chip to lock up with both TX and RX LEDs on solid.

    I suspect the FTDI chip’s internal 3.3 V regulator, in combination with the USB +5 V supply, in combination with the Pro board power, drove something outside its normal operation range. So I simply removed the 3.3 V pin from the connector, disconnecting that supply from the Pro’s overvoltage, and the thing now works fine.

    Side effects:

    • The FTDI board remains powered when the Pro board gets turned off, thus preventing Linux from changing the serial port device when the power comes back up again
    • I can actually turn the Pro power off, without having the FTDI supply keep it alive. Handy for soldering!

    The Pro pin labeled GND connects to the FTDI CTS line, an input that floats high when not connected. I yanked that pin and shorted CTS to GND on the FTDI board: one less pin to worry about, for reasons that you’ll see tomorrow.

    There are many different versions of the boards and USB adapters, so current production probably doesn’t match what I have. Pay attention to what you have, though…

  • Debugging Tube Circuitry: Open Resistor

    Open 2.2 meg resistor
    Open 2.2 meg resistor

    I dropped in to mooch some female header strips from my buddy Eks (which is not nearly as obscene as it sounds) and got the story behind this innocent-seeming 2.2 megohm carbon-composition resistor.

    It seems he was debugging a defunct tube-based audio amplifier. He’d probed everything and discovered that the grid bias on one of the tubes was totally wrong, which caused protracted headscratching over the associated circuitry.

    Now, in semiconductor work, a 2.2 meg resistor is an open circuit compared to the other circuit impedances. In fact, you can use pretty nearly any resistor with green or blue in the third band as a standoff in Manhattan-style construction in place of those small insulated pads.

    Megohm-value resistors are actually useful in tube circuitry; you’ll see plenty of green and blue bands sprinkled around those sockets. Although we didn’t get into details, I suspect this one was part of a grid-leak bias circuit that holds the grid voltage just a bit below the cathode; the bias comes from the few electrons that whack into the grid wires rather than passing through, so the total DC current is in the microamp range.

    After more headscratching, Eks yanked this resistor, measured it, and found it was a completely open circuit. A 2.2 meg resistor isn’t all that much different from an open circuit (it’s hard to tell the difference with an in-circuit measurement) when used in a transistor circuit, but the difference separates correct function from failure for a tube amp.

    Eks swapped in a new resisistor and the amp worked fine. Case closed!

    The digital multimeter in my desk drawer tops out at 2000 kΩ, which shows you just how much demand there is for high-value resistors these days…

  • Nichicon SMD Electrolytic Capacitor Polarity

    Nichicon electrolytic capacitors
    Nichicon electrolytic capacitors

    This should be obvious, but isn’t. The black bar marks the negative terminal and the corner-cut side of the base marks the positive terminal.

    How much would it cost to put little hyphens down the middle of the black bar?

    The data sheet for a related, not identical, series of caps is there.