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.
  • 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.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////



#include<avr/io.h>
#define F_CPU16000000UL
#define myPin DDD2 //change 2 to whatever D group in you are using
#include<util/delay.h>

/*
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 ); 


// BONUS COMMAND USING HEX vs. BIT TWIDDLING.

/* 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  */
  
     while(1)
     {

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

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

PORTD ^=(1 << myPin ); 
     _delay_ms(1000); 
     }
  }

/* don't breathe the fumes */

Saturday, January 5, 2019

ReneDSR: Fastest ADSR 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 ADSR 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 FADSRITW (I will use this acronym going forward, since I love acronyms) and thought "this will work".

 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))

where:

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 FADSRITW 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...so:

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", virtualbreadboard.io. 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


Next:

  • 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 does....you 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.

Cool!!!!

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!




Monday, December 10, 2018

ReverselandFill "Aconitum" Noise Board--Augmented with C1406HA VC Attenuation--Finished!

Hello again fellow readers and audio nerds.  This post: Time to finish off the Reverselandfill "Aconitum" board for my DIY modular synthesizer.

If you want to skip what's below and just hear what the module sounds like finished, that's here.

Also: Part one of this post is here. You are going to want to at least skim the first post or the rest of this one may not make much sense....

Getting to it: after a PCB swap with Reverselandfill's Martijn Verhallen he was nice enough to send me the eagle schematic for his analog noise mixer so I could understand how it works.

His "Aconitum" noise board is designed something like this (it's more complicated, but this is the basic idea):
Simplified block diagram of reverselandfill's Aconitum noise board

An NPN "avalanche" transistor gets sent through a couple of extremely musical passive variable filters, then mixed with two inverting op amp stages in series. There are accommodations for jacks and pots on the PCB, making it a good fit for your Eurorack modular synth.

NB: Martijn must have worked really hard on this design...."box stock" it's a really good sounding board. The filters yield extremely useful timbres for things like rain, wind, surf, everything between, all the way to frying bacon and back.

But "in spite of good tone, I can't leave anything alone?"  For extra headaches I stuck C1406HA attenuator SIPS in series and added a 4th input for external sounds like this:

I could have used VCAs for this.... but trying something new was more torture and thus more desirable.

See more about C1406HA's from my last post about this project; in general the C1406 is an easy to implement voltage controlled dual attenuator SIP IC--in goes audio and CV; out comes audio levels based on CV--the more CV, the more attenuation.  It's like a VCA that can only cut amplitude, not boost it.

One of the challenges for this build (other than some bonehead mistakes on my PCB--more about that in a bit) is that I use FrakRac and Martijn, like many more sane DIYers, uses the much more popular Eurorack format. So I had to piggy back my board below his to make this fit in my rack:


Thank goodness for 4/40 hardware?


Once I got all that bolted together, I separated out the boards and panel and got to work with stuffing and wiring them.

Aconitum board is on the right; my custom panel and quad attenuator PCB on the left.

Let's get building (finally): First I wired up the Aconitum board and powered it up so I could hear it:



Good news here: Martijn's board is flawless--no mistakes--nevertheless, he emailed me a few times to say he is improving it....cool! Martijn also PM'd me to say that he owes the legendary Thomas Henry and Ken Stone for design ideas for the Aconitum board.....if you get your hands on this board, for me it worked with +/- 15V without any mods, even though it's designed for +/- 12V.

Next I wired up my REV1 C1406HA quad attenuator PCB fresh off the DHL boat; and this is where my problems began:

The original schematic--anyone interested, I will post it in Eagle and PDF....


C1406board Rev1: a Plague of Locusts.  Here I've already fixed the power silkscreen issue.....

I rushed this design and fab and made some really stupid mistakes:

  • the V++ and Ground silkscreens on REV1 of the board are drawn backwards. Really?  Um, yep! Traces are OK but the silkscreen says to wire the power supply's V++ to Ground and visa versa.  Doh!! Nothing blew up, but my board obviously didn't work at all until that was straightened out. It took me an evening of head scratching to figure the errors of my ways....it was such a dumb mistake it took me a while to realize, hey, everything is backwards!
  • I forgot to put 100K resistors at the "output side" of the 1406 output decoupling caps. Since these caps are tied to a TL084 (super high impedance inputs right?) there was nowhere for the current to go so the decoupling basically didn't work at all, and I still had a DC offset at output. That's something my first tech boss always told me: always give current somewhere to go!  You'd think after 30 years I'd get this right, but, nope. OK kludged some 100K's on the bottom of the board....now the cap coupling works--fixed.
  • the C1406HA can't really support 10V P/P.  So its input needs to be gained down, while its output needs to be gained up. That remained unfixed; I just have to watch pegging the C1406, but I guess sometimes the pegging doesn't sound that bad (but often it does).  I'll put 6db gain at output I think on the next run. See R21 circled below--this is the standard 6db gain op amp configuration, that's the idea.

Some schematic detail about the resistor issue:


You need resistors (R13, R14, etc) to have upstream capacitor decoupling work!

...and my original design didn't have these!


OK I kludged/fixed all those mistakes.  Yes it's a pain to have to kludge prototype boards, but perf boarding all this would have been way more work.....

For those who want to share the pain: I have a revised board ready to be fabbed--as usual, any takers on trying the improved one out? no takers? OK I will get to checking REV2 one of these days, but the REV1 board works, anyway, after I have fixed all the DUMB ASS MISTAKES. I might make a smaller stereo version as well....

Moving on:





I wired the two boards together--a lot of wiring, but nothing too difficult.  

All done but no panel decal; ready for testing

The good news is after all of this I got (I think) some really good sounds out of this board.  Take a listen on Soundcloud here.

Details about the demo:

As usual the demo was made fast, fast, fast.  If I can do this in a few minutes, you should be able to better in say 15 minutes right?

00:00 to 00:28
: Surf part I. Each noise source in Aconitum went though an its internal passive filter then through the Aconitum's built in mixer. The wave crashes were produced by a slow random gate generator which was fed into an ADSR, which was then used to produce CV; that CV attenuated noise ("Tone1") using a C1406HA CV controlled attenuator. Tone1 was set to a very bassy, boomy filter sound. NOTE: I cheated a bit on this one: a tiny bit of phase shifting, reverb and bandpass filtering was used in series with the output to make it the aconitum sound a bit more "other world" but you can get good surf sounds stock right out of box (listen to the last cut of this demo?).

00:30 to 00:45: LFOs feeding the 1406 attenuator. Each of the 3 Aconitum noise sources had a different LFO input attenuating noise. The output of the Aconitum's mixer section went into a vactrol bandpass filter, getting rid of very high and very low frequencies so your speakers and ears aren't destroyed.  With some screwing around I probably could have gotten close to the Apocalypse Now "Helicopter Whup sound", maybe for another day.

00:45 to 01:00 same thing as 30 to 45, but different LFO settings. The "sprinkler" sounds were created by using a CV controlled LFO.

1:05 to 1:30: I put a drum machine snare and kick outs into envelope followers and used that to trigger ADSRs which fed the C1406HA attenuators. The kick and snare noise sounds you hear are substitutes for a 707 kick and snare. The hat sound was fed into the "external" attenuator channel and passed through to the aconitum's mixer.

1:35 to 1:45: A byproduct of setting up the gun range sound (which comes next). Fast Random gates hitting the noise attenuators and also throwing the sound into a stereo panner that was very quickly panning between L and R channels. Produces a frying bacon sort of sound.

1:45 to 2:15:  The gun range. Each output of the aconitum (noise, tone1, tone2) was fed into 3 VCF's and 3 VCA's.  The VCA's were modulated by ADSRs, each of which was driven by its own random gate. this went into an external mixer and into my recorder.

2:15 to 2:40: Same as 00:00 sound but I changed parameters to make it sound more like traditional surf.

BACK TO THE BUILD: Final step after testing and seeing what it can do was to decal it.  


Ok that's it for now.....Overall this modified board swap module was a lot of work but I had a lot of fun building it, and it's already become a really useful addition to my DIY modular synth. I think it sounds really good!

Not sure what I will work on next but the MCU world is calling me again. My girlfriend (who btw is a mental health professional) says I have become too obsessed with DIY, and I need to take a break, so I am almost done w/ week one of a two week lull.  Did I breathe too many fumes? Maybe! And always remember: "Sanity is relative".

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...