An update on my electronics projects (by )

One of the challenges of being a massive nerd - who loves learning complicated technical skills - is that it can sometimes be hard to find new skills to learn. Thankfully, analogue electronics has provided me with a rich vein to mine; it's full of things that take some work to master, yet offer the opportunity to create interesting and useful things.

So, after the success of the Polyp Mixer (in which I learn how to use op-amps and to manage impedances within a circuit) and the trickle charger (in which I gained experience with basic power electronics), I am currently working on a... thing. I don't quite know what to call it, but I'm going with the working title of "microphone pre-amp". And my goal with this (other than to end up with a working microphone pre-amp) is to master the class A bipolar transistor amplifier.

The Goal of the Microphone Pre-Amp

So, the Polyp Mixer sits on my desk, mixing the audio output from my two PCs, and with two spare channels - one of which I intend to connect to a radio transceiver in future, the other being spare for random laptops or listening into audio circuits I'm working on (such as the microphone pre-amp, as it happens). This means I can listen to all of these devices through my nice amplifier and speakers. I can even plug headphones into the amplifier if I want to.

But, when I talk to people in video calls, I am using the nasty little microphone built into my USB webcam - and I can't feed that audio to the other computer, nor to a transceiver or anything. Rather than have a plethora of microphones for everything, I'd much rather have a single microphone that just feeds microphone-level signals to all of my devices.

So, the first goal of the pre-amp is to have a box that has a microphone in socket on the front, so I can plug in a microphone, and a bunch (let's say 4: two computers, a transceiver, and a spare, matching the mixer) of microphone-level outputs on the back to feed into my devices' microphone inputs.

However, this is complicated by the fact that different microphones produce different signal levels (of the pile I've tested, I've seen signals from 5mV to 100mV peak-to-peak). Normally I'd deal with that by adjusting "mic gain" controls on the inputs to everything, but it would be simpler if I had a "mic gain" knob on the pre-amp to adjust for different microphones, and then all the downstream devices can have their mic gains set to a constant level.

But not every device has a mic gain knob, because some things are meant to be plugged into custom-made headsets rather than arbitrary microphones. So, as well as the front-facing "mic gain" knob to adjust to different microphones, I could also do with "mic level" output knobs next to each output on the back, so each can be tweaked to read the same volume.

Also, if I switch microphones, I'd like to be able to get the level right before talking into my devices - so it would be nice to have a mute control and a level meter. I can mute the outputs, talk to see the level meter deflect, and adjust the mic gain knob until it's just hitting the maximum and not going over it. (This is why vu meters always have a green bit and a red bit; you're supposed to adjust levels until they're using the green area nicely but not going into the red area). So, I need a mute switch and a level meter.

Some microphones have a really tinny frequency response, picking up high frequencies much better than low frequencies. It would be nice (and fun!) to be able to compensate somewhat for this. I can't quite stomach building full spectrum analyser, but a classic James-Baxandall tone control circuit would be a fun addition.

Some of my microphones have a push-to-talk button; it might be nice to be able to feed that into the pre-amplifier, and have it drive the mute control. So, the mute switch really needs three settings - audio on, audio muted, and do-whatever-the-input-push-to-talk-socket-asks-for. And an LED showing the current output status, so I can tell if it's working when in external-push-to-talk mode.

A radio transceiver needs to know when I push-to-talk so it can transmit, so there also needs to be a push-to-talk output socket on the back.

Oh, and finally - I have a few headsets, with a microphone and earphones, so it would be nice if the thing also contained a headphone amplifier with a line-level input and output, so it can be connected between the mixer and my amplifier, and save me from running a long cable down from the headphone socket on the amplifier. So stick a headphone output and a headphone volume knob on the front for that, too.

At first I wanted to put a number of different sockets on the front, so I can just plug headsets directly in - an Android TRRS socket has lines for a mono microphone and stereo headphones, and the Kenwood/Baofeng headset socket has mono microphone, mono headphone, and push-to-talk. But in the end I decided it would be simpler to just have separate headphone and microphone sockets like on a PC, and a 3.5mm mono push-to-talk socket, and buy or make adapters from other standards to those three jacks. I managed to find a TRRS->dual TRS splitter on eBay, and made my own Baofeng->headset, microphone, and PTT lead (using two five-ohm resisters as a passive mixer to mix the stereo headset signal into a mono one). Having these adapters also gives me the flexibility to connect Android or radio headsets to computers, or connect a radio headset to a smartphone.

In other words, this thing has accumulated some feature creep, through a bunch of weakly interconnected features! The most questionable of these is including the headphone amplifier - but it does feel convenient to be able to plug a headset into a single box, and as the mixer is conveniently situated on my desk while the amplifier proper is a bit more of a reach away, it would be messy to be running a headphone cable extension back; headset splitter adapters only have ten centimetres or so of lead, so the microphone and headphone sockets do need to be close.

Microphone interfacing

So, in order to design this, I had to learn about what a microphone-level signal is like. It's a different beast to the line-level signals I worked with to make the Polyp Mixer, in two respects:

  1. They are much smaller, typically 5-100mV peak to peak, instead of the 1V peak to peak of a line-level signal.
  2. They need DC power to be provided to the microphone, as (depending on what kind they are) they either need a voltage to charge a capacitor, or to drive a tiny FET amplifier, or to excited the coil of a dynamic microphone. This DC power can be provided directly to the microphone signal itself, as a DC offset to the AC signal (making it a weird bidirectional signal: power in one direction, signal in the other), or on a separate wire. Thankfully, you can provide both at once as a small DC offset won't harm a microphone that doesn't need it.

Because the signal is so tiny, you need to be careful not to introduce noise to it - 1mV of noise on a 5mV peak to peak signal will make a right mess of it. As op-amps, like I used in the Polyp Mixer, can be quite noisy unless you get fancy expensive ones, most microphone pre-amplifiers use a transistor first stage. Which gives me a perfect excuse to learn about transistor amplifiers.

A lot has been written about them - there are many kinds. Suffice to say, for this project, I am making a class A common-collector bipolar transistor amplifier as the first stage. This amplifier doesn't increase the signal voltage at all, but it does draw only a very small current from the input, while being able to drive a large current at the output. Since microphones often have a very high output impedance (hundreds or thousands of ohms) you can't draw much current from them. So this first stage is really just a driver for the second stage, allowing it to draw as much current as it wants.

The second stage is a class A common-emitter bipolar transistor amplifier, with a voltage gain of about 20. So weak 5mV inputs will become 100mV peak-to-peak signals after this stage, while strong 100mV inputs will become a rather lively 2V peak to peak. At this point, I run it through the front-panel "mic gain" logarithmic variable resistor, so I can tweak it down to a 100mV signal. That's now far enough away from the kinds of thermal noise voltages you'll get in an op-amp, so I break out my trusty friend from Polyp Mixer days, the LM358, to 10x boost it up to a 1V peak to peak line-level signal with a low output impedance. Perfect!

Now draw the rest of the owl

From there, the signal can go through the tone control circuit, then into another LM358 - one op-amp of which boosts the level back up to 1V peak to peak (the tone control will attenuate it a bit) and buffers it for distribution and the muting circuit, the other of which drives the LED bargraph level display (for which I plan to use a LM3916). They each get a separate op-amp, because the mute circuit will be dumping the output of the distribution amp to ground, and the bargraph display will have a trim potentiometer to set the gain so I can calibrate it to hit the red LEDs only when the signal is being over-driven.

I'm not too sure about the mute circuit - I still need to experiment to finalise the design. The signal coming from the op-amp will be a 1V peak to peak AC signal referenced to a 4.5v DC bias. I plan to connect a 100 ohm resistor in series with the output of the op-amp, in effect giving it a 100 ohm source impedance, and have an NPN transistor just pull the signal to 0v through a 47 microfarad capacitor when it's muted. This will hopefully suck all the AC components away and leave near silence; I'll put a small RC network in the base drive of the transistor so it has a bit of a fade in and out, to try and avoid having an audible pop when it mutes and unmutes. The LM358 op-amp output should be happy sourcing 10mA (1V peak to peak, through a 100 ohm resistor to ground) but I might need to go up to 1 kilohm series resistance, especially if the mute isn't quite enough at lower frequencies where the capacitor has more impedance. I just need to make sure there's enough output drive left to run the output stages.

As the transistor will need to be on to mute the signal and off to hear things, the three-position mute control switch can just connect the transistor's base to the positive power rail (via a resistor) for mute, and to ground for non-mute. For the external push-to-talk input, I can make use of the fact that push-to-talk switches on microphones are usually switches that connect the line to ground when pushed, and have a pull-up resistor connected to the external input so it's high (muting) when the button isn't pushed and pulls low to un-mute when it's pushed. But, as a general policy (and because I want practice with transistor circuits) I'll put a common-collector buffer between the external socket and the mute switch, to isolate it in case the microphone is doing something more complicated. Oh, and a second common-emitter transistor switch can drive the external push-to-talk output, pulling the line to ground in the standard manner. I can't just connect the raw input direct to the output, as my circuit will pull it up to 9v - and if it's plugged into a transmitter that tries to pull it up to 12v, that wouldn't end well for my circuit.

For the outputs, I will just distribute the audio signal to four identical common-collector buffers, each of which drives a potentiometer to set the output level, thence out to the sockets - via capacitors so we can ignore any DC power being sent from the device it's plugged into. We have plenty of DC power of our own.

And finally, the headphone amplifier will use everyone's favourite: a pair of LM386 power amplifier chips, one each for left and right, with a volume knob.

So, there's a bunch of exciting new kinds of circuit in there for me to experiment with - including using NPN bipolar transistors as common-collector and common-emitter amplifiers for AC signals, and in a saturated switching role in the mute circuit. Lots of fun things to learn!

This is also a device with a dizzying number of sockets, knobs, switches and LEDs on the front and back. Rather than mounting all of those on a single flat PCB and having a very wide flat thing, I've decided to make it as a bunch of modules, each on a vertical PCB, all joined by a horizontal motherboard at the bottom. This lets me use the three-dimensional space in the box better and makes it a bit easier to get everything mounted neatly inside, and also means I can swap modules out - one day, the tone control might be replaced by a fancy digital signal processor that can do voice effects or something.

So far, I've built the input circuit - the two transistor stages and the LM358 op-amp stage - on a breadboard, and it worked swimmingly. Then I built the tone control alongside it, but in the process, have broken the input stage as it's not creating any signals, and it's getting so cramped on this breadboard I've designed a PCB for the input module. I'm currently waiting for it to be shipped back to me from China, so I can build the now-validated circuit on the board and use it as a signal source to test my tone control circuit. I can build each module in turn and connect them via breadboard until the whole design is validated, then make the motherboard for them all to plug into and a case.

Expect a more detailed blog post on the final design, probably exploring it module by module like I did with the Polyp Mixer!

The next project

So, if I learnt op-amps with the mixer, power switching with the trickle charger, and bipolar transistors with this microphone thing, what's next?

Fear not, I already have a plan: I want to make a curve tracer. This useful piece of test equipment, at its simplest, provides a current-limited AC signal of a few volts peak to peak and applies it to a device under test. It then - either through an inbuilt screen, or by providing signals to an oscilloscope in X-Y mode - draws a chart of the current flowing through the device against the voltage applied to it. Voltage on the X axis, current on the Y axis. The current limiting is often provided by a 1kOhm resistor in series with the device, meaning that at most a few mA will pass if a few volts are applied. If you sample the current by measuring the voltage across the resistor you also get a simple relationship that one volt on the Y axis is one milliamp.

If you put a resistor in, then the current flowing will just be the voltage divided by the resistance, so you'll get a straight line - the gradient of which reveals the inverse of the resistance (bigger resistors have flatter lines as less current flows for a given voltage). If you put in a diode, then you get a flat line in the negative voltage area, extending into the positive area until around 0.6V (for a silicon diode) when it begins to conduct, then the line will sharply rise up to the 1mA current limit. Because of the 1k series resistor, the voltage on the device will never swing much beyond 0.6v. Devices with internal state (the charge on a capacitor or the field in an inductor) produce loops rather than straight lines, as the curve traces a different path while the input voltage is rising as when it's falling.

But you can test three-terminal devices, too. Commercial curve tracers usually have a circuit that steps a voltage to a third terminal that you can attach to the base of a transistor, at a fraction of the frequency of the main AC test signal, so you can see overlaid curves of the device's collector->emitter characteristic at different base voltages. I'd rather just have a potentiometer I can turn to interactively explore.

Anyway, there's a common design called an octopus curve tracer that uses a transformer to take mains AC down to a few volts, still at 50 or 60Hz, and then just feeds it to the device and the 1k series resistor. You connect your oscilloscope ground to the point between the device and the resistor, the X input to the other end of the device, and the Y input to the other end of the resistor. So the X axis reads the voltage on the device and, by measuring the voltage dropped by the resistor, the Y axis reads the current (albeit inverted).

I:

  1. Don't want to mess with the mains yet
  2. Don't want to have to plug this thing into the mains, which involves bulky plugs and cables
  3. Want a non-inverted current readout
  4. Want to gain experience in oscillators and transformers

...so I propose to make a curve tracer running off of 9V or 12V DC, with a 555 oscillator producing a square wave at a few kHz which can then drive a MOSFET (technically a class D amplifier) which has a tuned parallel LC circuit between its drain and the power rail - the inductor being the primary of a transformer. The tuned nature of this circuit will pick out the fundamental frequency but filter out the harmonics, turning our square wave into a sine wave, fairly efficiently. We can then have a tapped secondary winding with a selector switch so I can select peak output voltages of 1V, 5V or 10V to drive the classic octopus circuit with a 1k series resistor and the device-under test.

However, a second secondary winding with a central tap can produce +/-15V, with the centre tap joined to the ground point between the device under test and the series resistor. This can power a split-rail op-amp that inverts the current signal, creating a positive current signal. It can also power a potentiometer with a series resistor on either side, to reduce the range from +/-15V to +/-5V or so, to drive a third terminal for fiddling with transistors. An inbuilt voltmeter can display the third-terminal voltage, if I can find a decent voltmeter module that supports positive and negative voltages.

Anyway, yes, that should be fun, and will give me useful experience in driving power into transformers, which brings me to the next project after that...

MPPT solar charger with grid input

So, in my workshop, I have a bunch of DC devices that I run from a 12v lead-acid battery bank up on the roof. Currently, this is stuff like lighting, a dust filter fan, the wifi access point, the Polyp Mixer, and various smaller loads. This battery is charged from two 100W solar panels through a commercial solar charge controller, but during winter months this isn't enough: the base load is nearly an amp, and the batteries slowly discharge. I need to connect a mains-driven 13.5v power supply to it to help meet the base load and keep my batteries from being damaged.

I want to make my own solar charger - doing the whole MPPT thing while also implementing the small state machine required to properly maintain a lead-acid battery. But I want it to also have a grid input it can turn on when required, and supplement solar power with grid power. In particular, I want it to only draw current from the grid if the battery is getting too low, and then stop when the battery is fully charged. And if the state machine says we need to be feeding the battery twenty watts and the solar panels can only produce fifteen, I only want to draw five watts from the grid.

I propose to do this using a push-pull DC to DC converter, but with two primaries on the transformer - one drawing from the solar input and one drawing from the grid input, which will be an off-the-shelf 18v laptop power supply capable of sourcing a few amps (with the AC side controlled by a relay so I can turn the whole thing off when it's not needed). With careful microprocessor control I can alter the carefully-synchronised switching waveforms to the four MOSFET transistors pulling either side of the centre-tapped primaries down to ground, and thus be able to simultaneously perform the MPPT algorithm to control the solar input while then drawing enough additional power from the grid input to produce the power input demanded by the battery charging algorithm. This looks like great fun, and I can't wait!

But all the projects I've done so far and am doing lead up to this - gaining experience in the basic building blocks required, before I go and implement it using transistors rated to carry tens of amps, connected up to hundreds of watts of solar input and a battery bank capable of providing hundreds of amps if short-circuited!

1 Comment

Other Links to this Post

RSS feed for comments on this post.

Leave a comment

WordPress Themes

Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales