Thursday, May 20, 2021

AVR based Dirty Digital LFO--Written in Embedded C--Welcome to the Land of the Missing Blog Readers

Finally! after weeks coding, building and debugging a fully digital voltage controlled LFO module, it's done, it works, and ready to be racked.

Mod Synth LFO module based on an Atmel 328P, written entirely in embedded C.


The land of missing readers--what? This module was developed entirely in embedded C, read more about that in an earlier post; here. Many thanks to audio diy legend Grumble aka "BigDutchEd" for inspiring the switch to embedded C.

I figure most hobbyists won't want to build this LFO, or even read its underlying code, since it's not based on Arduino hardware and its Sketch programming language, Micropython, CircuitPython, mbed, or other high level languages, all aimed at makers who would rather "just build things".  

That's understandable and of course is A-OK, but it's not where I am coming from.  

For me this entire pursuit is about learning. How do these gizmos work, really? Otherwise, I'd build kits or even better, buy a lot of ready to rack audio gear from these guys.

So if you are curious about embedded C  and want to see how this works, or maybe even build C based audio modules (right?) check out my github page here.  It contains eagle files, wiring diagrams, PDFs, all the current C code, and all the rest, for this dirty LFO design to date.

ready to test....


About the Dirty Digital LFO: The "normal" way to code this would be to create an array of values and the walk the array to send the values to a DAC. Walk the array faster, by skipping memory cells, for higher frequencies. 

Something like this I figure is used on a lot of the commercial "ROMplers" and digital audio/CV generators out there now, and there are a whole lot of them available for purchase. 

Since this is diWHY--where it's OK to try something "different"--I tried to dream up an LFO that doesn't use a lookup table. 

The resulting output I figured would be gritty and distorted sounding, but at least it won't end up working and sounding the same as every other LFO out there. 

More info about the basics of how I made this work and software design choices are here. The simple 328P PCB--which cannot easily run Arduino sketches BTW, just C and C++ code--is discussed here.

OK let's make a simple synth module out of this.

This is still extremely experimental, so right away I know I want to use a more forgiving format than Euro--as usual, I used FRAC, which is cheap, super simple, butt ugly, and best of all, has no practical depth limitations for PCBs. 

I tried to make operation of this module simple as well--a 0-5V CV input to control output frequency, an output jack, a toggle switch to select course output frequency; a momentary switch (inspired by Mutable Instruments) that selects a waveform and lights corresponding LEDs, and pots to control frequency at input and offset voltage at output. 

 

The board in the center is a "mini AVR board", post is here.  Left is the PCB that lives behind the front panel.  Right are 2u Frac "blanks" for the front panel design.


Does the Dirty Digital LFO make balloon animals? 
No. The triangle wave still only goes to 22hz, but i can probably figure out a way to improve this (software based hardware builds--they are never done.)  As predicted, this LFO has an 8 or less bit grainy sound which is cool in its own way. Cleaned up with some lubrication when it needs to sound "more analog", but yes, it's definitely diff-rent.

I can also add other waveforms in the future--sawtooth? random? Stairstep? Sample/hold? In my addled mind I think this won't be hard to code--but finding the time may be. Overall, I tried to make the code as modular as I could, which is what I think C is designed for, and ads/changes should be relatively easy to add as I think them up.

The front panel used was built on a PCB; not metal, to save time and cost. How-to posts for that are here and here.  


For this prototype I printed out the PCB for the buffer circuit and taped it to a blank front panel.  Then drilled out the panel. Otherwise I end up with 4 leftover PCBs front panels from the fab house. instead I am left with 4 2u blanks I can use for other things

 
The new "pots board" used for this DLFO (again--github for schems etc. is here) is extremely simple; it's a few op amp buffers and home for switches, jacks, and LED's.  Also it has a socket for a 12 bit DAC (MCP4921--SPI--very useful and easy to use DIP IC) which is not a peripheral that comes built into a 328.  

If I was going to make a bunch of these I'd make make it +/- 12V "eurorack" and SMD; the circuits should work with +/- 12V without modification. I'd add a buffer/interter (post here--about halfway down) and the portamento subcircuit to the "pots" PCB but for this build they are daughterboards hanging off the front panel.  

The board could probably work with 3-4HP due to its simple hardware design if the SMD parts were laid out correctly. Not here/not now though...I don't have the time.



The MCU and pots board are at a right angle. Good for one-off prototyping of embedded C projects, but I wouldn't do this for something more serious.


Also on the bench it's easy to test....hook it to a scope:



OK enough C-thing for now.  I will use it in my rack for a bit before I add more waveforms and make more software and hardware modifications--but with so much time and so little to do that may never happen.  We will see....Oddly after developing in C for a bit, I don't see myself going back to a higher level language MCU programming with sense of urgency. I feel (oddly/unexpectedly?) that coding in Pure C is easier than Arduino Sketch once you get the hang of it. Embedded C can be straightforward, for AVR MCU's how to write code is extremely well documented, and of course, Embedded C is really frustratingly fun to debug....  

If I get around to that, I will do another post and update github. In the meantime, well, if you've made it this far, thanks for reading--and be warned: more embedded C posts are coming.

Update 10-31-21 The LFO that started on this post is done (finally!) go here.




No comments:

Post a Comment

EFM/KORG770 VCF--BUILD: yes, SOUND: no

Ahoy!  This time, I wanted to refine the quick prototyping idea discussed midway through this previous post : Minimal breadboarding--I hate ...