Running a Raspberry Pi off a LiPo battery

I wanted to take an IR photo at dawn. IR photos are easy enough these days, you can either butcher the camera you already have taking out the IR filter, or you can use a Raspberry Pi NoIR camera where they have taken the filter out/not fitted it at the factory.

The dawn part, however, is a problem. I am night owl 😉 I don’t do dawn, if I can help it, and since the target is static in my case, and the Raspberry Pi is the camera of choice, it seems a nice idea to get the Pi to do all the work of getting up early. Why keep a dog if you have to bark yourself?

There are no end of shims and gizmos that will up the 3.7 to 3.2V of a LiPo battery to 5V, for putting into the Pi. I’ve used a wide input shim to power Pi’s off a CCTV power supply rather than have one mains PSU per Pi.

In this case I favoured the piZero variant, and didn’t have aims to be connected to t’internet in the field. So I need a real-time clock, and all of a sudden a simple requirement has turned into dongle hell. This is where I wanted to be:

Pi running off a battery
Pi running off a battery

and at first considered a 5V LiPo plus RTC device like this only to discover it won’t start the Pi on a schedule. I then considered using a 16F628A PIC with one of the DS3231 dongles, a Chinese noname clone of this. It turns out the stock Raspberry Pi driver can support one single wakeup alarm on the DS3231 – the gory details are here. That will pull down Pin 3 on the alarm, although pin 3 isn’t brought out on the connector it’s easy enough to tack a wire onto that. Some Pis have a setting where you can pull a wire to ground to start the board; fortunately the DS3231 pin3 is open-drain so ti will work with that. The PiZero (not W, mine is a 1.3) draws about 30-40mA powered down, that’s much better than a real Pi but still a bit much for a battery. Continue reading “Running a Raspberry Pi off a LiPo battery”

piezo contact microphone preamp for plug-in-power

This is for a piezo contact mic that is powered off a field recorder’s plug-in-power  supply. That is for small recorders like Olympus’s LS10, LS-5, LS14 series, which are typically unbalanced audio inputs, stereo on a 3.5mm jack, not for a P48 phantom power from a mixer or pro recorder1. You also get an opportunity to drink beer.

Batteries are a pain in field recording. One battery to rule ’em all is best in my book, the fewer things with a battery required to make a system work the better. The recorder generally has to have a battery, and Sony agreed with that many years ago, back in the days of Minidisc, and came up with plug in power (PiP). to eliminate the battery in the microphone. An electret mic doesn’t need much power so battery life is weeks not hours, but it has a switch you often forgot to switch off.

Plug-in-power

Plug in power is about 3-5v supplied through a series 6.8kΩ resistor, with the output developed across the 6.8kΩ resistor. It so happens that electret microphones were coming in at that time, and typically had a FET to buffer the high source impedance of the capacitive electret mic, an audio source through a few tens of pF. The 6k8 resistor is the drain resistor of the electret mic. You can read more about plug in power here.

Ideally a contact mic would work with this just like an electret mic, after all the problem and the solution are the same – a high source impedance 2 requiring a FET to buffer it.

there’s not much power available in plug-in-power

The trouble is that both the FET piezo amplifier and the opamp version need a 9V battery, which is a pain in the backside. An Olympus LS10 needs two AA cells and will run hours, and then the piezo contact mic wants a box with a 9V battery all to itself. That’s not good, and you tie yourself up in wiring.

The opamp version will never run on plug in power. The basic FET buffer is optimised for 9V, so it won’t run off PiP either.

The design

Plug in power contact mic
Plug in power contact mic

Initially I tried this with R2 omitted (replaced with a short) but there is not enough current to get the drain off the 0V rail. That’s fair enough – the IDSS is specified as 2-20mA and the most current you are going to get from a 3V supply through a 6k8 resistor is a little bit shy of 0.5mA. I bought a job lot of 2n3819s and experimenting with the value of R2 showed 470Ω put the drain voltage about 1.7V, with the source voltage about 0.5V, dropping about 1.2V across the transistor and 1.3 across the 6k8 drain resistor, which is good enough. Surprisingly, though they were from Ebay, nominally Fairchild parts,  all five I tried biased about right with 470Ω up to 680Ω. Ordinarily you’d bypass R2 with a capacitor to maximise gain, but you are rarely short of signal level with a piezo mic, so I omitted that, it will slightly reduce gain, and also limit the current slightly if the piezo puts too much through the gate/source junction if I drop it. I have decided to take a chance with this omitting the diodes of the original FET version, because they’re hard to fit in. I expect peaks to be lower because I have mechanically damped the mic a lot. Time will tell if I get to regret that and the mic goes noisy or fails in service if I drop it once too often.

Your optimal value of R2 may be different due to the spread in FET  Vgs- put a multimeter on the drain and aim for about half the open-circuit voltage3 ±10%. Mine is chosen purely for the supply through the left hand channel. If you parallel the inputs you may need a different value. I have hopes of using two to record stereo, else for mono paralleling the inputs makes for easier monitoring in the field.

Plug-in-power contact mic construction

First open a bottle of beer, trying to preserve the shape of the crown seal rather than bend it in the middle cavalierly. Obviously you can’t leave an open bottle of beer in the lab, so drink it. A 2cm piezo disc fits in a typical bottle cap, as shown

2cm piezo disc and bottle cap

Now pick out any plastic seal in the bottle cap, and then clear the residue. I used a Dremel and the face of a small stone attachment to get this

Dremel-cleaned bottle cap

You are going to solder to that surface, it will be the ground, and the cap provides shielding on that side, the brass disc shields the other side. This is a good time to drill a 3mm hole in the side of a cap, I used a small modelling pillar drill. If you don’t have a pillar drill you are probably going to give blood and turn the air blue with cursing. So better file a U shaped slot with a round needle file instead 😉 A hole locates the cable better in the later glue stage, but it’s not essential.

Now assemble the amplifier Manhattan style over the ground plane of the bottle cap, which also takes the shield of the cable. Use relatively thin cable for the output signal, because else handling noise will drive you bonkers. Some cable protection against the sharp metal would be wise, heatshrink in my case. Solder the piezo to the relevant place. You don’t want too much of the red and black cable going to the piezo element because you will have to lose this in a load of glue. I had too much.

the amplifier constructed on the cap

Now would seem a good time to test this with your recorder, handling the piezo should be easily audible.

I wanted to keep a continuous solid interface to both sides of the piezo. Air is quite high impedance mechanically, and a contact mic detects signal in low-impedance solids. The sharp resonance of piezo discs is because they are a solid in air on both sides, and I wanted to damp this and match the disc to the solid medium. I used glue for that.This takes out a lot of the dreadful 2kHz honk in the sound, which is the natural resonance of the disc in air. In an ideal world you would put the contact mic in a solid medium with the same impedance as the ceramic either side to pick up the longitudinal vibrations, which would get rid of that resonance, but getting rid of the piezo-air interface on both sides helps a lot, even if epoxy and hot-melt glue aren’t a great match for the ceramic – they’re much better than air! The cap and glue mass-load the rear of the disc somewhat, which usually improves the sound.

In the final device, you want the disc to sit slightly proud of the bottle cap so the brass disc is in contact with the sound source, but the bottle cap isn’t. For that you can use hot melt glue all the way, though probably in two stages.

the amplifier as the glue is setting
the amplifier as the glue is setting

I wanted to glue a neodymium magnet to the other side of the piezo disc. Many things that are interesting with a contact mic are steel surfaces, and a magnet saves you trying to clamp or stick things to such a surface.

I discovered the hard way that hot melt glue is above the Curie point for neodymium magnets, and the loss of magnetism is permanent, turning it into an expensive metal disc. So I used epoxy resin to stick the magnet to the back of the piezo disc. I also got to resolder the red lead to the friable silvering on the back – best done quickly.

magnet glued to piezo disk
magnet glued to piezo disk

It pays to manipulate the magnet with non-ferrous tools, the best way to hold it in place is put it on the disc over a steel surface covered by masking tape. The next stage is glue this to the cold hot-melt glue encapsulated amplifier in the cap – the depth of the glue plus the magnet should set the brass disc proud of the cap. I also had to lose all the red and black wire in the gap and fill this with epoxy. I did this glue operation is two stages, because otherwise it was going to be a very messy job.

first the magnet and disk are glued to the hot melt glue surface

This stage is used to prove the brass disc is clear of the wires and the bottle cap. Only just in the case of the wires.

The second stage infills the gap between the disc and the cap, by mixing the glue on a piece of paper and using a fold in the paper to pour the epoxy into the gap.

The final product
The final product

You will get to scrape some epoxy off the disc. Aim to make nothing stand proud of the brass disc, which will then be held on steel surfaces with minimal gap.

Field testing – what does it sound like?

This is the mic attached to  galvanized farm gate, the excitation is entirely the wind. I could not hear this sound standing next to the gate, it was a strong breeze, not a hurricane. I found it was very easy to overload, because you can’t really hear those low frequencies and metering isn’t fast enough for the transients. I record the main output on the LH channel, and put a series 15k resistor to the RH channel, which gives me about 10dB attenuation, but also more noise. I had to take this recording from the RH channel because I made a mess of the recording level.

Experimenting with stereo

I made another one of these, to see what stereo sounds like in a contact mic. Using a Y cable that connected the tips of two TRS jacks to tip and ring on another, I can combine these. This was on a farm gate, tapping the gate to test the sound

this was recorded on the opposite sides of the middle vertical strut of the fence below

this was recorded on adjacent struts

and this final one was recorded as shown below

Farm gate recording setup
Farm gate recording setup

You can hear a bit of the wind impacting the cables, perhaps I will have to clamp them to the gate to get rid of that effect. The speed of sound in steel at nearly 6km/s  is much higher than the speed of sound in air at 330m/s o although the spacing of the third sample (pictured) would be outrageously wide for a spaced pair of microphones in air, the stereo effect is clearer for me on that than on the first two.


  1. typically presented on three-pin XLR, or five-pin for stereo. 
  2. The piezo disc doesn’t need anywhere near as high a source impedance as the electret. 1MΩ is fine for the piezo, the electret wants nearer 1GΩ 
  3. That’s o/c without the FET present, typically 3-5V on a PiP input 

Chinese HW-131 breadboard power supply, clone of YwRobot MB U2

I bought this Chinese HW-131 breadboard power supply, which seems to be a Chinese clone of another Chinese product, the YwRobot MB U2. There are reports of unreliability with that device run off 12V, the suggestion is to run it of less than 12V if you are drawing notable power from it because heatsinking is marginal, using the small board. And definitely test all the output voltages before wiring this to something valuable.

Chinese breadboard PSU

It uses a AMS1117 3.3 and 5V regulator, and the minimum input voltage is 6.5V, due to the regulator dropout of 1.3V, so I will look around for something more suited to this. A breadboard tends to get shorts easily, and I could see the AMS1117 getting shirty trying to dissipate 12W into a short at 1A current limit 😉 The schematic matches this Addicore one

breadboard PSU schematic

Absolute maximum junction temp is stated at 125C, and their example calculations say a good board will get thermal resistance of 45C/W, so if we start at 20C the chip can dissipate 2W max. I favour 12V since I can split the 12V off an existing LED lamp power supply, and sockets are a premium around the computer.

It’s hard to ignore some of the dire warnings on the Net about this, it always seems to be the 5V regulator that gives itself to the cause, failing short, which is bad in a series pass device, though typical. So before I put this into service I tested its resilience.

on a breadboard

I could reduce the short-circuit voltage with a power resistor or a PTC current limiter. I only had a 12 ohm power resistor, so I used that. Voltage drops to 2.5V into the AMS1117-5 when I short the 5V rail, but it recovers OK, and more importantly the 5V rail recovers to 5V. However, when I replaced the 12 ohm resistor with a PTC 550mA current limiter the series pass device failed short and a wisp of the magic smoke escaped. There’s not much of it. I can see where these get their bad rap from – show me the experimenter who never shorts the power supply rail with the scope probe 😉 As Bob Widlar said in his paper on the design of the LM109 voltage regulator “Actually, the dominant failure mechanism of solid-state regulators is excessive heating of the semiconductors.” And it happens pretty damn quick.

where the magic smoke gets out

Magic smoke output port. Single use only

So I ordered five of the AMS1117 +5V which set me back £21 and set about the spare board with a Dremel to break the + connection from the pin on the socket, to insert the resistor. There’s no need for the PTC 550mA device because it clearly heats up slower than the AMS1117. I shorted the 5V rail, and while you can smell the overheating resistor the +5V rail came back fine, and I diddled about with the short to see if I could catch it out. After about 20 seconds and a wisp of smoke rises from the resistor, although the picture shows it doesn’t discolour too much, and everything is still serviceable. I measure about 10V across it into a shorted 5V rail, across 12 ohms that is about 10W, pushing what is probably a ~2-5W resistor a bit. Resistors tend to fail open, not short, which is good in a series pass device. It was time to introduce this to the old National Semiconductor method of testing voltage regulator short circuit tolerance, dragging the 5V rail over a grounded rough file. As Bob Pease used to say

Don’t just see if it oscillates — see how it RINGS when you tickle it with a pulse of current. In other words, BANG ON IT.

5V rail grounded against a rough file

output of 5V dragged along grounded file

Analogue load test

Analogue shorted load test equipment

That has this sort of effect on the rail going into the AM1117 5V regulator. Since the DrDAQ I am feeding into the PicoScope only has one channel it is a different instance

12V over a rough file

12V input to AMS1117-5 with output dragged against shorted file

Modded board – you cut the +12V centre contact of the barrel jack and wire the resistor in its place

It’s not subtle, and it’s not clever, but it seems to save the board from swift destruction, at the cost of limiting power drain to 500mA. This one has taken a fair bit of abuse now. I am still tempted to desolder the great big USB socket and bridge a 5.6V 5W Zener across the 5V rail as a better use of the space.

It beats using a big lab power supply on my desk. My lab bench is in a garage, and it gets cold in winter, so for some PIC development I wanted to run a solderless breadboard on my desk. Two reasons – it’s warm in the house, and secondly the lab computer is an old Sony Vaio 32-bit machine. Microchip’s MPLAB X IDE demands 64-bit, because it is shocking bloatware built on Netbeans and Java under the hood. Until recently I’ve used MPLab 8 and assembler, but, well, they ain’t making any more time and assembler is time consuming as complexity goes up.

Tinkering with PIC programming on a breadboard tends to involve a couple of LEDs or perhaps an LCD display, so a few hundred mA is good enough for that sort of thing. If the project needs less than 30mA a decent alternative is to use the PicKit 3 programmer to power the board, but 30mA won’t power many LEDs.

Chinese electronics seems pretty hit and miss. I find buying components like power transistors there is a crapshoot, because these things are terribly easy to relabel2, which is probably what did for my SkyTec power amplifier, over and above the rotten thermal design 😉 I’ve had better luck with their modules, which are often the only way to tackle some SMD devices. There seems to be a mix of pick and place and hand soldering – looking at the reverse of the board

reverse

It’s a tad on the scruffy side. The jumper wires I got with the kit are OK, I normally use stripped Ethernet cable for jumpers so more colours are welcome. The breadboard is disgusting. The grip on wires is weaker brand new than my 20 year old main lab unit. Life is too short to muck around with janky solderless breadboards, so I will throw it way to save my future self hours of debugging it.


  1. Update – I replaced the faulty 5V regulator and fitted the resistor mod, and that board now survives the 5V rail being shorted. To change the 5V reg snip the three SMD legs of the old one, which lets you lever up the chip and desolder the tab, and then clear the snipped residue. It wasn’t too painful, but I am glad I found this failure mode out before losing something valuable. 
  2. I couldn’t find an ISO9001 supplier of the 2SA1941 and 2SC5198 transistors. Digikey carry the latter, on a quote required basis, so you probably have to buy 10,000. So I bought my transistors from ebay, and they probably got them from a Chinese relabeller. I should have put the effort in to identify a suitable substitute that I could get from a reliable supplier 

Mind Mirror repair and restoration

I was fascinated as a teenager by biofeedback, which was big in the 1970s and early 1980s. It’s called neurofeedback now, at least in the EEG guise. Technology and digital processing has made this easier, though some of the fundamentals remain. Wherever you see a puff piece about the latest and greatest dry electrode technology, be that from Muse or from some games gizmo, you are not getting optimal signal quality, because the Holy Grail of the messless EEG pickup has never been found 1. You can get some sort of signal using dry electrodes or capacitive tech, but the EEG signal is weak, in the order of microvolts, so things like Muse and EEG games controllers are frustratingly inconsistent, sort of serviceable but not great IMO. Colour me a cynical bastard but I suspect poor signal quality is why it seems to be the devil’s own job to get the raw EEG data out of Muse, although this and this indicate it might be possible. You’re stuck on a F7-F8 montage with Muse, although that has the advantage of being outside the hairline.

I found Muse a mildly expensive mistake/rathole. I could get somewhere with it, but it was frustratingly inconsistent, I found it stressful using a phone as the interface and the dumbed-down interface grated. I was glad to give it to someone who will use the product as it is designed.

I was intrigued way back then by the Dragon Project, an attempt to measure effects around ancient sites. The physical monitoring part of that project didn’t yield anything of note, but one device they did use was called a mind-mirror, a transportable EEG, there are some pics in their gallery.

This was designed in the late 1970s by the late Geoff Blundell of Audio Ltd, a heroic piece of analogue design to make a multichannel audio spectrum analyser using hardware.

I managed to get one second-hand since publishing my first article on the Mind Mirror. This didn’t work properly – the right-hand side didn’t display right, one of the LED channel boards was down and there was an odd output from the lowest frequency LED display. It’s challenging trying to fix something with no circuit diagram, particularly when it is something that quite this one of a kind, you can’t draw parallels from other designs.

Mind mirror display daughterboards

However, what made this easier is the display is made up of plug-in daughter boards fed in parallel.

one of the mind mirror daughterboards
one of the Mind Mirror daughterboards

This made it easier to isolate faults and by swapping boards trace whether the issue was on the board or the common backplane drive.

At first this was a sick puppy – the left hand channel didn’t work at all. I compared this with the right hand side, discovering the quiescent signal voltage was 0.82V as opposed to 2.5V on the right hand side. The 5V power line on the RHS was mirrored by 1.7 on the left.

So I pulled display boards till I found the offending board dragging down the power supply. The LHS still didn’t work, so I traced the input signal to a 4016 CMOS analogue switch which had failed on one section. Changing the chip cleared this fault, so I replaced the daughter board till I found the one that pulled the power supply down, which turned out to be a faulty CA324 quad opamp.

The last fault was a weird display on the lowest RHS channel. That turned out to be a duff LED gone short, which due to the odd Charlieplexed display on the UAA170 made me first suspect the UAA170. These are still available NOS on eBay, but swapping the chip didn’t fix the problem. Modern LEDs are much more efficient and a slightly more orangey red than the 1970s ones, so I had to shunt the replacement LED with a resistor to balance brightness.

The unit was originally designed to work with two 6V SLA batteries, but the strip on the PCB joining the mid-point of batteries is not connected to anything else. This is a 12V unit, though the system ground is not connected to the battery 0V.

Tracing out a daughter board was tiresome. an example active filter is

Mind mirror active filter schematic
Mind mirror active filter schematic

and simulated in LTSpice this is

Mind Mirror example filter LTSpice simulation
Mind Mirror 16 Hz filter LTSpice simulation

This reasonably matches the expected display. Bear in mind the display is linear steps up to 16 levels, so the difference between minimal display and full-scale is about 1:16 or about 24dB, so if all LEDs are lit by the peak  the display will extinguish (show the lowest LED) for the same amplitude frequencies < 12.2 Hz and > 20Hz.

The output of the filter goes to a pin on the DB25 socket, and is rectified and low-pass filtered before going to the UAA170 16 LED display IC on the same daughter board.

I have set this on soak test for a few days. In the video the 26Hz channel is off on the LHS, this was due to an unsoldered joint.

unsoldered joint. The messy flux residues aren’t my work, but I figure if it doesn’t cause grief after 50 years I will leave well alone, though I did solder this input to the high side of the level pot.

To feed the signal in I made a special differential driver from a quad opamp and padded the output down. I did test the input impedance which was of the order of >100k, though it got noisy with 100k source impedance. I suspect there’s another one of those CA324s on the input stage. There’s nothing that special about the CA324 nowadays. The datasheet is silent about noise performance, speed is similar to a 741 opamp. It is specified to work down to 5V , and the input common mode goes down to the negative supply, which has the edge on a 741. Looking at the internal design, there’s much in common with the nasty2 LM358 and indeed Texas Instruments lump the LM324 and the LM358 together in this application note.

You can do a lot better now, I’d be tempted to run it on the 100uV range and use a preamp to get a higher Zin, though I should test first. Perhaps the high noise is the 100k source being amplified so much – the specification is for a 10k typical contact resistance. You can only achieve this with wet electrodes, which is something I have yet to wrangle.

The spaces top left and right was originally to take two 6V sealed lead-acid batteries, nowadays the same capacity can be had in much less space in NiMh or a 3S LiFePo drone battery.

In the meantime I also got the Olimex EEG-SMT to tinker with. Although I feel the openEEG antialiasing filter leaves something to be desired I didn’t observe shocking levels of interference so perhaps I was overthinking that. Reading the archives of the openeeg mailing list I was impressed with the care taken over the analogue design, to the extent an easy win would be to use the EEGSMT in the LHS battery slot and break out the analogue signal from C51 and C52 to go into the MM. The driven right leg grounding scheme of openEEG works very well, and I verified that messing about with the EEGSMT and a pair of Olimex active electrodes used dry.

Sadly I screwed up buying only two active electrodes, since the channels are differential you need two active electrodes per channel, four in all. Since the UK has left the EU there is a whole world of hurt associated with buying from the Bulgarian company Olimex that I didn’t have when I bought the original devices a couple of years back.

However, I have a working Mind Mirror EEG and a serviceable Olimex OpenEEG system. After a frustrating foray into the dry electrode world of Muse, I can return to tackle the problem I never faced up to, which is eschewing the mirage of decent dry contact solutions. There aren’t any, because you cannae change the laws of physics. Dry contact solutions means higher contact resistance, which associated with a weak signal coming through a high resistance means more noise and less signal. I need to suck that up, because I have wasted too much time on that sort of thing.


  1. The effects of electrode impedance on data quality and statistical significance in ERP recordings, Kappenman + Luck 
  2. Nasty because these damn things are responsible for a lot of audio crossover distortion when used by tyros drawn to the low cost and low voltage performance. See TI application note page 17. If you really must use these at audio frequencies, pull the output down to the negative rail with about 10k to bias the output push-pull NPN Darlington into Class A.  The TI app note preamble
    The LM324 and LM358 family of op amps are popular and long-lived general purpose amplifiers due to their flexibility, availability, and cost-effectiveness. It is important to understand how these op amps are different than most other op amps before using them in your design. The information in this application guide will help promote first time design successes.
    should warm you up to ‘here be dragons’
     

Constant current LED driver as a weapon of battery destruction

These Chinese fairy lights cost less than £5 somewhere on Amazon – you can get 3 for £8. In the ad there’s this lovely golden glow

but in practice the damn thing is dimmer than a Toc H lamp

not very bright – in design and in output

These things are basically a throwie upscaled to a 50 LED string. Powered by two CR2032 lithium cells in series, the LEDs are in parallel, Current is limited by the internal resistance of the batteries. The whole thing is a disposable hazard to the environment, intended for a single use at someone’s wedding or party. It shouldn’t be allowed 😉

They make quite a nice distributed light in an outdoor shed, where I can fix the wire along the ceiling, just as well as the solid enamelled wire is going to break if moved too many times. I was surprised that you could put 50 LEDs in parallel. They are all fed from one end, and in the original configuration you couldn’t see any gradation along the string. However, putting 700mA  through them generated a very welcome increase in light, and a slight gradation down the string, due to the voltage drop.I feared that would be bad for LED life, so I ran a third piece of enamelled wire through the string and fed one side of the LEDs from the far end and the other side from the near end, the drops along the string sort of cancel out. Using a light meter with the LED taped to it the original version as received gives a single LED output of 10EV, with 700mA it’s 15EV, a gratifying five stops more light – about 30 times more.

now a more healthy 15EV, typical of full sunlight on a cloudless day, although about 1mm from the LED

The 700mA is split among 50 LEDs, about 14mA per LED. I’ve never come across a LED (designed for illumination, rather than an indicator segment) that’s rated at < 20mA, so I figure I am OK.  I was looking to upgrade this to 12V, powering off three 18650 LiIon batteries. The obvious solution was a Chinese LED current limiting switchmode supply, but the obvious solution comes with a nasty wrinkle for battery powering. Current rushes up as the voltage drops

a constant current driver is a very unkind battery load

Run off 12V it worked a treat. I used three LiIon cells scrounged from laptop packs and bits, and I found that this is a weapon of battery destruction – first I wrecked two cells out of three, then another two. Hmm. On the upside, at least I have now selected the strongest cells. On the downside, four LiIon 18650s have met their demise.

What’s up? The constant current LED supply is one of these

5-35V 3W LED Driver 700mA PWM Dimming DC/DC Step-down Constant Current. From these guys on ebay

and I really should have been paying attention to that 5-35V spec, because as my Li-Ion’s fall from 11V down to 5V, it will say gimme, gimme, gimme more current, NOW.

Gimme all you got – particularly as the battery dies

And you don’t get to see that the batteries are running down from the LEDs dimming until it reaches less than 5V, because the driver is good for 5V. Oops. My bad. That’s why I am four 18650s down. Most things you run off batteries tend to draw less power as the voltage fades, but these suck the last dregs out of the battery in double-quick time, giving up just as it discharges the second weakest battery to below recovery.

I was imagining low-voltage disconnects and mucking around with P mosfets and PICs, then I spotted the PWM pin. You either leave this open, or ground the sucker to disable the output, the basic chip is the XL4001 from XLSemi. The EN wants to be < 0.8V to turn the thing off, and > 1.4V to turn it on. I had a vague recollection you could use a TL431 to get an active low power is high enough output, and Google delivered inspiration from ON1AAG on electro-tech online. TI also have a rather nice app note Using the TL431 for undervoltage and overvoltage protection which goes into some of the trials and tribulations of such misuse. One of which is quite a high Low condition voltage of about a volt or so – to wit

A lower bandgap reference voltage as seen in the TLV431, allows for a lower logic”low”output voltage without the need for external hardware.

Testing this with a LED showed it basically worked, but feeding the signal to the EN pin did ‘owt. As TI say, the resting Low voltage is over a volt. They’ve also got a Understanding Voltage References: Using a Shunt Reference as a Comparator blog series which points you at the TLV431 for this sort of thing. I needed to pad the output down with two diodes to get it just below 0.8V

Low Voltage disconnect for XL4001 PWM LED regulator

There’s no hysteresis in this. I did first consider a 5.6V Zener instead of the two diodes, but that introduces a nasty pathology. The LVD turns the chip off at about 10.5V, but switches it back on again at about 5V, and the XL4001 goes way-hey, let’s suck the maximum current out of these dead and dying batteries. At least with the diodes it has to get down to < 3V and the XL4001 doesn’t draw half an amp like it does at 5V since 3V is out of its operating region which is 4.5V to 40V.

I’d be better off with the TLV431, but TL431 is what I have to hand. I’ll get some TLV431 next time I order some parts.

Recycling Neato 4/5AA batteries.

Looking for an alternative I hit on an old Neato XV robot hoover battery up for recycling. These get thrashed in this application, but the problem is there are two 7.2V battery packs with six 4/5AA size NiMH. To me these look pretty much like 18650 size. One of the cells has gone high resistance, but the remainder charge well on my MAHA battery charger/analyser

A decent capacity of 3700 mAh, typical of all but one cell

Although no chemistry appreciates full discharge, NiMh will tolerate the odd deep discharge. I’ve learned my lesson running constant current LED drivers off LiIon batteries, and while I have a LVD now I’m not taking the risk again.

I’ve also got a chance of trickle charging these via a solar panel. Battery University say you shouldn’t trickle charge NiMH at > .05C which is ~180mA or less. Mine is an old Maplin 1.5W @17.5V solar panel which would theoretically give 86mA in blazing summer sunshine. Which is not the time of year when you want lights in a shed, so I’m not going to be anywhere near endangering these batteries 😉 11 of them will give me a nominal pack voltage of 13.2V

 

Piezo contact mics on low voltage power supplies

A few years ago I did a couple of piezo contact mic amplifier designs, because people often moan that these things sound tinny and crap. There’s a wrong way and a right way to use these – they want to work into a high impedance. Using Piezo Contact Mics Right sets you right. Trouble is these use a 9V battery, and it seems world + dog want to use 5V, because that’s what they had. Time was when power supplies were +/- 15V for analogue and 5V for digital, but that’s a different story for later.

So what can you do with your piezo contact mic at 5V then?

Not much. If you are looking for low signal level performance an emitter follower biased at an output of 2V would work well, but if you only have 5V available it’s likely you are trying to digitise this signal and bung it in an Arduino or something. In that case, think laterally. Toss the power supply. I developed those amps because as a field recordist I wanted to hear faint signals from the contact mic. You know, like the whispering in the rails as a distant train approaches, though you need to avoid the Fredzania Thompson ending.

These days people would look at you funny if you attach a box with wires to the underneath of the rails. Don’t try this at home and all that.

Turns out many people want to use their contact mics on an instrument, or drum pad, or generally something they bash seven bells out of. Life is a lot easier for you. As established in Using Contact mics right, you want an input resistance of about 330kΩ so the bass doesn’t roll off with the typical series tens of nF capacitance of the sensor. 330kΩ is a damn sight more than your typical plug-in-power audio recording doohickey, which usually feeds the electret mic power from 3V via about 6.8kΩ. I measured my Olympus LS-14 and even the line input is 10k.

So stick the 330kΩ resistor in series with the input. Even writing that makes me cringe, because it will lose a hell of a lot of signal level, making a potential divider with the input resistance – for a 6k8 input you’ll take a loss of 33dB. That translates into a direct worsening of your noise figure by that much, that’s a lot of performance to throw away1. OTOH it works perfectly well down to 1.8V, it’ll be OK down to 0V as it doesn’t use power 😉

how much signal do you get from a piezo contact mic?

Let’s take a look at the sort of signal level you get from a piezo disc sensor. I got one on the bench and fed it into a DrDAQ signal capture device and Picoscope Continue reading “Piezo contact mics on low voltage power supplies”

Raspberry Pi 4 with touchscreen and FLdigi

I got a new Raspberry Pi v4 and the official touchscreen. The aim of this is to be able to run FLdigi and WSJT-X1 in a portable setup. Also to stop FLdigi getting hopelessly confused on my main PC – with two sound cards already adding a third sound card as interface for the radio meant portaudio, whatever that is, gets hopelessly confused on Windows and loses touch with the hardware intermittently.

Setting it up was surprisingly painless – blow a new 16Gb SD card with Raspbian, connect screen to the 5V and 0V on the GPIO and the ribbon cable to DSI. Normally you then have to remember to add the empty file ssh to the boot partition with the PC so you can talk to the damn thing, and perhaps wrangle the wireless config if the Pi doesn’t have Ethernet.

With the touchscreen I didn’t need all that. Although I started it up on ethernet, the onboard Bluetooth meant I could connect a Bluetooth keyboard using just the touchscreen, and then set up the wifi in the usual way. The touchscreen needs a reasonably firm press, this is no responsive smartphone screen, and being so small it is sometimes hard to get the right target, even with a conductive stylus, particularly as I set the font size a little smaller to use the screen area more. Continue reading “Raspberry Pi 4 with touchscreen and FLdigi”

International Dawn Chorus Day – getting bird sounds indoors without opening the window

International Dawn Chorus Day 2020 is somewhat overshadowed by the coronavirus pandemic for its human listeners. The birds probably appreciate getting some peace! The Wildlife Sound Recording Society was after getting a live broadcast of this from as many members as possible. They proposed two methods of live broadcast, their preferred option using Mixlr and a more gonzo alternative using locusonus.

Mixlr seems all about tablets and mobile phones. If a project’s got a mobile phone in it I’m not interested. I loathe smartphones – jack of all trades and master of none. They don’t do stereo1, FFS… Mixlr is Cloud. I don’t do Cloud, particularly if it comes with a subscription. It’s bad  enough when Cloud goes AWOL and you’ve put effort into the platform for free. Pay for the privilege?  Nope.

So I passed on that and went to locusonus, who are doing this under the Reveil soundcamp moniker. Locusonus is funded by the French State, bless their arty dirigisme – just look at their publications. And sponsors

So arty! So French!

Reminds me of reading about musique concrete as a kid in the 1970s, IRCAM and all that, while I was piddling about with a hand-me-down Stellavox tape recorder. Mad, but inspirational. I’ll hitch a ride on French exceptionalism.

I’m lucky in that way back when I bought a Cirrus Logic sound card for a Raspberry Pi. Or perhaps unlucky in another way – I never found a good use for it till now, as the software drivers were a whole load of hurt. By the time they got incorporated into Raspbian, the card was end-of-lifed so you can’t buy them any more.  That’s Linux for you. Free as in beer but slow to integrate hardware. If you are doing this from scratch, either use a cheap audio adapter with mono audio or something like the Behringer UCA202 USB audio card – stereo line in and works great with the Pi, right out of the box.

Despite fiddling with the CirrusLogic on and off I came to the conclusion a timed bird sound recorder is better done with a Dribox and a real audio recorder and a timer. However, a Pi and the CL card is perfect for locusonus. Perfect enough, indeed, that downloading the relevant Pi SD card image, blowing it onto a SD card and firing it up on ethernet gave me an instant win2, using a set of OKMII binaural mics into the line in port with the bias enabled.  I was able to hear myself, albeit at a low level, but the locusonus software lets you ram the Cirrus programmable gain amp up to +30dB and max digital gain. Sure, it’s noisy, but showed the principle.

Now all I need is an outdoor microphone Continue reading “International Dawn Chorus Day – getting bird sounds indoors without opening the window”

Fixing a short-sighted Logitech C920 HD webcam.

The Logitech C920 is a lovely little webcam, and having the MP4 conversion on the onboard processor means you can use it with gutless hardware. I got mine as a cast-off from Jason at Wildlife Gadgetman and wanted to use it for video-conferencing, what with the coronavirus lockdown and all that.

Trouble is the damn thing is short-sighted. It seems to be a common problem with the C920, and the autofocus is ratty. Sometimes it would work, sometimes not.

I am short-sighted too, so a temporary fix to get it to focus on distant objects is to Sellotape one lens my glasses over the front, but it’s not a good look. AF was still ratty. Poor distant focus is a common complaint with the C920. This fellow shows you how to take it to bits

but unlike him, my fault was the little piece of metal had become loose and was fouling the movement of the lens.

the squarish metal washer with three notches had come adrift.

Extracting the washer from the lens, using the notches to pass the castellations on the lens mount let me isolate it

I did consider leaving it off

but figured I’d get flare from reflections from the plastic cover in front so I used thick superglue, carefully to avoid getting it on the lens. Four dabs at the corners sorted it.

Job done, sorted. This doesn’t seem the only way for these cameras to misbehave on focus, and unfortunately you can’t see the errant washer because of the baffle  on the plastic cover. But you have to take it to bits if your problem is the focus is off as the one in the video. There’s a neater way to do the glasses thing with an eyepiece adapter lens as in this video, which doesn’t entail taking it to pieces, but that wasn’t the problem for me.

 

Maplin geiger counter

Maplin published a design for a Geiger counter a year after the Chernobyl explosion in the September 1987 issue of the Maplin Magazine. I bought the kit for the remote head and constructed this. I never built their meter, because I used two CD4017 decade counters to make a faux dekatron display, feeding the output of the chain into a mechanical counter bought from H.L. Smith in Edgware Road in the early 1980s. Edgware road used to be a haven of weird and wonderful surplus electronics shops.

I’m not really sure why Maplin didn’t go the counter way, it’s not like seven-segment LED displays didn’t exist then. The dekatron display is better than a digital count for the first couple of digits, because the spin of the display gives a feeling of count rate, in a way that changing digital display numbers doesn’t.

Counter part of Geiger counter
Counter part of Geiger counter

The kit was shockingly expensive at the time – the Maplin Magazine shows the kit was £79.95 in 1987. That’s about £221 nowadays. Perhaps markups were much better in Maplin’s geeky heydays, whereas now they are competing against Banggood and Dealextreme. The original schematic shows an oddball AG1407 GM tube, it looks like I couldn’t afford the kit when it came out and built it in the early 1990s, when they had substituted the LND 712 tube, which is still made, LND 712 datasheet here. Datasheet seems to indicate 6E-5 R/hr for a count rate of 1CPS for Co60 source, so a conversion 0.0036R/hr for 1CPM

Continue reading “Maplin geiger counter”