Thursday, August 11, 2022

Euro VCA--"Bay Area Modular" Group Build


#include <stdbool.h>

bool real_nerds_dont_socialize = false;

Every other week I meet up with the fine audio geeks of "Bay Area Modular". Here we discuss life, liberty, if Behringer  is modular methodone, and the final -2db off the noise floor.  

An ongoing project/meeting recently completed: members proficient at audio DIY showed the less civilized members how to lay out and build a complete Eurorack synthesizer module.  

The build chosen was the "Farm VCA" from the website here (the original post from a server in Japan appears to have been taken down...but its open source design lives on....) 

This time we go over the successful outcome: a simple EuroRack Voltage Controlled Amplifier.

The two boards (main board and front panel) were laid out in Kicad 6.0 by Elton at Otter Mods and the rest of the group.  

My sponsor, PCBWAY, generously donated the PCB fabrication.

(Great news--except for a blown up trimmer--my fault!--the module worked first time, no kludges, no rewiring, no fixes.) 

Here's the finished module: 






Wrong trimmer--should be 100K, not 100R. Oops, blew it up during my intial test, but it was easily replaced.


The group laid out the board with components occupying both sides of the PCB to get the design into a 3HP configuration


Elton testing the module in his rack

Works--Rack em!


Get the schematics, gerbers, BOM etc., from PCBWAY's project page, here.  

More analog hardware?  Less Digital?  Less C nonsense?  Bring back Arduino? We can only hope.....See you next time! 

Tuesday, August 9, 2022

AD9833 C Library Port for RP2040 MCU

For the 10 or so of you out there coding audio projects using C and the Raspberry Pi Foundation's RP2040 microcontroller, good news: the world has yet another C library for the AD9833 function generator IC.  

I'll use the library in upcoming projects, but for now, the RP2040 AD9833 C library can be found on github--get it here.

Test the library....

This was one of the more complicated embedded C coding exercises I've taken on to date.

The library does far more than its predecessor (blog post here--github here--Atmel 328 version).  

Progress? I put descriptions of what each function does in the AD9833.h file, and main.c has routines to test the methods using the UART serial protocol (see the last post--here).

Wiring on the bench for the library tests.....

I only had one issue while coding, but it was a big time-waster and took a day and a half to figure out.  

All the functions for register0 for the AD9833 IC worked, but any time I tried to use anything saved in register 1 I got nothing--like the entire register was smoked.

It turned out I was using SPI mode 0 initially, but the AD9833 needed SPI mode 2 to operate.

Because of this mistake, any SPI MOSI transmission that tried to use a 1 as the MSB didn't work--for AD9833, that one means you are sending data to register 1.

I figured this out (finally!) by comparing a logic trace from an Arduino Uno R3 <--> AD9833 with a sketch running the AD9833 Arduino library that I wrote previously, the Arduino C library is available here.  

I then did similar a logic analysis of my RP2040 library wired up in the manner you see above. 

When comparing the logic analyses, it was obvious that my PR2040  code was trying to use SPI mode 0. 

Why?  Dumb bug!  

I had an if/then statement error in my previously posted RP2040 SPI library  (here). Simple fix once I spotted it.  

Lesson learned: use your logic analyzer to debug code issues!! 

Early and often!!

UPDATE 10-1-22 I copied the library and examples to a new project and it wouldn't compile!  It used to! I was getting multiple definition errors--hello?  I was adding #ifndef--etc in the h library files correctly. So that wasn't it.

After some cursing, I made a lucky guess: adding the static keyword before the global array declarations in ad9833.h and uart.h made the error go away.  

Best I can guess, some part of the toolchain--maybe GCC?--was recently updated, the old version was correctly inferring which variables were "extern's" vs "static", but the new version couldn't or didn't want to make this inference. 

I read that correctly implementing static vs. extern keywords in C is tricky....Good video on static variables in C/C++ is here 

After reading up on these keywords and then watching the video, I was a bit surprised the linker didn't throw errors linking initial versions of the ad9833 library and examples code. 

Anyway, I have updated the github reposiotry for the library with these changes. It now compiles again without issue.

As a side note: I also added to github a couple of bin2hex.c functions, as well as a python script that can be used to craft binary to frequency tables, which I figure I will need for future projects. 

Get those here and here.

Next time it's back to hardware. Analog! I'll be hitting my generous sponsor PCBWAY up for more boards soon and post the results, working or not. For example, I have a commuinty Eurorack VCA almost built and ready to post. Coming soon! Until then don't breathe the Sea fumes. 

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