Search This Blog

Monday, 10 February 2020

Reverse-Engineering An AdLib Clone [Part One]

Home Page

A long article, so part one is about creating the schematic, while part two is about fabricating, constructing, and testing the board.

Back in November of 2016 I was fortunate enough to acquire an AdLib clone via eBay. It had been sitting in someone's loft for goodness knows how long prior to being discovered and sold so it was in bad shape. I restored it fully, however, and it worked perfectly. For a short while.

My attempts to repair the card were rushed, clumsy and ultimately destroyed the board. For many this would be the end of the road, but instead I embarked on a project to recreate the card from scratch, such was its value and uniqueness. I thought I would share the process I employed to achieve this, now that I'm on the verge of ordering a replacement board.

The first step was to take a high resolution photo of the component side of the board in its original state. This was so I would know which chips went where, and what their orientation was. The only components on the rear were resistors and non-polarised capacitors, both SMD type.


Next, I desoldered the through-hole components.



You can see on the picture of the component side where I've scorched the PCB by leaving the soldering iron on it for too long. In removing other components I lifted some pads, too. To be honest this isn't much of an issue when you've already written off a board and intend to recreate it. I have since upgraded my equipment.

I then made a list of all the component labels, thanks to the handy silkscreen, on a piece of paper and desoldered the SMD components. I used tape to stick each of the components on the page next to each label with values where known, so I could store them safely and not get them mixed up with each other. While the resistors had standard markings on them for their value the capacitors did not, so I would have to measure those later.

The final step was to get very high resolution scans of the board so that I would be able to zoom in and follow each trace. I did this at 1200dpi, giving me five times more detail than photos would.



Removing the SMD components was a lot easier and you can see how cavalier I was with the rest of the board. Partly I blame 30 year old solder. Note how I have flipped the rear scan. This is so I can import the images to Photoshop and switch between layers, which makes it a lot easier to trace the vias. This board is well and truly toast by now.

Another layer I needed to introduce was pin numbers. When you're zoomed in close on a trace and following it to an IC, you don't want to be taking your eyes off the screen. Having the pin numbers visible makes it a lot easier to transfer the information to a schematic.



What's that you say? A schematic? Yes. I previously had very little experience of creating PCB schematics. As I using an Apple Mac most of the time, KiCad seemed like an obvious choice for the task. It's very capable, easy to learn, and is powerful enough to appeal to experts too. Much like with programming when I first started learning it, I thought I'd be crap at it. It turns out my sense for structure, organisation and clean layouts works in my favour for such things.

If you do want to get into reverse engineering, starting small is a good idea. My first project was to work out how the hell the control circuit in our cooker hood worked. It was misbehaving, it used a number of relays and other discrete components, and I figured creating a schematic would be the best way to study it - sometimes just looking at things makes my head hurt. Schematics create more of an organisational view of things, so that it can be a lot easier to see how power and data flow in a circuit.


Trust me, it didn't look this neat after the first attempt. Unless you've learned electrical engineering formally, making something like this is going to be an iterative process. First it will be a complete mess and won't make much sense. Over time, things like component placement will become clearer but it's hard to teach such a thing. I think having a feel for it helps.

I fully accept that I am naive about this stuff, so I'm probably not a great example to follow. I know nothing about best practice, procedures, standards, documentation or anything like that, but I've learned a lot from looking at other people's schematics. Examples I've looked at are Sergey's AdLib clone, a replica of the original, and even an s100 board with OPL3 and game port. The more complex the project, the more experience you're going to need.

Now the laborious bit - the reverse-engineering itself. It's a bit like trying to recreate a jigsaw puzzle that you've only got a photo of. I don't know if there's a particular method that is best, but here's what I did:

1. Place each of the ICs into the schematic. This is done with models of the component, which are drawings that include information on physical form, number of pins and their designation. While KiCad has a huge component library included and many more available for download online (if you can find them), when you're dealing with obsolete components they may not exist anymore. Not only does this mean that you might not be able to buy equivalent replacements, but you will probably have to make your own models. (More on this below).

2. Voltage and ground connections. Each IC has at least one pin for power and at least one pin for ground. Labelling this pins is the easiest way to start, much like finding the corners and edge pieces of the puzzle.

3. Connecting the other pins. This is like finding all the sky bits in the puzzle, or a particular building. In the case of a computer expansion card, this usually equates to bus connections. In this case it's the ISA bus, so having the bus connector on the schematic is a good start.

4 & 5. Laying out and adding smaller components. As you add more components and connections, the schematic is going to become increasingly complex. As a result you need to stay on top of how things are organised. Keeping discrete parts of the circuit together, but separate from other parts of the circuit, is helpful. For example, the Amstrad AdLib clone is made up of the following elements:

- Sound generator
- Amplifier
- Bus logic
- Game port
- Power supply
- Timer / buffer circuits

Some are connected to each other, some aren't. Often a naturally-fitting layout will become apparent. I wish I had kept a record of the iterations that were involved in refining my schematic as an example but, much like writing an essay or an article, incremental changes overwrite the old document. Version control only really comes into it when you have a complete, initial version.

6. Fine tuning and double-checking. More than once I checked each trace from each pin on the ISA bus edge connector and each trace from each IC pin. Looking at schematics of other, similar projects can help to build a familiarity with how the circuit should work, so you can look at it and think "hmm... that ain't right" and then focus on a particular section until it makes sense.

I've never published a schematic before and I'm 99.999% sure that I've not made any mistakes but, until I build and test the board, I won't truly know.

Here's what I've produced so far, and here's a link to the PDF version.



There is a workflow that is managed by KiCad that goes in this order (summarised from this page):

1. Eeschema - schematic design and component model creation. This includes the electrical rules check, which ensures that the circuit works in theory. Errors highlighted in this check require returning to the schematic and fine tuning it.
2. Cvpcb - step one establishes how each component is connected in the circuit. Step two relates a physical footprint for each component to the eventual format of the PCB. The first two stages produce a netlist, which is the basis of step three.
3. Pcbnew - footprints are placed on a blank canvas and physical copper connections are laid out. There is a certain amount of automation available here, but it's mostly a manual process from what I understand. (I haven't done this bit yet...) This can then be checked with design rules, which ensure tracks aren't too close together, etc.
4. Gerber - this is a set of files that are used by a fabricator to make the actual boards. The closer the relationship between the PCB designer and the fabricator, the quicker errors or changes to the design can be realised. This is why it pays to spend more time getting things right if you're one person who is sending your stuff off to a fab in China. A mistake could cost weeks of progress.

Luckily I'm not in a hurry. At the moment I'm just making a replacement board for myself but I fully intend to publish the final schematic and related files when it's complete so anyone can if they want. One major obstacle to this additional step is that I need to find equivalent replacements for the SMD ICs this particular card uses and, if I can't, I might even redesign the board to use through-hole components instead. I guess we'll see.

No comments:

Post a Comment