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 (abbeviated as "BoB") using Microchip's MCP33151 analog to digital converter (ADC).  Data sheet 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 bunch of their 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

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!

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