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 low 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 BreakOutBoard:



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 inverts the output signal again.

 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....Data sheet is here; nat semi application examples (untested by me) can be found here.

There are lots of comparators out there--why this one? 
LM311 is a good choice for low parts count comparators because its output is buffered with an internal NPN transistor:



Which means: a pullup resistor at "collector Out", 3 to 15V at Vcc (pin 8), GND (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 and tie EMIT OUT to GND. 

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

Cool!

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

That turned out to be useful because when I first wired up Elton's design it didn't work due to an incorrect valued resistor. Throwing a DMM on Pin 2 helped me figure out my mistake.

THE BUILD 

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 back:

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; get your 100mil pin header  male to male material and using needle nose pliers pull 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 it on a breadboard to test.



And at output I got--nothing.  

The output was slammed high, against the Vcc rail.  

What? 

This circuit is 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 is essential the same thing as the divider's source voltage.

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

"One of these things is not like the other" 

With the correct part values: "seems working"

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

Low parts count--and, if I went with 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:


  

 

DESIGN

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. 

BUILD

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

tested...worked!


OUTPUT--WORKED!


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?  

Onward!

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