Close

Lessons learned (part 1)

A project log for DB6502

Yet another homebrew computer based on 65C02 CPU

dawid-buchwaldDawid Buchwald 08/03/2020 at 17:113 Comments

Part one of many

There is no way I could fit all the things I learned, even if just using bullet points, in single blog entry. I will probably share these as I go, mixing them with general descriptions and new experiments. Starting with one that is most obvious: always have some reference point, working revision that you can revert to.

Version control

Use it for anything and everything. Keep your sources, even if they are temporary, one-off experiments. Save your schematics, even if you design them for temporary ad-hoc device. Use branches to separate developments that might or might not go into final design – it will be easier to merge them with release branch than to remove them from it.

This was obvious, but what else? Well, in general it’s not recommended to store binary results of any build, it should be possible to generate them easily from sources (schematics, configuration, etc.) stored in repository. That being said, I was asked number of times to provide PDF of the schematic or HEX file with firmware by people who didn’t want to install the whole software stack just to take a look at how I did certain things.

What I also decided to keep was the datasheets of used chips – reason being: you can find different versions of datasheet when looking for it online and sometimes they differ significantly. Git handles large binary files that don’t change often very well, so don’t worry about repo size.

If you intend to go to PCB at some point, make sure your design your circuit first, build in on breadboard second, test third and move to PCB layout at the end. Things that are not documented properly will be missed when designing PCB. And no, you will not remember that one little obvious detail next week. You will forget it, trust me :)

Fail often and fail early – but understand what happened

One of the most difficult parts at the beginning of the project was writing LCD interface. If you watched Ben Eater’s videos about it, you might be wondering what was so hard, he made it look easy.

Problem is that Ben uses the most “default” version of the interface, where I decided to go for more complex one (4 bit instead of 8 bit; 4x20 LCD instead of 2x20).

I built my LCD interface on breadboard and it worked. Sort of. Sometimes it did, sometimes it didn’t. I blamed instability of breadboards and moved on. I was lucky, it was only my software that was busted, and after migrating to PCB, when issue occurred again, I had to look closer at the code and fixed it. Then, couple of months later fixed it again :)

Similar thing happened when I started playing with new serial interface. It all seemed to work pretty well, with some exceptions. I blamed ribbon cables, was about to move on, but this time stopped and started looking at it again. And again. And again. What I almost attributed to ribbon cables was serious hardware design flaw that, when moved to PCB, would render it useless. There was no way of fixing that in code this time.

So, when it fails, even if rarely – don’t just rewire or shrug and move on. Try and understand what happened. It might have been freak accident, but most likely there is something you didn’t consider.

Use the right tool for the job

So you want to build 6502 based computer? Or any other embedded hardware? It’s pretty obvious how to do it: prototype the whole thing on breadboard, write operating system for it, upload, test and then design PCB reflecting your breadboard connections. Easy-peasy :)  

Except it’s not. Not even close. I have tried and learned a lot from it, but the most important lesson is you don’t really want to do it. Do small things in isolation, and always, always, always use the right tool for the job.

No, you don’t need expensive 500$ 100MHz 4-channel 1GS/s scope for it. You might need 13$ cheap Saleae Logic8 clone. Sure, proper scope might come in handy, and it will help here and there, but you can easily do without it. Since you are dealing with digital electronics and the chips you use are pretty tolerant to poor design, most likely you will not encounter issues that can be found, understood or resolved only using a scope.

That said, building system like that from scratch (like I did) is plain stupid. I wasted countless hours troubleshooting my LCD interface (more on that one soon) and trying to guess what was happening, where the right thing to do was to hook it up to Arduino and bit-bang from there with serial monitor providing convenient access to debug information.

Remember that when you start you have very limited system with little to none information about what is going on inside. Sure, after a while, when your connections become “solid” (as in tested and working) and you get convenient I/O subsystem with some sort of monitor capability, you will be able to sort out most of the issues without external hardware, but when only starting and trying to bit-bang new chip? Use Arduino instead. You will learn much more about the hardware you are interfacing with.

Beware of feature creep

That’s the worst part. You will always have one more idea. There will always be something more to do. Remember – one step too far can turn your PCB into useless crap. If you’re lucky, simple cut and patch will do, but sometimes it’s not that easy. Remember that with proper PCB design you can provide yourself with enough flexibility to make some decisions later. Don’t leave everything open, it defeats purpose of PCB, but don’t treat the first revision as the final one. Each is just a step in your journey.

To be continued...

Discussions

George Foot wrote 08/05/2020 at 21:05 point

Great advice, especially regarding breadboards.  Yes they have their issues, but so do our circuits, it's important to tell the difference between the two!

Have you considered veroboards, or other soldered prototype boards?

  Are you sure? yes | no

Dawid Buchwald wrote 08/06/2020 at 13:20 point

Sorry, for some reason I missed your message. Yes, I also used these solderable prototype boards, and they are great... almost. I still haven't figured out what kind of wires goes well with them. Kynar wire seems flimsy (but I also butched the soldering on that one), while the regular hookup wire has low tolerance to heat, resulting in melting (or shrinking) insulation.

That being said, designing PCB was actually a lot of fun (exactly the opposite of what I anticipated) and the production/delivery time from China was 6 business days. Insane!

  Are you sure? yes | no

George Foot wrote 08/06/2020 at 17:03 point

I've had the same heat problem.  I also find that somehow the stripped wire seems "dirty" to the solder, it doesn't flow onto it properly, maybe due to residue from the insulation.

One advice I saw was to get plain wire, without insulation, and slide on your own insulation after cutting it (and soldering one end, I guess).  I'm not sure what the benefit was, maybe cost, or being able to choose the insulation more carefully.  Nor where I saw this advice.

The main thing I dislike on soldered prototype boards (and breadboards to be honest) is wiring buses.  It's so much easier on a real PCB.

Laying out PCBs is a delight but it takes me ages, because I'm too much of a perfectionist (especially given my lack of real experience doing it...)  Before I know it, I've spent hours playing around with layouts and traces.  It is such a soothing process, like a kind of puzzle.  I was really pleased with the result when I got it manufactured, and fitted all my components to it.  Only thing I left out was bypass capacitance which I think actually caused some problems in the end.  I definitely got a lot more things wrong in the layout, but you learn best by doing, maybe next time will be better. :)

  Are you sure? yes | no