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.

IMG_3153_1

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:

IMG_3158_1

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

IMG_3161_1

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).

IMG_3156_1

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.

IMG_3152_1

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.

IMG_3076_1

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.

IMG_3096_1

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!

 


The 5 stages – a guide for testers to the stages an engineer goes through when you tell them you’ve found a bug.

October 29th, 2014

I didn’t write the following. It came a QA manager of mine, John Crook, some years ago when I first started out as a tester. I went on to be a developer for some time before returning back to my tester roots so I know these words to be the truth…

The 5 stages – a guide for testers to the stages an engineer goes through when you tell them you’ve found a bug.

1 – Astonishment

Typical reactions that identify an engineer being in this stage are phrases like “but that code is bullet proof” or “that can’t have happened because that code hasn’t changed for months”. During this stage the idea that there may actually be a problem starts to slowly sink in, this can take from seconds to days depending on the engineer’s ego. If the engineer lingers in this stage you can help guide them through more quickly by suggesting that if there is a bug it’s almost definitely someone else’s fault.

2 – Accusation/Anger

When moving to this stage the engineer is beginning to believe that maybe there is a product defect at issue here. However, if there is, it is almost certainly someone else’s fault. Typical phrases to look out for are “well, if that’s happening you better go an see so-and-so about it because he’s probably doing such-and-such wrong” or “that’s not how it’s supposed to be used – it wouldn’t crash if your tests were better”. You should seize this as an opportunity. Agree vigorously with the engineer that it’s surely someone else’s fault. Carefully worded agreement at this stage can propel the engineer into the final stage. However in many cases there are still two more stages to pass through before analysis is done.

3 – Assumption

During this stage an engineer will assume they know exactly what the problem is and exactly which line of code needs changing to fix the problem. This can sometimes happen before you’ve even finished explaining what the problem is. Phrases to look out for are “yes, we know about that, we discovered the problem ourselves and fixed it this morning” or “yes, it’s a C++ compiler issue and I need to change my code to work around Microsoft’s problem, come back in 5 minutes and I’ll have a new DLL for you”. It can be tricky to deflect engineers from this path once they have it in their head they “know” what the problem is. If you’re quick off the mark you can try pointing out how their assumption does not fit the facts however this can have varying degrees of success. Often there is no option but to redo your tests with the new DLL and go back to the engineer when the product defect still shows up.

4 – Acceptance

During this stage a few neurons finally connect and fire. The engineer realises that he will have to look seriously at the problem. This is good but you’re still not quite out of the woods yet. Watch out for delaying tactics like “OK, maybe this needs looking at but I’m working on this new work which is far more important, I’ll try to look at it later in the week”.When this happens it can often help to praise the engineer in some way – make out that they are so brilliant they could probably fix the thing in 5 minutes and that would help the product immensely.

5 – Analysis

Finally they will look at the log files and data you have collected and do some analysis of the facts.


A model railway dining table – Part 11.

August 24th, 2014

The table is finally nearly finished. Joss came up with some screws for the corners, the sides and the castors. I added two counter sunk screws to each corner from underneath.

IMG_2508_1

For the sides I worked out a nice pattern using magnets to see what different spacings would look like. In the end I just went for an even spacing down both sides. The screws are zinc plated domed slotted screws. I removed the zinc by sticking the heads in hydrochloric acid until the bubbling stopped.

IMG_2510_1

The strap around the edges was taped then marked, punched and drilled. You need three bits for this. A pilot bit, one sized for the screw threads then another sized for the shank of the screw. To get the depth of the shank drilling I wrapped tape around the bit at the right level. Drill down to the tape and the hole will be the correct depth.

IMG_2511_1 IMG_2513_1 IMG_2512_1

One annoying thing about my drill is that it has a ‘handy’ LED light in it that is totally useless. It’s positioned so that the chuck shadows the light completely and no light goes on the actual bit itself. Pointless really.

You can see above the plastic sheet on the floor in preparation for the next step – oiling!

I took the top outside and left the rest indoors. I used boiled linseed oil thinned 50/50 with turps for the first coats. The oil is put onto a rag then the rag rubbed over the wood. The wood soaks up the oil and leaves a nice, warm finish. It takes many coats. Thinning it makes it easier for the first coats to penetrate the timber.  Joss told me the rule in theory is one coat an hour for a day, one coat a day for a week, one coat a week for a month, one coat a month for a year then once a year after that.

In practice I just did a  bunch of coats. So far I have used about 3/4 of my 50/50 bottle. Once that’s gone I will start in unthinned oil. I started with the bottom of the top and the underside of the table and the legs. I turned it upside down to make that easier.

IMG_2514_1 IMG_2517_1 IMG_2515_1

Then, after I had a bunch of coats on that I turned the table over and bought the top in and started doing the top of the top. Mike was off to the demolition yard for some things so I made use of his trailer too and got a sheet of 10mm ply to make a temporary top.  There is no point getting the glass until there is something to see under it. I cut the ply to size using my jigsaw. The opening in the top is square. Unfortunately my sawing isn’t so the gap around my temporary top isn’t quite even but it’s good enough.

IMG_2518_1

I then had to come in (damn that getting dark thing in winter) although I kept putting on coats throughout the evening. So you could say I was on the turps all night! One thing people had warned me about was the linseed soaked rags spontaneously igniting. I didn’t see that as a warning so much as a challenge! So I stuffed the soaked rag into a tin and put that in my fireplace hoping for some ignition action overnight but nothing happened.

IMG_2519_1

Still it does actually occur apparently so you do have to be careful with the rags.

This morning I got a brass finger pull thing from Joss so I added that to the temporary top board. It goes through the board so I added a block underneath as well as some foam strips to raise the board to the level of the rest of the top. The pull just means you can easily lift the temporary top off.

IMG_2524_1 IMG_2526_1

Because everything is now oiled it’s slippery. To locate the top I was thinking of strips in slots or dowel pins but I didn’t like any of those ideas since removing the top might result in chipping of the top or the base where the strips or pins touch the wood. Instead I got some of the left over sticky anti slip matting I had (and used previously when planning the top) and cut that into strips and that is now preventing the top sliding. It is working well so far. Of course the table being on wheels means if you push the top the whole things moves. I need to get some wheel cups for it then see how secure the top is.

IMG_2520_1 IMG_2522_1

Today I added the screws to hold the castor cups in place and kept oiling. The legs have come up really dark and the top and sides not so dark but overall the effect is good. The oil really brings out the warmth in the timber and it will  be a nice waterproof and hardwearing surface. All it needs is some oil wiped on it now and again. I will keep adding coats but I am already noticing that the oil isn’t soaking in as much now.

And finally I have useable table!

IMG_2527_1

I think I might try eating dinner at it tonight.

 

 


Next Page »