Tuesday, October 14, 2025

AD5761: Arduino Library and S/H Mux--one worked, the other sucked

 

Two goals since last time: see if I could create an IC library for Arduino sketch, which was surprising easy, and breadboarding an Arduino based bipolar audio Sample &Hold multiplexer, which I never got working. 

A basic sample and hold circuit, aka S/H or just SH. The HOLD COMMAND is provided by a microcontroller switching multiples of this S/H circuit one after another in rapid succession, allowing a single DAC to produce multiplexed output voltages.

At the bench I used an AD5761 16 bit bipolar DAC IC (previous post here), an Arduino Micro, a library for the DAC I wrote for Arduino Sketch (get the library on github, here), and, for the mux switch, the ADG413 analog switch featured in previous post here.

Writing the sketch library took a lot less time than anticipated.  

I used the Helge Langehaug's sketch here as a starting point and combined it with embedded C code created previously--post is here

To get the C library working with an Arduino sketch IDE:

Worked first time--after initializing the DAC I could enter values into an AD6751_out() function and sure enough, correct voltages were present on my scope. 

You can get the working library file and a sample .ino sketch on github, here.

Whole thing took less than an evening to craft. Joy!

With confidence soaring I used the same library to create a 16-bit four-channel sample and hold. 

It's the idea found in this previous post, but employing Arduino sketch .ino/.h files instead of embedded C.

Guess what: the AD5761/ADG413 based S&H circuit never worked. At all.

I could get pretty steady sampled DC voltages out of the circuit, but the voltages at output were never close to being accurate, especially when voltages went below ground.  

I speculated that the issue was a combination of trying to breadboard the design (I read that accurate S/H circuits need to have caps and buffers close to one another which didn't happen here), using the AD5761 in bipolar mode instead of 0-10V, which I hadn't tried in a mux design before, and the lack of precise timing in the world of Arduino--I constrained my sketch to use only delay(), digitalWrite(), Serial.begin() function calls and the rest, in the best Arduino fashion; I could have called out Atmel registers in my code and slammed away, but I might have well have used embedded C for that.

And/or some really stupid mistake(s) I never figured out.  

After a too many evenings (four? five?) I gave up; easier to use unipolar dacs then level shift them with op amps.  

Or, use 3 AD5761's in parallel.

Or, buy a 4- or 8-channel DAC with the mux built in.  

Or, whatever.....

Thinking I had an issue with the ADG413 I tried a CD4051 Mux. Nope, that sucked too.  

The S/H worked, sort of, but the voltages were never close to accurate. I stripped things out and tried to use a Salae logic analyzer to sort the issue. Nope, it wasn't SPI.   


OMG, too many wires, too much mess.  

Overall: breadboarding is NO FUN

I am probably returning to ditching breadboards and getting small quantities of PCB's for experimentation from the blog's faithful and patient sponsor, PCBWAY

If said PCB's don't work because my design is crap, well, I will pitch them and try again.  

Even with the tariffs, I think time- and money-wise I would have come out WAY ahead this time. 

Overall a win in library land, but this was a lot bench time spent chasing what I thought was a cool idea with zilch to show for it. 

Enough! See ya next time.

No comments:

Post a Comment

AD5761: Arduino Library and S/H Mux--one worked, the other sucked

  Two goals since last time: see if I could create an IC library for Arduino sketch, which was surprising easy, and breadboarding an Arduino...