Monday, February 18, 2019

Korg MS20 Filter--the Why in AudioDIWHY.....

OK this one drove me crazy. 

This should have been easy, we know that Rene Schmitz stuff sounds good (I have already built his "FEITW" ADSRs and his MS20 Ring Modulator) and I thought, let's try his MS20 filter.

Original MS20 filter

So: Did the Eagle design based on what's on Rene's site, put together a board layout, and sent off for fab. 

This is a pretty simple circuit and from a good looking schematic, from a smart synth DIY maven, why wouldn't it sound good?

You know how I sometimes post: worked first time?  This one most definitely didn't work first time. It didn't work for beans for at least 3 evenings--this got me to wonder, why not just buy someone else's filter design? Does a kit qualify as DIY (of course it does....but it's not enough torture for me?)

I used a 2x dual concentric pot PCB for filter #2 which I cut down from this PCB.

OK I built two and at first both builds passed audio but both filters sounded--wimpy.  Almost like a cheap stereo tone control, not that nice fat MS20 sound with dirt when you crank up the "Peak". I know Rene's designs are high quality, and a skinny sounding filter must be on me.

Building Filter #2....

After an evening with my scope I ended up tracing this to a stupid mistake: I copied the schematic wrong into Eagle!  I had drawn up a critical voltage divider incorrectly, which was causing a journey to 6db cutoff, wimp ass sounding low pass land. But the 8-28-18 PCB is still useful, although you have to do a trace cut and then do with some kludge wiring to get it sounding up to snuff.

But then again: what would DIY be without trace kludges?

If you're as big a masochist as I am, you can get my PCB design (the one needing a trace cut, 12-28-18, and fixed yet untested version, 1-9-19) here.  My website includes BOM, wiring suggestions, and info about the trace fix--what I think you'd need to know to make a working MS20 filter.

MS20 filter #1 finished, no decals yet, but it works and (I think) sounds Rene-errific

Great! we get that crunchy peak sound, fat lowpass and nice Korg growl!

Next I turned my attention to the second unit (two VCFs so I can HP + LP = bandpass? Two on the original MS20 right?) But even with the trace fix, the second MS20 filter had a strange problem--when I cranked the CV up the audio output went completely dead.

Damn! It took me 2 more evenings of comparing the working VCF to the broken one to figure out problem! I suspected a parts placement error, but after checking twice, no, everything is OK.  Bad IC?  No; swapped everything and no change. Could I live with a VCF just not eating any CV above about 4V DC?  No, not really.  And besides, #1 worked, so #2 needs to work the same way.

Arrg!  Too much shotgunning! 

Ended up tracing this to a wiring problem with one of the grounds:

Filter #2, turns out, the normal is the fault

Goes like this: for an MS20 OTA filter: if you want High pass, stick audio into one end of a critical cap. If you want low pass, ground the same end of the same cap and put your signal into the circuit's main input:

Not having room for a switch in a 1U Frac, I used a normal to ground the cap, and the normal had a cold solder joint!!! So when I put audio into the "LP" input, it would cut out at high CV.  If I put audio into the HP input, it wouldn't work at all. Not at all the way I would think this issue would manifest, but then again I am not an electron?

OK with all that sorted, I did a recorded the quickee demo, here.

Second MS20 filter works! Filter 2 has 2 mod inputs, I was going to use this as the primary filter of the two.

I have to wonder, was all of this worth it?  There are a ton of PCB's for MS20 filters already out there, did I really have to do my own PCB? I doubt it, really.  Hell, I could have just bought one of those MS20 repops, and if it went south, bug the PCB vendor for help right? Maybe not?

I think I just like to torture myself, building machines that I go crazy trying to fix over the course of 3 evenings. Welcome to the world of DIY.

I realized something important: I hate, hate, hate haatteee it when things I build don't work. More than I should. I'll have to ask my girlfriend, who is a mental health professional (really!) why this is, because really I have no idea. Was I dropped on my head at a young age?

Granted--too many fumes. I need a break.

Monday, February 4, 2019

ReneDSR: Fastest Envelope in the West, Finished; Sound file and Build Notes

Back Again!

I needed more ADSR's in my modular so I built some based on a very cool design from Rene Schmitz.....You may want to read part I of this post here., where I create the PCB, discuss what "Tau" means, show you useless bench build photos, and so on.

Left to right: finished modules: ReneDSR, Return of Son of ReneDSR, and Son of ReneDSR

Does capacitor size matter?  

That's the "rayson d'tre" for these builds, but?? From last time, the basic design of these sorts of ADSR's sends gate logic to an RC circuit.

Good news: 

 The size of the resistor and cap (the resistor being a pot and/or a resistor network) determine attack, decay, and release speed. So, should we build these with large caps and small pots?  Small pots and large caps? I think the jury is still out, because to me it all feels and sounds good. You can mix and match caps and pots here and have fun; the sun will still come up the next day.  And, set up right, either can provide mix-cutting, DJ boogeying, MDA popping sweaty bodies dancing w/ body-odor snappy synth decays.

I tried to create a very simple demo for these modules, and you can hear sound samples here.

About the sound sample--other than the WAV loops this is all my modular with ReneDSR:

00:00: multitracking 6 mono notes on a DAW (Ableton Live 10).  Attack time is set to minimum; release is set to max; it's a very fast attack (I didn't measure it on a scope, but you can hear, IMO anyway, it's a reasonably fast attack) with 23 second decay for VCA, and same for VCF.  I put a lot of rez on the filter to make the sweep more noticeable. You're hearing a 10uF cap and 2.2M audio taper decay pot creating the ever import tau (see the last post).

From this I get an MiniMoog's long release or maybe a Prophet 5-ish sound. I am happy.

00:33: Dual Osc bass line, maybe a bit of a Stevie Wonder? I always like that; Stevie and the late great George Duke are my all time favorite synth bass players. I remain happy.

00:55: Sequencer patterns. This is 2 sequences overlapped, making heavy use of ReneDSR's fast decay, without which the moving patterns sound mushy. I am not a big Gorgio Moroder sequencer guy but I know a lot of synth freaks out there are and for this the ReneDSR performs well.

01:44: Single Oscillator to VCF to VCA, with SonOfRene controlling the VCF and Return of Son of controlling the VCF cutoff.  In many mixes I find that a single OSC bass sounds sit better than dual or 3 osc basses. Maybe a bit Roland SH series sounding. Why not?

The Roland SH-5 has one of my all time favorite ADSRs.  From the shop manual, its a pretty simple design from those crazy and creative 70's Roland dudes, so a PCB maybe for a later build?

The Return of Son Of uses a 2.2uF cap and 3x dual gang 1M audio taper pots. Each switch selects very good control of a 1M audio taper pot; or, tap off the wiper of a 2M pot.  This allows for a good fast attack and decay with a longer release as needed.
Return of Son Of RenayDSR Switch Wiring.

Another build idea: In any Rene 2.2MB pot build, you might want to put the 2.2uF cap on a DPDT switch with say 10uF cap for longer decays and releases.  Or for 1MB pots, a 4.7uF and a 22uF.  You get the idea.

Front Panel didn't come out very well for ROSO, lumpy and bumpy, but it's good enough.

The other 2 units--ReneDSR and Son Of ReneDSR--are pretty much a straight builds of Rene's two design variations on his site.  The 1U device has 1MB audio taper pots for ADR and a 4.7 and 10uF cap on a DPDT switch with 100ohm resistors in series.  The second unit was featured in this post, and uses 2.2MB Audio taper pots, which can be a bit hard to find.

One more tidbit: Rene's design calls for CMOS 555 timer chips, I bought about 10, and couldn't get a single one to work in the 3 circuits you see here.  A standard 555 worked every time. So they may be something wrong with my PCB, or maybe I got a bad run of CMOS chips. Whatever--gotta move on.

Overall, a fun build, and more good sounding ADSRs were very much needed in my rig. 

So if you're looking around for an EZ ADSR that performs well, and is fun to build, this may be it. I have some extra PCBs from this project, if you want to do a board swap PM me via the electro-music forum, I am "cslammy" there.

And as always, don't breathe the fumes!

Saturday, January 19, 2019

Front Panels: The Technique So Far

Not only am I learning about electronics but also working with metal?

Here's a quick post about how I do this, hope I don't forget this in a couple of years. This technique (?) is good for drilling holes, reasonably accurately lined up, in flat metal prototype panels. Maybe not 1001 uses, but maybe more than one use.

First: I get my aluminum blanks from PCBWAY in China ("Alubase PCB").  Personally I use FrakRac format for my Audiodiwhy craziness but this should work for 5U, Euro, a one off front panel for a preamp, a 19" 2U panel for a power amp, or whatever.

Today I am building an ADSR and need extra drills for SPDT switches and the PCB bracket's 4/40 screws....

Using Eagle (but really any illustration program should work) I create a 1:1 drawing of the existing blank with existing holes, and add any extra holes that are needed.

Next I see if it all lines up--this one is getting close.

More alignment, but still not there.

Once aligned (or before) I can add pencil marks for anything else I want to drill. I am basically being lazy--it makes more sense to put this on the CAD drawing, but, oh well. Here, it's for the brackets to hold the PCB. A straightedge and ruler are friends for this.

In the words for my personal hero, Frank Zappa: here is the "crux of the biscuit": The glue on the left will attach the paper print out to the front of the panel, with enough stick to not come loose or tear during drilling. The solvent on the right will completely remove the paper template and any glue that doesn't come up when it's time to ditch the paper.  Warning: the solvent stinks to high heaven, so wear gloves or whatever, work outdoors, and as a last resort, try not to breathe the fumes.

All can be purchased at amazon, craft stores, hobby stores and the like.

I use a very small hand drill to create the pilot holes. These can be found on line or in hobby shops--the model airplane folks apparently use them quite a bit for instance. I have found that punches and the like can distort the metal panel's shape.

I invested in a small drill press and put it in my garage. Highly recommended. But!! Caution: Use sharp bits, and always wear gloves and eye protection with this tool--seriously, I have had some close calls here.

Here's a mock up of how things ended up this time. Pretty good, but not perfect! The left hole for the PCB got screwed up; the drill press skittered because I didn't have the bit tightened down enough.  Damn! Glad I was wearing gloves!  This time, I am going against every fiber of my mild OCD; I am going to try to leave it as-is. It's good for me!

Final mock up. Not bad for a prototype, in spite of the screwed up goof on the left. Damn! Oh well.  I need to finish the ADSR, and it's a 3 day weekend here in the US so maybe I will do some Lazertranning.

Moving on....happy drilling!

Friday, January 11, 2019

Programming Arduino in "Pure C": Now We're Playing with Power! First steps!!

Let's jump right into the why. 

I have been corresponding a bit with an audio DIY master: Grumble, from the electro-music DIY audio forum. Just when I think I've done something cool, I see what Grumble comes up with and shake my head: Wow, this guy's kung fu is unreal!

A lot of Grumble's projects (but not all) are digital in nature, using Atmel CPU's.

I was curious how some of his stuff works under the hood and Grumble was nice enough to send me some of his Atmel C code to study.

Hmm, not entirely what I expected. It seems his projects are too advanced to be easily crafted from Arduino's super friendly sketch programming language.  I started to dig in and found Grumble uses what professional microprocessor programmers call "pure C" instead.

Pure C: not a Citrus Product. I've also seen it called "raw C". So what's all this then? Arduino's sketch language is a library, written in C and C++, allowing us DIYers to do hard things quickly with user friendly code.

If you dig deeper into the C library for Arduino, you see a lot of code like Grumble's. That's because the Arduino sketch language itself is written in Pure C!  Here's the idea: let's cut Arduino's sugar coated, human friendly feel-good C library and instead use C in a stripped down, bare knuckle form.

Like it or not, Pure C's the way the big kids roll when programming MCUs.

OK, I need to roll up my sleeves and start learning. I'm a masochist for that.

Here's an example of Pure C. What the hell does this mean?

DDRD |= ( 1 < DDD4);  // answer: same as pinMode(4,OUTPUT);

Why read when there is YouTube? A really good (albeit lengthy) vid about "why to use pure C, what is pure C, how do I get Pure C, how do I make Pure C go, is here. For anyone with previous Arduino Sketch programming experience, I think the the vid is clear and easy to follow. Worth a look.

I watched the vid a couple of times and began to screw around with Pure C. here's what I've found so far:
  • You can code with the usual Arduino Sketch feel-good stuff in the Arduino IDE, and throw in dashes of Pure C as needed. It all works; the two can mix. UPDATE: not quite. I noticed to mix analogRead() statments into your pure C plus arduino library mixed masterpiece, you need to use void setup() for initialization, not int main() as shown in the code example below.
  • Does the usual SIM suspect, Tinkercad, work for Pure C development? Sort of. A vid showing Pure C on Tinkercad to get the immortal blinking LED to blink is here. But I could not get Tinkercad to work reliably beyond simple blink tests--for instance, using pure C to set up one of the simulated Atmel CPU's built in timers--all programmed in Pure C--caused the simulation to bog down in terms of performance to where I felt it wasn't useful.
  • Virtual Breadboard, as described in this post, works. Oddly, using the IDE to talk to an Amtel ATmega328P directly didn't, but using a Nano SIM, it did.  The developer told me a patch will be needed to have the Atmel SIM work but it's not available yet. Update: in version 6.08 of VBB I have verified that this is fixed.
  • I have found using a NANO V3, pure C programming experiments (which to date, for me, are mostly redos of the "blink the LED" sketch) work as expected. So I can take my existing breadboard setup, Jam-o a Nano, put Pure C code into Arduino IDE, compile, and upload. We're good!  

Took this picture between blinks, but the LED works....

Still with me?

If you want to play along at home: here's a rundown of some essentials I needed to get started with Pure C:

I needed the datasheet for the Atmel chip that constitutes the guts of the Arduino on my bench.  For me, it was an ATMEGA328P, data sheet for that is found here. Why? Pure C is all about finding bits in registers. These registers hold essential information like "is this pin an input or output?" "Do you want this pin high or low?" Flipping register bits is the key to making things work.

So, you need to understand what many registers and bits do.  No way around that. There are a whole ton of registers in all these Atmel CPUs.

I needed to see how my Arduino board is wired--really.  Pure C goes straight to the heart of an Arduino: the CPU itself. If a pin on the Atmel CPU isn't wired to the same pin on the Arduino PCB, or if the board has a different pin designation, your Pure C code may not work.

For the Nano I found the Nano Eagle schematic, here, which clearly shows which pin on the ATMEGA chip goes to which pin on the Arduino board. With that in hand I could successfully move LEDs around, change my pure C code, and still have them blink.

I needed a simple breadboard setup: Nano and an LED.

I needed to understand the strange statements you see over and over when reviewing pure C code. One we already saw:

DDRD |= ( 1 << DDD4);

This means, for register DDRD, put a 1 (high) into bit DDD4.  This specifically tells the Nano's CPU that pin D4 is going to be an Output.

Getting further into beginner's stuff:

You can OR these "bit shift" statements together:

DDRD =  ( 1 << DDD4) | ( 1 << DDD5) | ( 1 << DDD6) ;

Same idea, but we are putting a 1 in for bits 4, 5, and 6.  So D4, D5, D6 are outputs.

So how to make DDD4 a zero?  So DDD4 is an input? Use a NOT, also known as an XOR:

DDRD ^=(1 << DDD4); 

And another way to change DDD4 from 1 to a zero (so, flip things?)  This tests DDD4, if DDD4 already contains a 1, it makes DDD4 a zero. If it's a zero, make it a one.

DDRD &=~(1 << DDD4);

You also set the entire register--for instance, make every pin in the Pin Group D inputs. Here 0x00 means use hex (base 16) to set all the bits to zero.

DDRD = 0x00;

And this sets them all to one:

DDRD = 0xFF;

Tip (for me anyway?) Remember that even after you power cycle, the CPU chip "remembers" your register settings. Compiling and uploading code again won't change registry bits unless you specifically twiddle them.

Enough for now? Just with these few discoveries, I can already read small chunks of Grumbles code and maybe see what he's after. Go A's! To wrap up: Here is a Pure C program I wrote that compiles in Arduino IDE and flashes an LED. Works on my bench anyway. Remove comments, change 1's to 0's, etc., and have fun.


#define F_CPU16000000UL
#define myPin DDD2 //change 2 to whatever D group in you are using

my expanded pure C blink demo.  
Nano V3,0, with LED tied to pin D4; 
1K resistor between LED cathode and ground so to not fry the LED.
uncomment stuff to experiment.

int main()

/* all pins in D pin group are now input. For DDRD, 1 means output and 0 means input. */  
DDRD = B00000000;

/* we are putting a 1 into bit DD4 in the DDRD //register, making D4 on the nano an output. */  

DDRD |= (1<<myPin);  

/* make DDD4 (pin D4 on Nano) a zero, now it won't flash because it's an input.  So do the opposite of what I say. */
 // DDRD &=~(1 << myPin); 

/*test DDD4 to see if it's a one. If it's a zero, toggle the //bit to one.  If it's one, toggle to zero  */  
 // DDRD ^=(1 << myPin ); 


/* this will set all D pins but leave TX RX to output */
  //DDRD = DDRD | 0x00 ; 

/* this will set all D pins but TX RX to input */
  //DDRD = DDRD | 0xFF ; 

  /*Note: if you screw up TX and RX, 
   * which are part of the DDDx, DDRX, PINx" pin group mishpucha,
   * upload into your arduino a normal sketch with serial.begin().  this fixes it.

/* WHILE(1) is the same as the main repeat forever loop you see on arduino  */

 /*     PORTD=B11111111; 
//all port D pins (0-7) are now high.  
      /* I put in 200 to make sure I'm not running the default "blink" sketch. */
       PORTD=B00000000; //D2 is now low.  same exercise.

/* same way to do what we just did with 2 lines!  Go Pure C!

PORTD ^=(1 << myPin ); 

/* don't breathe the fumes */

Saturday, January 5, 2019

ReneDSR: Fastest Envelope in the West: Zen and the Art of Tau

Hello again, just finished a new module based on a custom PCB.  The original design seems pretty well known in the DIY synth audio community already: Rene Schmitz's "Fastest Envelope in the West".

Find his original page for this design here--scroll to the bottom of the page....

FADSRITW Prototype. No LazerTran front Panel Art yet, still testing it.

The Why in AudioDIWHY: I needed more ADSR's in my rig. What I have now works but doesn't always give me the super quick snappy decay I'd like.

I saw Rene's Fastest envelope schematic and thought "this will work!!"  Note that to me "fastest envelope" sounds postal and the acroymn is FEITW ("feeet-oo"?), so I am calling it "fastest ADSR" or FADSRITW or even FDITW "Fastest Decay in the West". For funk bass I like snappy filter decay and this will remind me to always tweak it down!!

I will use acronyms going forward, since I love acronyms.

 Here it is:

Eagle BRD and SCM files, wiring diagrams, PDFs used for my take on FADSRITW are available on my website, click here.

About the module: Rene describes a couple of variations of his design--one with 2.2M A,D,R pots, another with 1M pots. Increase the the cap value if you decrease the pot value. To me, with analog envelope devices, the size of the cap creating the "TAU" (which, my EE brother explained to me, is simply the R*C value used as the heart of the ADSR) matters.

Let's examine this phenomena:

Warning: Math zone ahead. Math?  Did I say math?  Yes, math.  As much as I'd like, I can't do electronics DIY and completely dismiss math. Maybe none of us can? Sorry! I was pretty good at math in college (when Madonna ruled the airwaves and dinosaurs roamed the earth) and have since forgotten most all of it, however the math here seems relatively easy: No imaginary numbers! Euler's number (I remembered that!!) Exponents, I remember those as well! like it that way.

OK for ReneADSR decay here's the formula to compute your decay control voltage:

V = S*(e^(-t/RC))


V is the voltage at any given time--what we are after.
e is Eular's number (about 2.718), so, a constant
^ means "raised to a power of what follows", so, e raised to -t divided by R*C
-t is (time * -1).
RC is the resistance * capacitance.  That's TAU, baby!
S is the voltage at time = 0

If you plug this into a graphing program like this very cool one you get beautiful curves:

You take that voltage changing over time, and plug it into an appropriately designed VCA or VCF (such as this one, Matohiko Takeda's "Farm VCA") And: Aaaahhhh! The classic Moog/Roland analog synth sound awaits! That's what I am talking about!

I don't know about you, but a good sounding ADSR > VCF curve makes me very happy indeed.

Slight aside: TAU is a Greek Letter and looks like the PI symbol that is missing a leg or pi cut in half:

It  means something different in mathematics, or biology, or astrophysics, or whatever; ditch the RC crapola if you're not a physicist? Tau means way different things to different scientists! This confused the hell out of me for a bit. You learn something every day eh?

OK back to it: from the equation above, it shouldn't matter if R gets big as long as C gets small right? Within reason perhaps. That's basic math. But again, that's not how it sounds to me. So what sounds best, really?

Guess we'll find out.

I built my first FDITW using 2.2M pots I found on Ebay (linear taper). 2.2M pots are not at all easy to find, but I found 'em, they arrived via eBay from China and 5 minutes later were soldered into the prototype. Yep! Worked first time!

Honking big 2M2 pot. The US dime to left, for nonUSAers playing along at home, is approx. 17.9mm in diameter. 

obligatory on the bench shot.

Can't find the pots? In an ElectroMusic forum post, DIY mensch donpachi lays down a cool trick for getting 2M out of a dual gang 1M audio taper pot:

I put this on the bench, and it works, but, if there is a +/- 20% error on each pot you might have -40% error overall, giving you a < 2M pot not 2M, so choose your pots accordingly. I dug some 1M dual gang audio tapers out of my junk box and pachi'd them in, replacing the linear taper honkers. To me, the FADSRITW sounds more musical with audio taper pots for A, D and R. I also jammed in a switch to select 2.2uF and 10uF to switch-a-tau. Overall another very fun build. You can get the Eagle stuff, etc. here.

One more tid-bit. For some reason, I got the circuit to work w/ a standard 555 IC, but not a CMOS 7555. No idea why. I will build more of these and see if I can track that one down.

Going forward: I went online and bought some 1M audio taper pots from Small Bear. Waiting for those as I write this post.  I will build another FASDRITW with 1M, 100 ohm resistors vs. the 220's and maybe some other TAU-values (taulues?).  I'll also post some sound samples.  But no, no scope snaps. My eyes always confuse matters like these. The question: What sounds best, really? I figure the different RC combos will sound exactly the same but who knows. Until then, DBTF.  See ya.

Wednesday, December 26, 2018

4051 CMOS Voltage Controlled Switch--bringing together ATTINY, VBB Simulator, Zener Clamping in a Single Post

I had 4 days off from work for the holidays so it seemed a good time to close out a few topics and actually build something.  Wait? Build something?  Yes....

topics that need closure:

First, ATTINY Atmel chips in DIY audio.  When (small) size matters, these chips are amazing, and amazingly inexpensive. Think of an Arduino the size of an 8 pin op amp!  Yeh!

I have already written about these in this post: introduction, setting them up, how to program them, etc.; as well as this one: Pros and Cons. Why use ATTINY vs. something else? And finally here: interrupts (useful for all Arduino audio DIY perhaps, examples are for ATTINY85).

Second: The Virtual BreadBoard (VBB) simulator.  I simulate a CMOS/CV controllable switch toward the bottom of this post.  With the simulation successfully running, I made it into a working DIY synthesizer module with minimal breadboarding.

The 4051 switch

Third: Clamping. What is the best way to get CV or audio into an Arduino Analog in without potentially frying things? (Answer--getting ahead--using zeners is the best thing I could find)

And of course, the inevitable "probably useless to anyone but me" build notes along with photos.  And: the obligatory sound sample of the module: here. The vid below captures a small part of the demo as it was being recorded. You've been warned!

OK let's get started:

In case you don't already know the 4051 CMOS MUX chip is super useful to Audio DIY.  Think of a solid state switch that can select 8 sources and, using 4 logic lines, output the chosen source to a single common pin. Or send the one source to 8 outputs--same idea.

Along with the 4051's cousins, the 4052 and 4053, these are staples of the audio world; you can see the 4051 at work here and here for instance.

But I had never built anything w/ any of them and it was time for that to change.

Along the way there were a few challenges to overcome:

Buffering.You probably won't need to buffer Arduino logic to a CMOS chip, but that's not what we are exclusively doing here. We are connecting analog CV and audio to a CMOS chips' input pins, and it's a fair bet you can't plug a 4051 I/O pin directly into a 120V AC socket and have the IO pin live to tell the tale. To solve this (and no, please don't really plug your 4051 to your house mains, bad idea!) I used a 1N5231 zener diode and op amp.  More in a bit.

Powering the 4051. Notably the 4051 has 3 power inputs--VSS, VDD, and VEE, for negative supply volts, positive, and ground, respectively.  So you can switch bipolar AC audio through the chip if you set up its power and logic levels correctly.  I don't use bipolar switching for this module but it's good to know you can.

From messing on the bench, the signals sent to VSS, VDD, and VEE determine the amount of voltage needed to equal "HIGH" in digital logic-land. To make this module easier to build I used 0 to 5V to power the ATTINY; logic and power for the 4051 is 0 to 5V as well. I have adequate level shifting and bias voltage offset circuits (previous posts here and here) elsewhere on my modular so this works for me.

But: if I used a 2u panel I would have gone for +5 for VSS, ground for VEE, and -12 for VDD. That allows a 10V bipolar analog signal to get through the switch relatively unscathed. The switch action is still controlled by 5V logic. This is an interesting configuration for future 4051 builds. More at this forum post.

About the module: Design goals are to allow 4 CV inputs switched to 1 output using a pot or 0-5V CV; LED's to display which channel is selected, and use of an Atmel ATTINY vs. all the other Arduinos, comparators, op amps, relays, etc., that could do this. Cram all this behind a 1U FracRak panel. And of course, recycle code from Virtual Breadboard--see the post on VBB here, that's what started all of this.

Block diagram for this module....

I used a new experimenter PCB for this project. I call the board an "ATTINYfactory" which you can see on my website. The idea is one size fits all for whatever ATTINY DIY audio project I conjure up. Some of them anyway.

If you go to the site, feel free to download the eagle files, send em off to get fabbed etc. if you want, or do whatever. If you use it or modify it please comment below and I'll post whatever you come up with. Or, p-m me: cslammy on the electromusic forum. I can probably send you a leftover if I have one.

For a change, there were no major mistakes on the REV1 board, however, the V+ on the bottom right, directly below the ATTINY chip, is wired for +5V not +15.  Should have labeled that better.....

The "ATTINYFACTORY" board, Rev1.  Rev2 already in the works....

Buffering and zeners. Atmel MCUs will accept decent amounts of current+voltage at their input pins, and can source decent amounts of current at output, but you run the risk of blowing up the pin if you get too crazy. After some discussion with fellow synth nerds and a bit of time on the bench, using a zener diode to clamp the output of an op amp is easy, and can limit current fed into the Atmel MCU to something safe.

The basic idea: slap a 5V zener between ground and the side of a resistor facing away from an op amp:

R6 has to be chosen to not exceed the wattage (V x Current) of the upstream signal, but for most of what we do a standard 1/4 watt 100K is fine. If you don't have 100K, use something bigger--470K or 1M will work. 

The op amp has very high impedance at its non inverting, virtual ground input, so it doesn't care what is upstream really. For this project I used 1N5231's for 5V.  Seems to have worked.

Good news is that 1N5231s are small and were easy to kludge into a quad non inverting buffer.

I just noticed the extra crappy soldering job for IN1, but hey, it works....

I tried other clamps--such as a rail to rail op amps, but they didn't work as well. The easy solution wins out again.

OK time to build--first I drilled out a PCBWAY fabbed "alubase" front panel to accept the LEDs. I used Eagle to create the LED legend at 200mils apart, printed out the legend, and taped it to the front panel.

The input jack and LEDs on the right were fabricated on perfboard.Yes I still use perf.....rarely.
Next, whamboozle it with a drill press:

And check to make sure the ATTINY circuit originally crafted on VBB works in the real world when modified for ATTINY...yes, it does!  If you want to review the code it's on GITHUB.

Let's gather up all the daughter boards....I have lots of op amp mini boards already fabbed.

Now it's a matter of assembling all of it, documentation for the entire module is here. Lots of wiring as usual. Easier than creating "skiff" PCBs and then just having to kludge the crap out of it? Because pots go the wrong way? The LEDS light up backwards?  Maybe. Maybe not. A couple of times I wondered "will this ever get done?" because of all the 22 gauge hook up wire used.  I have to cut down on the amount of wire I use in these one-off prototypes!

Test fitting some of the boards.  Will it fit into 1U?
Almost done.  The 4x op amp board fits best in back.  The TL081 output board is soldered to the side.

Christmas Day in the evening I tested the finished module. CMOS.  CMOS run.

One LED didn't work (bad solder to the perf) and I had the CV buffer board VSS wired incorrectly so the A1 pin on the ATTINY wasn't seeing anything at all. Easy to trace the signal with a scope and fix both of these--took only a few minutes. Now it all works.  I just have to Lazertran this and another one is in the bag. This one was fun!

Ready to test....

Update: about the sound clip for this module. I thought the 4051 switch would be good primarily for slowly switching CV's for VCO and VCF modulation but it turns out it's powerful being switched at audio speeds, turning this odd module into a very strange waveform generator (VSWG). 

Everything on the sound clip was created this way. Switch input sources are various combinations of pink noise, mad bees, aconitum noise, a 40106 oscillator,  LFO outputs, ground (so, no sound, causing a gap in the waveform produced), and various DC voltages (so odd square waves are produced) as well as the usual sine waves, ramp, pulse, and triangle. 

To generate the 0 to 5V CV to switch between inputs I used a audio frequency random gate, aconitum noise, a 13700 TH-VCO (ramp worked best; sweeping the 4051 switch CV with audio slowing to low frequency proved interesting), and CV controlled variable tempo square wave LFO's at near audio frequency. The trick seemed to be to make the 4051 sweep through its four inputs hundreds to thousands of times a second vs. just some boring CV at input swept every few seconds. Sometimes in a linear fashion; sometimes randomly.  The 4051 can work fast!  Makes me wonder what an 8 channel version of this would sound like?

As usual no DAW tricks to get this sounding the way it sounds here, this is pretty all my analog DIY synthesizer.  I did roll off some low and high EQ and add a touch of reverb here and there to keep speakers from frying. 

OK that's it for another round.  Not sure what is up next, always so much to do, so little time....I could see doing a 16 channel version of this with CV in (ramp to make it go 1 to 16, sawtooth for 16 to 1? Random for random?and clock in as well; use it as a easy sequencer? As an audio oscillator if you pushed the 4051 to switch really fast? Not sure.

The Christmas holiday is over with New Years coming up. A few more days off work. There was a time when every new years I was out playing, but no longer. Maybe that's for the best, now I can enjoy the holiday at home with my new family. Until next time, Rudolph: it's the holiday--don't breathe the fumes for a change.

Sunday, December 16, 2018

Virtual Bread Board: Simulate Your Trip to the Land of Lunetta

Howdy again. 

Another post for the world of AudioDIY and Arduino.

This time let's look at a new Simulator I have been messing with called Virtual Breadboard or VBB.

The background:

I stumbled upon VBB while messing around with unrelated programming at my day job. It's a really cool SIM but not nearly as straightforward to use as say Tinkercad--VBB does a lot more, but with that comes more complexity.

However, the more I use VBB the more I like it.

And, I wanted to write down how I got VBB to work with the Arduino IDE.

Hence this post.

Goes like this:

Tinkercad Circuits is cool but lacks a wide range of CMOS chips to play around with. And you know how we Audio DIY folks love CMOS--the 4051, the 4049, the 4066--on and on! they are our friends.

For this let's take a look at VBB:

 First the bad news:
  •  For SIMS using Arduino, VBB costs $30 per year. The free version doesn't support Arduino. That may not break the bank--and once you get VBB going you get a hell of a lot for $30 a year--but it's notable that it costs anything at all considering that TinkerCad Circuits is free. But then, this Blog is free as well. Boing! Take that!
  •  VBB is only available through the Microsoft Store for Windows OS. I try to remain positive at all times and as a Linux guy I look at that like this: I figure VBB is maintained by one or two programmers (?), working out of a garage or basement maybe, so don't expect VBB to have an huge army of programmers porting VBB to every platform out there you can think of.  So, Marky Mark: Swallow your pride and get Windows going....
  • VBB is not documented well by 3rd parties on Youtube, including some baffling tutorial videos that I couldn't follow at all. I mean what the hell is this? it seems to demonstrate VBB and Arduino, using methodology pretty far from the VBB tutorial, and using an Atmel chip that the current software doesn't seem to contain. hello?
  • VBB almost exclusively simulates digital circuits, not analog ones.  There are no op amp chips for instance in VBB. There are in Tinkercad and Fritzing. This makes VBB good for banging together things using CMOS and 74xx chips, but not analog simulations of VCAs for instance. However there is a "function" component in VBB that can be used to (say) add two voltages together--op amp type stuff. Really, that alone is very cool indeed. Maybe a topic for another post?
 Now the good stuff:
  •  VBB includes a whole crapload of CMOS chips to mess with, along with function generators (squarewave only), voltmeters, PWM,  D to A, and other goodies very useful to Audio DIY folk and Lunetta devotees like me:
This is only some of it!!!

  • Like Tinkercad Circuits, you can program your SIM with the Arduino IDE (once you set things up correctly, more about that in a bit.) 
  • VBB doesn't bog down as badly as Tinkercad under normal to heavy use.
  • Unlike Fritzing, VBB is currently maintained.
  • VBB includes a few extremely useful I2C chips for Audiodiy in its SIM mishpucha including the Maxim DS1803 digital pot. Very Nice! 
  • Since the SIM runs off compiled Atmel binary code, if you can find the library for whatever you are doing, and can successfully compile your sketch, you can probably use it in your SiM. This is worth the cost of admission alone! 
  • I wrote to VBB tech support a few times now and the tech there got back to me superfast--like, a few times, within an hour.  Wow! that's unusual in the tech support world!!  Hats are off!

So how to get this set up with Arduino IDE?  VBB is natively a java app, not C, so you have to tweak things a bit to get the good old Arduino IDE C programming going.

This tutorial explains how to do it; but I reiterate and perhaps simplify it a bit

Here's the quick way to get this software set up to program using the Arduino IDE--

  • You have to have Windows 8+; I use Windows 10 Pro.
  • Download VBB from MS store and if you want to part with dough (I did--it's worth it) purchase the $30 a year Proplan.  The free version of VBB doesn't support Arduino...
  • Create a username and password for the VBB "cloud site", You will need these credentials later to launch the desktop version of the software.
  •  download the VBB desktop app here.  For this blog post, we are going to use the desktop version, not the cloud version, of the software.

The VBB Cloud app. Cool, but for this post I focus on integrating the Arduino IDE with the desktop version of the app


  • Download and install the latest Arduino IDE on the Windows 10 system you will use for your VBB simulations. No, VBB doesn't have the Arduino IDE "built in" the way Tinkercad or Fritzing have to install it.
  • On this same Windows system, make sure if you double click a .INO file the Arduino IDE opens, not something else like Notepad or Wordpad.  So create a file called "test.ino", save it, double click on it, and see what happens.  If double clicking an INO file doesn't open the Arduino IDE, follow the directions here to fix it so it does.
  • Create a basic sketch in Arduino.  It can be anything--blank sketch, with setup and void and nothing else, that is good enough. For what I am writing here, I use the blink demo sketch as proof of concept.  I call it blink3.ino since I already had a blink.ino file on my HD.

In the Arduino IDE, issue the command Sketch > export compiled Binary:

  • Give the hex file/project folder/ino file a name salient to your project, again I called this "Blink3"
  • Store the compiled hex file on your system's hard drive (I use Dropbox--same thing)
  • Note where you store the hex file.  Write it down in notepad for instance. You will need to find this hex file again later.
  • Open VBB desktop, enter the username and password you crafted when you paid the $30.
  • When running VBB for the first time, I got a bunch of warnings that VBB.exe isn't certified by MS, might be a virus, might be ransomeware etc. Sorry. Keep going.
  • Once open, make sure your VBB SIM is in Single panel mode. See the screenshot below. 

This icon is found in the top right of the main VBB screen.

  • Create a new VBB sim project, add a Arduino Uno, an LED on PIN13 and a 1K resistor like this. You can get more information about adding parts to a VBB SIM project from this tutorial; it's pretty straightforward.  Note we are using pin 13 connected to the resistor to the LED anode.

  • Left click on the UNO board in the SIM, selecting it.

  • In the VBB panel on the right, go to the properties dialog for the UNO and make sure "Java App" is set to sleep and "AVR App" is set to "Arduino IDE monitor".  This is on the right part of the screen.  You left click on the "..." icon to change that:

  • File > Save the VBB SIM to some location (doesn't really matter where) as "Blink3" and note its location.

Now, the trickiest part of the whole process:

  • Close VBB after creating your SIM project.

  • Open Windows File Explorer:  Right click Windows icon >  left click "File explorer"

  • Find the files that VBB created above.

  • The files are going to have the extension .SIM, .VSM. and .VBB

  • Copy all 3 of  them to the location of the Arduino ino and hex files you created when initially making your blink3 sketch.  It all has to be in one folder!

  • Important--the .SIM, .VSM, .HEX, and .INO files have to all have the same file name.  Not the same extensions obviously; and the exception here is the .VBB file. So if this isn't working, close all apps, reopen file explorer, and make sure all files that end with .ino, .hex, .sim, and .vsm all have the same filename; if not, rename things.  The screenshot immediately below gives you an idea of what I mean.

Now you see why you needed to note each folder's location right?

OK with everything in one directory we can actually run the Simulation:

  • reopen the VBB app
  • File > open > browse to the SIM VSM file you just copied, so in my case I am opening blink3.VSM

  • Run your SIM by clicking on the power icon.

Run Icon is in the top left corner

The LED should blink, It did for me!  Yes you programmed this blink simulation action by creating the hex dump and then having VBB read it--you programmed the SIM with the Arduino IDE.


Now make sure you can change things:

  • Go to your Arduino IDE (It's outside VBB--you have to have both running at once--you can alt + tab to it) and change something.  Say make the "LOW" 100 MS sleep but leave HIGH at 1000:

  • In the Arduino IDE, Reissue the command Sketch > Export Compiled Binary

  • This overwrites the hex file you created at the beginning of this whole process.
  • You don't have to do anything to VBB--just leave it running. The blinker rate is now 1000 on then 100 ms off, give or take.  The code change will be visible almost immediately--
    "Export compiled Binary" is essentially the same as uploading code to a "real" Arduino from your PC.
So here is in a nutshell what you do to change either the components in the SIM or the sketch controlling it:
  • Make changes to the IDE and issue Sketch > export compiled Binary
  • Make changes to the VBB SIM project and file > save 
  • Run the SIM in VBB.  
  • If you're just changing code, you don't have to stop the VBB Simulation; if you want to swap out parts on your virtual breadboard, you will have to stop the SIM, make your changes, and restart the SIM.
  • In any event as long as everything "lives" in the same folder, one component will be in synch with the other.  Go A's!

UPDATE: To further understand VBB, I simulated a 5 Channel 4051 CMOS based audio/CV switcher. Incoming 0-5V CV determines which channel at input is sent to a common output.  This is a very simple circuit if you use an Arduino and was easy to implement using VBB. In a future post I will give more details but the sim looks like this--and I'll try to build a "real" module, that I can use in my modular synthesizer, based on this SIM, in the next few weeks.

A slider is used to send 0-5V to A0 of an Uno. 0-1V connects in 0 to the common out; 1-2V sends in 1 to out, and so on.

UPDATE: I got confused by how to see variable values in VBB, display things to the serial monitor, etc. but I was overthinking things. It's easy. Hook up the VBB terminal to RX and TX ports as shown below,  RX to TX and TX to RX, set everything to work at 57600 baud, and then use serial.begin etc. for Arduino as documented here. Works great!  

OK enough for one post. Next time (or one of these times soon) I will have more SIMs to show--a CV to 4066 switcher and a trigger delay module, both of which I need in my DIY modular, like, right now.

Until next time, breathe the fumes, but only the simulated ones!

Korg MS20 Filter--the Why in AudioDIWHY.....

OK this one drove me crazy.  This should have been easy, we know that Rene Schmitz stuff sounds good (I have already built his "FEI...