One-Chip ADSR using the ATTINY1616

Readers: If you'd like to build the ADSR experimenter's board featured in this post, please go to PCBWAY's Community pages--gerber file; KiCAD 10 project/pcb/schematic/library files, Arduino .INO file, modified .h and .cpp helper files, B.O.M., and more, are here.  

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

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

This one started when DIY rockstar--this guy's kung fu is the best--TJimmyChonga--emailed me about an earlevel C++ library that abstracts analog synthesizer ADSR functionality into a compact C++ library--articles documenting the library begin here; zip of the CPP and H files are here.

Experimenter's PCB for the earlevel ADSR library, and probably a lot more AudioDiWHY fun. 


Looking over the code, I guessed it might be easy to use an ATTINY1616 --that's a <$1USB MCU, folks--to create an entire ADSR since the ATTINY1616 has ample ADC's and a single reliable 8-bit DAC built-in.  

Designed it, gerbered it, got it fabbed, built it. Fast, fast, fast...Good news--yep, it worked.

THE DESIGN

Instead of breadboarding, which drives me nuts, I drew up a 99 x 99 mm PCB using Kicad10.  

I added 3.5mm input and output jacks; a shottky diode clamp for the trigger input (so a 10V or 12V gate signal didn't blow up the input pin on the MCU) and a few pots....I buffered the output using a DIP TL071....simple stuff. 


....for future expansion, remaining GPIO was brought out to JST connectors....

As usual, a 3-pin JST in series with a 470 ohm resistor was used UPDI programming.

I included a 7805 regulator, although I could have gotten 5v from the Euro power cable, but hey, why bother.

I chose mostly thru-hole since I have tons of THT in my junk box.

Happiness is bubblewrapped new PCB's from this blog's patient sponsor, PCBWAY, where ten 2-sided PCB's less than 100mm x 100mm can still be purchased for $5USD.  

THIS BLOG'S SPONSOR

The gerber got sent off to this blog's trusty sponsor, PCBWAY and came back with alacrity.  

The shameless plug:


....why bother breadboarding when you can throw your ideas into Kicad, ship them off to PCBWAY and get lotsa boards back to mess around with. If they don't work: don't swear, don't stomp around, don't cry....e-waste them in an environmentally friendly way and try again. What's your time worth? 

Prototyping with PCB's is faster and a heck of a lot more fun than breadboarding....wait, there's more! Kicad experts: check out PCBWAY's 2026 Kicad Design Contest--nice schwag and cash prizes may be yours.

Back to it....

PROOF OF CONCEPT

Since nobody codes any more I used Claude Code to put together the Arduino sketch for a 3 pot ADSR proof of concept--Attack, Sustain and Decay/Release--some bugs at first but easily fixed. 



The output worked surprisingly well--nice analog-sounding log response....I thought 8 bits wasn't going to get it done and the output would be "stair stepped" but it was fine.

For the PCB, there were a couple of stupid mistakes but overall this one was easy--maybe too easy.  

Testing the POC board with a dual MS20 filter (MS20 VCF post here). Overall the Proof of Concept single chip ADSR, using the C++ Earlevel library, worked a lot better than expected.

OUTRO

In general, all heavy lifting was done with the ATTINY1616--if I hard coded the ADSR values, jammed 5V from my bench supply into the MCU, and didn't care about input or output levels, this was literally a one-chip/$1USD design....if there's a lower parts count ADSR out there, I haven't seen it.

OK, whatever....the question, what to do next.  

The fact that the entire EG lives on a single inexpensive MCU means I can sprinkle the damn things all over--add it to a filter, add it to a VCA, add it to a mixer.  

But I also envision adding various logic outputs to this--end of attack, end of release--and using them to trigger other events.  

Also it should be easy to modify the DAC to produce linear outputs, log outputs, or whatever you want in-between.

Or, I could go full Behringer and rip off + remarket someone else's function generator design--how about The Intelligel Quadra (4 AR's with clever I/O) with expander, allowing VC of attack and decay, this module sold for something like $300 before being discontinued? I figure I could recreate it using a 4x ATTINY's for something like $30USD?  And add sustain to each of the 4 AR's?   

Make it itty bitty/Eurorack so only folks with tiny little fingers can use it.  

Finally, I'd need to say it was made by "Bellinger" and call it something like "Quad Fumer"--indeed, too easy.

  


KICAD 10: Hierarchical Sheets and Blocks: Lay 'Em Out Once, Use 'Em Over and Over

Readers: today's post assumes you have a working knowledge of Kicad, an incredible open source EDA program. If not, this post might be pea soup. Newbies: watch a great Kicad tutorial here.  And--previous audioDiWHY posts focusing on Kicad are here, here, here and here


I have read that good engineering is modular engineering. Is good audio synthesis modular audio synthesis? 

Not sure.

Kicad--our beloved schematic capture/PCB layout/simulation software--has recently added some great features in making bits of your previous designs reusable--a huge timesaver.  

Let's go over this.

"Hierarchical Sheets"

....let you put subcircuits into other designs, treating the subcircuit as a "black box"--don't worry what's in the box, just enjoy what it can do....you expose I/O between your black box and main design using "hierarchical labels."
  • Because I'm lazy, I will abbreviate hierarchical sheets going forward as "HS"
  • Create a new project, this will contain your HS.
  • In the schematic (.sch file), put whatever components you want in your HS--you are creating a normal schematic at this point.
  • For I/O you need to share outside your HS issue the command: "Place" > "add hierarchical labels"


  • Save the schematic.
Next--Create a new parent project; in the next few steps, we are going to embed the "HS" content into it.
  • In the parent's .sch file, click on this icon on the right:

  • using this tool, draw a box inside the parent schematic. 
  • You will see a blue box...this represents the HS:



  • A properties dialog appears (if you don't see it, select the "Untitled_Sheet" and then tap the letter "e".)
  • Give the HS a name
  •  in "sheetfile" click on the folder icon and navigate to the kicad_sch file you created initially, the one that contains your HS.

  • At this point you might see dialogs about using relative filenames and something about database tables being messed up (?).  
  • Pretend you didn't see any of that and click OK twice.
  • Still in the parent schematic, click on this icon on the right:

  • Click on the HS box; the I/O pins ("hierarchical labels") created in the the source .sch file appear in the parent schematic--they are placed sequentially
  • Create the rest of the parent schematic and wire it to your HS.
In the screenshot below I ran a DC simulation on a parent schematic containing a hierarchical sheet; the HS contained a single 100k resistor with "in" and "out" labels. 

The simulated DC voltages in dark red show that this works--the 100K resistor in the HS is hidden from view but is part of the simualtion.
This is an OC simulation--DC values--not to be confused with "OCD"
 


DESIGN BLOCKS

....allow you to create a subcircuit, save it in its own library, and import it into future designs. 

This feature showed up in Kicad 9 (See the video here). 

With Kicad 10, you can put schematic symbols/wires and PCB traces into a single design block.

And--again, due to indolence/laziness, I will call "design blocks" going forward "blocks". Have a nice day.  

Organizing blocks: Blocks are organized into libraries, same idea as Kicad symbols.  Each block is a folder containing a json description file and file(s) for the .sch and/or .pcb components.  

For both the people out there who are interested--get a zip of my custom blocks from Github, here.

Creating a block: select some or all of your design, then right click on "blocks" 




From the drop down, choose "Save Selection as Design Block"





But! Be careful about "hide library tree", if you click that, the entire block's user interface section disappears. This threw me at first. I had to go back to view > panels > design blocks to make it reappear.  
 
Tidbit: By clicking "New Library" you can also choose if you want the block to be visible in the current project only or globally (all projects); the default is global:


Viewing existing Blocks: from the schematic editor View > panels > make sure "design blocks" is checked.... you see something like this (your block names will be different....)


Using existing blocksDouble left click on a block, drag it into your schematic, creating a group of components and wires.

Editing blocks:

  • Select either PCB 
  • Right clock inside the block and say Grouping > ungroup
  • Edit.

Before



After: now it's editable components like everything else in the schematic.


NOW: A WORD FROM THIS BLOG'S SPONSOR

OK, you just created something awesome using these new Kicad 10 tools and need to get some PCB's, then get them assembled.

For this, check out this blog's sponsor, PCBWAY, who can fabricate the PCB's, do the component assembly, and then, do everything else.

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

And!!! Kicad Mavens (you must be if you've made it this far?): run, don't walk, and submit your Kicad masterpiece to PCBWAY'S Kicad PCB Design Contest--winners get cash and/or RPi goodies. Check out the contest here.

As always--you can help this blog by checking out the PCBWAY site.  Thank you!


SCHEMATICS AND FOOTPRINTS/TRACES IN ONE BLOCK--New to Kicad 10--How To Do This

Super useful--capture the schematic and layout of a subcircuit in a single block. However--work slowly and carefully. This feature is one of those "miss any step and the whole damn thing won't work" situation.  

The steps:

Creating the combo block--start with the schematic:
  • Create a schematic subcircuit with all the symbols, wires and values you want in your block.
  • Tool > create associations  
  • Make sure everything is OK, that all symbols have associated footprints and so on.
  • Create a block--for this let's call it europower w traces




Next, create the associated traces.
  • Go to PCB and update the PCB from footprint
  • The footprint appears
  • Draw in all traces you want to include in the combo block
  • Save the selected footprint and traces (you must select both!) as a block  (right click on block > save selection as block)
  • For the block name, type in the exact same name you used for the schematic block--this is case sensitive: in this case, "europower w traces"
  • Kicad 10 will ask "overwrite block"?  Say YES

To use it:
  • In your schematic, pick the block europower w traces and put it on the schematic
  • In your PCB, pick the same block europower w traces and put it on the pcb
  • Hit F8.  
  • If all goes well you will see a footprint with traces appear--the PCB and the schematic are "synced"--it's all wired up.
  • If you messed up, a new footprint will appear with no traces. Fiddlesticks! Try again, make sure to follow each step.
  • You can now grouping > ungroup your Schematic or PCB block and change things.  





Tidbit: I noticed when upgrading Kicad 9 > 10 I had to set the global blocks path manually.  Preferences > Manage Design Block libraries > global libraries:


For Kicad 10.0.1, I had to set the Nickname, the "Library Path" (where the global block libraries are stored--the local location might vary if you are using a cloud repo on different hosts), and the Library Format (pulldown to "Kicad") by hand for this to work. Not sure why this didn't come over with the rest of my preferences.  

OUTTRO

Think "She's so Heavy": another brilliant John Lennon time signature change, with rapid master tape cut.