DS1881 Experimenter's Board Part II--Rheostat Experiments and an AI Created Library

 I had a lot of fun with the DS1881--see this previous post--so I made another breadboard-eliminating experimenters' board for this cool digital potentiometer IC.

This second design deviated from the example found on the last page of the DS1881's data sheet: I added an on-board MCU (ATTINY1616) and exposed the IC's potentiometer pins as well as GPIO on the PCB's edge connectors.

I also uploaded the DS1881's datasheet into Claude Code then told the bot to create a CPP library for the experimenter's board, something I had never tried before. Get the code from Github, here.

Did it work?

At first--nope. 

Eventually, yes.

 

  

THE BUILD


Double happiness is new PCB's from this blog's patient sponsor: PCBWay!


.No smoke yet....

The DS1881's I2C address is configured through hardware. If you build this project jumper or short the 0x28 or 0x29 pins to choose its I2C address.  

....soldered a few components, hooked up bench power, test. If there is a short I isolated the fault to parts recently soldered. If no issues I kept building.


For proofs-of-concept I am using UPDI MCU's (ATTINY generation 2 and 3) more and more often.  UPDI is super easy--one wire and ground to blast firmware into the MCU--see the video here. Serial monitor isn't through USB however--for that I exposed the TX , RX and ground pins on edge connectors which got fed into a NUC Linux PC running minicom.

CLAUDES AND SODS

Normally I would have read, re-read then re-re-read the DS1881's datasheet; over the coarse of a few days created a C library file for it. Not this time--my tech friends told me to get with the program and get AI lazy.

OK.....I used Claude Code to create a C++ .h driver file for this project:

  • Installed Claude Code
  • Logged in using my Claude account.
  • Using browser Claude, I had it talk me through the Claude.MD file by describing what I was trying to do.
  • I created the local directory for the project, CD'd into it then typed claude.
  • I uploaded the DS1881 datasheet PDF into Claude.
  • I didn't record the prompts I used (sorry) for the initial builds. I discovered the free tool to see previous prompts (here) but at this point I was too lazy.

The library and test sketch didn't work at first--using a DVM there was no change in resistance present the H0/W0/L0 and H1/W1/L1 pins (the DS1881's "pots" pins).  

As a rheostat the DS1881 wasn't working.

I emailed Analog Devices who got right back to me--yes this should work; if I coded my firmware right, I should see resistance values of about 40K to about 4K across H0/W0 as I swept the DS1881's digital pots using the MCU.

It didn't--the DVM always showed about 30K no matter what--so I fired up my logic analyzer.

After years of using cheap logic analyzers I spent a small fortune upgrading to a saleae. Worth it? Yep.

This revealed that the I2C initialization was working but after that nothing--no I2C traffic.  Hello?

I reported this discovery back to Claude Code and it revised the .h file and even created an ino Arduino file for testing.  Took like 5 minutes. 

Uploaded the revised code and ino into the ATTINY1616 and--it worked.

WAIT! FROM THIS BLOG'S SPONSOR:

 


....why bother breadboarding when you can throw your ideas into Kicad, ship them off to PCBWAY and get boards back to mess around with. That's what I did here and overall a huge timesaver. 

In addition to top shelf PCB fabrication they also do great work with assembly, 3D printing, injection molding, and much more. 

Yep, prototyping with PCB's is faster and a heck of a lot more fun than breadboarding....more experimeter's boards to come in future posts--maybe some day I can even throw out the breadboards entirely.

Back to it.

NOW WHAT, DR. SHANNON?

No photos but I breadboarded some basic circuits--voltage dividers, op amp gain, an active filter--using the exposed DS1881 pot pins.  I could type on and on about this, but I'll spare all of us a lot of time--to me, there was nothing I could come up with using the DS1881 as a rheostat that was better than what I could do more efficiently with more "traditional" voltage or current controlled variable resistors like OTA's or Vactrols

The DS1881 shines doing what it was designed to do--a simple stereo atteunator with a nice sounding log curve. Beyond that, not so sure.

I think that's where I will leave this for hitting the coda.

Along with my hero, Bob Widlar, Claude Shannon (the real Claude) was one of the most brilliant and colorful tech dudes of all time. Wikipedia here.


THE CLAUDE CODA

Reviewing what Claude created: the library looked a lot more professional and succinct vs. what I would have coded by hand in C, employing extensive bitmasks, #defines than I would ever have used, and everything else C++ that drives me nuts.  

I need to test each method, but haven't yet. Something about Claude Code makes me feel--lazy?

I went through the robot generated code and tried to figure out what Claude had done, really, which might be more than a lot of other programmers do these days.

The output made me realize that I suck at Boolean Algebra so I got back into claude code and had the same bot whip up a Python/UV learning tool that (hopefully) will help me master bitwise statements in C.C++ someday.

this tool was created with a single prompt--no revisions:

I need to learn bitwise operations in C and C++. This includes &, |, XOR, |=, ~= example statements like uint8_t commandByte = reg | (value & WIPER_VALUE_MASK); the learning tool should allow me to use single bytes (8 bits) and perform bitwise operations on them. Write a program in Python to help me learn the syntax of these C and C++ calls. Data entry and what is shown as the final output should entered and shown as Hex (0x04 for example) and bits (0b00001111)

The output came out way better than I expected--and does a lot more than I would have thought of.   

Get the learning tool from github, here. We're cooking with oil! 

I'll admit it--Claude is smarter than I am, maybe some day I will catch up a little?  Nope. 

See ya next time.

No comments:

Post a Comment