DS1881 Experimenter's Board Part II--Rheostats and an AI Created Library

Readers: If you'd like to build the DS1881/ATTINY1616 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 a sample sketch and C++ library for the DS1881, 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!

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

I had so much fun with the DS1881--see this previous post--that I made another breadboard-bustin' experimenters' board for this cool digital potentiometer.


"DS1881-as-rheostat expermntr. brd."

The board deviated from the example found on the last page of the DS1881's data sheet: I added an on-board MCU (ATTINY1616) and exposed the IC's potentiometer pins as well as GPIO on the PCB's edge connectors. Gone were the op amp buffers. My idea: see if using the pot's L/W/H (low, wiper, high) pins as a rheostat could yield cool things like I2C controlled active filters.

I also uploaded the DS1881's datasheet into Claude Code and told the bot to create a C++ .h library file for the experimenter's board, something I had never tried before. 

Did it work?

At first--nope. 

Eventually, yes.  

 

THE USELESS BUILD PHOTOS

Jumping right to it....

Double happiness is new PCB's from this blog's patient sponsor: PCBWay!


No smoke yet....

The DS1881's I2C address is configured through hardware. If you build this project jumper or short the 0x28 or 0x29 pins to choose its I2C address.  


For proofs-of-concept I am using MCUs that support UPDI (ATTINY generation 2 and 3) more and more often.  UPDI is super easy--one wire for data and one for ground to blast firmware into the MCU--see the video here. Serial monitoring isn't through USB however--for that I exposed the TX /RX and ground pins on edge connectors which got fed into a NUC Linux PC running minicom.

CLAUDES AND SODS

Normally I would have read, re-read then re-re-read the DS1881's datasheet; over the coarse of a few days create a C library file for it. Not this time--my tech friends told me to get with the program and get AI lazy.

Fair enough.....I used Claude Code to create a C++ .h driver file for this project:

  • Installed Claude Code
  • Logged in using my Claude account.
  • I created the local directory for the project, cd'd into it then typed claude.
  • Using "browser Claude", I talked the bot through what I was trying to do.
  • The bot helped me create the Claude.MD file, necessary for project sanity, which I saved in the project root directory.
  • I uploaded the DS1881 datasheet PDF into the same directory.  
  • I didn't record the prompts I used for the initial build, but it was something like read the datasheet PDF and create a single .h file C++ library for the DS1881; use Arduino wire for I2C Hardware abstraction, and create an Arduino INO file to sweep each pot from 0db to -60db every 300ms then sweep back from -60db to 0db. 
  • I discovered a free tool to see Claude prompt histories (here) ex-post-facto.
  • This tool works great, but at this point I'm too lazy to dig back through the Claude directories and get you guys the actual prompts. Maybe later.

As already mentioned, the hardware, library, and test sketch didn't work at first. Using a DVM there was no change in resistance between H0/W0, W0/L0, nor the H1/W1,W1/L1 pins.

Meaning: As a rheostat the DS1881 wasn't working.

Begged the question: can the DS1881 be used as a rheostat at all? I thought so, and AI said it should work, but I didn't see a smoking gun in the DS1881's datasheet.

So--to be sure, I emailed Analog Devices, who got right back to me--yes this should work; if I coded my firmware right, I should see resistance values of about 40K to about 4K across H0/W0 or W0/L0 as I swept the DS1881's digital pots using I2C.

However, the DVM always showed about 30K no matter what; it was broken, but why? 

I fired up my logic analyzer:

After years of using cheap, crappy logic analyzers I spent a small fortune upgrading to a saleae. Worth it? Every dime.

The I2C data stream revealed that the DS1881 I2C initialization was working, but after that, nothing--no I2C traffic to sweep the pot's wiper. 

Good news in a way--it meant that I2C was basically working, the MCU recognized the DS1881, but still--the damn thing didn't work. 

Hello?

I reported this observation--initializes OK but no sweep--back to Claude Code. The bot revised the .h file and the ino sketch.  

Took the bot like 5 minutes. Would have taken me a few days.

Uploaded the revised code and .ino into the ATTINY1616 and--it worked.

WAIT! FROM THIS BLOG'S SPONSOR:

 


....why bother breadboarding when you can throw your ideas into Kicad, gerber-a-roni, ship them off to PCBWAY, and get 5 or 10 boards back to mess with. 

That's what I did here and overall: a huge timesaver. No messing with SMD to THT adapters. No junky dupont cables breaking. No being off by one 100 mil pin and frying your expensive IC. 

PCBWAY is super fast and their prices are so affordable breadboarding sometimes makes little to no sense. 


Just say no to breadboard spaghetti!


In addition to top-shelf PCB fabrication they also do great work with assembly, 3D printing, injection molding, and much more. 

More experimenter's boards to come in future posts. 

OK, back to it.

NOW WHAT, DR. SHANNON?

No photos, but I breadboarded a few circuit ideas using the rheostat--voltage dividers, op amp gain, an active filter--using the exposed DS1881 pot pins.  

I could type on and on about this, but I'll spare all of us all a lot of time: to me, there was nothing I could come up with using the DS1881 as a rheostat that I couldn't do more efficiently with more "traditional" voltage or current controlled variable resistors like OTA's or Vactrols.

The DS1881 shines doing what it was designed to do--an I2C controlled stereo attenuator with a nice sounding log curve and a anti-click algorithm baked in its hardware. 

Beyond that, not so sure.

I think that's where I will leave things this time before the DS then.....


THE CLAUDE CODA

Along with my hero, Bob Widlar, Claude Shannon (the original Claude!) was one of the most brilliant and colorful tech dudes of all time. Fascinating guy....Wikipedia here.

Reviewing Claude's Code: the library looked a lot more professional and succinct vs. what I would have coded by hand, employing extensive bitmasks, many more #defines than I would ever have used, and everything else C++ that drives me nuts.  

I need to test each method, but haven't yet. Something about Claude Code makes me feel--lazy.

Good enough?

The AI's output made me realize that I suck at Boolean Algebra so I got back into Claude Code and had the Claude whip up a Python/UV learning tool that (hopefully) will help me master bitwise statements in C and C++ some day.

This Python script was created with a single prompt--no revisions:

I need to learn bitwise operations in C and C++. This includes &, |, XOR, |=, ~= example statements like uint8_t commandByte = reg | (value & WIPER_VALUE_MASK); the learning tool should allow me to use single bytes (8 bits) and perform bitwise operations on them. Write a program in Python to help me learn the syntax of these C and C++ calls. Data entry and what is shown as the final output should entered and shown as Hex (0x04 for example) and bits (0b00001111)

The output came out better than I expected--it does a lot more than I would have thought necessary, and maybe is even fun to mess around with.   

Get the bitwise learning tool from github, here. Get UV here. Get stoopid here. We're cooking with oil! 

I'll admit it--Claude is smarter than I am, maybe some day I will catch up a little?  

Nope. 

See ya next time.

The Road Ahead

Hello again. I recently took up boxing and injured both wrists making me unable to type, work at the bench efficiently, or play musical instruments. These are a few of my favorite things..... Bummer!


I thought I’d use this downtime to (literally) record ideas I have for upcoming projects. 

Then augment this post in coming weeks and months as untyped content aka SPTKTO, aka a Single Place To Keep Things Organized.

If this post reads like I’m talking into a mic it’s because I am--the illustrations in this post were created with AI but my prose never will be.

Control/Alt/Delete?

First things first--on my Windows 11 system how do I make Voice dictation work--remember: for now I can’t type....

 

Is voice dictation in Windows 11 included for free? Nothing in Windows 11 is included for free.

After getting the internal microphone for my W11 computer working, I said into the mic “voice access wake up” and Windows took me through a quick wizard; surprisingly it worked right after that. 

To toggle the dictation feature off and on I clicked on the mic icon at the top left of my main screen: 



To kill the feature entirely I right clicked on the main Windows icon then Settings > Accessibility > Speech > Voice access:



I read online that the "Windows Key" plus H also turns voice dictation on and off. Oddly, I could not get this feature to work on two different Windows 11 machines. Tried to fix: many steps here, here, here, and here (and here as well as here).

After all this and several reboots one of the two started to work vis-a-vis this feature; now I can toggle voice dictation on and off with Windows key + H. 

What fixed it? 

Turns out to make Win + H work, you have to turn voice access (the button shown in the screenshot above) OFF.  

This is because Windows has 2 competing systems for this: "voice access" and "voice typing" and one clobbers the other. Yeh, I knew this--ChatGPT didn't help, it led me down a path of nonsense ("the longer it takes the more this guy makes") and the many links above didn't mention it? they all did, and I missed them? Whatever--time wasted--about 1 hour.

Overall, Window's ability to accurately transcribe voice worked surprisingly well but The Windows Plus H issue drove me nuts. 


Shut up and list the audio projects!

OK! A recent post (here) centered on Analog Devices/Dallas' DS1881

This is a super-cool digital potentiometer with musical sounding attenuation and a built-in hardware anti-click algorithm.

As an audio attenuator it works great, but I have other ideas for this interesting chip--using it perhaps as a rheostat, for MCU programmable variable gain using an op amp, in all-pass filters, and/or as the basis for a perennial favorite: analog multiplication. 

My always-patient and always-enthusiastic sponsor, PCBWAY, have already fabricated a never-ever-breadboard-again PCB for future rheostat experimentation. 

Meaning: a post about the rheostat application is coming when I can solder again and vet that the board doesn't turn into charcoal. Stay tuned.

 SBC's





Recently posted--using single board computers ("SBC’s") as the basis for new AudioDiWHY projects--series starts here

I need to flesh out the quadrature LFO--go here; code sample is at the very bottom of the post.

Another: a CV And MIDI based quantizer using an SBC running a web-based graphical user interface to set scales and ranges. Also add voice activation? Why not. For the web piece I'll probably use an RPi Zero running Flask; see the post here. For voice recognition maybe an Arduino BLE 33 and Tensorflow Lite.   

And: an extremely accurate bench clock using GPS and a Raspberry Pi--from some quick research I should be able to get gazillion dollar clock performance for absolute minimal dough going this route. 

But--all I have so far is the stupid AI illustration you see above and this link from SBC mensch Jeff Geerling.

Meaning: overall...."miles to go before I geek."

DEE-ES-PEE?


Any primate can write DSP Code with a $200/month Claude Subscription. But what about the layoffs?

My interest in learning digital signal processing never sleeps. 

I created simple proofs-of-concept using Python (here) but (doh!) I have a complete sh*t-ton more to learn. 

A scary smart tech "Borogrove" in my audio Discord group turned me on to a freely-available PDF that will motorize this pursuit: Hal Chamberlin's "The Musical Applications of Micro Processors"; find it online: here .

The book covers (along with other extremely useful topics) DSP basics that are spot-on for what we do-- not overloaded with math; containing examples (this is an old book--code fragments are written in  BASIC!!) that are reasonably easy to follow. Borogrove leveraged the book's code samples to create a professional sounding -24db per octave low pass VCF he brought to a recent meeting.

7-25-26 update--the YT vid here is first in a series where the content creator does basic DSP proofs-of- concept with an RP2350/Pico2 and some popular breakout boards. He includes C code and schematics. I have some Pico2's and both breakout boards in my junk box and would like to breadboard or better yet, create a PCB for experimentation based on his videos--but when Scotty, when?

STRING SYNTH?


 


Another: creating an analog string synthesizer based on top octave generation, frequency dividers, and some sort of mega-attenuator (probably based on aforementioned DS1881's). 

For the project the super-talented TJimmyChonga from the BAM Discord group created working C++ firmware for an RP2040-based top octave generator and shared it with me--TJimmy's DIY kung fu is stunning!

Using that I breadboarded a TOG, frequency dividers, and ASR envelope control, creating a few working Solina notes on the bench. However, I’m not happy with the sonic results-- Nothing to post yet. The work continues.

BAAH-RINGER?

If Behringer can rip these guys off why can't I?

In the same Discord group meetup: Tjimmy, Elton from Otter mods and I discussed jettisoning some of our commercially available recording and electronic music hardware and replacing it with prototypes we design and build. Time-wise this is an extremely bad idea but sounds like a challenge and maybe even a lot of fun. 

For me: low hanging fruit are modules like my intellijel dual ADSR. I figure the basis of this will be the one-chip ADSR described in the post here--who knows.

Roland's amazing JP8 was designed by some of the greatest audio engineers of all time. If they are the big leagues can I swing in Single-A? 

As long as we are jettisoning months of our lives--how about a programmable single- or dual-voice PCB that can be expanded into an 8-voice polyphonic synthesizer. So reverse engineering something like a Jupiter 8 or Prophet T8. Why not--??

STOMPS



It’s been a long time, but many years ago I had fun making guitar pedals that sounded good but broke the first time I gigged with them. I might start building them again (my fab skills have improved a lot since 2002) to try to toughen them up.

ARTIFICIAL INSUFFERANCE


Of course: the 800-pound gorillas in the room. Ever-useful, ever-terrifying, ever-potentially-economy-busting AI tech has already changed every aspect of my 9 to 5 job. Actually it’s more like my 24 x 7 x 365 job where the VIP's let me screw around with electronics when they don't need me screwing around with AI.

How to best incorporate AI into DiWHY? And! How can I not have pages and pages of Di-AI-WHY ideas already? 

Other than speeding creation of assembly BOMS and invoking sometimes-accurate-often-not OpenAI chats about electronics fundamentals, I'm coming up empty--figure I might wake up in the middle of night with something brilliant but so far: AI, for me anyway, is InfoTech automation 1000, AudioDiWHY 2.

A PLUG FROM URANUS--THIS BLOG'S SPONSOR: PCBWAY!

PCBWAY Community's servers are not in orbit (yet). Still--super cool. Check 'em out here.

Once ideas are off the drawing board I’ll need prototypes made; for that of course I go straight to this blog's wonderful sponsor: PCBWAY.

My work can, at times, be e-waste fodder, sometimes even burning up on re-entry, but PCBWAY's work is always stellar!! 

You can greatly help this blog by checking them out--using the link here.

OUTTRO

Enough for now, hopefully when my wrists are better I will start building things again.

Until later--don't spend all your tokens on one ride. See you next time.

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 vibe coded 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 when it shouldn't have-- in the end the bot's "answers" were nonsense, leading me down a lot of dead ends-- See the "How did it Sound" section below).  

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 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 with a 2V DC offset) 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 vibe coded 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 attenuates 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 de-clicking 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 DC bias 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'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, clicks, clacks, 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 chatbot 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. Update 8-15-26: posted! Go here.

See ya next time.
 

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.