Sunday, June 30, 2024

Bluetooth Bench Mixer

Readers: If you want to build the project featured in today's post, please go to PCBWAY's Community pages--gerber files (front panel, main board) ready to download and/or fabricate as well as STL and FreeCAD for the breakout board tray, KiCAD pro/pcb/schem files and a BOM are here.  

You can also help out this site immensely by checking out PCBWAY using the link here. Thanks!


This time I decided to do something old school: a simple mixer circuit that isn't crammed onto the head of a pin. Yes, this 4x2 mixer doesn't have a lot of features, but does feature Bluetooth audio inputs derived from a popular breakout board: the BT-XY-MINI.

Did it work first time? Yep--one stupid mistake when sizing the pcb--but it all worked.

This mixer was designed around the Eurorack standard. It's 14HP , meaning it's wide for a 4 x 2 Eurorack mixer. 

This meant less space for more and more Eurorack gizmos on my bench. But enough is enough--you don't need tiny hands to use this module--and sometimes it's OK when the damn thing gets big.


The star of the show is an inexpensive breakout board available from Amazon as well as some of the larger Chinese electronic marketplaces, the latter of whom I no longer do business with, after having gotten ripped off by those guys too many times.

I was introduced to this board via the video here although the content creator never says what the board is. 

Matching the look of the board in the video against the many BT boards out there I determined it had to be the "BT-XY-MINI"; I got a few from Amazon for next to nothing. (Amazon link that works as of 7-7-24 is here

I couldn't find a datasheet nor a schematic for the XY-MINI, nor even figure out what main IC the breakout board uses, but, at about $1.80USD per breakout board how risky could this be? 

I wired it up on my bench (5v, left out, right out, ground) and the bluetooth board worked great.

From here it was a matter of designing the XYMINI into a simple 4x2 mixer.  

Using Kicad and FreeCad I did just that and in a few days the boards were back from my sponsor, PCBWAY:


Simple enough to build:

For hookup wire I used JST connectors purchased from Tayda. These came recommended from other techs, who said JST's can't be beat in terms of price, reliability, and ease of use. 

I used FreeCad to design a tray for the XY MINI board.  2mm screws and nuts were used to fix the breakout board to the tray; 2.5mm screws and nuts to affix the tray to front panel.

MISTAKES? Yep. One BIG one.

I spent a lot of time and energy making sure the 3d printed tray fit onto the front panel, the BT-XY-MINI could be screwed to the tray, and the hardware (JST's, regulator, 3.5mm jacks) were correctly sized for the pcb. 

However I forgot to check if the width of the PCB was too wide for the front panel--DOH!  Turns out the PCB stuck out about 2mm from the left side:

Not a big deal; this issue was corrected on the version uploaded to the PCBWAY community site.

Overall this was a refreshingly simple project, super easy to build. 

Now I have integrated BlueTooth on my bench that I can mix with other audio sources. 

If i were to improve this: the line out of the xy mini is a bit low--maybe 2-3v peak to peak. To match the levels of other audio devices found in my rack--mostly 10v p/p--it might make sense to gain the xy-mini up by say 12db and at the same time bias it for bipolar operation (which would eliminate the need for the 4.7uF decoupling caps) using a TL071 configured for non-inverting gain.

Also bring the stereo output jacks to the front panel; maybe in parallel with the rear mounted screw terminals. This would allow it to be used on the bench or in a "normal" Eurorack.

But what I created for now--good enough, for me anyway. Keeping it simple is always stupid? Something like that. 

Wednesday, June 19, 2024

Audio Frequency Counter using an RP2040

Readers: If you want to build the project featured in today's post, please go to PCBWAY's Community pages--a gerber file ready to download and/or fabricate as well as KiCAD files and a BOM are here.  Firmware for the reader (work very much in progress but freq reading the OLED display function) is here.

Also please visit PCBWAY's site--using the link here--it will help this blog immensely. Thanks.


I want to build a clock multiplier for my bench, but first I needed a way to accurately read frequencies of incoming signals. Between 10hz and 100K?  Sure. Good start.  

I got that working this morning:

For prototyope hardware I used an already fabricated PCB I designed: post here.

This time, as with many times before: my patient and tolerant sponsor, PCBWAY, helped ameliorate my frustration with breadboarding....for $5 and shipping, I threw most all my error prone dupont jump cables into the dumpster.  

Then I coded  in C using more reliable hardware--a PCB:

When I breadboard, and it doesn't work, why not?  Is it a broken dupont cable? A wire put into the wrong .1mm hole? A dumb design mistake? All of the above? The PCB I used this time is an encoder + GPIO  development board centered around a PICO dev board which in turn is centered on the RPI RP2040 MCU.  A mouthful but it saved time and anguish. Get this PCB here.

Unfortunately for this bench configuration not all the breadboards were gone! 

To buffer the incoming signal I tried out two different designs, "anything to clock", see posts here and here--each A2C version was on its own PCB which in turn was mounted on a breadboard. 

These small PCB's rectified incoming signals to turn them into rising and falling edges and clamped the output to 0-3.3V so as to not blow up the RP2040's GPIO inputs.  

The firmware for the reader is based on a cool RP2040 counting algo by Jeremy P. Bentham--see his blog post here and github page here

I modified Mr. Bentham's clde a little, but not much, and made it display observed frequencies on a small OLED display using David Schram's open source C library for SSD1306'shere

A few minor code changes were needed, for instance, the frequency reading algorithm put the frequency value into an integer in memory, but for the  Schram1306 library I needed a string.

Easy--there is a function in C to change ints to strings that I didn't know about--snprintf:

#include <stdio.h>

#include <stdlib.h>

char buffer[10];

int value = 234452;

snprintf(buffer, 10, "%d", value);

//buffer -- input string

//10  -- base for conversion

//%d   decimel output

//value   input number to convert to a string.

Another cool thing--the Bentham code traps the frequency and sends it out the RP2040's UART pins if you configure CMAKE to do so. Not sure what I'd use that serial stream for, but hey, it worked, and for the final build I will probably bring this data to the front panel on a TRS jack.

The ink on the firmware from the reader is still wet--there might be bugs? This is version  "less than point one", folks. 

But for me, JOY! it worked.

Get the code here.


Adding a wiring diagram below because in 3 days I will forget how I wired all the dev board crap on my bench and be extremely unhappy to have to figure it out again. Live and learn?  Usually nope, this time--maybe.

Still to Do: Lots!

--I need another algorithm to analyze incoming low frequencies--say .5hz or .1hz to maybe 10hz. Not useful for audio, but in music synthesis, recording studios, bench automation and other environments I see these low frequency rising and falling edges--um, Frequently? 

Might as well count them.

--It would be nice to do something that utilizes the 2nd core on the RP2040--looks pretty easy, see the video here. I've been putting off messing around with this important feature; it's time to dig in, maybe next time?

--Autoranging is needed--since the counting algorithms change based on the rough frequency seen at input. So far I can think of 3 different settings: low frequency to 10hz, about 10hz to maybe 2K, and 2K and above. So some sort of ranging hardware and software are needed, yes, but I will probably get lazy and put this on a switch, which might be good enough.

And of course, once I have everything jumpered together on the bench I need to turn it into a working prototype. The gerber to PCB part is super easy, using my sponsors, who BTW are celebrating their 10th anniversary and have asked me to provide a video so they can continue to party down. 

If I can get my phychiatrist wife to hold the camera, I might do that today?

More coming up. Until then, enjoy the beginning of summer.

Saturday, May 25, 2024

RP2040 Dev Board--More Encoding, Less Breadboarding

Readers: If you want to build the project featured in today's post, please go to PCBWAY's Community pages--a gerber ready to download and/or fabricate as well as KiCAD files and a BOM are here.  

Also please visit PCBWAY's site--using the link here--it will help this blog immensely. Thanks.


Pretty quick one this time. 

I had some back-of-the-napkin ideas for a clock multiplier. Instead of breadboarding I had PCBWAY make some development boards to accommodate an RP2040 MCU ("Raspberry Pi Pico"), an OLED display, a rotary encoder, and some GPIO pins. 

Less to go wrong!

Dev board for this post's project...

The dev board primarily uses 1206 surface mount components

My thinking: it was easier to swap SMD resistors and capacitors if I needed to change values compared to through hole. Less work and very little risk of damaging pads and traces.

However, changing and rerouting traces when working with really small parts was not as easy as my older through-hole designs. 

I am still puzzling through the best practices here but I know I didn't want this:

Something about breadboarding, with the dookie-duponts going all over, just drives me-----nuts!!!!! 

No more, please!

The dev board's "features" reused ideas from previous posts:

  • Rotary encoder with hardware debounce--post is here. After some experimentation, the values for C and R and .1uF and 100K seemed to work OK.  
  • OLED 1306 I2C--post about the 1306 embedded C library I will probably use for the multiplier's  UI is here.
  • UART output with buffering for handling printf() statements and serial input data. Got this idea from the fantastic YouTube Channel low level learning.  More information about this in the previous post here.
I wrote embedded C test code, that's on GitHub (here), which "seems working": turning the encoder produced "CW" and "CCW" on the display; clicking its switch cycled the 4 LED's.

The RC + CMOS 4011 based debounce worked most of the time, but not all of the time. This drove my crazy for a few evenings, thinking: where is the mistake?

I simulated a rotary encoder in Logisim (here) which informed me the existing debounce--the digital side anyway--should work.  

I looked over my code many times, no, I thought it right. 

I tend to always blame my own crappy work, bad assumptions, sure I'm right when I'm not, etc, but this time maybe it's something else?  

Perhaps the issue was with the encoder itself? The part says "ALPS" on it, which should be a quality encoder, but I bought 20 in bulk for something like 50c each from China.  

The real deal is more like $2.25US and up per unit.  

So my encoder might be a fakecoder, a counterfeit, which is why its performance, even after hardware debouncing, was not spot on. 

I will buy some name brand encoders from Digikey, not fakes, we will see what happens.

Anyway, I got building:

Happiness is new boards from this blog's sponsor PCBWAY

"Parts is parts"

Rev 2 board will have changes to the silkscreening, they always seem to, but otherwise, this dev board "seems working".  I have uploaded the revised board to PCBWay's community site, here

Power test. Good news--the 4011 did not fry.

For serial monitoring I used an "Adafruit FTDI Friend" adapter (here) to a Linux PC.

So what's next?  I have some open source algos I found to get the time between GPIO pulses (for instance: here and here. Beats writing the code from scratch!

Next step I figure: as easy (?) as averaging a few readings of  the incoming frequency, then multiplying that value by 10 let's say.   

Then, use PWM (using the  Pico SDK or maybe the library here) to output the 10x frequency. 

But is it ever that easy?  I am sure there foobars I have not thought of yet.

I am really short on time these days, but if I can find time to code this, as I say after an Olzempic pizza and beer chaser: I will let you know how it comes out.

Friday, May 17, 2024

Git and Github: Crash Course

Hello again--this post isn't about audio, hardware, MPUs, soldering, DACs, or even electronics tools like EDA's and scopes.

Instead, I present my lab notes: how I have configured GIT/github, a popular version control system, for my various development computers. Excitement!

Why the kitten with the octopus tentacle?


Even a small potatoes software developer like me needs version control. 

Back when dinosaurs roamed the earth I wasted a lot of time screwing up (a.k.a "disimproving") working code, then, after laying the working code to waste, spending hours cursing and hating life while I got the code "got back to square one".  

Did I save a copy first?  Nope.

And! I still have major headaches at my day job when a contracted programmer takes working code and breaks it.

Now users are crying. 

"Do a damn git reset!" I tell the programmer's boss, a big shot compsci contractor CTO with a Posh PhD. 

"We don't use VCS's" the CTO says. 

Righto--what's the red wire for again?


I have been a big advocate of VCS since I was introduced to version control (Gnu CVS).

Nowadays I use Git, but don't set it up often enough to remember the anything beyond the basics--that's why we use AI, oops I mean, that's why we write things down.

So! If you are a beginning programmer and want to learn a bit more about this free VCS--"version control system"--Git is the most popular VCS nowadays--this content might be of interest.  

If you know GIT better than I do--which is likely--I only know and use maybe 5% (?) of its commands--you're probably going to want to skip this one. 

EVEN BETTER: if you are an experienced Git geek, please read this post; where you find it oversimplified, misleading, or downright butt, please comment so I can correct things and better learn GIT.


  • Your development computer has GIT installed--here.
  • You have some previous experience with version control software or at least knows what it's used for/why it's important.
  • You are not a CTO who drives a Range Rover and lights cigars with $100 bills yet doesn't know red is positive.
  • You have a user identity already set up on Github (mine is "cslammy"; yours isn't)--if not, get one! New user creation is well documented--go here.
  • You use SSH to securely communicate between your dev system(s) and Github--there are other ways to do this, but I know SSH pretty well so it's what I am use and what's covered in this post. 


============CREATING PASSWORDLESS SSH=========== 

On your development PC(s) install OPENSSL if needed.

For UBUNTU desktop (22.04), openssl was already installed; nothing to do. If not? different distros have different installation steps. As a Ubuntu/Debian/Mint guy, for me it would be something like this.

For Windows: get cygwin64, install using defaults, and add C:\cygwin64\bin to %PATH%. This will allow opensll (needed for keygen) to run from Windows command line (cmd). Step by step instructions for this are here.

===========SSH PRIVATE AND PUBLIC KEYS===========

For a machine to talk to github using SSH you have to create SSH keys, store the private key locally, and upload the public key to github; more here.

The following command creates a public/private key pair in ~/.ssh on linux; the same command works for cygwin Windows:
ssh-keygen -t ed25519 -C [github assigned email address]

so for me:  

ssh-keygen -t ed25519 -C

why ""? Why not the gmail email address I associated with my account when I first created an account?

It's the way Github works: each user gets a email address when they join github.

This Github assigned email is used for SSH key management; you use in the git CLI for ssh remote, but you use your personal email address (e.g.: for other github related things, like getting informational emails from the github community.  

These 3 different logins/identities confused me at made more sense after I used git and github for awhile.  Like it or not, you will need all 3.
========POTENTIAL LINUX GOTCHA?=========

Check that the generated keys are copied to ~/.ssh by default.

On one of my ubuntu hosts I saw that the keys were not stored in ~/.ssh directory. 

or maybe I didn't choose to save to default location?

As far as I can tell, the keys (at least private?) need to be in ~/.ssh or SSH to github will not work!!

If they are not there:
  • Figure out where the keys got stored (maybe in your home directory?)
  • Note existing CHMOD's/CHOWN's for private and public keys
  • Copy keys to ~/.ssh directory
  • If needed, CHMOD and CHOWN copied files/folders to match originals.

===========UPLOAD PUBLIC KEYS TO GITHUB===========
On the dev system's ~/.ssh folder that has the private key there will be a public key; its filename ends in .pub.
  • Cat the .pub file or in Windows open it in Notepad.
  • Copy the .pub text content without any spaces, extra lines, etc. to your clipboard.
The public key will look something like what you see below, which is an example, not a real public key:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAFBAAIFo+Zumzwrm/DsmDqJCZLJQQmr4CA5Qhgb2TyxI1gtqX

  • Go to, log in
  • Click on your profile icon in the top right of the main page.
  • Go to settings > ssh and gpg keys > ssh tab
  • Upload the SSH public key text to github (more here).
NOTE: as far as I can tell, the public keys uploaded to github don't stick around forever. You may need to re-upload your public keys from time to time.

============ADD GITHUB TO KNOWN HOSTS============

I have only seen this on Linux, and only occasionally,

ssh-keyscan >> ~/.ssh/known_hosts #Not sure this was needed

Did it work?
➜ .ssh more config
User git
IdentityFile ~/.ssh/id_rsa
Was/is this is step needed? Probably not.

=========TEST WITH SSH===========

From a system that has the required private key etc.

ssh -T

Note you use as username/domain, NOT your git username (for me, cslammy....) 

ssh -Tv #includes verbose debug info.

If if works, you should see something like this:

Hi cslammy! You've successfully authenticated, but GitHub does not provide shell access.

NOTE: Again, you must use<> when testing SSH protocol to github. Not some other username. Not clear from most docs I read when trying to learn GIT.


=========GIT CONFIG ON YOUR PC=========

Git has a lot of options you can configure on your dev PC.

One is to make sure to set: that the default Git branch is “main” locally.  That will match’s default. 

You have to change this for at least some Linux distros--local default branch for Ubuntu git for me last time i set up git/Github was “master” which did not match the Github default.

On linux or Windows, from terminal:

git config --global init.defaultBranch main


There are other things to set up.For instance, you may need to set how carriage returns are handled--different for Windows OS vs. Linux....details here.

There are a lot more things you can set--at a minimum for each dev PC I set the features here; kitchen sink details are here.

========GET THE URL OF THE NEW REPO==========

Create new github repository at the public github website (how-to is here).  
  • There is a green button called CODE in the new repository
  • There is choice for what to display: SSH or HTML.
  • click on SSH
  • You will see a URL looking string to use for SSH to this new repro; here is an example. 

Copy this to clipboard, add it to notepad, save it using textpad, whatever.  
You will need this again shortly.

==========LOCAL DIR AND GIT INIT=======

Create new directory on local Linux or windiows machine for the new project.


CD to an existing directory where you already have some code.
issue this command:

git init

This creates .gitignore, DB files etc, for any data in the directory.

============SETTING UP PUSHES AND PULLS==========

Ah! Now we are getting somewhere....

Now that we have the above steps done, we can start using version control for code and copy code changes to github. That way the data is in two places--always a good thing.

To do pushes and pulls git uses commands like this:

git push [variable] [branch]
git pull [variable] [branch]

But before any of that works, in addition to having SSH set up (above) you have to set things up so git knows the values of [variable] and [branch]

First, think of a variable name, a common one in our situation is "origin"

Make sure your variable isn't already set. If it is, you want to get rid of it.

DANGER! Failing to do this can lead to all sorts of problems.  

open terminal and CD to your project's directory.  Then run this.

git remote -v

if you already see an "origin main" pointing to a different repo, you need to get rid of it (or choose another variable).

git remote rm origin

Then, set a git variable to the remote repo. In my case I usually call it “origin” again. I have no idea why.
Here is an example:

git remote add origin

[Branch] is the info you wrote down or copied into clipboard or notepad....will look something like this: 

AD9833VCO.git is the name of a repo folder you want to push to.


.gitignore basics are here

.Gitignore is a text file that tells Git what files and folders you don't want to version control. 

You will probably want to modify .gitignore for each project you version control--otherwise a whole buncha crap of you don't want to replicate will replicate (such as a "build" folder and all its contents, created by cmake).  Doh!

A pretty typical .gitignore file for me, for VSCODE/CMAKE coding, that seems to work, has only 3 lines:


Deprecated is where I put anything no longer salient to the project; docs are things like PDFs of IC's used. Whatever. Up to you.
======README AND LICENSE=========

Optional, but I do it: on the local system, for public repos, create a and a License file. 


Assuming I already have some code in my project folder, I do a git push first.

Git needs to know about your work so far...git status says what needs to get uploaded; git add . adds everything except gitignore files and folders to the queue, and git commit gets everything packed up and ready to go:

cd to your project directory if you aren't already there, then:

git status
git add .
git commit -m "initial upload"

Then, use this to push files for the first time to github.

git push -f origin main
After successful push you will see your local files in your new repo online. 

And...if it worked, you will see something like this:
git:(main) git push origin main
Warning: Permanently added the ECDSA host key for IP address 'x.x.x.x' to the list of known hosts.
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (13/13), 6.52 KiB | 667.00 KiB/s, done.
Total 13 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.

You now have version control working and your precious code in more than one storage repo. 



Once your git/Github setup works you can use the gazillion other commands (reference is here) to pay off your Range Rover. 

Obviously I won't go into all of it here--just the basics, ma'am.

A good command to see what changes you have made since the last commit:

git diff

OK, you've made some code changes, now you want to get save your changes as a new version.

git status
git add .
git commit –m “added foobar function to main.c”  

If you just say 
git status
git add .
git commit

your commit notes will be editable in your text editor--which you can configure using git config, how to do this is here.

Finally push the changes up to the cloud:

git push origin main


git log

this shows the messages you tagged to each commit and its commit ID 

Once you have locked in on the ID you want to roll back to, here is the command to roll things back.

git reset --hard 0ad5a7a69ab9240da


I use this all the time, useful not just for version control but to see your last bread crumb trail

git diff


Wow already a long post, and this post only covers the very basics.

Git can get pretty complex--there are tons of commands--but try not to let that get you down, the basics aren't that difficult.  

I will be adding to/correcting/updating this post as time goes on and I have git projects in front of me. 
I am revising code for a RP2040 clock multiplier, that will have a fair amount of embedded C and need a gitload of work. 

Will it work? Who knows?  Hopefully more about that project in the next few posts.

Monday, April 29, 2024

Son of Anything To Clock--LM311, Lower Parts Count

Readers: If you want to build the project featured in today's post, please go to PCBWAY's Community pages--a gerber ready to download and/or fabricate as well as KiCAD files and a BOM are here.  

Also please visit PCBWAY's site--using the link here--it will help this blog immensely. Thanks.


Last post I described a subcircuit that would take an audio signal from maybe 50K to below audible frequencies and turn it into a square wave--useful for turning audio into a clock signal for an MPU. 

It worked, but discussion ensued at my geeky audio meetup: is there an easier way to do this? 

Of course there is....Elton at OtterMods had a similar circuit, with lower parts count, based on an LM311 comparator.  

This post I'll discuss Elton's design, the LM311 comparator and build a prototype Break Out Board.

The Design:

How it works....

D1 turns a bipolar input at J1 into a signal at 0V and above.  

That's fed into the inverting (-) input of the LM311. 

The non-inverting (+) signal is the reference, with 12V for Vcc, the 47K and 10K divider sets pin 2 at about 2V.  

R5 sets the duration of the output signal.  

The LM311 needs a pullup resistor (R7; 1K) while the 2N7000 FET and R6 re-inverts the output.

About the LM311

This chip was new to me....Elton is super cool and gave me a few DIP IC's to try out.

An excellent overview of the LM311 can be found at DIYODEMAG: here .  

For the 311....Datasheet is here; NatSemi application examples (untested by me, and knowing National, untested by them as well?) can be found here.

There are lots of comparators out there--why this one? 

LM311 is a good choice for low parts count comparator applications because its output is buffered with an internal NPN transistor:

Which means: a pullup resistor at "Collector Out", 3VDC to 15VDC at Vcc (pin 8), GND at pin 4, and a reference voltage (can be ground at presented at pin 3, the non-inverting input) is all you need; let the balance and bal/strb inputs float; finally, tie EMIT OUT to GND. 

We are talking 2 parts....the IC and one resistor, to get a fully working, reliable, fast comparator. 


The 2 component comparator.  For the pull up resistor: try 1K.

More in the LM311 benefits column:

  • Vcc to Vss can be 36V apart before you blow up the IC. Since we synth and audio nerds often work with +/-12V or +/- 15V for our voltage rails: good fit. 
  • Simple operation--if the non-inverting voltage at pin 2 exceeds voltage at pin 3, the output (pin 7) goes from hi-z to low. 
  • Unlike an op amp, the 311's the inverting and non inverting-inputs are not virtual grounds--you can see the incoming signals on pins 2 and 3 with a DVM. 

The latter turned out to be useful: when I first wired up Elton's design it didn't work due to an incorrect resistor value I soldered in by mistake. Throwing a DVM on Pin 2 helped me figure out my mistake--good luck putting a DVM on inverting or non-inverting pins of an op amp; those will always read 0V no matter what.


Elton emailed me his schematic and I laid out a small Breakout Board ("BoB") in Kicad

I created a gerber and off it went to this blog's patient sponsor, PCBWAY.

In a few days PCB's were in my mailbox:

Wham Bam, boards are back from PCBWAY. Please help out this blog and check 'em out.

Like the BoB in the previous post, I screwed up silks below the pin designations; pin numbers are wrong, and what pin is what? This is fixed in the version I uploaded to the PCBWAY community site.

To make the BoB easier to breadboard I used 200mil edge connector pins; I bought some 100mil pin header  male to male material, broke off a 14 pin section, and using needle nose pliers pulled out every other solid wire.

It took me about 15 minutes to solder the parts to the board and connect the pin headers.

The IC went in then I dropped the BoB onto a breadboard to test.

And at output I got--nothing.  

The output was slammed high, against the Vcc rail.  


This circuit was so simple, no way it could go wrong????  

I probed the 311's pins, and Pin2 was 12V, not 2V.  Hello?  

No issues with soldering or traces.  

After some fear and loathing: instead of a 47K/10K voltage divider, I errantly used a 470 ohm resistor  for R3. 

A 470 and 10K voltage divider provided, as a reference voltage, about the same thing as the divider's source voltage.  So no, this won't work.

DOH! Easily fixed--once I put in the right value resistor!!

"One of these things is not like the other" 

With the correct resistor values: "seems working"

Elton's design worked great, nice clean square waves regardless of a sloppy signal at the LM311's inverting input. 

The BoB featured a low parts count--and, if going forward I used an SOIC LM311 and SMD resistors, this design could get really small. 

So what next? I hope to use this BoB for input buffering and rising edge detection for a clock multiplier, perhaps based on an RP2040.  

But! With my day job going full swing post-pandemic, will I have time? We will see.  

Sunday, April 14, 2024

Anything to Clock Subcircuit

Readers: If you want to build the project featured in today's post, please go to PCBWAY's Community pages--a gerber ready to download and/or fabricate as well as KiCAD files, PDFs, a BOM, etc., are here.  

Also please visit PCBWAY's site using the link here--it will help this blog immensely. Thanks.

For upcoming projects I needed a breakout board to turn any waveform in the audio frequency or low frequency range into a pulse wave. Then: use the output's rising edges and throw an interrupt on an MCU.

So, I needed a comparator; lots of ways to design and lay this one out, easy. 

I also needed a few more features....

What I came up with:




As usual I recycled ideas used in previous projects. 

The MCP6002, an opamp I discovered looking at buffer subcircuits from Mutable Instruments, provided clamping. An easy way to clamp J6's ground to positive voltage was to limit the MCP6002's power pin, Vcc, pin 8, to 3.3 or 5 volts--whatever voltage my MCU expected. 

The MCP6002's output will match Vcc--easy.

Warning: for any circuit that uses an MCP600x, do not supply greater than 6VDC to its Vcc pin--exceeding 6v may damage the MCP6002.  If you need to use a larger voltage (say +12VDC for VCC) consider using a different op amp--pretty much any dual op amp will work, but you might lose the MCP6002's nifty clamping characteristics.

The MCP6002's second stage provided an inverted output, while J7's non-inverting output voltage was determinded by the voltage present at Vdd and not constrained to the clamp voltage.

VCC-VDD jmp wirepads could be shorted with a small jumper. This allowed the Vcc and Vdd to be supplied by a single voltage source.

The diode in U1A's feedback loop made U1A a precision rectifier, the same idea was used in a VCO triangle to ramp converter.

A final "feature": I could change output shapes with one additional part: C4. C4 can be omitted, but its value along with R2 provided a simple active filter, allowing different output shapes at J6 and different pulse widths at J7. 

With R2 at 1K, values for C4 could be anything from say .01uF to 4.7uF and beyond. Omit C4 to get decently fast rising and falling edges at J6 and J7. 


New boards from the blog's sponsor, PCBWAY.  

Mistakes in the original run: problems with silks not showing up (in Kicad, I put the designations on a non-existent layer instead of front silkscreen--oops) and J1-J7 being incorrectly ordered. These issues are corrected in the project uploaded to the PCBWAY community.


Whole board took minutes to populate--this was an easy one.

100mil spacing for breakout boards presented a challenge to me, so I laid out J1-J7 200mils apart, grabbed some inexpensive 100mil edge connector material, and pulled out every other wire with needle nose pliers. 

Now I have a 7 pin edge connector with pins 200mil apart. This made the board a lot easier wire up I thought and worked a lot better than anticipated.

power tested: no problems



Simple circuit, simple results.  Purple trace is input, Yellow trace is output; screens were captured with Siglent's easy to use.  This was what I was after. 

So--I made a few errors with my silks but otherwise worked first time!  When was the last time I saw that?  


Bluetooth Bench Mixer

Readers: If you want to build the project featured in today's post, please go to PCBWAY's Community pages--gerber files (front panel...