DS1881--Clickless Dual Digital Attenuator--Experimenter's Board--Amazing IC!

Readers: If you'd like to build the DS1881 experimenter's board featured in this post, please go to PCBWAY's Community pages--gerber file; KiCAD 10 project/pcb/schematic/library files, a link to github repo with Proof of Concept sketches, an assembly B.O.M., and more, are here.  

You can also help out this blog immensely by checking out PCBWAY using the link here. Thanks!

=============

 Hello again!

I've breadboarded digital potentiometers before, only to find they make an ugly, audible "click" when changing resistance values when used in 30hz-20Khz AC circuits.

I recently stumbled upon an IC that purportedly does away with the click--Analog Device's DS1881--dual pots, I2C, log response--everything needed for an MCU controlled audio attenuator--but also sporting onboard hardware to detect AC zero crossings (like an old Akai sampler?) and change its resistance values quietly.

TLDR: Does the DS1881 work as advertised? Yep. 

Datasheet here.   





PCB DESIGN

"Not this post's project"

Instead of breadboarding (I hate breadboarding!) I created a simple DS1881 experimenter's board, used an Arduino UNO4 to generate the necessary I2C calls and vibecoded test sketches to create proofs of concept.

AI was a huge help (coding the test sketches) but also a burden (out to lunch--why the DS1881 was producing audible clicks--leading me down dead ends).  

The circuit fragment for the experimenters' PCB was stolen from the DS1881 datasheet; my test PCB offers additional circuit protection.


The  PCB:




For the op amps I used an MCP6004--DIP version--I had a whole tube of them.  

It's a rail-to-rail quad op amp, affordable and easy to use, but can only withstand 6VDC max at its rails without blowing up.....good choice for this application: the 6004 buffers the incoming signal (I added schottky diodes as well) to clamp AC input signals to about 0-5V.

Since I had an extra op amp stage I inverted and cap coupled one of the outputs--why not?

Power can be from wirepads (PWR-IN) or from a Eurorack style power 2x5 100 mil header (don't put power to both!!!).  

PWR-OUT  is +5 from the regulator, added it as a test point.

Audio ins and outs are on the top left "EYE-OH" 100mil edge pins; from the top: 

  • output for channel 1, 2.5V DC offset 
  • output for channel 0, Cap coupled
  • output for channel 0, 2.5V DC offset
  • input 1: used 4V P/P with 2V offset (worked for me--you might want to experiment with P/P and DC offsets)
  • input 0: ditto but for input 0.

For the 12V to 5V step down, I accommodated both a 7805 regulator (I have a whole box of them) and a low dropout, more "modern" choice: SOT-23-5 LP2895. If you build this board, please use one regulator or the other--don't use both!

USELESS BUILD PHOTOS

Always: happiness is new PCB's from this blog's patient sponsor, PCBWAY.


I used both THT and SMD for the project...sorry.  Grab the Kicad files (here) and modify away if you want....1001 uses.
.........built a bit of it, powered it up, and saw if there was a short. In this case, no short (yet).  Kept going.





Still no short! I had an ancient UNO-R3 I use only for getting I2C addresses (code here). Worked! Default with A0-1-2 pins grounded--I2C address for 1881 is 0x28.


I used an Arduino R4 for the rest of it--worked great for getting I2C calls into the test board quickly, then seeing serial output through the Arduino IDE.

Good to go! used a siglent function generator for the test waves (4V P/P) and a Eurorack patch cable to the bench BT mixer (here) to hear output--"seems working". Get the Coax to whatever boards here and here.

THE SKETCHES

Get them from Github: here.  

AD's I2C implementation for the DS1881 was simple; I vibecoded then debugged/modified the code--fast, fast, fast. The days of coding every line of anything may be gone for good.

For each .ino file you may need to drag the .ino into a new folder you create with the same name.

Simple stuff: take a look, experiment with different values, vibe code additional features, and have fun:

  • DS1881-diag.ino Run this first, the basic g/no go tool for the experimenter's board. Reveals if I2C can reach the DS1881, tells you via RS232 the IC's I2C address, does basic reads and writes to the DS1881's registers. Nothing for you to enter into serial monitor; the serial monitor's output tells you if your build works or is butt.
  • DS1881-enter-db-attenuation-value.ino. Entering a value 0 to 64 in serial monitor attenates 0 and 1 channels by said DB.
  • DS1886-30ms-steps-100ms-hold.ino  Rapid attenuation followed by gain increase for both channels. So, a sort of poor man's tremolo. I wanted to see if fast fades caused clicking--so far, none heard. Suggestion: Mess with the ms values in the sketch to experiment with how fast I2C can control the pots and what sounds good to you.
  • DS1886-choose-zero-cross.ino The DS1881 fades inputs to -64db then the signal is gradually brought back to unity. Enter z into the serial terminal to toggle on and off the declicking algo inside the chip. This will give you a rough idea of how the DS1881 will sound vs. a digital pot that does not have a zero cross detection algorithm built-in.  

HOW DID IT SOUND?

At first--crappy.....no matter what I did I heard clicks. Hello? The whole idea: no clicks.  

Pouring over my circuit and code, many times--I think I got it right....but the IC wasn't working as advertised, so--did I?

Plugging everything into Claude, using every prompt I could think of, and adding the DS1881 datasheet to Claude.ai's RAG (Resource Augmented Goober-fication), whatever, the chatbot told me that the audible clicks were just the way the DS1881 rolls and, like a bad marriage, I should just live with it.  

Did that sound right?

I took the project to my local group meetup--everyone meant well as always, but as far as a fix, no one (including me) had any idea why the DS1881 was clicking no matter what, I just got puzzled looks.  

Driving home it dawned on me--what if I set up the input signal wrong? Electronics is the same as US politics: always suspect stupidity. 

Went back to the bench and sure enough, I was not adding a 2V offset to the test input signal.  The datasheet clearly indicated that a bias offset was needed, but no, I booted it, which was confusing the hell out of the DS1881 IC's anti-click algorithm.



I added a 2VDC offset and the IC worked--perfectly--no click, nice natural sounding butter-smooth fades, quick moves from -6 db to -60 db to whatever than back to mute--all without any distortion or unwanted cross-tweeze. Musical. This is a really cool chip! 

Plugged this fix back into the LLM and it sort of said "oh yeh, my bad". Which is better, I guess, then a bot scolding me for being stupid.  



THE SHAMELESS PROMO


Quick word from this blog's sponsor! Once you have your design laid out, and want to see if it runs or is a smoking turd, RUN don't walk, to PCBWAY and get some prototype PCB's made....They also do great work with 3D printing, assembly and can even act as your OEM. You can support this blog by checking them out--link here--as well as the PCBWAY community (here).  And--best of all! for support you always get a friendly human, not a bot. Yes, it still can happen!


WHAT'S NEXT?


I am having a rev-2 experimenter's board fabricated as I write this. It allows the DS1881's two channels to be used as MCU controllable rheostats. 

I am not quite sure what I'd use that for, or if it will work at all, but that's the great thing about DiWHY in an era where small quantities of PCB's are available quickly and for little money; try it out, see what happens. 

Assuming I can get something useful out of this 2nd revision: it will show up in a future post, for sure, for sure.

See ya next time.
 


digital potentiometersPCBWAY

No IC's allowed, part II: determining active vs. saturation state in BJT transistors

Back for more discrete transistor design punishment!  

Quick one this time.

Last time I discussed BJT basics...if you are a "BJT cookbook" tech as I am or was--find a bipolar junction transistor circuit fragment, put it in your design, and hope it works--you might want to skim the last post before reading this one.

Maybe simulate it using Falstad?



If you are a BJT superstar--you taught 1970's electronics at a community college and already know all this--by all means skip this post and instead watch the video here.

but really? this is all for me.

SATURATED VS. ACTIVE

You can get Falstad simulations for these "No IC" posts from github, here.

So...how do you figure out if a transistor is in its active or saturation region?  Should be easy, but this one drove me nuts...

Cheat code: Plug your BJT circuit fragment into Falstad, hover over the transistor and see what it says?  



Nope, too easy. 

We start by guessing we are in active region, and go with these assumptions:

  • B-C junction is forward biased; its voltage drop across B and C is .7V
  • current at emitter and current at collector are the same
  • B-C is forward biased; B-E is reverse biased.(normal situation for active region)

Let's do some simple alegbra and use ohm's law to see what's really going on.
  • Base is 2V less .7V to ground, so the voltage at the BJT emitter is 1.3V.  
  • Using ohm's law: current at BJT emitter junction is 1.3/1000 or 1.3mA  
  • Assuming active region for the transistor, Ie and Ic are about the same, so let's assume Ic is also 1.3mA
  • Again using ohm's law, for emitter to be at 1.3mA, the voltage drop across a 10k resistor would need to be 13V
  • But, the the collector power is only 5V!!
  • The transistor lowers its Ve to Vc resistance as much as it can to satisfy the need to satify the 13V drop
  • But fails--even if C to E is a short, the transistor can't make the Vc junction 13V relative to ground.
  • Transistor is saturated; B-C and B-E are both forward biased; E to C works a lot like a short circuit.
Let's try again:


  • BJT collector current is 1.3mA; that hasn't changed.
  • Assuming active, Ic = Ie, so Ie is also 1.3mA
  • 1.3mA * 1000 = 1.3V  (drop across collector resistor)
  • 5V - 1.3V is 3.7V0--that's the collector voltage
  • B-C is forward biased; B-E is reverse biased (see "active" assumptions above)
  • Transistor is active.

OK with this framework, any simple fragment can be analyzed.

For PNP, all the same ideas, but all polarities are reversed.  

Notes for this post....


This helps explain the typical graph you see when reviewing transistor datasheets:


Voltage between collector and emitter (X-axis) vs. current  at the collector (Y-axis). The uA values on the right (10uA, 20uA etc) is a constant current seen **at the base node**. Which means, voltage and resistance B to C change, giving us the various X/Y values we see on each red line.


The saturation area is the vertical area shaded in blue--as described above: when the voltage from C to E is nearly zero volts, the resistance between C and E is almost zero; C to E acts like a dead short.  However, the values further to the right on the X axis result in amplification: as C-E voltage swings back and forth along the X axis, to the right of the saturation region, current swings up and down along the Y axis, since C to E resistance is changing.  The horizontal area shaded blue results from B to E not being forward biased--transistor is cutoff; C to E acts like an open circuit.

OH NO IT'S THE PROMO



Quick word from this blog's sponsor! Once you have your design working in Falstad, run, don't want to PCBWAY and get some prototype PCB's made....They also do great work with 3D printing, assembly and can even act as your OEM. You can support this blog by checking them out--link here as well as the PCBWAY community (link here)

OUTTRO


OK no more this time, it's Juneteenth, I have to get to the bench and mess around with some IC's.

No IC's Allowed!

I am retiring soon--they've put me out to pasture.  

I hate hate hate being bored so, what now?

I fired up Falstad to simulate basic electronics building blocks using only transistors, caps, inductors, resistors, and diodes--NO IC's!!! 


A video game!!!!

Rules:

  • (already stated)--No simulated IC's--even if the simulator has 'em, I can't use 'em.
  • FETS/MOSFETS, maybe? Try using BJT's instead....
  • No finding fragments online then copying them into the sim...which "works", but is way too easy, and I learn almost nothing. 
  • Goal: understand "discrete" electronics well enough to look at old audio schematics (e.g.: Aries synths here--cool) and have a decent idea of how these OG/transistorized/very-few-IC designs from way back work.
I discovered that my ability to conjure anything without IC's--like, how to make a comparator without using an opamp--sucked.    

FALSTAD

Why breadboard when I can do it behind glass.

I've tried many simulators--Kicad's, Everycircuit, others, and keep coming back to my local installation of Falstad

Falstad and my brain get along; I get instant gratification, seeing voltages change in real time, seeing current flow like the ghosts in "Pacman".  I can spin up virtual scopes, I change values while the sim is running to see what happends and a lot more. 

Best of all--it's free! 

Get an offline version of Falstad here; web version here.

I put my Falstad exports for this post on github (they are text files...so, file > open the txt files in Falstad to run the simulations). Repo is here.

AI (OF COURSE)

Since no one thinks on his or her own any longer I uploaded the Falstad exports into Gemini, Claude etc. to help me understand how the sims work, find mistakes, help with analysis and the rest. 

These LLM's (I didn't try copilot because I frigging HATE copilot) both say they support analysis using Falstad exports--didn't know that!.

But! Claude.ai Opus was terrible with all things falstaff, making all sorts of bizarre and inexplicable mistakes. Gemini Pro worked a lot better. Of course in 2 weeks this could be completely flipped.

EG: I asked Claude to vibe code a text file to create a current mirror I could upload into Falstad. Here's what it came up with. Righto!



BJT LOGIC GATES

Getting started--a warm up.

Even with my limited knowledge of BJT's I could figure and AND, OR, NAND, and so on. pretty easy. 

NOR gate, get it here. Fake LED demonstrates logic out.

Moving on....

BJT TRANSISTOR BASICS

I know this component, right? BJT transistors are easy right? Nope. I created a simple simulation complete with fake current and voltage meters: 

 Sim herecheck out a great "Kevin's Cave"
newbie video BJT tutorial starting here.


Which led me to:

TRANSISTOR FU 

Looking at the NPN transistor modeled in Falstad--messing around for a few hours--throwing a screenshot into claude.ai when I got stuck--what (I think) I know now:

  • In general, the voltage drop between base and emitter determines C to E behavior. 
  • It's not voltage relative to ground found at the the BJT's base that determines this. It's the voltage drop between B and E.
  • C to E can act like a variable resistor. When doing so the transistor is said to be in "active" mode.
  • While in active mode the B to E current is multiplied the transistor's "beta" (in Falstad: 100 by default)
  •  this allows for amplication
  • This beta multiplier is also called "Hfe" to keep things confusing.
  • But--the transistor can only alter the resistance between C and E so much.  
  • At some point the resistance is as low as the transistor can make it, at which point the transistor is "saturated."  
  • When the transistor is saturated C to E behaves like a small resistor--maybe 30-50-90 ohms.  In this case additional base to emitter current won't change the C to E behavior; the transistor is maxed out. Saturation means the Vc to Ve voltage is as small as it can be, usually around .2V.  Increasing base current will no longer make this voltage decrease. Good video about this here.
  • Cheat code: Active vs. saturated, for the default NPN transistor modeled in Falstad, can be boiled down to this: if voltage between collector and emitter is greater than about 200mV the transistor will be active; if it's less than 200mV it will be saturated.
  • If limited or no current flows between B and E, you can end up with no current flowing between E and C. Transistor is in "cutoff" mode and the collector is "high-z", as if the collector is an open circuit.
  • Falstad has a useful feature: if you hover over a transistor, in the bottom right corner of the app you can see things like B to C voltage, C to E voltage, and its mode (saturated vs. active vs. cutoff).
  • If BJT is saturated, current flow in falstad is shown flowing C to E, as expected. But I've seen current flow from B to C while in "active" mode as well, but sometimes not, which I found confusing.  
  • A BJT transistor is analogous to a valve--it can't generate current, only let various amounts of it (or none) pass through. Basic concept, but this escaped me at times.
  • For amplification, we usually work in the BJT's "active" range.  
  • For logic and switching, work in the BJT's "saturation" and "cutoff"modes.
  • You program what you want the BJT to do by surrounding it with voltage sources, current sources, resistors, diodes. The trick is getting the surrounding components right 
  • To get it right, you have to use math (basic algebra, mostly). Sorry.
  • Transistor prose and videos can be a flurry of capital letters and italized subscripts. Get used to it:
  1. Gm ("transconductance") a transistor's ability to see a change in B-E voltage drop and turn it into a change in C-E current.  
  2. Ic, Ie, Ib: current at collector, emitter, base
  3. IcRc represents the voltage drop across a resistor tied to the collector, since V=IR....same idea for IbRb, IeRe.
  4. Vce is the voltage drop from collector to emitter
  5. Vbe is the voltage drop from base to emitter
  6. Etc.  
  7. Video series that I found helpful--kickoff video links : Vocademy
  • Falstad is a great place to mess around with values and see what happens.
  • See more about saturation vs. active in the post here.

DIODE BASED COMPARATOR

On to the next sim.




The idea of using diodes to choose the greater of 2 voltage sources was new to me--a nice hack.  I tried building this comparator using a long tailed pair but for me a 2 diode + 1 transistor solution worked better....Sim here.

CURRENT MIRROR




Upper 2 transistors form a "long-tailed pair" while 2 lower are a current mirror--left lower is the reference transistor.

I see these everywhere in IC designs, but, why? How? After screwing around with simulations: By tying B and C together on the lower left transistor (the "reference"): assuming lower transistors are in their active regions, C to E in the lower right transistor (the "mirror") acts like a variable resistor, its resistance increasing and decreasing with collector voltage. This rock-solid current sink is needed to make sure the balanced pair actually balances.

If the right lower transistor was replaced with a normal resistor, the voltage drops seen across the balanced transistors (upper ones) would impact overall gain, leading to distortion.   

Sim is here.



LC OSCILLATOR (SINE, SQUARE, ETC)

I've been doing the DiWHY thing off an on for 25+ years and, outside of linear power supplies, have never used an inductor in a single design of my own. 

After trying unsuccessfully to come up with a transistor/cap only solution for an oscillator, I remembered that inductors pass DC and not AC, while caps pass AC and not DC.  If I put them in parallel, they might fight each other?  Yep. That's the thing about simulations--try weasel, try squirrel.  Nothing is going to smoke. Something eventually will work. I messed around with the parts until I found something that worked. Now I need to figure out the math right? Nope.

I even threw in a FET buffer.  Buffers in general have proven tricky in my discrete design attempts. Just throw in a 741 right? Not in this post....Oscillator simulation is here.

FRENCH, GERMAN, AMERICAN

To make discrete circuits useful some math and science is needed (sorry, Arduinoheads). When transistor analysis is discussed, the dudes below are discussed. so far the math I've seen is algebra only. 

KIRCHHOFF: "The man with a redundant H". Russian, moved to Germany. Hell of a guy, discovered all sorts of things, including cesium. Big ideas: Kirchhoff Voltage law: the sum of all voltages in a closed-loop circuit is always 0. Example in a transistor analysis video here: go to about 4:11. Kirchhoff Current law: currents in closed-loop circuits don't magically vanish; for example, current at transistor C is a sum of currents B > E plus C > E.

THEVENIN: French. You can take a complex circuit and reduce it to a single power source and a single load resistor.  You know the blocks in schematics labeled "load"? That's the "Thevenin Equivalent".  How-to video for computing thevenin equivalent is here. I'm a reductionist, maybe he was too.

MILLER: Miller was American, discovered the capacitor hoo-ha using tubes (not transistors) and worked for RCA, among other places. The Miller Effect: in AC circuits the transistor has parasitic capacitance which impacts frequency response. Good video here. Another video (Zappa backing track? Sounds like it!) here.


OP AMP

This one blew chunks--hard!! I remember I have to combine a long tailed pair, a gain stage, and a class B amp, but that's all I recall. So far, no love, I have made lots of BJT matched pair thingys that don't work.....I am really REALLY tempted to cheat, since a simulated op amp using BJT's would create a bullet-proof buffer, much needed!  

And I figure a bunch of folks smarter than me have a simple low parts count design already posted online. But--So far, no love!  

THE SHAMELESS PROMO



Indeed....Once you have your sim go to PCBWAY and get some PCB's made....check out their online community.  They also do beautiful work with 3D printing, assembly and can even act as your OEM. I got in the shameless promo in. Go A's!!!

THE-THE-THE THAT'S ALL FOLKS!


enough for one week. Until next time: discrete-ion advised.