Saturday, 11 April 2026

My Project Workflow

Projects can take a long time to bring to fruition. This means that I often have several on the go at the same time, which in turn can cause me to miss out some important steps. So I thought I'd gather all of the tips and tricks I've learned in one place as a reference.

The idea
  • scratch an itch
  • read other makers (for example on hackaday)
  • that new-fangled youtube can be useful too
Prototype
  • use a breadboard and dupont connectors for speed
  • sketch the schematic on paper as you go
  • use an llm for advice or as a search engine to find similar projects
  • plagiarise other people's designs, you might find one which does everything you need
Schematic
  • break out KiCad or similar and copy the paper schematic
  • separate subsystems and connect with labels
  • add test points (and expansion points if that makes sense)
  • use the electrical rules checker
  • rebuild the schematic on breadboard to test it
PCB Design
  • add component footprints
  • use the design rules checker
  • print the PCB at 1:1 on paper and check footprints
  • make holes in the paper with a pin and check footprints again!
  • use a ground plane and mounting holes
  • use the silk-screen for component values, labels and version information
  • add your email address (you never know)
  • use a plugin to send your design for fabrication (for example to PCBWay)
  • save the design and its firmware in version control (for example GitHub)
Board Assembly
  • don't rush!
  • add low-profile components first
  • socket everything you might want to reuse
  • solder up each subsystem and test immediately
  • clean off flux with isopropyl alcohol and a toothbrush
Post Mortem
  • if it works, document it on a blog like this one
  • if it doesn't, fix it immediately, update the version, and document it on a blog like this one
  • don't worry about anyone caring about your successes or failures!


Friday, 10 April 2026

Emulating a Commodore Chessmate

 A couple of years ago, Hackaday published a short piece on the Commodore Chessmate. As is usual with their articles, its shortness of length was more than made up by the breadth of its links. The last of these led to Hans Otten's Retro Computing page. 

(One of the few comments beneath the article is by Peter Jennings, creator of the original Microchess program, linking to his reminiscences about the Chessmate: well worth a read!)

Chessmate by Commodore

Anyway the article caught my attention because I'd had one of these as a nerdy kid. I remember opening it up, hoping to find... I don't know what, maybe a sort of PET? but not recognising many of the components; nowadays I could just Google it, and probably end up at Hans's page.

Among a wealth of other information, Hans provides ROM dumps and a memory map. I thought, should be pretty easy to write an emulation of that, and so it was. (The hardest part was probably mapping the 7-segment LEDs onto the TFT screen, which is to say: not very. Probably about a weekend in all.)

Chessmate by me

(The emulation uses r65emu, my emulator library for Arduino, running on an esp8266 connected to a TFT screen.)

Time passed and r65emu slowly improved. One update was to support other kinds of displays and keyboards besides the original TFT and PS/2. Sometime after this I decided to build a retro-modern version of the Chessmate with an anachronous mix of whatever parts I had lying around, and knocked it together on a couple of breadboards. 

I don't have a picture of that, but it was an unholy mess of wires, and languished on the side of my desk for over a year before I sat down with KiCad to turn it into something more permanent. I must have been in a rush because I made several mistakes with that PCB, getting some footprints wrong. I fixed them and parked the design, slightly depressed.

Things might have stayed like that for yet another couple of years, had I not been contacted out-of-the-blue by Liam from PCBWay who expressed interest in sponsoring r65emu. And so...
Chessmate by me and PCBWay

This uses a node32s microcontroller, push-button switches, a buzzer and 7-segment LED displays. The four status LEDs are represented by decimal points. Its software and hardware lives on GitHub.

It would be interesting to run a modern chess program on this hardware; one possible candidate is by Sergey Urusov.

(Incidentally, Michael Gardi has a much nicer modern rebuild of the Chessmate, complete with 3D-printed replica case!)


Monday, 19 January 2026

Scoping out a UK101

The first thing to measure when repairing a retrocomputer is the main oscillator. In a UK101, this is called CLK and found on U58 pin 3.

CLK (8MHz)

 This is divided by U29 and sent to the processor from pin 11 as Phi0 and reaches the counting chains as C0.

Phi0 (1Mhz)

The processor uses Phi0 to produce the processor clock Phi2. This is sent from U8 pin 39 to the hardware devices which populate the address and data buses.

Phi2 (1Mhz)

The counting chain is made up of U59, U60, U61 and U30. These divide C0 into C1-C15. About halfway along the chain are C8-C10, which are fed into the character generator's address lines A0-A2.

C8 (7.8kHz)

Ultimately this produces a Composite Video signal on J2 pin 12.

Video (15.5kHz)

So it's fairly certain that when this is connected to a monitor, there will be some sort of picture!

(This work also turned up an error in the serial clock generation. C3 (125kHz) is used to produce the transmit  clock TxCLK. However while the former is OK, the latter is missing: further investigation is required.)


Tuesday, 6 January 2026

Solving a simpler problem

Project Euler is a popular site among enthusiasts of mathematics and programming problems. A very common template for its problems goes something like:

Let F(n) be some function expressed in words. You are given that F(100) is some relatively small number. Find F(10^7).

 Often the best approach to such problems is to write a brute-force solution which gets the correct answer for the given data to verify that you understand the problem. Then examine the order of growth of this brute-force solution, say O(n^2), to determine what the best approach is, maybe O(n*log(n)), given that Project Euler says that all of its problems are solvable in under a minute.

This approach works well for software because it's easy to code up a brute-force solution and play around with it. It's not so useful for hardware for a similar reason: it isn't so easy to build hardware prototypes.

Nevertheless the MicroUK101 described last time was an attempt at a test-bed for those chips in the UK101 which weren't testable with Arduinos: the 6502 CPU and 6850 ACIA. A working MicroUK101 would verify that those chips were working too.

Unfortunately when assembled, it didn't work! Now what? Last time I tried to strip it back to the bare essentials required to test a 6502: a power supply, reset circuit and CPU clock. When this didn't work as expected, I had assumed that the 6502 had gone bad. This assumption was incorrect.

Time passed and recently I bought an OWON vds1022i USB oscilloscope and decided that an easy first task would be to fix the MicroUK101. Very quickly I discovered that the clock circuit wasn't oscillating at 4MHz as it ought to: according to the scope it was oscillating at 40MHz!

The simpler problem required another simpler problem: build the clock circuit on a bread-board and try to make it work there before making any changes to the PCB version. The problem turned out to be the 680R resistors in the clock oscillator: these did not provide the stability required, at least with the choice of crystal and 74LS04 I had on hand. Upping the resistors to 4k7 fixed the issue and with it the MicroUK101.

MicroUK101 by Grant Searle and Steve Gray

Incidentally if I were making changes to Steve Gray's PCB, I would drop the power switch and RS-232 interface, using only an FTDI adaptor to power the board and talk to it.

Friday, 14 June 2024

Testing a 6502 CPU

 It's relatively easy to test the UK101's discrete TTL chips using a simple Arduino-based IC Tester, and the ROMs can be read by an EPROM programmer but what to do about the more esoteric chips, i.e., the CPU and ACIA?

As CPUs go, the 6502 is a masterpiece of simplicity. It turns out that you can have it run the most basic of programs with no support logic whatsoever! This is the well-known NOP test, in which the CPU is fed an endless stream of No-Operation instructions, see for example here.


Breadboard 6502 flanked by Clock Circuit (L) and Logic Analyzer (R)

The image shows the test-set-up. The board on the left is a Micro UK101 which is only used as a power-supply, reset switch and clock source. (This is a more rewarding way of testing CPU and ACIA, but only if they both work!)

The CPU does not need many connections to run the NOP test: its data-bus is hard-wired to EA (the opcode for NOP), it also has IRQ and NMI tied high, and the input clock and reset line from the Micro UK101.
 
The logic analyser on the right is a cheap 8-channel model which works with PulseView. It is triggered by the reset pin (high-to-low transition) and samples A0, A1, A2 and the output clock.

When powered up and reset, the 6502 reads its reset vector at $FFFC and $FFFD. Unsurprisingly it reads the address $EAEA and jumps there. It then reads an endless stream of NOPs at every address between $0000 and $FFFF. Its address pins will show this.

Or they would show this, if the CPU was working. The screenshot below shows what happens most of the time:

Dead

The top trace is the reset line and the bottom one is the output clock, which seems to be working. The three lines in the middle are A0, A1 and A2 with nada.

However sometimes the CPU shows signs of life. About every 10 resets, there would be a short burst of activity for a few microseconds:
Some signs of life

So it looks as if this CPU is a goner. It was made by Synertek in the 35th week of 1980 and spent the last 40-odd years in a cold damp attic, where it expired: RIP.

Update: Hans Otten has written about NOP testers here.
Update #2: It seems my test-setup above was flakey and the CPU is actually OK: stay tuned!



Thursday, 14 March 2024

TommyPROM

Some time ago, I mentioned that I had been unable to test the various ROMs in the UK101, lacking an EPROM programmer. That has now been rectified, thanks to the fine work of Tom Nisbet, creator of TommyPROM. 

In addition to an Arduino sketch, the Github linked above hosts a couple of circuit boards, and I had them made as part of my last order from Seeed Studio.

TommyPROM with a very old 2716 EPROM

Populating this PCB cost under €10, quite the bargain. This version of the programmer can read 27-series EPROMs but can't manage the voltages required to program them.

Configuring the programmer requires editing the Arduino sketch for chip series and type, and uploading the modified sketch. This wouldn't pass muster in a commercial product but is absolutely fine for this project's target market: hobbyists on a budget.

Opening a serial port to the board shows the following menu:

Main Menu

Reading that EPROM, which is nearly 40 years old, produced the following output:

Amnesia?

Unsurprisingly, given its age, it seems to have lost its memory! Luckily it is not too difficult to find copies of UK101 (and Superboard) firmware online, Mark's Lab has copies for instance.

Burning old-school 27-series EPROMs requires more advanced hardware, and the second TommyPROM board I had made can do it, TommyPROM32. I will review that iteration when I have assembled it.

What the current version of TommyPROM can do is write to 28-series EEPROMs, e.g., an AT28C16. This is pin-compatible with the 2716 so once it arrives and has been programmed, the next step in testing the UK101 can be taken: hooking the board up to a logic analyser and spying on the data bus using another fine Open Source tool: 6502Decoder.

(I have several PCBs left over from that order. If you want one at cost, PM me.)

Update (April 2024): after some further investigation, it turns out that the basic TommyPROM can only handle 28-pin chips so any data retrieved from smaller chips (as above) won't be valid. TommyPROM32 is definitely the way to go here. Stay tuned for a review of that coming soon!


Sunday, 21 January 2024

Bodge Wiring

A bodge wire is defined as a "wire added to a PCB to fix errors in the layout or broken traces." The first is as a result of a design fault while the second arises from mistakes made in maintenance of an existing PCB.

Bodge wires don't introduce new functionality, they only restore intended functionality. Therefore they should be as unobtrusive as possible.

When restoring an old computer, bodge wires are frequently necessary to fix traces which have broken due to excessive heat during the desoldering of defective parts for replacement, most often ICs and IC sockets.

Bodge wires

When a trace lifts or breaks, I mark the PCB on the top-side with Tipp-Ex as a reminder that a bodge will be necessary sometime in the future. The bodge is then later made on the bottom-side of the board, to keep things tidy.

Bodges required!

It can be useful to differentiate bodge wires from wires adding functionality by colour, or adding functional wires to the top-side of the board.

Kynar wire, Wire stripper and Magnifier

Essential tools for this are 30 AWG Kynar wire, a Wire Stripper and Eye magnification of some kind. Care is needed to ensure that the correct joints on the bottom-side are actually the correct ones. Check your work with a continuity tester!

Some useful additional tips in the EEVblog.

Tuesday, 9 January 2024

Testing ICs


It seems like about two years ago, IC testers made quite a splash, judging by reviews of the Retro Chip Tester Pro (Adrian's Digital Basement) and the BackBit Chip Tester Pro (Noel's Retro Lab). Nice products though they are, they are a little out of my price range for this project.

TTL testing

Luckily for my wallet, there are several DIY projects out there which can be assembled from commonly-available parts in not too long. Nick Gammon (who's excellent interrupt and power-saving pages were inspiration for my Interrupted project) has a super-simple one which can be assembled on a breadboard in about an hour for the cost of 16 resistors, some dupont connectors and an Arduino Uno!

It ain't pretty but it works!

Nick credits an Instructable by one "JorBi" for inspiration for his work. That project is more elaborate, using an Arduino Nano and a display --- Nick's just uses the Arduino serial port, nothing wrong with that. JorBi's project also provided the data file containing the actual chip tests: JorBi stores this in an EPROM while Nick puts it in the on-chip flash.

Another tester of note is the Smart-IC-Tester: an Arduino shield with TFT display. This stores the test database on an SD card, in a format very similar to JorBi's, just adding a one-line description to each part.

So? Well out of 34 74-series TTL chips on the UK101, Nick's tester flagged 7 as bad, 15 as good, 4 were unknown and 8 not tested, due to having wires soldered to them. Not bad for a day's work!

The bad chips were as follows:

  • Two 74125s
  • Three 74123s (all from the same batch)
  • One 7403
  • One 7404 (in bad shape, one pin broke off in the socket)
Note, it could be that the 74123 and 74125 tests are incorrect. I have none which tested good.

Update: After playing with the IC-Tester for a while longer, I managed to add tests for the hitherto-unknown chips. The latest score is 9 bad, 22 good and 3 not tested. My fork of Nick's repo is here.

Update 2: I built this circuit on a piece of vero board and piggy-backed it onto my home-brew Uno!
An improvement anyway!

Memory testing

In addition to the discrete TTL chips, the UK101 also had 32 2114 static RAM for main memory and another 4 for the display. Nick's tester is unable to test this IC. Luckily somone named "skjerk" has written a sketch for the Arduino Uno which does exactly this.

The 2114 has a pretty bad rep when it comes to living into old age so I didn't hold out much hope for my set. Rather incredibly however they all came up good!

Untested so far

Chips which I haven't been able to test yet:
  • The 6502 and 6851
  • The Basic ROMs and Character Generator ROM
  • The monitor EPROM

Given an EPROM programmer, it should be possible to read the ROMs and compute their checksums. Stay tuned for that!

Of course the two commercial testers mentioned above can test all of these chips, out-of-the-box. But where's the fun in that?

Thursday, 7 December 2023

Desoldering stuff

Progress? Maybe!


Last time, the next planned step was to remove all of the bodges and restore the machine to something resembling a "factory configuration". This aim has changed slightly: a lot of the bodges are gone but some remain:
  • The 48x32 display mod was just too tricky to undo without a display to test it against.
  • Similarly will leave the 300/600 baud and RS-232 mods until a later time.
  • The monitor switch mod also stays until the EPROM has been verified to work.
So what has been done here?
  • The piggybacked RAM and its decoding logic is history. New sockets were added where necessary.
  • The 6522 VIA board is also gone.
  • A new expansion socket was added to facilitate testing with a Logic Analyzer.
To replace the IC sockets I found the following tools essential:
  • Soldering Iron and solder
  • Desoldering pump
  • Headband Magnifier
  • Bench vise
Don't expect existing IC sockets to survive this process! 
  1. Use the desoldering pump to remove most of the solder; this helps free some of the pins but others will probably remain attached. 
  2. Gently lever the socket away from the board: it will likely break, leaving some pins in place. 
  3. Desolder these one by one. 
  4. Some VIAs will most likely remain at least partially full of solder. To clear them, mount the board vertically in the bench vise and heat each VIA from one side while applying the desoldering pump from the other. It may be necessary to fill the VIA with solder before attempting to clear it, counter-intuitive but it works!
  5. When inserting a new socket do not use force. If it doesn't go in easily, repeat step 4 until it does!
To desolder an unsocketed chip:
  1. Use the pump to remove most of the solder as before.
  2. With a small screwdriver gently push each pin until a click is heard. This means the pin is mostly free of solder.
  3. From the other side of the board, gently lever the chip away from the board. If it doesn't move, mount the board vertically as before, heat the pins on the chip side while applying the desoldering pump from the other. Repeat!
This all requires patience, and a steady hand! 

Flux pen, Desoldering braid and Pump

I also ordered a flux pen and desoldering braid which should be as good or better as the desoldering pump. However I wasn't able to get good results with it. Perhaps my soldering iron isn't hot enough?

Adrian's Digital Basement has a great tutorial on this subject. He also has better tools than I do!

Sunday, 22 October 2023

Restoring a UK101

 

Yes children, computers looked like this once

This contraption is a Compukit UK101 built over 40 years ago by me from a kit. If I remember right, the kit cost £99 (so must have been one of the last ones) and was smuggled across the UK-Ireland customs border in my parents' car.

Its home is a case made out of aluminium by my brother in our school's metalworking shop. Until fairly recently it resided in my father's attic before being rescued in a clear-out.

An unusual feature (by modern standards anyway) was that its manual contained full schematic diagrams. This led to the proliferation of many third-party hardware modifications, in addition to the ones mentioned in the manual itself. I implemented several of the easier ones.

Under the hood.

Under the hood, it is quite a mess! This was a result of inexperience and lack of funds to "do things right". Looking at the board now, the modifications I seem to have made (or at least attempted) are:
  • Switchable Monitor ROMs
  • Double-speed CPU, to 2MHz
  • Double height display, to 64x32 characters
  • Double-speed tape interface, to 600 baud (or maybe even 1200?)
  • RS-232 interface (used to communicate with a Sinclair QL)
  • 8kB RAM expansion, from 1kB (below the UHF modulator and PSU)
  • Extension ROMs 
  • VIA-6522 board (above the keyboard, on the right)
Some time in the 1990s, I pulled all of the ROMs and read them to use as the basis for an emulator which has been described before here. This explains the empty sockets above the keyboard, on the left.

Whether it still works or not is anyone's guess but inspired by Usagi Electric's fine work on a Centurion mini-computer, I've decided it might be an interesting project. A rough outline of the steps involved might be:
  • Verify the power-supply is working. Done!
  • Remove all of the piggy-backed chips and other bodges; replace IC sockets where required; test RAM chips and leave 1kB system RAM and 1kB display RAM.
  • Using a 16-channel logic analyser and the excellent 6502 decoder project, verify that the system boots by comparing the CPU trace to that from the UK101 emulator.
  • Clean up the video circuitry by connecting to a video monitor, either by buying an old one second-hand, or using this adapter to connect to a modern (HDMI) one.
Once all that has been done, I can start to think about adding new hardware:
  • 32kB static RAM chip (62256-80 seems to be suitable) and 16kB ROM (27C128). The former will occupy the lower half of the address space (0000-7FFFh) and the latter the next quarter (8000-BFFFh).
  • Display modifications: double-height, colour.
  • I/O board: disk controller, VIA
One very interesting possibility would be to build a "universal hardware module" out of an Arduino (e.g., an esp32). This would run a modified UK101 emulator and provide all of the missing hardware by listening on the address bus, data bus and CPU control lines. The CPU would initially have no RAM or ROM: it would all be provided by the emulator. (This idea is reminiscent of the ROMulator as featured on Adrian's Digital Basement but would be more flexible.)

Quite a laundry list there: stay tuned!

Thursday, 24 September 2020

Tinysensors Redux

 

Raspberry Pi Zero-W with Tinysensor Hat

It is often instructive to revisit an old project: you never know what you might see with fresh eyes. Such is the case with Tinysensors, which has featured here several times over the years. Since it lives in Github I use that platform's Issues feature to collect ideas which pop into my head when I am otherwise occupied. This provides a nice context from which to start revisiting.

Among the issues addressed since the last time we featured this project are:

  • Switching to the ATTinyCore. From my point of view, the most important feature of this great project is its support for Optiboot. This decreased the testing time for changes to the Tinysensor sketch by an order of magnitude. No more external programmers!
  • Removing the RF24Network library. This supports a very versatile model of organising nRF24L01+ radios into a fully-connected 5-way tree. However it necessarily limits the number of leaf sensors to 5, requiring bridges to interconnect different levels. A star topology removes this limitation, and also reduces the code footprint enough to support debugging via SoftwareSerial.
  • Reducing power-drain. With the above improvements in testability, it didn't take long before a gotcha in power consumption was spotted: a voltage divider made with a built-in pullup resistor consumes current even during SLEEP_MODE_PWR_DOWN!
  • Moving the hub to Raspberry Pi Zero W. This has more memory and more processor for smaller footprint; in addition to built-in WiFi and Bluetooth. Once that was complete, a proper Hat was designed to hold the nRF24L01+ radio and status LEDs... and a power button, just 'cos.
  • Outsourcing the RF24 library to nRF24. These guys have put a lot of work into improving the performance of Maniacbug's excellent original library, which means I don't have to!
Future work? A nice next step might be to redesign the sensor PCB for a coin-cell and surface-mount components. However I'm pleased enough with these changes to park it for another couple of years!

Thursday, 27 August 2020

Soldering surface-mount components

 

ncp1402 boost converter


The image shows a breakout board for an NCP1402-based boost converter which steps-up 1.5v to 5v; these circuits are widely-used to power 5v (or nowadays 3.3v) from a single coin cell. (The board is my design, in KiCad, based on the manufacturer's recommended application.)

Of more interest here is the regulator component itself. This is the small 5-pin chip midway up the right-hand side of the board. It is a surface-mount SOT23-5 part, approximately 3mm by 1.5mm, far smaller than a grain of rice. Building this breakout board was more an exercise in seeing if it was possible to hand-solder these parts than anything else, since they are widely available for cheap on t'Internet.

So how did I do it? The first step was choosing a hand-soldered footprint for the part in KiCad. Then, once the boards had arrived, this part obviously had to be soldered on first:

  • Apply solder to the pad under one of the further-apart pins (on the left in the picture)
  • Place the chip over this pad with a tweezers and hold it in place
  • Melt the solder on the pad until it flows over the pin
  • Solder the other pin on the left-hand side
  • Solder the three pins on the right-hand side together. 
  • With a desoldering pump (braid should work too), remove the excess solder from these three pins, so they are no longer shorted together.
Tweezers and magnifying glass (or low-power microscope) are essential, unless you are some sort of assembly robot. Fine-gauge solder and a fine-tipped soldering are helpful too.

Note that the circuit itself helped me "get away" with the final two steps of the procedure above: of the three pins on that side of the regulator, one is NC and the other two are connected to Vout. However checking with a continuity tester indicated that they were no longer shorted together, so the pump had worked as expected.

So the experiment being successful, the next step is to build more surface-mount parts into my designs. 10k resistors and 100n capacitors crop up very often so they would be obvious targets for replacement. Stay tuned!

Wednesday, 22 July 2020

Simple Variable Voltage Bench PSU

Back in the days of the desktop PC, a common DIY project was to re-use its ATX power supply as the basis of a Bench PSU. Sadly those days are slipping into the past as more and more of us move to laptops. All is not lost however, as most laptop transformers also deliver a reasonable output voltage which can easily be down-regulated and supplied to nascent bench projects.



The circuit schematic could hardly be simpler --- I am fairly embarrassed that the best I could do to obtain it for insertion here was "Print Screen" in KiCad. All of the action is provided by an LM317 linear regulator which costs peanuts these days. The output voltage is given by:

Vout = Vref * (1 + RV1 / R1), Vref = 1.25v

Note that this is independent of the input voltage, although obviously it can't be greater. Also we want to choose R1 so that the output is at sensible values for differing positions of the (linear) potentiometer RV1. Given a transformer rated at 19v, we choose R1 = 680R, giving values of Vout:

RV1    Vout 
0      1.25
2k5    5.8
5k     10.4
7k5    15
10k    19.6

Obviously the last value is a little too high, however this value of R1 gives the greatest precision for the transformer at hand.

The design is completed with a cheap LED voltmeter as shown below.

 

Simple extensions to this design would be to use a combined Voltmeter/Ammeter display (also costing peanuts); adding a current-limiting circuit, or a switched constant-current source, also supported by the LM317. Next time!

Friday, 19 July 2019

KiCad Kata

Pretty (but dumb) LED Matrix
The picture shows the result of another workout with KiCad as executed by Seeed Studio and finished by me. This looks rather prettier than the original and was considerably easier to solder, not to mention more LEDs!

However a few defects are obvious too:

  • the LED spacing is wider than on stripboard, which can make patterns harder to discern
  • the interface split between anodes and cathodes is the same as the original, for no good reason
  • it now uses 16 gpios!
The first and second of these are my fault but the last could have been mitigated by adding an LED driver, such as the MAX7221 to the design:
MAX7221 DIP package
This particular chip requires only a couple of capacitors and a single resistor to function (see the circuit here). Also it is cheap, less than €1 from China and has a mature Arduino library. It could comfortably have fit in the space occupied by the resistors on the left of the picture. On the downside, it requires a 5v supply. (The Arduino playground has a lot of information about it.)

So, it was instructive to lay out an LED matrix and write a library for it, and I'd encourage you to try it for yourself. (However I also won't blame you for simply buying one on eBay, they seem to be cheaper than the cost of parts somehow!)

Wednesday, 17 July 2019

At the Margin

(Who knew that the Economics of Seinfeld was a thing? Given that it was the first link returned by Google, everyone but me I guess!)

The idea of "marginal cost" is usually in mind when I'm preparing a PCB order from Seeed Studio. That's because their product is cheap and high quality but shipping rates are high. This means that it's almost free to load up an order with small items which would not of themselves justify the total cost.

This post describes a couple of such items, which gave me practice (I'm learning KiCad) yet took no longer than a few hours to produce.

The first of these is a breakout board for the (pre-ESP8266 anyway) ubiquitous nRF24L01 radio module. Its main advantage is its low power, allowing projects using it to run off batteries. Its main disadvantage is its breadboard-hostile pinout. Enough said: see picture below.
nRF24L01 breakout
Sparkfun does something similar; however theirs is better, and more expensive! I kept mine pin-compatible though, because why not?

Next up is a breadboard-friendly development board for the attiny84. This had been on my maybe-list for a while but it was only when I discovered Spence Konde's awesome Arduino core for ATtiny that I decided to go for it. The presence of Optiboot sealed the deal for me: the pin header allows sketch upload via a standard FTDI dongle.

attiny84 devboard
Lastly, just to show that they both play nicely together, the pair wired up, and programmed with a sketch using my ATtiny port of the RF24 library (originally written by Maniacbug of course).
All together now!

Wednesday, 22 May 2019

Soldering Kata

7x7 LED Matrix
When I were a lad, LEDs were a big deal, literally: £1 each. Now someone in China manages to make a living selling them for £1 for 100. With inspiration provided by an Instructable, a rainy afternoon and the need for some soldering practice I set to work.

The Instructable's, err, instructions were clear enough:

  • take a piece of protoboard (the sort with pads instead of strips)
  • solder each row of LEDs anode (longer) first to hold them in place
  • cut the cathodes to size and bend them through 90 to connect each row's together
  • test each row after soldering!
  • I then cut a piece of stripboard ("veroboard") into single strips and connected each column's anodes together in a sort of DIY dual-layer PCB arrangement, see below.

Rear view: anodes connected in columns

The last step was the only point where I deviated from the instructions. (I first attempted to fit a single piece of veroboard over all of the anodes but found this impossible: there was too much variation in their positions. Perhaps aligning each row of LEDs as it is soldered using veroboard might work?)

Next: mount vertically on breadboard, add a handful of resistors (470R) and connect to an Arduino!

I wrote an Arduino library for it, available on Github. It contains a couple of examples, the simplest can be seen running below. (The moving light makes keeping the camera focussed impossible, sorry.)




The disadvantages of this bit-banging approach to driving an LED matrix are fairly well-known:
  • it uses an excessive number of GPIOs (14 here)
  • the GPIOs themselves can't supply very much current, so the more LEDs lit, the dimmer they are
  • PWM-style dimming is not practical
  • timing is tricky: since it relies on persistence of vision to work, each refresh cycle must take no more than 40ms
For all of these reasons, using a dedicated driver chip is recommended. More when my MAX7221 (another £1) arrives on the ship from China in a couple of weeks!

Friday, 1 June 2018

It speaks!

Porting TTS to the ESP8266 processor has been on my to-do list for a while now, prompted by a comment on an issue I'd created to remind me. To do this, I realised that I'd have to reacquaint myself with PWM on the ATmega328p.

At its most basic, a PWM waveform is a square-wave with a varying duty-cycle. Both the frequency of the square-wave and the duty-cycle are determined on an AVR by the its built-in timers. PWM on Arduino pin 9 (hardware pin 15, OC1A), for example, is driven by Timer-1, a 16-bit timer.

Several PWM modes are available; TTS chooses the "phase and frequency corrected" option.


The diagram shows how this works to change the duty-cycle of the output pin:
  • the timer counts from BOTTOM to TOP and back down again
  • when it crosses the OCR1 threshold going up, it sets the OC1A output high,
  • when it crosses this threshold on the way down again, it sets the OC1A output low. 
Therefore by dynamically changing OCR1, we can change the "volume" on the output pin.

The final piece of the puzzle is how the frequency of the square wave is determined. Since the timer ticks on every clock cycle, it will take 2*TOP cycles to cycle from BOTTOM to TOP and back. The AVR has a clock frequency of 16MHz and PWM_TOP in the TTS library is defined as 1200/2. This gives a frequency of about 13kHz.

By default PWM on Arduino/ESP8266 has a range of 1023 and frequency of 1kHz. However it provides APIs to change these values. By setting them appropriately, the ESP8266 speaks!

Wemos Mini D1 with TTS amplifier and super-cheap speaker
The picture shows a Wemos Mini D1 connected to a modified version of the simple LM386 amplifier described at the TTS GitHub. (The modifications arose from a Hackaday article on the LM386 and are summarised in the GitHub's README.)

This amplifier sounds surprisingly good, considering its total cost was about €1. Hooking it up to a signal generator and oscilloscope produced the following pretty pictures.

At low volume, the output is a pretty faithful inversion of the input signal (a 1kHz sine wave):

Undistorted Signal
At high volume, the output is clipped by the supply rails (but still sounds pretty good to my untrained ear):
Clipped Signal
These pictures were produced using an Xprotolab Plain, an amazing combination of Oscilloscope, Signal Generator and Protocol Analyzer implemented on an AVR XMEGA. Buy one!
Xprotolab Plain

Tuesday, 29 May 2018

ArduTouch

One of the very few downsides of ordering PCBs from Seeed Studio's Fusion service is the shipping cost. While an individual PCB can cost less than $0.50 in multiples of 10, shipping to Western Europe can add another $20.

One way to amortize these costs is to add more PCBs to an order, either from my own "design pipeline" or by searching online for cool projects. One very cool project discovered in this way, was ArduTouch from Cornfield Electronics.

One the hardware side, this is basically a battery-powered Arduino Uno with an LM386 amplifier driving a 4-Ohm mini-speaker, or your HiFi via line-in. The keypad is very nicely integrated into the PCB, see my construction below.
ArduTouch with Batteries and Cheap Speaker

Software-wise its GitHub provides five (at the last count!) different synthesizer sketches and a library for constructing your own. As usual, sketches are compiled in the Arduino IDE and uploaded by FTDI cable. A nice touch is that they uploaded a BOM for Mouser, making ordering the parts a snip!

I have several PCBs left over from this order. If you want one, contact me through the Tip Jar on the right. However I would encourage you to support the guys who made this great project possible by buying one of their kits.

Saturday, 13 January 2018

Web-Configured ESP8266

A unique feature of Internet-enabled "things" is that they often have an Internet connection and little else. First-configuration of these devices therefore presents a challenge, which most solve by creating their own wireless access point, to allow their owner to supply credentials for the local wireless network.

Web-Configured ESP is an attempt to abstract away the boilerplate required for this task, and other related ones. It's a "starter" sketch providing the following basic features:

  • Creation of a temporary Access Point ("MyESP") allowing the configuration at the conventional url, http://192.168.4.1
  • A basic web-server running at this address, serving config.json and storing updates to it
  • An HTTP update server, allowing upload of new sketches "over the air"
  • An mDNS responder allowing access at http://myesp.local
Together, these features allow bootstrapping of sketches without requiring the devices to be tethered to a development machine, and user-provisioning of the finished article in the field.

Wednesday, 8 November 2017

WifiWeatherGuy

My title will no doubt remind regular readers of 2013's Weather Guy, a weather app which completely maxed out an ATMega328. Well it's had a technology refresh replacing Ethernet with Wifi, XML with JSON and AVR with ESP. A surprising amount of display code survived the upgrade and can be found on GitHub (along with Eagle files and Gerbers).
WifiWeatherGuy

The hardware has also been simplified and now comprises merely:
The Wemos has been mounted on the underside of the board as can be seen above, because I soldered its pin headers on the wrong side; however this suggests to rotate the display by 180 degrees, making the build more compact.

The software is built on the following fine components:
Perhaps the most interesting aspect of this build is its configuration:
  • Stored in JSON format in the onboard flash filesystem
  • An index.html is served to a browser which loads the configuration file and initialises form input items (via Transparency)
  • Submission of the configuration form transmits the form values in JSON format to the server where it is stored back in the filesystem
  • The index page also supports firmware upgrade
This pattern, where the client assembles a UI for the user out of pieces obtained from the server is finally becoming prevalent in the wider web, but nowhere is it more useful than here where the client has maybe 200x the power of the serving microcontroller.

The Weather Underground API provides current conditions, a 5-day forecast and astronomical information. Two of these can be seen below.

Sunrise and Moon Phase



Current Weather Conditions