Tuesday, December 27, 2022

2023 Goals...

Reaching the end of the year quickly. My psychiatrist girlfriend and I are going on a much needed vacation. We will sit in the sun and ponder life's true meaning of course, but I  will be thinking about what she calls "my geeking". 

That's what I cover in this blog--my trail of breadcrumbs, as I try to teach myself CS and EE. 

Let's get a head start, what next for 2023?

DSP

....Yes it could happen. A friend from my synth audio group is a DSP professional and has offered to walk me through the basics. He already loaned me "A Digital Signal Processing Primer" by Ken Steiglitz but the math was way above my head--like trying to sight read a Chopin Etude. The sad thing: I was really good at math when I was about 20. Can you (re-) teach an old dog etc.?  




RP2040 Mach II

The RP2040/Pico dev board is a $4USD gift that keeps giving. There are aspects of this useful, fun, and superbly documented MCU/dev board that I haven't touched yet--DMA , its PIO feature set, and the 2040's timers.  I have ideas for projects that will use these components, looking forward to working more with this MCU.


FPGA

There's great FPGA technology coming out of the non-DiWHY (se habla "commercial") sector--UDO Super6 VCO's for instance. The FPGA train is leaving, I want to hop on. 

There are open source tool chains for some FPGAs (APIO)--installing a new tool chain is always fun.

Shawn Hymel, who along with Ben Eater has become a bit of a DIwhy hero to me, has an FPGA video tutorial (here). I will probably start there.




Stomp boxes?

I used to build them but they were never realiable enough to use at a gig. So I gave up on 'em. But they are fun....but I don't gig a lot any longer....but you can put dumb stickers on them. Whatever. Maybe now that I have gotten better at single board fab (skiff type designs in synthesizer modules--apply it to a stomp box--why not?

C to C++

For embedded systems I code almost exclusively in C. C gets the job done, but I find a lot of code online I want to use that's written in C++.  And I have learned from trial and error: if you can't read and understand code you are going to depend on, don't use it. I have dabbled with C++ and don't like it; its poor readability (to me anyway) drives me nuts. But in 2023 I figure it's time to hold my nose and get on with it.

RISC-V

I started learning RISC-V assembly language during Covid-19 house arrest. Really fun (the code, not the disease)--I only got as far as using a simulator. To motorize this pursuit, I picked up a few "Mango MQ-R" dev boards from AliExpress.  Maybe I can do a simple assembly language project with one of them.

Not this one! Just noticed when writing this post, I thought I bought the F113 version (RISC-V) but AliExpress sent me T113 (Arm A7).  Or maybe MangoPi soldered on the wrong processor? We'll know when we smoke the damn thing. Never again right? I always say that, then I buy more unreturnable crap.



???

So much more of course--I want to Euro-rack some of my previous Frac builds (it's time) but that's mostly manual labor.  There are a few projects I started in '21 or '22 that I put aside, I should get back into them.  

Also, I've had ideas for some analog projects, building a string machine, seeing if I can come up with a high fidelity preamp, who knows what else.
 

(??) 



The main thing, I think, is I want to leave myself open to finding rabbit holes and jumping in them. That is what makes this whole thing engaging. 

Happy New Year, fumers!


Saturday, December 17, 2022

RP2040-AD9833 VCO--Triangle to Ramp Waveform Conversion

Hello again! This time I continue design and fabrication of a Eurorack audio VCO based on an RP2040 dev board and AD9833 function generator

the bench battle begins.....

I discussed the volt per octave ADC and MCU in the previous post here.  The V/octave PCB worked on the bench, but the AD9833's output leaves a bit to be desired for DIYaudio:

  • Its output is 0V to 600mV--we need more bipolar beef!
  • It can output triangle, sine, and square, but only one waveform at a time.

How can we turn this puny triangle signal into the bipolar 10V peak to peak triangle/ramp/pulse found in a traditional analog VCO?  

A common way achieve triangle to ramp conversion is to invert the "downward slope" of the triangle.  The inversion means instead of the waveform going up and down it only goes up.  

Easy right?

You can use an op amp to invert things:



...but as per my lab notes you have to turn on and off the switch at exactly (and I mean, exactly) the right time!


How can we create this critical switching signal?  

That's the tricky part! I had some (complicated) ideas using comparators to trap the top and bottom of the triangle, or maybe an ADC and MCU, but my notions seemed overly complex. 

There must be a simple way to do this, but how?  

At the advice of a friend I turned MODWIGGLER DIY FORUM for help.

MW is an amazing resource!  

After posting my problem some really talented techs jumped in with suggestions; the thread on MW is here

Guest from OpenMusicLabs conjured up a simple Falstad Simulation--fantastic!

Guest's from OpenMusicLab's design--you can see the sim he created here.


I drew up a schematic based on his idea--my schemo also provides for a pulse width modulated square wave, which I fully stole from the DIY legend Thomas Henry, as well as a buffered triangle output:

Values changed for the bench prototype (so far): C3 and C6 are are .0022uF; zener is 5V; R18 is 50K.

I turned that into a PCB to try out on the bench.....

Then I sent the gerber to this blog's patient and always helpful sponsor, PCBWAY, who quickly got it back to me:

My usual shout out to the folks at PCBWAY, please help out this geekly blog and give them a look for your next round of fab....

Cool! 

Did the PCB work right away?  

Nope.  

It wasn't a mistake in the design, nor in the converter circuit's basic concept, rather, I suck at breadboarding and was sloppy with soldering....I don't know exactly what it was, but all the wires and parts and alligator clips and things all my bench over drove me nuts.  

After blowing up a SEEED RP2040 **and** a 9833 breakout board, cleaning up bad solder joints, trying out some different cap values, and wasting a lot of time due to stupid breadboarding mistakes, yes, I got it to work.

The horror....

The horror....

The ramp wave created wasn't perfect but it was pretty close; it sounded a bit gritty, which was A-OK by me.  The distortion at zero crossing was less evident at lower frequencies where it counts most.  


Distortion at 4k; it diminished at lower frequencies


There was further discussion on ModWiggler about how to clean up this distortion. For instance, don't use a 2N7000 MOSFET for the switch, use a comparator. Update 2-27-23--putting a .01uF cap between pin 1 of the 2N7000 and ground improved this switching distortion somewhat. I will include this mod in a future "improving the tri to ramp converter" post.

The conversion conversation continues....this is an extremely helpful and enthusiastic community, and I am grateful for all the techs who helped with this design to date. 

OK I will put the AD9833/RP2040 and this waveform conversion board into a single package to make a Euro module VCO prototype in the next post. I will also make it easy to swap in different waveform conversion boards so the design can be further refined by making the VCO truly modular, from a design and layout perspective.

If I have time? Really folks, it's time to keep moving forward. Please stay tuned.

Saturday, November 26, 2022

MCP33151 14 bit ADC breakout board--Inexpensive High resolution ADC for embedded C Projects

I'm trying to better understand volt per octave circuitry.  

To that end I built a RP2040 based circuit that used V/Oct input to create a voltage controlled oscillator, based around an AD9833 function generator IC--previous post is here

Can the VCO be improved by implementing higher resolution analog to digital conversion? Let's find out.

For this post I built a simple breakout board (abbreviated as "BoB") using Microchip's MCP33151 analog to digital converter (ADC).  Datasheet for this IC is here

Let's get right into it.

The MCP33151 BoB has 100mil edge connectors and will drop into a DIP-14 IC socket. 


DESIGN

I went to Digikey and looked at a whole lot of SPI 14 and 16 bit ADC's. Many had features I didn't need, such as registers to store the last ADC read when the chip was powered cycled.  

And: most of the >12 bit ADCs in their catalog were quite expensive--anywhere from $8USD each to over $40 per chip and beyond.

The MCP33151 however was quite affordable ($2.83 USD each for the 1Mhz samples per second version); great! 

It had another feature I thought would be good for us makers: you can power the chip with 3.3V and ground, but use 5VDC as the reference voltage for its analog to digital conversion. Event better: MCP33151's SPI logic voltage follows Vdd so you don't blow up your MCU when sampling 5V sources. 

A complication: the MCP33151 requires a 1.8V source in addition to Vref and Vdd, for "analog power".  From its datasheet: the maximum and minimum voltages permissible for this input were +/- .1V. Deviate from that and you might blow up the IC.  

A low dropout 1.8V regulator is needed. Fortunately I had some MCP1700CM's (TO92--1.8V) from another project. 50c US each...again, affordable! 

I used 100mil connectors and a DIP14 layout, with 4 "NC" pins, to make the BoB easy to insert into a standard 14 pin DIP IC socket. 

 I laid it out in Eagle, added 1206 sized SMD filter caps, and sent it off to the blog's patient sponsor, PCBWAY.

Wham bam, the boards are back:

top to bottom: gnat-ass-tiny MCP33151 chips, MCP1700CM regulators, a US quarter for reference, and the unpopulated BoB's. Thanks as always to PCBWAY for helping out this blog.

BUILDING OUR DOG BoB

The MCP33151 is an MSOP-10 surface mount device (SMD). These are really really small. SMD work intimidated me at first, but after buying a decent stereo bench microscope, working with parts this small has been--managable?  

I reviewed a SMD how-to video and got to work. Once I got everything set up on the bench and took a chill pill soldering the parts to the BoB was not that difficult.

You can get gerbers, eagle files, PDFs etc for the BOB from Github: here.  Or from the PCBWAY community: here.

Ready to program and test....

PROGRAMMING

The 33151 acquires its samples very quickly, at a speed that cannot be changed programmatically.

With SDI pin tied low: after a chip select (CS) logic low the IC quickly samples the voltage at input. 

On CS down (or, when the sampling is done, whichever comes last) the IC also puts 15 bits of sampled data onto the SPI bus. The least significant 14 bits--0 to 13--are sample data.  Bit 15/MSB--which oddly is never mentioned in the datasheet anywhere I could find--is put onto the SPI bus as well as a "don't care" bit.  Bit 14 is always zero when SDI is held low.

The datasheet calls this "without busy mode". 

However there is a slightly more advanced "busy mode." 

I found its description in the datasheet hard to follow at first but figured it out (well, I think I did....)

Busy mode works like this:

Tie SDI high. Now, bit 14 can be zero or one. In "busy mode" a one located at bit 14 means the CS interrupted the sample process; otherwise it's a 0.  

The idea: detect if CS high-to-low stepped on the sample process; read the value of bit 14 and if it's a 1, take action--for instance, go to the Hotsy Totsy and talk embedded C with the fellow geeks.

I drew up a lab note about this:



However, JOY! I wasn't working with fast SPI speeds, so I forgot about all the chip "busy" crapola and tied SDI to ground:

 




Next I wired it up to a Raspberry Pi Pico--the affordable and highly capable 16 bit dev board I've been experimenting with lately:


I took a break, came back, and double-checked my work--building the BoB was a bit tricky and I didn't want to smoke the little turd.



For signal IN I used an no name/made in China bench power supply. I put either 5V or 3.3V into the IC's "REF" pin. 

I used my usual embedded C coding computer--an Ubuntu VM running VSCODE and a Raspberry Pi 4 for receiving/sending serial data--to write a loop that read the SPI output and threw the RP4's minicom app.

After fixing a few dumb mistakes my code worked...I could see 14 bit values from my serial monitor.  

But! There was a lot of variation in each read and an unacceptable amount of slop in the ADC conversion process. 

Was it my layout, the cheap power supply I whose output I was sampling, or something else?  

I solved this pretty quickly. I used a second MCP1700 reference voltage IC as the voltage source to re-test the analog to digital conversion process. 

The MCP1700's output, when sampled, was not jumping all over the place. Better still, if I threw away the 3 LSB's (x >> 3) the signal was pretty steady:


 

I am not sure yet but this is probably good enough for volt/octave DCO's.

Next, I need to use the MCP33151 as the A to D for the V-octave DCO currently on the bench and see if it helps make the VCO's output acceptly steady. 

I will cover the result in a future post....update: the V/octave DCO worked fine with 12 bit ADC.  But, i am sure I will find uses for an inexpensive 14 bit ADC in the future.

In the meantime, you can get the MCP33151LIB embedded C code from my github repo here.

Coda: ARDUINO and MCP33151

I didn't try to port my code to Arduino Sketch, but this BoB would be useful for that development environment--however, since Arduinos are mostly 8 bit and this is a 14 bit ADC, you have to do some slicing and dicing. I found this Sketch code snippet that looks like it will work--here

Enough! it's time to move on.  Until next time, don't breathe the fumes.

Wednesday, November 23, 2022

EuroRack "LFO Prime"--Worked the First Time!

 I have a few days off for the Thanksgiving Holiday. Time for more DiWhy fun! 

Doepfer smokers: this time I completed a EuroRack analog LFO design from my distant past--"LFO Prime".


For more about the features and development of this LFO check out the previous post here. To summarize: I cobbled together different LFO designs back in 2002 or so, into this module, but didn't document anything. It took me a bit to figure out how the 2002 era circuit worked, but I did, and this is it. 

I figured the build would work without issue and it did....since I already built this same circuit for Frac and large format. 

Let's build!    

As they say at the dentist's office: "you know the drill".  

I laid out the boards on a Windows PC using Eagle CAD, then shipped gerbers off to PCBWAY (this blog's trustworthy sponsor) for quick fab.  

The boards came back posthaste: 


Unbagged them and inspected. Looked good.

Front panel and main PCB for a "skiff" (<30mm depth) module layout

Rounded up the parts....

From here it was like building a kit....my calculation: +/- 12V Euro power should work without issue....

I put the C3 and C4 caps and the trimmers on the back of the board.  
  
Ready for final assembly and testing

"Seems working!"

I experimented with different values for the speed pot (A25K was best--higher values for this component led to issues with the symmetry of the triangle wave at output) and "speed" caps C3 and C4 (ended up using 47uF (range = "fast") and 1000uF (range = "slow"); if you build the LFO you may want to experiment with the values of these two capacitors.

I also used a two color 3.5mm LED (green/red) and increased R8 to 10K (15K for even dimmer LED action) since the unit was racked at eye level and the LED was too bright otherwise.

Of course the LFO could be modded--how about a rotary capacitor select switch for "range" instead of a DPDT?  Variable bias offset pot instead of a toggle switch? It wouldn't be too hard to add ramp or sine wave, etc., deriving them from the triangle/square wave.  

Easy to mod, but for me it's time to move on.  

Thanks again for PCBWAY for helping the audiodiwhy blog out. You can get the boards and plans to build this puppy--gerbers, Eagle files, PDFs of the layout, and so on, at their community site: here.  

Next time on to something a lot tougher: working with very small SMT parts to create a 14 bit ADC breakout board. (Update--done, works, go here). Until then, Gobble gobble!


Friday, November 4, 2022

Attenuator Expander--Adding DiWhy Features the Easy Way

I have stopped using hook-up wire in my DiWHY builds. This means less labor since hook-up wire takes a lot of time to prep and solder.

But these wireless "skiff" builds also make it harder to modify a finished design since there are no wires to desolder and hook up to something else.

A workaround: add optional 100 mil connectors to PCBs, then connect expander modules to things like outputs and switched inputs. 

Case in point: I added 100mil test points to the Attenuverter from last post.  

Next I designed, laid out, and built a 4hp expander module that added 2 inverted outputs with level and bias offset control:




...the expander module (shown on the right) accommodates 2x attenuverters:



IT's.....bench photo time:

Boards were fabricated by this blog's sponsor, PCBWAY.  Please help out this blog--for your next DIY build, please check 'em out.

To fit this project onto 4HP Euro, SOIC opamps were used, I find those pretty easy to solder--use a fine tip iron, flux, and patience.


Ready to assemble and test....

To connect the expander to the attenuverters, any sort of locking 100mil/2.54mm connector would have worked; I chose All Electronics CON series (CON-242 in this case) since they are relatively inexpensive and easy to get in the US.  

All Electronics CON-242 Connectors

Interconnects....

With all this in place it worked first time...I now have inverting outputs for each attenuverter!

...although the expander could be used for any dual CV or dual audio output to dual inverting output.

If you want to build this expander, get schematics, board layouts, Eagle files, gerbers, etc., you can get them from PCBWAY's project page, here.

For future projects: expect expanders for an expanding universe. See ya next time!

Sunday, October 30, 2022

EURO SEM style Attenuverter

I already have a DIY attenuverter in my rack, in FRAC format (+/- 15V). My Modular Synth geek group have been telling me: stop it, the only format left is Euro and large format

I have a bit of space in my Eurorack setup, so, let's get building--let's port last post's design to Eurorack.

Previous posts for this SEM style attenuverter are here (prototyping), here (Skiff depth attenuverter) and improving the module's bias control--here.  

To summarize those posts, because, who reads blog posts anyway? I always liked the sound/feel/response of the attenuverters found in the Oberheim SEM

The legendary Tom Oberheim confirmed via email that his design used a center tap pot

I bought a few ( ALPS RK11K114) and built a few.

Finished module

Boards were already laid out in Eagle; I only needed to change power connectors and add a  few 100 mil test points to gang 2 attenuverters in series.  

I also needed to design a Eurorack sized front panel:

I used the previous board and paper templates to create a new front panel.  But--would everything fit?
 
Next I sent the gerbers off to the blog's trusty sponsor, PCBway.  

BAM!! they are back:

Happy weekend--new boards from PCBWAY.  Thanks to those guys for helping out this blog.



Next I got soldering. 

The design had 2 SOIC op amps, but those aren't too hard to solder. Use a fine tipped solder pen, flux, and patience.

Beyond that, this is all through-hole. Happy day.



The design required a standoff board for the center tap pot. Otherwise its threads won't stick up far enough through the front panel. I included this small standoff in the gerbers and sch/brd files you can get here.
I had 2 pulled standoff boards from earlier projects so i reused those......


Only a couple mistakes, which i corrected in the gerbers uploaded to the PCBWAY project page (here); I forget to silk "red stripe" on the back of the PCB (oops) corrected below with a p-touch label. Wow, dumb error.



Beyond that everything worked first time!  Front panel fit fine, everything lined up.

The CON xxx connector sets from All Electronics are inexpensive handy for connecting signals between modules.  2.54mm spacing...nice.

As far as new features: after having this module (I have built two) in my rack for several months, I found I was patching the output of module 1 to the input of module 2 frequently to get complex inverted CVs, audio phase shifts and whatnot.  

Using CON-242's from All Electronics I wired two Euro attenuverters  together from the back, so the output of 1 hit the switched input of module 2:

Rear view--two attenuverters chained together


I also added another CON-242 male to each module's output.  This will allow me to wire up something new to the module's output in the future.  I will build an output expander for this next month--let's hope it works.

Update 11-4-22: I have created an expander module for 2x of these attenuverters, adding simultaneous inverted outputs with level and bias control. Project here. Blog post here.




All in all this was a fast and fun build.  

If you want to play along, get BOM, gerbers, PDFs of schematics, eagle files, from PCBway's community page here


2x Attenuverters with Expander (right)



Remember: If you have to vert, go up and down not back and forth.  See ya next time.

JTAG to SWD Converter

Readers: If you'd like to build the project featured in today's post, please go to PCBWAY's Community pages--gerber file, KiCAD ...