Orwell computer case.

April 25th, 2015

IMG_3783_1 IMG_3784_1 IMG_3775_1

IMG_3785_1 IMG_3789_1 IMG_3768_1

Since no one reads this stuff here is a film :)

Over the last month or so I finally got around to making a housing for my Orwell computer. After a little distraction trying to get a SID chip working (I didn’t) I decided the hardware is finally done so it’s time to build a case. This is how I did it.

The case is custom made from steel with timber ends. First though I made up a cardboard mockup and from that started marking out steel sheet.


The steel is 1mm on the base and 0.8mm for the top. It is in two pieces that gets screwed together with 3mm screws.

The case itself is simple sheet metal work. Lots of marking out then bending and folding and hammering around whatever bits of whatever you have hand you can bash steel around!

IMG_3680_1 IMG_3683_1

IMG_3684_1 IMG_3686_1

I know these days it’s all about 3D printing and plastic. Bleargh! I prefer the hand crafted approach and metal and wood. I used the same approach for my Enigma watch and that came out great.

A bit of work later and you get a top. Yes I am using the back of my vintage car as extra workspace. It’s flat and it’s there!

IMG_3687_1 IMG_3690_1

IMG_3694_1 IMG_3696_1

The base is a simple steel tray. I joggled the front and back of the top so it neatly slides into the base. To hold the timber sides on I made some side plates, also joggled so they fit flush, that I soldered to the top. They not only provide a way to screw the sides on, they stiffen the entire top.

IMG_3714_1 IMG_3716_1 IMG_3718_1

After making the top and soldering the sides in place I started cutting the openings I needed. The back opening for the connector panel was easy as was the slot for the front panel. The keyboard opening was a bit trickier. To do this I photographed the keyboard from above, printed it out 1:1 scale onto cardboard then cut it out. I used that as a template for cutting the hole.

IMG_3705_1 IMG_3706_1

I roughly cut the hole with an angle grinder then nibbled out the rest with a hand nibbler. Final finishing was with a flat bastard (that’s a file – found that amusing when I was 10, still do now).

IMG_3709_1 IMG_3710_1 IMG_3711_1

To hold the keyboard in place I did use some plastic! But this is just some blocks cut from plastic chopping board. It holds the keyboard at the right angle but I deliberately made them low so I could then use washers as shims under the keyboard to get it to exactly the height I wanted. The wooden sides are attached to the top which then fits onto the base. To attach the top to the base I made up some little brackets that are drilled and tapped for 3mm screws and then soldered to the top of the case. My aim was to have no screws visible from the front or top of the machine. All the screws are underneath or on the back of the machine.I made some temporary sides from some plywood to get a template of the shape I wanted.

IMG_3719_1 IMG_3720_1 IMG_3723_1

IMG_3727_1 IMG_3730_1 IMG_3733_1

The timber for the sides is oak recycled from an old dresser a friend got for me off the side of the road (we had an inorganic collection – so much great stuff people throw out). It wasn’t worth restoring so I broke it all apart for the timber.  Good timber is hard to find these days so recycling old stuff is the way to go like I did on my railway dining table.

IMG_3754_1 IMG_3755_1

I’ll use other bits of that dresser on my car I am sure. I love oak. It’s seems a good, old, English timber to me. I know it comes from elsewhere too but it has that old fashionedness about it I like.

The front panel and rear panel are made from aluminium. These were drilled and cut out and painted dark green. The front panel is held to the case from inside by screws into threaded inserts soldered to the inside of the case so no external screws are needed. Those paying attention will see the serial port is the wrong sex! It was the only spare connector I had till I could get some more.

IMG_3737_1 IMG_3739_1 IMG_3742_1

Before fitting the sides thought the case I had to paint the case. Again inspired by the Enigma machine (I love those things!) I used crackle black paint. This stuff can be tricky to work with. The best thing is to get on a good, heavy coat (put on with lots of passes with no runs) then just leave the thing in bright, hot sunlight and let it do it’s thing. It will look like it’s gone all wrong at the start but if you just leave it things should come right. I actually didn’t do quite heavy enough coats so if you get the light just right you can see my spray pattern but the final finish was good enough to go with. The inside I painted with zinc rich weld though primer so it won’t rust.


After it’s dried I also bake it in the oven at about 100c for an hour or so. You eventually end up with a nice, hard, textured finish. The real Turing/Welchman bomb at Bletchley has the same finish actually (although I wonder if it’s painted or powder coated though?). I was so annoyed the one film that didn’t come out when I was there was the one of the Bombe.

After the paint dried I could assemble thing. First I had to make sure the main computer mounting was correct. This is the aluminum chassis the main Orwell board and the IO board were attached to. I did experiment with a SID sound board but in the end abandoned it when I couldn’t get it to work right. Orwell wasn’t designed to take one so I never got it to work right. I think the issue was the addressing/chip select. You can see the SID board here though. It’s the bottom most board.


The main chassis is just attached to the base of the case with 3mm screws and nuts. It’s a bit hard to see but on the left hand side of the main chassis are the voltage regulators and the amplifier module.


The front and rear panels were painted a very dark green and I etched and painted up a custom brass logo for the front of the machine.

IMG_3757_1 IMG_3768_1 IMG_3784_1

The D sockets on the back are a serial port, an analogue joystick port and a general purpose IO port.

There is a speaker driver by an internal amplifier. The volume control is on the front panel. We also have an external audio output as well as composite out and a power supply  for the LCD screen. This screen is a 7 inch car monitor from DealExtreme. It works very well and also has a VGA input in case I ever upgrade Orwell.

A few software changes to mention (I am sure no one reads this stuff). I tweaked my loading routines. Running the serial port flat out was causing the machine to go mental. It would just lose it’s brains. At first I thought it was because the serial port was overloading somehow but in the end I figured what was might be happening was that I was trying to ram characters into the parser too quickly and ended up sending it rubbish it couldn’t parse correctly. to test this theory I ended up using the flow control and stopping the serial port when a full line was received and then starting it again after the line was parsed. This seems to have fixed the issue.

I also added a binary load mode. This lets me load data directly into memory at a given location. This is handy for uploading machine code routines (which is so painful via BASIC) or other binary data. With the new screen working well I also set the default width back to 80 columns too.


A three rotor Enigma machine wrist watch.

March 24th, 2015


This is one of the most satisfying projects I have done I think. Mainly because this is a real device and something so historically important. It is a fully functioning Enigma machine you can wear on your wrist. This is a three rotor Enigma machine as used by German Wermacht in WW2 for encoding messages. If you don’t know what an Enigma machine is you can read all about it here. Or watch this great YouTube film that explains it (all the Numberphile films are great). Since most people don’t read the details here are some pictures. The technical details are below!

IMG_3624 IMG_3625 IMG_3626

IMG_3627  IMG_3629 IMG_3630

IMG_3631 IMG_3632 IMG_3637

A film of the watch in action is here on YouTube.

I’ve always been interested in the Enigma machine. For years I had it in the back of my mind to make one using Meccano or LEGO Technic. I never did that though.

Last Christmas I was visiting the UK and one of my trips was to Bletchley Park, home of the WW2 code breakers. For a geek like me this place is heaven. It was absolutely amazing being there. Definitely worth a visit. I only had a day and it wasn’t enough time (especially if you want to visit the National Museum of Computing next door). One of the most impressive things at Bletchley is the Bombe machine. I vaguely knew about it but sadly didn’t spend enough time studying it while I was there.

Back in London after visiting Bletchley I decided to go see the film The Imitation Game film. At Bletchley Park they had an exhibition about it and the actual bar set used in the film is in the mansion house. Unfortunately I had missed it by a day and it wasn’t showing anymore so I had to wait till I was back in NZ to go see it with some friends.

The first viewing of that film was really annoying. To me it seemed like it was Benedict Cumberbatch playing Sherlock Holmes playing Alan Turing. The character didn’t seem right. And the film was full of Hollywoodisms and the technical details were all very obvious wrong. Or rather very, VERY over simplified (the Bombe doesn’t crack Enigma, it just reduces the possibilities). I decided to find out the real story and figure out exactly how the Bombe actually works (nothing like in the film).

To cut a long story short my aim is to recreate a Bombe using Orwell, the little 8 bit computer I have built. In order to know how a Bombe works you need to know how an Enigma machine works (and is used). And the best way to know how something works is to build it yourself.

So I did.

The operation of the Enigma is actually pretty simple. The Wikipedia article explains how it works pretty well and there are plenty of other great articles online.

To convince myself I knew how it works I coded up my own version using an Arduino. It’s been done before of course but the whole point was to ensure I understood how it works. I had to redo it all myself.

To start with I just used the serial port to input and input characters. It occurred to me though that if I could get that working I could probably make a real working Enigma machine. With a tiny Arduino and a equally tiny OLED screen and a LiPo battery I could make a very small Enigma machine. I decided to make one that was possible to wear on your wrist.

The idea here wasn’t to make the smallest one possible. I decided to make a device that was practical and useable. And something that looks like it was from WW2. Something that could actually be used in the field in place of a real Enigma machine. Obviously there were some limitations. I could have a 26 key keyboard for a start so I had to come up with a UI that would work with a minimal number of keys. I bought a small 128×64 OLED, a suitable battery and started breadboarding it all up. With it working on a normal Arduino I bought an Arduino Pro Mini (or a good replica!) and started looking at getting it running on that. That was pretty easy to get working. The only tricky thing being  having to use a USB to TTL programmer to download to it and those can be fiddly.

The code for the actual Enigma is all my own. I used the brilliant UG8Lib graphic library to drive the screen. This allows you to create your own fonts. The font I am using is a free gothic one called Fraktur which I got from here. I had to convert that into .bdf format using FontForge then I could use the UG8lib tool to convert that to suitable code format.

Fraktur is an interesting font. It’s one that most people would associate with being ‘that Nazi lettering’. It actually is much earlier than the Nazis and they, Hitler himself even, were trying to get people NOT to use it because it was un-German! It’s a funny one that seems to appear in odd places. I used it since it looks right and it was used on WW2 documents such as the covers of the code books. This enthusiastic guy explains it pretty well. Of course the whole UI is in German because it is meant to be a German WW2 device. Trying to find short German words that would fit on such a tiny screen was tricky! Thanks to my German friend Bernd who helped me a bit here.

IMG_3233_1 IMG_3245_1 IMG_3249_1

With the tiny processor, tiny screen, tiny German words, and tiny 150mAh battery I could start designing a suitable housing. Remember the idea wasn’t to make the smallest working Enigma possible, I am sure you could make it smaller, the idea was to make a functioning, practical device. I decided something about the size of a matchbox would be about right. That seems about right for a WW2 era device and it wouldn’t be so tiny to be impossible to build.


My wrists aren’t huge and my normal watch isn’t massive. I started making a casing from steel approximately matchbox sized after laying out the main components on some 1mm graph paper to get an idea of sizes.

The case is made from 0.8mm panel steel. When you’re into making cars it’s the sort of stuff you have lot of lying about. It was some simple metalworking to make a suitable base. I got to use my new Dremel to cut the slots and used some scrap oak wood to make a former to make the rest of the base.

IMG_3290_1 IMG_3291_1 IMG_3292_1

IMG_3294_1 IMG_3297_1 IMG_3299_1

The holes either end are for the on/off switch and a recharging socket. The rectangular slots are for the strap. Recharging is via a little USB single cell LiPo charging board from Sparkfun similar to this one.

With the base done I made a simple top. To make this I used a tool called a joggler which bends a step into the metal (used for doing flush lap joints in car repair). This made a lid that would slot nicely into the base without leaving any open gaps along the sides.

IMG_3300_1 IMG_3302_1

IMG_3306_1 IMG_3313_1

To attach the lid I used counter sunk, domed head screws, similar to those used on a real Enigma machine. They are quite hard to find these days but I got some from the local RS supplier. I had to get 100 but I can use them on Orwell too. To give the screws something to attach to I machined up some brass standoffs. These have a small nipple on the base that fitted into a hole in the bottom casing. They were then soldered in place. To get the position accurate I first made the holes in the top panel, countersunk them then ran a drill through the hole to make a centering dimple in the base. I could then drill the mounting holes in exactly the right place.

IMG_3332_1 IMG_3334_1 IMG_3335_1

IMG_3337_1 IMG_3341_1_1

The stand offs were soldered in place and the bottom sanded smooth.

I then thought about how to actually mount everything inside the casing. I decided to use a small circuit board to which I could mount the screen and buttons. The Arduino Pro Mini would fit into a cut out in the middle of the board. I cut a suitable shape from some PCB board blank. Here you can also see the 2.5mm recharge socket and the main power switch. That was a toggle switch with the toggle cut down to more reasonable proportions.

IMG_3344_1 IMG_3349_1

IMG_3351_1 IMG_3353_1

The screws I had for the lid were too long so needed cutting down. The trick to getting these all the same length it so cut them roughly then insert them into a steel plate you have drilled and tapped previously. The screw protrudes though the plate then you can simply grind the exposed thread until it is flush with the plate. This makes all the screws the same length and makes the ends of them square. If I need to buy a lot of screws or bolts I tend to go for longer than I need since you can always cut them down but it’s much harder to make a short screw longer!

The next step was etching the board. I use the laser printer toner transfer method to do this (plenty of info of that online). I used the same technique to etch a tiny brass nameplate.

IMG_3377_1 IMG_3379_1_1 IMG_3385_1

There is actually a mistake on this board I didn’t notice until it was fully assembled but it was easy to fix (see if you can spot what it is).

Around this time I also started making the strap. I recently decided to learn how to sew so now I have a sewing machine of my own. I used that and some scraps of leather to make the straps. I actually hand wound the machine instead of using the motor so I could accurately position the stitches. I sewed first then cut out the straps to ensure the leather would feed evenly though the dogs. The straps are two layers of leather glued back to back. Masking tape gave me the lines to follow when sewing.  The masking tape also allowed me to mark the centre line so I could punch holes and fit the eyelets. After sewing the tape is removed.

IMG_3357_1 IMG_3358_1 IMG_3361_1

IMG_3364_1 IMG_3356_1 IMG_3365_1

The final part of making the straps was to insert short lengths of piano wire between the two layers to form pins that stop the straps pulling out of the watch. This makes inserting the straps easy. You remove the pin, insert the end through the slot in the case, reinsert the pin then pull the strap home.

IMG_3367_1 IMG_3382_1

The straps and pins also hold the PCB board down in place. Next I made little brass stand offs to mount the screen. This is held down with some 2mm brass screws. I also fitted the tactile switched and machined up some little brass buttons (which are a top hat shape) that poke through the top panel and rest on the tactile switches. I had another OLED screen that I accidentally burnt out I used for mocking up. The one I used in the watch has tape over the rear to prevent short circuits from happening.

IMG_3388_1 IMG_3389_1

IMG_3398_1 IMG_3404_1

I was then able to test fire everything up, first with the board outside the casing. Unfortunately it didn’t work! I’d forgotten I had changed the pin ordering to the OLED to make the wiring simpler. A quick re-download to the Arduino fixed that. I was able to measure the current consumption at this point. When displaying the splash screen about 40mA is drawn. On all the other screens the current draw is about 25mA.

IMG_3413_1 IMG_3419_1 IMG_3420_1

IMG_3421_1 IMG_3422_1 IMG_3423_1

The piece of black felt is there to fill the gap between the screen and the top cover. It also stops the brass buttons from rattling about in the casing.

After that all that remained was to take everything apart and paint the case. The inside is painted with zinc primer just to stop the bare steel rusting. The outside was painted crackle black. I baked the finish in my oven to give a nice hard coating.


The finishing touch was the tiny Enigma badge I had etched. This was infilled in black then glued to the housing.

The actual UI is described below. The device is designed to be used in the field as a real Enigma machine was. The flow is based on the key sheets the Enigma operators used to set up their machines as described here. The UI is simple. The left two buttons work as left and right selectors. The right most button is the select button. Left and right selection are indicated on screen by left and right arrows.

First you turn the machine on.


A key press on any key takes you to the Walzenlage, or rotor setting, screen. Here you can view the current setting or change the settings. It was hard to find suitable German words for the menus. I used Beibehalten, meaning ‘Maintain’ and Ändern meaning ‘Change’. I had to think of words that would have made sense in WW2 so things like ‘Save’ and ‘Edit’ might not have made sense as these seem more modern UI terms.

The first screen you see is the rotor selection screen. You can edit the selection and choose each wheel from left to right. The selection list gets smaller as each wheel is selected of course.

IMG_3525 IMG_3526 IMG_3527

IMG_3528 IMG_3529 IMG_3530

Next is the Ringstellung, or ring settings screen. Again we can edit and choose each wheels ring setting.

IMG_3531 IMG_3532 IMG_3533

Next we go onto the Steckerverbindungen, or plug board settings, screen. This was the trickiest part of the UI to get working with only three keys. The way it works is this. The left and right buttons increment the left and right columns. You select the pairs of letters you with to plug together (called steckering). The UI will tell you how many current pairs you have. If you reconnect a letter that is already in a pair it will break the previous connections and make a new one so the total number of pairings won’t increase. If you stecker a letter to itself it will break any previous connections to either of those letters. If you are reading from the daily key sheets you simply enter the ten pairings indicated. If you want to enter less there is is blank letter setting. If you select this the plugboard editing will end and show you the list of current connections. Clearing connections is as simple as connecting a letter to itself (called self-steckered in Enigma talk).

IMG_3536 IMG_3537

Next we get to the Grundstellung, or initial indicator setting, screen.

IMG_3538 IMG_3539

IMG_3540 IMG_3541

Next we go to the Umkehrwalze, or reflector screen. Since this is a three rotor Enigma we have the choice of the ‘B’ or the ‘C’ reflectors only.

IMG_3543 IMG_3544

Then we finally get to the encoding screen. The left and right buttons let you select the letter to encode. As you encode each letter the display shows the current rotor positions and the encoded letter in a ticker. The ticker displays 5 letter groups as this is how Enigma messages were transmitted by radio.

IMG_3545 IMG_3546 IMG_3547

This is where I deviate a bit from a real Enigma. I believe that only the Naval Enigmas used rotor wheels with letters on them (I think I remember that from Bletchley Park?). The Army and Airforce machines used rotors with numbers instead. That doesn’t work so well on a UI so I went with letters instead. Funnily enough it seems most online simulations do the same as does this brilliant kitset you can get from the Bletchley Park shop.

As well as the letter we have two additional settings. Klar, to clear to reset the ticker, and Ausgang to exit from encoding.

IMG_3548 IMG_3549

That takes you back into the settings pages. The grundstellung will now be set to whatever the rotors were at after encoding and they can be reset back to the initial settings as per normal Enigma operating procedure.

That’s basically it! It is a one off and it isn’t for sale. Although if anyone really wants to buy it I’ll sell it for US$10000. $5000 so I can go back to visit Bletchley Park and $5000 I’d donate to them :)

Orwell joystick.

February 15th, 2015

As well as the railway table I also finished Orwell’s joystick. Actually I made several since the first one I muffed up a bit. The DA15s I ordered arrived a few days apart so during the week I wired up the Orwell end. I used the same pinout as a PC gameport. Well, the top half as I only need one stick. I was hoping I could use an old PC stick on Orwell but I found that won’t work. I’d forgotten over the years that PC joysticks don’t have the pots wired as voltage dividers as Orwell does. Instead one end of the pot is floating.

I went for a walk to Surplustronics and got a small thumbstick and a couple of buttons. I did a temporary wire up and it all worked so I put it all in a box. The thumbstick module was mounted on metal board spacers. They were a little too long so I machined them down on the lathe a little.

IMG_3099_1 IMG_3101_1 IMG_3102_1

I went for a vertical format. Awkward but that was the way things were in the 80s! It reminds me of Boilerplate. It all worked but with a few small issues. Mainly that I misunderstood the way around the axes went. I wanted the 0,0 point to be in the top left so that the stick mirrors the screen co-ordinates. That makes it much easier to do things like drawing on the screen with the stick in BASIC as you don’t need to flip co-ordinates. I couldn’t just rotate the thumbstick as the mounting holes aren’t square and it wouldn’t fit anyway. So I made a new one.


Actually I made several. The first with black jiffy boxes. They were really cheap and nasty though and the plastic was rubbish. You couldn’t drill it without it chipping or tearing. So in the end I used a blue box. And I turned it sideways to be more useable. I also mounted the stick lower down (more machining of the spacers) because I found with these sticks the useable range isn’t across the full movement of the stick. If you make the hole in the box just larger than the mushroom on the stick (well, it has to be larger or you can’t get the stick through!) and mount it with a minimal clearance between the curved part and the bottom of the hole you get the full range almost matching the full travel. That’s hard to explain but easy to understand if you see it in action.

Another trick is on the VIA port B at the lowest memory location ($4400 or 17408 decimal). Port A is one address up ($4401). So I wired the stick and port so that the X axis goes to port B and the Y to port A. So now in the code you PEEK the two locations in sequence to get X and Y in that order. It just makes the coding a little easier. After doing all that it works really well!

This is the code that you use to read the axes:


A simple PEEK on each location to read the axes. Running you get this:


That was with the second button pressed hence the odd number on X and the even number on Y. I can then do my (X and 1) trick to test for the button press. Unfortunately you do have to reverse the button logic since a 1 means the button isn’t pressed and a 0 means it is!

I did various test programs. One lights up the debug LEDS, another played silly sounds depending on the position of the stick. Another draws a dot on the screen at a point corresponding to the stick position.  I actually went back to one of the old games, Death Valley,  I had already typed in and made it joystick enabled. That worked well too. So we can call that done!

The other thing I did was replace my LM7805 regulator with a more modern module using a LM2576 from Surplustonics. These are much more efficient than the old linear regulator. As long as the input voltage is a couple above the output it works well. It is set for 5 volts by the trimmer. It definitely gets far less warm. I probably won’t even need a heatsink on it (but one won’t hurt).


You can just see on the end I attached a small bridge rectifier. That’s because I want to be able to plug in different DC supplies but not have to worry about polarity. I hate having to try to work out which way around a power supply should be wired!

Next is to start finishing Orwell off with a nice case.


Railway table access panel.

February 15th, 2015

Since I am soon starting a new job and will be working from home I really want to get the glass for my railway table so I have somewhere to set up my laptop to work on. Before I can get the glass I needed to make the access panel in the bottom of the table. This is so I can access the underside of the layout in case the train gets stuck or derailed inside the tunnel.

The other week I cut out the hole. This weekend I made the sliding panel. I set up a temporary router  table and cut a groove in some strips of pine. These would go on the base of the table to allow a piece of thin ply to slide to open and close the hole.

IMG_3135_1 IMG_3137_1 IMG_3142_1

I made the edge rails longer than needed so they can help stiffen the table bottom. A simple cut out in one end piece allows you to slide the panel with a fingertip. I didn’t really need that, you can slide it easily with the flat of your hand.

IMG_3145_1 IMG_3146_1

I gave it a quick coat of oil and then screwed the base back on this time using proper cup washers I got cheap in a second hand shop. I still really need slotted screws though but I can replace the screws when I find some easily enough.

IMG_3149_1 IMG_3148_1

With the layout back in you can see how the hatch give access to the underside of the layout though the holes in that.


So next, get the glass!

Orwell IO daughter board.

February 8th, 2015

Recently I was in the UK for Christmas and New Years. One of the trips I did was to Bletchley Park which is where the codebreakers in WW2 cracked the Enigma code. Bletchley has a working version of Turing’s Bombe machine which is used to work out the possible settings for the Enigma decoder. Next door to Bletchley is the National Museum of Computing which contains a working reconstruction of Colossus, one of the first true computers. Seeing all these Enigma machines and Bombes and computers has inspired me to finish off my Orwell machine. If you are any kind of computer geek and in the UK you absolutely have to go visit Bletchley Park. It’s well worth it!

To make Orwell into a full, useful computer I needed to add a few more things. Mainly some extra IO capability. I decided I wanted a joyport with an analog stick as well as more general purpose IO. One fo the main reasons for this is for when I get up to reviewing the Usborne computer books that talk about hardware interfacing. Ultimately I want to reconstruct the robot from the “Practical things to do with a microcomputer” book. That will be recreating a science fair project I made back when I was about 14. For some reason I have three copies of this book – I went a little mad trying to get them all!

The easiest way to do IO is with more 6522 VIAs. I got two more of them and decided to use one as the joyport and the other as the general purpose port. To make the joyport work I added two ADC 0804 analog to digital converters. These ADC can be controlled and read from a micro controller directly but I took a shortcut. I run each ADC in free running mode and feed the 8 bit out (well 7 as I will explain later) of the ADC continuously  into one of the VIAs 8 bit ports set up as an input. I did this because it made the code much simpler than trying to read and write the ADCs every time I wanted to make a reading. It would take a little fiddly assembly code to do this and I wasn’t sure I could successfully add it into the Orwell BASIC. It would also mean having to provide new commands to read the ports.

Instead of needing fancy code and commands all I do now is let the ADCs free run as fast as they can and when I want to read the value I PEEK at the VIAs ports to get the value. Simple!

There is one little bit of code needed to set this up. To start the ADCs free running you need to pull certain pins on them low momentarily. I achieved this buy connecting these pins to CA2 on the joyport VIA. In the rest routine I set this to be an output, momentarily pull it low then set it to an input again (which make it high again). I pull it low before asking the Cold/Warm start question and set it to input after the user has made their selection so I have a good long low reset pulse.

With one ADC on port A and one on port B of the VIA I can read two analogue values and hence can attach a simple analogue stick.

Now how to do buttons? I was hoping to use the peripheral control pins somehow but that proved tricky. They work using interrupts so again the code would be fiddly to handle it. I did think about using a couple of pins on the other VIA but I really wanted to leave all the pins on that free as general purpose IO pins. Again I took a shortcut! The ADCs have quite a bit of jitter. That is if you continuously read the value coming from them you’ll notice it jumps about a bit by a small amount. So for a any 8 bit number (from 0..255) you might see a value that’s changing by +/- 1 or 2 each reading. I decided because of the jitter I was never going to get a highly stable reading with the bottom bits jumping about. For a simple joystick you don’t actually need it to be hugely accurate. So I thought what if I drop the least significant bit and use that input on the VIA to monitor the buttons instead.

It’s a definite hack but I works surprisingly well. Instead of feeding all 8 bits from the ADC into the VIA I drop the bottom bit. Instead that input is wired to a 10k resistor to pull it up. The button then connects to that bit and pulls it down when the button is pressed. Since I have two ADCs I can have two buttons.

In practice what this does is this: When you PEEK at the VIAs ports you get a 0..255 value returned. But since the bottom bit is missing it will either be an odd number when the button isn’t pressed or an even number when it is. So you are still getting a full 0..255 range but you’ve lost a bit of accuracy.

To check if the button is pressed in the BASIC code you get the reading with a PEEK then simply AND it with 1. If the answer is 1 the button isn’t pressed. If the answer is 0 the button is pressed. The logic is backwards to how you think because the button is physically pulling the pin low when pressed. The reversed logic is easy to deal with in software. I had to use AND because MS Basic doesn’t have a MOD function.

You can convert the 0..255 odd or even values into a 0..127 range with continuous values by dividing the value by two and dropping the fraction.

To read the joyport (returns 0..255 odd or even values depending on button state):
X = PEEK (17409) ;Axis 1 (port a on the VIA)
B = X AND 1 ;Check lowest bit
IF B = 0 THEN … ;0 = button pressed 1 = button not pressed

To read the joyport (returning a 0..127 continuous range):
X = PEEK (17409) ;Axis 1 (port a on the VIA)
X1 = INT(X/2) ;Convert to a 1..127 value with no gaps

For a simple 8 bit machine this seems to work very well!

The second VIA is wired as a straight general purpose IO port with both ports a and b broken out to provide 16 bits that can be independently made inputs or output and then set and read at will. I also broke out the four peripheral signals, CA1, CA2, CB1, CB2 but I am not sure they will be much use for the kinds of things I will use Orwell for. Because I am running BASIC there is no easy way to handle interrupts. I would need to write general purpose handlers in the ASM code and I don’t think it’s a complication I need at the moment.

One other thing I added since I had board space was a 555 timer based power on reset circuit copied exactly from Jeff Tranter’s blog. He used it on an Apple Replica 1 which is another simple 6502 machine. This circuit works very well and removed the need to manually hit the reset button after turning the machine on (although you still need the manual reset when you do something silly in the code).

I did all this on a breadboard to start with to make sure it all worked.


Since it worked I made my usual strip board version with the bird nest wiring from hell.

IMG_3083_1 IMG_3084_1

The reason I can get away with such masses of wiring is Orwell isn’t running particularly fast, only at 1mHz so you don’t start having to worry about wire lengths. Given it works on a breadboard with wires all over the show I know it will work on strip board too. The advantage of all those loops is if you need to add wires or move things around you usually have enough length to do so. This became important after I made a slight cock up in making the board.

The two board are mounted on an aluminium chassis but back to back. To connect the two boards I am using ribbon cables. I spent a lot of time working out how to attach the connectors to the cables to make sure physically things would plug together. The IDC connectors I used are keyed so you need to get this right. In my mind the connectors on each board would have identical pin layouts. In my mind I was thinking there are two board, laid in line so the ribbon is a simple straight connection. So I built the daughter board like that, with the IDC pins the same as on the CPU board. Unfortunately I am running the boards back to back which means the pin connections on the cable are effectively reversed! So after building it I realised my mistake then had to reverse all the pin connections on the daughter board. Luckily that wasn’t difficult to do.

It’s a bit tricky to get your head around (well I found it so hence the cockup!) but the pictures will help.

IMG_3086_1 IMG_3090_1

IMG_3093_1 IMG_3095_1

I added mounting brackets to the existing aluminum base plate so all the hardware can be mounted in a chassis soon. One mount needs a slot cut in it to run the ribbons through. The whole thing is compact but with some cooling space and all the delicate birdsnest wires are protected.


I haven’t yet wired up the cables to connect the ports to appropriate D type connectors. I will use a DE9 for the serial output (male) and a DA15 for the joyport (male) and a DB25 for the general purpose IO port. These connectors will go on the back of the chassis. I am still thinking about the main box to put all this in. I am thinking steel with wooden ends (ok that’s a bit 70s rather than 80s) with the steel painted crackle black (inspired by my car instrument panel and the finish on Enigma machines).

Everything has been tested with jumpered wires though. The analogue inputs work great and the push button hack seems to work well too. It’s certainly all easily workable in BASIC too. With the IO port LEDs it easy to write little programs to read a pot and light up LEDs. Or to produce different sounds as you turn the pot. Or to plot points on the screen. I only have one pot so will get hold of a small joystick module or, even better, a proper 80s style stick of the kind that used to be used on radio control transmitters. These are really hard to find these days. Dick Smiths used to have them. That was in about 1983 though! Luckily my friend Mike has found one at his place.

Another small change was I made the default text size 40 characters rather than 80 as it looks a lot better on the small LCD screens. On a proper HD tellie 80 columns looks great but these small screens just don’t have the resolution.

I’ve basically spent most of a long weekend working on this and it’s been so much fun. I feel the same enthusiasm for this as I did when I got my first computer when I was 10. Only know I understand exactly how and why everything works. Even so just being able to twiddle a pot and push a button and have that light up LEDs or draw things on screen or make silly noises is a real thrill. Another small thing I did was measure the current consumption. Orwells seems to draw between 400mA to 450mA mainly depending on how many LEDs are on. They are very bright and thats with a 220R resistor in series with each. That small LCD screen is drawing 200mA (at 12 volts). I am not sure what I will do for Orwell. I think I will use a regulator and a bridge on the input so polarity isn’t an issue and it can be run off the same 12 volt supply as the screen. I have a small regulator board now but the heatsink is a little small so it gets quite hot.

Here is a small film showing it working.

As I mentioned Bletchley Park inspired me. I would very much like to create a simulator of the Turing Bombe machine on Orwell if possible. I still need to work out exactly how it works though! A first step however will be making an Enigma simulator as I need that to encode and decode messages. I think that will be a great little project to run on Orwell especially as the results can be checked independently online with other Enigma emulators that can be found.

io board cpu_board

These are just here so I have them somewhere safe!


Next Page »