Skip navigation.

Paul Gallagher

Syndicate content
My occasional technical diary of thoughts, tips, and tools from some of the more interesting things I'm playing around with at the time. That means all things Web, Open Source, Polyglot-programming, Electronics and Data, or just my latest rant.. who knows!
Updated: 2 hours 44 min ago

Embedded: Specialization is for insects

Sat, 2016-04-16 02:34
embedded.fm has fast become my favourite podcast of the moment (always excepting QOTD). Great ideas shared in an inclusive and warm-fuzzy way.

Elecia's end-of-show quote always makes it worth listening right to the end. Until I heard #146's,
I'd struggled to find words to express exactly this. It's a quote from Robert A. Heinlein:

A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.

LittleArduinoProjects#201 Yet Another Doorbell

Sat, 2016-04-16 02:21
aka door-fart according to my better half ... 555 Timer-based oscillators are not exactly the most musical creatures.

#201 is a kit build. Ridiculously cheap on aliexpress, it even came with extra components, so a bit of a bargain impulse-buy.

The kit turned out to be a simplified version of a circuit I've built before. It lacks the power control circuit, and draws about 4mA when idle - so if you actually use it, expect to be replacing batteries on a regular basis.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

Here's the start of the "ding.." on a 'scope..

LittleArduinoProjects#200 Mini Solenoid Engine

Tue, 2016-04-05 08:02
Solenoid engines? They definitely fall into the the category of because you can.
Some people take it to a whole other level (like this V8 model).

What I have here is much more modest - a single-cylinder engine powering an impromptu-wire-art drive train. The mini-solenoid used here has a very small effective stroke - about 8mm - which necessarily constrains the gearing. I was inspired by 30GB's similar model for the layout.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.



LittleArduinoProjects#199 CD4026 Bucket-brigade LED driver

Mon, 2016-04-04 09:21
This is an extension if the ideas in #196, demonstrating how it's possible to build a "bucket-brigade" of CD4026 chips to drive an arbitrary number of 7-segment LEDs with a single data line.

It just requires the carry-out from the first CD4026 to be chained as the clock input for the second and so on.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.


LittleArduinoProjects#198 Hall Effect Switch

Sun, 2016-04-03 04:53
Hall-effect sensors generally support one of three modes:
  • switch - turn on in the presence of a magnetic field of a specified polarity
  • latch - turn on in the presence of a magnetic field, and stay on until exposed to the reverse polarity
  • linear sensor - output is proportional to the magnetic field strength
The components I have for testing are marked "44E/938" and are nominally compatible with the A3144 or OH3144. These are switches that turn on when facing a south magnetic polarity

The chip is rated for continuous output current of 25mA, so that is sufficient to drive an LED (as demonstrated here). For other switching applications, the output can be used to switch a transistor or pull a microcontroller output low.

Testing with some neodymium magnets, I get a strong full-on when the south pole of the magnets are within 23mm directly to the front of the chip. The output remains on until I pull back to over 40mm.

A common use for Hall-effect sensors is to detect and measure rotation. A good demonstration of this is to sequence a PoV display as demonstrated in Great Scott's latest video - HACKED!: Old Fan becomes a POV Display

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#197 Wien Bridge Audio Tone Generator

Mon, 2016-03-21 10:11
A Wien bridge oscillator is essentially an RC Band Pass Filter with a high Q factor at the resonant frequency, and generates a nice sine wave. I wanted a simple audio-frequency test signal generator, and a Wien Bridge turned out to be perfect for the job.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.


A good old LM324 does triple duty in the circuit:
  • a non-inverting amplifier with a gain of ~3 provides the feedback required to sustain the oscillator
  • one unit buffers a half-supply voltage to provide a "virtual ground" for the non-inverting amplifier
  • a third unit buffers the output signal to avoid load interference with the oscillator
The LM324 doesn't have great upper and lower limits, and clipping is severe in the basic circuit. This is solved with diode stabilisation.

The result is a pretty decent sine wave at ~1.574kHz, very close to the theoretical resonant frequency of 1.592kHz.

LittleArduinoProjects#196 Driving a 7-segment display with CD4026 Counter

Sat, 2016-03-19 20:09
Here's yet another way to drive a 7-segment single-digit display unit - using a CD4026.

The CD4026 is a 5-stage Johnson decade counter with decoded 7-segment display outputs and display enable. With RESET and CLOCK INHIBIT low, and DISPLAY ENABLE IN high, the 7-segment display outputs progress through the 0-9 sequence on the rising edge of the CLOCK pulse.

It's an interesting alternative to a shift register for driving a 7-segment LED (as in the ShiftDrive project). While a latched shift register provides random addressing and clean transitions to any digit, it requires the 7-segment display outputs to be decoded externally (like in code). On the other hand, the CD4026 takes care of the decoding, and external circuits just need to send a counter pulse.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#195 Coil Resonance and Inductor Testing

Thu, 2016-03-10 06:41
I've been trying to do some RF experiments, but instead being driven mad by hand-wound coils that never seem to behave as the standard coil inductance calculations would lead us to believe.

As always, it's w2aew to the rescue with a neat deconstruction and demo of a circuit for coil or inductor measurement.

I built the circuit out, and was easily measuring down to 10µH on a breadboard, and sub-1µH once I put the circuit on a hacked up copper board with islands. Using the LC circuit resonant frequency formula, it's possible to work backwards from known frequency and capacitance to determine the inductance (wolframalpha is great for this).

So now I hope to get back into some RF without the nagging doubt of not really knowing what my coils are doing!

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

Here's a beautiful trace of a (nominally) 10µH choke with a 150pF capacitor. I measure the frequency at 4.26MHz, therefore an actual inductance of 9.3µH .. pretty close!


Even with a super-bodgy 4.5 turn coil whipped up on the spot and put in parallel with a 30pF capacitor, I'm still getting a decent oscillation at 34.09MHz for a calculated inductance of 0.73µH


And here's the board delivering the results:

LittleArduinoProjects#194 DIY ESP8266 DevBoard

Tue, 2016-03-08 09:25
With the funding of the MicroPython on the ESP8266 campaign, my interest in the ESP8266 is rekindled!

I have an ESP-01 module lying around, but I'm a bit tired of wiring it up a breadboard again. So here is a little "devboard" I whipped up on a 4x6cm protoboard and hot-glued to a business card holder.

Now it's plug'n'play - add power and plug in a USB serial adapter and I'm good to go.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#193 PoV LED Shake Stick

Tue, 2016-03-08 09:22
This AT89S52-based "shake stick" kit pops up all over the place for a few dollars. I built it and hey, it works great!

But it's not packaged to be easily re-programmed for other messages or graphics. So started my sleuthing.. which turned into a fascinating story.

It seems the kit was originally designed and built as a uni project by Zheng Zhong Xing 兴向荣 (aka zhengzhongxing39) studying Control Technology and Instruments/Principles and Applications at a Chinese University. Reportedly "... soldering was troublesome, with lots of changes and no solid basic skills, so burned out the first board" ;-) But it seems persistence paid off, and ended up commercialising the kit and starting electronics business and taobao store where you can find this kit and many others.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub, including my annotation of the source code and schematic for the shake stick.


LittleArduinoProjects#192 Sagrada Família model with LED effects

Mon, 2016-02-29 07:15
The Basílica i Temple Expiatori de la Sagrada Família has been under construction since 1882. The magnitude of the vision driving the project - both physically and creatively - is striking, especially at first hand.

Then you see the work in progress - the cranes, scaffolding, workers scurrying around the site. But that is what I think really brings it to life. This is not a frozen, finished statement of something other-worldy. It's a vibrant expression of the hope and aspirations of a whole bunch of people working together.

In other words, it is the ultimate maker project! Personally, I think it will be a sad day when someone declares it actually "finished".

Now at the extreme other end of the maker-scale is this neat little paper nano Sagrada Familia kit that I picked up in my travels.

I've "electrified" it to some extent with some LowVoltageGlowingLEDs that animate the background, just running off a 1.5V supply. Although I think I could have slowed down the LEDs even further.

A nice effect I think..



As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#191 glowing LEDs on 1.5V

Sat, 2016-02-27 22:51
So for another project I wanted some "glowing" LEDs, ideally powered from a single 1.5V AA or AAA battery. That seemed like an interesting challenge, especially when the forward voltage of the LEDs I'm using is about 2.1V.

I had a feeling I could cobble together a couple of ideas (Relaxation Joule Thief and RC Oscillator) .. and lo, it works!



As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.



Here's a glimpse of the "modified oscillation". CH2 (red) is the LED cathode/transistor collector - as it rises and falls the LED slowly switches off then back on.


For protoboard-based builds I tend to layout the schematic with PAD tools (Pencil-Aided Design) ...

LittleArduinoProjects#137 Toroidal Joule Thief

Thu, 2016-02-25 08:07
In #129 I posted about a two-transistor boost circuit. This is an even simpler circuit - very common over around the internet and known as the archetypal "joule thief". The smallest I've seen is Eric Wasatonic's micro version.

I stuffed my circuit into a AA battery holder and it works great as a night light, powered by either a single somewhat-depleted AA or AAA battery.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#129 Relaxation Joule Thief

Wed, 2016-02-24 09:54
I was inspired by w2aew's excellent video to check out the Ears To Our World humanlight project. It's a good cause, although shipping costs kill the idea of buying one myself - better just to make a direct donation.

It's also an interesting circuit - a variation on the many "joule thief" circuits out there - and also demonstrates some of the basics that under-pin boost converter power supplies.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.


With my particular mix of components, I'm getting almost 40% duty cycle which actually produces an apparently very bright LED on just 1.5V supply.

LittleArduinoProjects#001 basics of 7-segment LED control

Mon, 2016-02-22 09:38
Going back to basics - this project is a test of directly driving a common cathode 7-segment LED with an Arduino. It covers the fundamentals behind more advanced circuits like this custom PCB with register interface.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#178 making a 7-segment LED PCB

Sat, 2016-02-20 03:43
My version of the second project from the KiCad like a Pro course (the first was an nRF24 breakout board).

The board combines a common-cathode 7-segment display with a shift register and current-limiting resistors. Nothing earth-shattering, but a good little KiCad exercise. I recently got the boards back from OSH Park, and they work just fine!

As always, all notes, schematics and code (including the KiCad project) are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#188 read/write AT24C02 external EEPROM

Fri, 2016-02-19 10:23
The AT24C02 is from Atmel's line of serial EEPROM chips with a whopping capacity of 2K! (256 x 8) That's not a whole lot more than the onboard EEPROM in an Arduino, but it does have the advantage of being external:
  • it can stay in-situ even if the microcontroller disappears/gets exchanged
  • multiple devices can share access
There are a few libraries available that encapsulate the interaction with external EEPROMs, but first step is a simple test of the basic read and write capability using the basic Wire library. Surprise, it just works (as long as you get your bits and bytes ordered correctly).

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#187 nRF24L01+ Ping Pong

Thu, 2016-02-18 12:22
So now I have my nRF24 breakout boards back from OSH Park, time to try them out.

This is a simple script that runs on two Arduinos. They bounce messages back and forth over 2.4GHz using the nRF24L01+ modules, flashing their LEDs when messages successfully handled. Sweet, and the breakout boards work just fine.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

LittleArduinoProjects#184 Adjustable Pulse Generator

Wed, 2016-02-17 07:55
Yet another variation on the basic 555 timer astable oscillator to allow a wide range of frequency and duty cycle adjustments. It's similar to the circuit used in kits like this.

As you can see from the schematic, it's the combination of pot and capacitor selector that produce the wide range of oscillator control:


But the challenge with the classic 555 astable circuit is trying to hold frequency or duty cycle constant while adjusting the other. This circuit doesn't solve that problem, but for something different, I plotted the functions with WolframAlpha. If you correlate the two graphs below, you can see the severe penalty you pay in terms of duty cycle when attempting to push for maximum frequency. It definitely is a case of trying to find the best compromise for your application.

As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub, including live links to WolframAlpha to reproduce these plots.

Frequency for all values of R1, R2 (C=1µF)

Duty Cycle for all values of R1, R2 (C=1µF)

LittleArduinoProjects#176 nRF24 Breakout Board

Wed, 2016-02-17 07:52
So recently I've been intrigued by small-batch PCB fab services, like OSH Park. Like the ready supply of components from various online sellers, it's amazing how cheap you can get boards made over the net these days. How do they do it? As I learned in this hardware hangout, there are some neat tricks done behind the scenes to aggregate small orders into full panels sent to a fab.

But to get PCBs made, you need to be able to drive an EDA tool like KiCad. KiCad's a beautiful open source tool, but it is quite idiosyncratic. In some spare time, I dived into the KiCad like a Pro course and found it an excellent leg-up on the process.

The nRF24 breakout board (below) is just the first trivial exercise from the course. But it will come in handy - I have a batch of nRF24's lying around that I've been planning to experiment with, and the breakout board will be quite handy for that.

I just received my boards from OSH Park (1 month from order to delivery in Singapore - not bad, especially for $4.80 all-in). Very impressed with the board quality. Not so much with the board design! A few things I can see could be easily improved, but that's my fault (see my notes). But they do work!

As always, all notes, schematics and code (including the KiCad project) are in the Little Arduino Projects repo on GitHub.