Saturday, July 31, 2021

Quick Comparator--First time using an SMT stencil--A Win!

Time to branch out further into the land of surface mount!  

Viewing videos that feature SMT stencils and hot air guns (here and here for instance) made me want to try this fabrication technique. 

With generous help from this blog's sponsor, PCBWAY, I got some PCB's for an op amp based comparator design I conjured up, an SMT stencil, and gave it a try. 

It took PCBway about 5 days from upload to getting the boards and stencil from China to the US--cool! 

Good news: this technique was really easy, very fast, and I have a new fab methodology at my disposal. 

And! the SMT stencil results came out MUCH better than I thought. Happy with all that.

What was needed: Stencil (still in its shipping cardboard) and SMT-ready PCBs from PCBWAY, MELP SMT resistors from Mouser, and some large unused boards I had lying around. The latter will be used for the masking process.


"Let's get Started"! (how many videos begin that way?) :

I placed the PCB to be populated between old boards I had lying around. Next I taped them down with "Scotch magic tape" which may be my most used fabrication material. 

I positioned the sencil and taped it on only one side:

Board in the middle is a mostly SMT 6HP Euro comparator. The design is untested, I pretty much laid it out with best guesses and intuition--Might work right?

Folded over the stencil:


I used this solder paste--"Chipquik No-Clean T3" (chosen after a bit of research--there were a lot of choices, this one worked....)


Slathered it on boys, I ended up having to use more paste than I thought I'd need....:


No photo but I spread out the paste over the stencil with an old credit card. Then I very carefully and slowly used tweezers to flap the stencil back over, like opening a door.  

Good news, the stencil did the trick--I had neat little pads of paste as needed.

Again no photo, but I placed all the tiny parts with tweezers. The paste was sticky so this wasn't too hard. I feared my parts would blow away when I "hot air gunned" them; fortunately they didn't.


Next I used my trusty hot air rework station (information here--the Sparkfun 303D was relatively inexpensive and has turned out to be a quite useful tool) set at about 350 C and about 9AM on the air pressure pot. This was a guess....but it did the trick.  

As I saw in the videos, upon heating, the paste turned a snowy white, then after maybe a minute, quickly turned a beautiful shiny silver, and each part was drawn via capillary action to its pads. Perfect! 

It was like magic...it worked!!!!

For clean up (I got some paste on the bench--yuck) Testors plastic enamel thinner did the trick....



Here's what I ended up with:




I thought the result came out GREAT! 

This was so much easier than I thought it would be. The entire process, from unbagging to taping to pasting to placing parts to using hot air to solder everything down--took maybe 1/2 hour and yielded professional looking results.

Great! I added the thru hole parts, Euro style power, and powered it up. 

So--did the board work? 

NO!

So much for the fun part, the rest of the morning was spent chasing down stupid mistakes.

I found 3 problems--one due to poor layout, one due to design carelessness, and the third because, well i have no idea why: I had an airwire on the design (so, no traces when I needed a trace) and I missed it. 

Warning to SMT PCB novices like me: "Be careful about via locations!"


When laying out SMT boards, don't put vias too close to parts.  My assumption was that during the soldering process the solder would go right where I wanted want. Not always!  

If there is a solder bridge between an SMT part and the via (there was in my case) you will have a short. 

And, since the via carries a different signal than the component, the short can break the signal flow, which is what happened for me; it grounded out the input signal and the entire circuit didn't work. Nice.

If and when I get this board fabbed again I will fix this by moving the via further from R6.... .

How I fixed the via issue.....


The rest of the problems were not due to SMT fab, rather, bad design choices. I had to lift another SMT resistor and use a kludge wire to get the output to work due to a "your current has to go somewhere" design error.  See R3 in the schematic below. Oops. 

I also added a zener to clamp about 0-7.5V at output. This is optional, for 0-10V systems you could use a 10V zener, or for a rail to rail comparator leave this part off.

Finally I fixed the airwire but putting a solder blob between pins 13 and 14 on the TL084 surface mount IC.  

Overall, debugging, fixing, and modding SMT builds was harder than fixing thru hole PCBs, because everything was tiny, but I laid out the board sparsely and used some thru hole parts such as D1 and D2 because I figured I'd be fixing and modding. I was right.

Here's the working comparator after the mods:



Here's the schematic with fixes:


schematic with fixes....the zener sets output voltage range

Going forward it would be nice to have an inverted output and a few other mods, but this design and build was more about experimenting with SMT stencils than coming up with a fantastic audio comparator. Overall, since using the stencil and hot air soldering elements was easier than anticipated, so I am going to consider it a win. On to other things.

Shameless plug: if you want to help support this blog please check out my sponsor--PCBWAY, link is here


They are super friendly and have been soooo helpful..... thanks to Wendy and the gang for helping me get all of this going. Always good to try new things right? 

More fun next time.  See ya.


 

Monday, July 26, 2021

LFO Prime--Reverse Engineering my Own Work, And It Still Doesn't Work (Yet!)

Before we begin: introducing this blog's new sponsor: PCBWay. Link is here, check them out. I am extremely grateful for their support of this blog!

I cobbled together an Analog LFO back in 2003 and didn't document any of it, now I want to make a clone. So far no love: two different attempts failed for different reasons. But I will get this clone of my own work to work someday! Really!

The LFO prime, almost 20 years later.....Which one works? Neither!!!!

In my ewaste pile are two PCB layouts, both don't work, and are too broken to fix with kludges. 

Where did I go wrong? (Always liked that song). A few dumb mistakes of course.  The design is based ont his core 2x op amp osc design you can find all over the internet; here for instance....



for the stage on the left--the feedback is to the non inverting terminal!  Wait, I thought op amp  feedback is always wired to the inverting terminal?  Not here. So I laid out the feedback on the rev1 board and of course it didn't work. To wit: if you want to break an audio DiWhy circuit, wire up the op amps wrong!!

The rev2 board had another stupid mistake--when I look at it of course it doesn't work--how did I miss this?

The idea here is that BIAS DPDT on the top right the switch offsets the circuit output by +5V, so we have a switch to choose between bipolar and unipolar output voltage.

But, the switch adds the gain stage to the bottom left to only the "bias A - Bias B" switch in one of its two positions--dumb! The output won't be the same if the only one signal gets 4x gain. That's what I was seeing for the output of Rev2 on my scope. Not what I want.

I rewrote it like this, new layout is coming.....


Now both unipolar and bipolar should get the 4x gain boost. Much better.  

Using a Hakko 301 tool, I managed to get all the useful parts off the 2x bad boards...that's good.

I fabbed a front panel for this hopefully--before I knew my rev2 design was NG--the drilling came out pretty well, so i hope to reuse that for the rev. 3:

Tape a 1:1 output of the PCB....drill your holes.

Line it up, place in the parts and solder.....using PCB material for front panels all of this is easy.

Lessons learned:

First: always document your DiWhy! 

When I first started this odd quest to make audio electronics myself, and not just buy something, and I got something to work, I wanted to light a cigar, not go through the boring laborious process of  documenting what I built. 

Of course if I wanted to make a second identical circuit or repair or improve my DIwhy creation, well, I had to reverse engineering my own work. That's not alway7s easy....since the original build was perfboard spaghetti, good luck with that.

Second: try not to make dumb mistakes, but sometime you will, right? Let it go, mo! I was pretty happy that I wasn't too upset about this (an odd sentiment on its own), as I have been angry things on the bench that I can't get to work in the past, especially surrounding relatively easy circuits. Not sure why I'm more mellow about my mistakes?  Age?....improved diet?....something like that.

Third: The coolest and best thing about analog electronics is that it always acts the same.  Ohms law always behaves like--ohms law.  Voltage dividers always divide. If you don't give current somewhere to go, it stays put. We are dealing with laws of nature here and if it doesn't work, it's because I misunderstood some law of nature. It's not software! And best of all? It's not going to act differently by rebooting!!  In its own way, analog design is beautiful because of its repeatability. 

How many other things in life are like this?

So, onward.  I will send the revised board out in the next PCB run and try this again.  More coming....

Update: I figured it out, post for a working LFO based on this design is here.



Saturday, July 24, 2021

Analog Devices AD5761--EZ Embedded C library for Bipolar DAC--Works!!

 Hi again, follow up from the last post, where I was wasting hours trying to get an AD5721 12 bit Bipolar DAC to work. 

Giving up on that, but I got the AD5761, a more expensive version with 16 bit resolution, to work just fine.  

Through an EE I know, he confirmed via AD tech support that the 5721 uses the same code as the 5761, except that the data register is a bit different, so that's not the problem.  

Something on my bench? Phases of the moon? We may never know.

So my solution about getting the AD5721 to work on my bench is simple: don't use it! The 16 bit version is about $3USB more per chip; that will have to do.


They both don't work!


This one does! 

Looks OK on the scope....

I did learn an important thing about Analog Devices ICs--for some (many? most?) Analog Devices provides really thorough open source example code, written in C.  

For the AD5761 for instance, go to its "product overview" page on the AD site (here) and scroll down.  

You see the "NO-OS driver", go here. Wow--There is a lot of  C code here to peruse and if you are feeling lazy, just use that in your embedded C project and call up the methods Analog Devices provides. 
Cool.

For me, I am only going to use this DAC in a very specific application--bipolar DAC for +/- 10V P/P.  Otherwise I'd use a less expensive DAC.

I need to send a 16 bit word in, in straight binary, and need that value converted to analog at the chip's output. If I end up using this for +/- 5V, 0-10V etc. etc., I can write new functions, it's only a matter of changing the 24 bit control register that tells the chip what you want to do (which again is cool).

If you want to get my super easy embedded C micro library for this, the Github content is here.  If you fork this dork, please comment below, let me see what you did, I am interested in seeing what others do to expand/improve/correct this code.

In the meantime, this all took way, way longer than it should have, and I am a bit burned out and frustrated. I guess we can't have fun all the time, right?  Coding means no fumes, but a lot of sitting around.....

Enough! See ya next time.

Monday, July 19, 2021

Analog Devices AD5721: welcome to BIPOLAR DAC HELL!

Hello again. I've not been posting as much lately due to health issues, but still had time to mess with some new ICs on the bench. 

This time I went to war with Analog Devices AD5761/21 bipolar DACs.  

AD5721/61 requires +/-15V, a 2.5VReference, 3 data lines for SPI, and 5V to tell it what is logic "high".  Add Pulseview to analyze why it doesn't work and you have a lot of bench clutter.

DACDAC go: The advantages for audio design using a bipolar DAC, especially one with a buffered output like the AD5721/61, is lower chip count.

Hook a bipolar DAC to your MCU (for me, on the bench, an Atmel 328P on an Uno R3, programmed from Atmel Studio 7), write a few lines of C code and the result is a nice bipolar ramp wave--or any other bipolar low frequency analog signal--at the DACs output. No need to use op amps and/or caps to get the output to straddle 0V.

Perhaps an entire complex AudioDiWhy circuit can be built using only two chips and a few caps: the MPU and the bipolar DAC IC.  16bit fidelity. 20hz-1Khz or so waveforms. Low noise floor.  Nice!!  

Wiring for  TSSOP version of the 5721/61. you can use 2.5V from a bench psup for pin 4, which is the DAC's reference, instead of 2x 10K resistors from 5V to ground. WARNING! Wiring for the LFCSP version of this IC is different--don't misread the datasheet.....  


On paper this looks like a game changer. These 2 DAC IC's are a bit expensive--the AD5761 is 16 bits and costs about $10 USD in small quantities while the AD5721 is 12 bits and costs about $7.  

One the projects I've been thinking about only needs 12 bits, so for starters let's be frugal and use that.

The AD5721 is a very tiny IC and we need to make it ready to breadboard. OK, for tiny tiny tiny SMD to DIP applications I like Schmartboard--more expensive than most SMT to DIP adapters but quick to fab and easy get right. And sometimes they have blow-out sales, which is how I got these adapters for about $1USD each.  

On paper the AD5721/5761 has some other cool features, like the ability to change its output range from your code (no need to use a processor pin for this).  Also the ability to read what is in its registers back to the MCU. It also has the ability to output its temperature and daisy chain several of the DACs together for multi channel output. Cool!

OK that's the good news, but here's the bad news: I worked for about 3 days to get the AD5721 to do anything (other than just sit at 0V at output) and--nothing

Welcome to DAC HELL!!!! 

I swore, laughed, and I cried. I sat up at night trying to brainstorm what I was doing wrong. I went into full OCD mode complete and at times was not being able to talk to anyone. 

I read over the data sheet 1000 times then another 500 times to be sure I didn't miss anything. I poured over the timing diagrams and used Pulseview to verify SPI was within the chip's speed limits and the chip was receiving the SPI traffic intended (it was). 

It could have been my chip?  My SMT to DIP soldering work?  I built a second one. Same thing.

I tried all different variations of my code.  Nope. No output.

I was coding it wrong?  Um, from the data sheet, I am going to say no. But maybe--yes.

I need to explain this.

First let's talk about how to program this little beast. 

As DACs go, this one is a bit harder to set up than say a MC4725 but really it's not that bad. 

The AD5761/21 uses SPI. It needs to see 24 bit words but that's easy--pull CS down, send your clock and data using 3x SPI transmits, then pull CS back up.

So......

  • Power up
  • Send a reset (a byte followed by 2 "don't care" bytes)
  • Send 3x control bytes to tell it things like what output voltage range to use
  • Send a byte to say "send the next 2 bytes to the DAC register"
  • Send two bytes to the DAC register.  That's the data you want at output.
  • Wham Bam--you have output.  Right?  
  • Um, with the AD5721, no.  I tried.  I really did try.
So working psuedo code might work something like this:

CS low
 7 0 0 // soft reset after power up
CS high

CS low
 4 0 0 // control bytes; we want +/- 10V at output
CS high

CS Low
3 255 255 // write 0xFFFF to dac register, which puts voltage at DAC's output.
CS high

 

Nothing worked, so I tried the 16 bit version, the 5761.

YES! Dropped it in, same code, same bench setup, same footprint--it worked!!! 

Output from AD5761, see how easy that is?  TWO POINTS!


But same everything with 5721 (again, I tried two) NOTHING!  

I will skip the photo of the scope flat lining.

I have read the AD5721 datasheet more times than I've perused barf bag instructions on a commuter plane--says other than the 4 LSB's of the data registers being "don't care bits" on an AD5721 there is no difference between the 2 chips.

The input register on the 5721 ignores the last 4 bits, but the control bits for BOTH CHIPS are documented as being 24 bits wide. 

How can that be when the 5721 ignores the last 4 bits?

So my guess: the control words for the AD5721 must be different than the 5761. That's why the former doesn't work.  And AD didn't document this difference in the datasheet correctly

And oddly I see posts online for AD5761 uses, libraries for it, etc., but really nothing for the AD5721.  

Does anyone even use the AD5721?

Maybe someone can enlighten me, if you have ever gotten an AD5721 to work please, please comment and let me know the data words you used to get the chip to do--anything.

But for now it's 16 bits for this project. 

I am going to see if anyone at Analog Devices can tell me what i am doing wrong for the 5721....but they are big, and I'm not, and I may be out of luck.   

Update 7-19-21 after asking around and calling in a few favors, I may be able to have a pro EE help me sort this...he has contacts at AD.....AD says no, the control register for AD5721 is 16 bits, in spite of what the data sheet says, so that's not it....16 and 12 bit chips should be interchangeable, but really, they didn't know, and figured I was doing something wrong....to their credit, I am told Analog Device's support on this matter was attentive, polite, and overall top notch.

UPDATE-7-24-21  Giving up on 5721 but the 16 bit version works OK.  See the post here.  I gotta move on......


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