The ‘Makr-B-Bot’ Part 2: Building the mechanics

After collecting the parts and studying the drawings and instructions of the Printrbot it’s time to  start building. Before I got started I realized two things are very important for a 3D-Printer: It must be rigid, and all angles must be exactly 90 degrees. For lengths up to 30 cm the makerbeam seems rigid enough, although in the end I found that if you lift the bottom frame at one end it still deforms slightly. By using only the pre-cut length pieces I made sure all angles 90 degrees and all guides are exactly parallel .
This is the basic frame. Although over time many things have adde and modified, this part has remained basically unchanged.
Fixing the vertical rods,both at the bottom and at the top.
Mounted the Y-Axis stepper motor on a piece of Aluminium L-profile. A frame made from 4 pieces of 100 mm  is used as the carrier. Four ball bearings on the side, four on the front to carry the Y-Axis sliders.
The Y-Axis slider is assembled from two rods and some 100, 50 and 40 mm makerbeams. Note that on the photo’s most parts are still assembled using Ty-Raps. Later on I replaced most of these with hose clamps, but during the build and test phase this is more flexible.
The print bed will be placed on a frame made from two rods and some 100mm makerbeam pieces. I mounted a piece of 40mm beam to the front of the steppermotor and two 10mm ball bearings to that. 

 The Z-Axis motor is placed in the corner, and fixed using one long hose-clamp.

Basic setup, with some electronics to test if all motors run and if it all moves as expected…


Advertisements

Commodore VIC-20


The famous VIC-20. Predecessor to the Commodore 64, introduced in 1980 and thus being the very first affordable (US$300,-) colour computer.  Almost three million units were sold at the time, so they are still not very rare.
The unit I got (for €40,-) is in pretty good condition. The case has some inevitable yellow marks, caused by the reaction of UV light with the flame-retardand in the plastic. Something that could be removed (just google for ‘RetrOBright’)  but I think I’ll just leave it like it is and not risk damaging the plastic.

The unit came without any cables, so the first step will be to find out how to connect the monitor. As always, this information is easy to be found. I found a complete overview on Retro Isle this time.
The video is on the 5-pin DIN plug, 2 = GND, 4= Video. 
Unfortunately it does not seem to work.

My small LCD monitor (that works fine with my TRS-80 and Acorn Electron) says ‘no signal’. When measuring the video signal on the outside and on the board itself using an oscilloscope it looks good. But even adjusting the output level to the max does not solve the issue.

Just to be sure there is something wrong with it I connected it to the flatscreen television in the living room, only to find that it actually does work….
Looking into this issue I found several references to the fact that the video signal of the VIC is really bad, which did not really matter in those days since the standard television and monitor was pretty tolerant, but is a problem for our modern, all digital, LCD screens.
On the ‘Denial WIKI’ there are a few suggestions on how to improve video output which might be worth trying.

Acorn Electron

For only €20,- I purchased an Acorn Electron in excellent condition. The Electron was developed around 1982 as a direct competitor to the the Sinclair Spectrum, and even though it had some drawbacks it was sold in such large quantities that it is not to rare today. No need to tell the history, since there is already an excellent article on The Register about that.
Although this machine was not really on  my wish-list it’s a pleasant surprise. First it’s very compact and well-built. The housing is made of solid plastic, which even after 30 years does not show any colouring or scratches.
The keyboard is pretty good, and although most keys have multiple functions they are not crammed with it like the Commodore 64 or Sinclair spectrum.
The inside looks equally good. Just four screws have to be taken out to reveal a very clean motherboard and separate power supply .

  
They were very serious about the shielding against electromagnetic radiation, as clearly visible on the keyboard side.  
The user guide is excellent. It starts (as many user guides from this era) with an explanation of what a computer is: 
“A computer is a general purpose electronic machine that can be instructed to do a great variety of things – play games, perform complex calculations, store and retrieve information, display graphs and so on.”
(You can read the whole guide on Acorn Electron World . )
What surprised me is the possibilities of the Basic interpreter. It actually has named functions and procedures, a ‘repeat..until’ loop, quite advanced graphic functions and a built-in assembler to write machine code. And this machine code is definitely worth checking out, because the Basic is not really fast…

Enabling Colour on the composite video output

After working with it for while having it connected to a LCD monitor I noticed that it did not display colour. Initially worried that maybe the video circuit was damaged, I soon found out that this is intentional. The standard composite video output is set to black and white, but there is a link on the board that can be made to enable the colour signal. 
It’s marked ‘LK4’, and I just soldered a link on it. After that the monitor shows colour as expected, but I do have the impression that the letters are less crisp (which was probably the reason for Acorn to have just black and white as a default)

Loading software

The machine came without a cassette recorder, but it should work with any standard audio recorder. Which in these days can be replaced by simple recording / replay software on a PC. I used Audacity to record a simple Basic program, and after fiddling a bit with the audio levels (for recording as well as playback) it worked fine.
Loading standard software appeared a bit harder. Almost all software published for the Electron is available online, usually in the ‘.UEF’ (‘Universal Emulator Format’) file format. A very simple Windows program named FreeUEF can be used to either replay it as audio or to convert it to a  .WAV file that can be replayed by other software. The last solution did not really work for me. Replaying the created .WAV files using Audacity always gave an error after reading the first block. All other blocks seem to load fine, but the program will not run on the Electron.


Finally I used an Android App on my tablet named ‘TapDancer‘. This works flawlessly and because it actually looks like a Commodore Datasette it adds a little extra to the retro-feeling…

And if you want to go a step further, there is the GoSDC  expansion module that lets you load programs from an SD card. But let’s face it: compared to loading programs using the tape interface it only saves you a minute during the loading itself. So unless you switch programs every 5 minutes I doubt if this is really worth it.

Go for C64 – Part II – The Arduino Leonardo solution

After trying to turn my C64  into a USB keyboard the whole project ended in a cupboard for a year at 90% completion. In the end the whole PICAXE – Arduino Pro Micro combination felt a bit clumsy.
Then I recently stumbled on a blogpost where someone connects a ZX81 keyboard to the Arduino Leonardo, and I found a cheap (€12,-) Leonardo-clone so I decided this was the way to go.

The board came with front headers, which makes connecting the keyboard super easy.

This is the C64 Keyboard matrix: ( diagram from the ‘WaitingForFriday‘ blog)

Corrected C64 Keyboard matrix and keyboard connector diagrams
It is connected to the Arduino as follows:

A – D0
B – D1
C – D2
D – D3
E – D4
F – D5
G – D6
H – D7
0 – D8
1 – D9
2 – D10
3 – D11
4 – A0
5 – A1
6 – A2
7 – A3

The code can be a mix of the code from ‘Biosrythm‘ and TechTonic . :

#include <Keyboard.h>

// ZX81 USB Keyboard for Leonardo
// (c) Dave Curran
// 2013-04-27

// Modified with Function keys by Tony Smith
// 2014-02-15
// Adapted for use with Commodore 64 Keyboard by Cees Meijer
// 2015-11-04
// Enable the debug mode (serial output) by keeping F7 pressed when 
// starting the program
// Special Commodore graphic characters are not implemented

#define NUM_ROWS 8
#define NUM_COLS 8

#define SHIFT_ROW 3
#define SHIFT_COL 1

#define RSHIFT_ROW 4
#define RSHIFT_COL 6

#define F7_ROW 7
#define F7_COL 7

#define DEBOUNCE_VALUE 100
#define REPEAT_DELAY 500

// Keymap for normal use

byte keyMap[NUM_ROWS][NUM_COLS] =
{
{'1', '3', '5', '7', '9', '+', '$', KEY_BACKSPACE},
{KEY_LEFT_ARROW, 'w', 'r', 'y', 'i', 'p', '*', KEY_RETURN},
{'~', 'a', 'd', 'g', 'j', 'l', ';', KEY_LEFT_ARROW},
{'~', 0 , 'x', 'v', 'n', ',', '/', KEY_UP_ARROW},
{' ', 'z', 'c', 'b', 'm', '.', 0 , KEY_F1},
{'~', 's', 'f', 'h', 'k',':', '=' , KEY_F3},
{'q', 'e', 't', 'u', 'o', '@', KEY_UP_ARROW, KEY_F5},
{'2', '4', '6', '8', '0', '-', '~', KEY_F7}
};

// Keymap if Shift is pressed

byte keyMapShifted[NUM_ROWS][NUM_COLS] =
{
{'!', '#', '%', '\'', ')', '+', '$', KEY_BACKSPACE},
{KEY_LEFT_ARROW, 'W', 'R', 'Y', 'I', 'P', '*', KEY_RETURN},
{'~', 'A', 'D', 'G', 'J', 'L', ']', KEY_RIGHT_ARROW},
{'~', 0 , 'X', 'V', 'N', '<', '?', KEY_DOWN_ARROW},
{' ', 'Z', 'C', 'B', 'M', '>', 0 ,KEY_F2},
{'~', 'S', 'F', 'H', 'K','[', '=', KEY_F4},
{'Q', 'E', 'T', 'U', 'O', '@', KEY_UP_ARROW, KEY_F6},
{'"', '$', '&', '(', '0', '-', '~', KEY_F8}
};
// Global Variables

int debounceCount[NUM_ROWS][NUM_COLS];
int altKeyFlag;
bool serial_output;

// Define the row and column pins

byte colPins[NUM_COLS] = {0,1,2 ,3 ,4 ,5 ,6 ,7}; // A,B,C,D,E,F,G,H
byte rowPins[NUM_ROWS] = {8,9,10,11,A0,A1,A2,A3};

// SETUP

void setup()
{
// Set all pins as inputs and activate pull-ups
serial_output = false;
for (byte c = 0 ; c < NUM_COLS ; c++)
{
pinMode(colPins[c], INPUT);
digitalWrite(colPins[c], HIGH);

// Clear debounce counts

for (byte r = 0 ; r < NUM_ROWS ; r++)
{
debounceCount[r][c] = 0;
}
}

// Set all pins as inputs

for (byte r = 0 ; r < NUM_ROWS ; r++)
{
pinMode(rowPins[r], INPUT);
}

// Function key is NOT pressed

altKeyFlag = ALT_KEY_OFF;
pinMode(rowPins[F7_ROW], OUTPUT);
if (digitalRead(colPins[F7_COL]) == LOW) serial_output = true;
// Initialise the keyboard
if (serial_output )
{
Serial.begin(9600);
}
else
{
Keyboard.begin();
}
}

// LOOP

void loop()
{
bool shifted = false;
bool r_shifted = false;
bool keyPressed = false;

// Check for the Shift key being pressed

pinMode(rowPins[SHIFT_ROW], OUTPUT);
if (digitalRead(colPins[SHIFT_COL]) == LOW) shifted = true;

pinMode(rowPins[RSHIFT_ROW], OUTPUT);
if (digitalRead(colPins[RSHIFT_COL]) == LOW) shifted = true;

pinMode(rowPins[SHIFT_ROW], INPUT);
pinMode(rowPins[RSHIFT_ROW], INPUT);

for (byte r = 0 ; r < NUM_ROWS ; r++)
{
// Run through the rows, turn them on

pinMode(rowPins[r], OUTPUT);
digitalWrite(rowPins[r], LOW);

for (byte c = 0 ; c < NUM_COLS ; c++)
{
if (digitalRead(colPins[c]) == LOW)
{
// Increase the debounce count

debounceCount[r][c]++;

// Has the switch been pressed continually for long enough?

int count = debounceCount[r][c];
if (count == DEBOUNCE_VALUE)
{
// First press

keyPressed = true;
pressKey(r, c, shifted);
}
else if (count > DEBOUNCE_VALUE)
{
// Check for repeats

count -= DEBOUNCE_VALUE;
if (count % REPEAT_DELAY == 0)
{
// Send repeat

keyPressed = true;
pressKey(r, c, shifted);
}
}
}
else
{
// Not pressed; reset debounce count

debounceCount[r][c] = 0;
}
}

// Turn the row back off

pinMode(rowPins[r], INPUT);
}
digitalWrite(rowPins[RSHIFT_ROW], LOW);
digitalWrite(rowPins[SHIFT_ROW], LOW);

}

void pressKey(byte r, byte c, bool shifted)
{
// Send the keypress
if (serial_output) 
    { 
    Serial.print("|");Serial.print("\r\n");Serial.print("|"); 
    Serial.print(r);Serial.print(",");Serial.print(c);Serial.print(":");
    }
byte key = shifted ? keyMapShifted[r][c] : keyMap[r][c];

if (serial_output)
{
if (key > 0){ Serial.write(key);}
}
else
{
if (key > 0 ) Keyboard.write(key);
}

}

The ‘Makr-B-Bot’ Part 1: Getting started

Go for….C64

My first computer was a TRS-80 Model I. I still have fond memories of this black and grey box with it’s black and white screen, 128×48 monochrome graphics, 12″ monitor and tape drive for data storage. Unfortunately we sold it when we got the twice as fast and portable Aster CT-80 (4 Mhz clock, two floppy drives!). Only for sentimental reasons I’d love to own one now., but  they are quite rare and therefore relatively expensive on eBay…
Anyway, I always kept a weak spot for these all-in one keyboard computers like the TSR-80, Atari 2600, VIC-20 and of course the Commodore C64. According to Wikipedia 12 to 17 million of these units were sold at the time making this a lot less rare.
 (An uncertainty of 5 Million ? That’s so weird there are even special pages dedicated to this mystery..)

Anyway, 12 million or more seems to be enough to saturate the demand even 30 years later and complete systems can be bought for 50 to 100 Euro’s. Actually I own a complete system myself. It’s a complete, working set including an original tape recorder and diskette drive. I might have to wipe the dust off and find a suitable TV-set to check if it’s still 100%. In the meantime I thought it was a nice idea to have just an empty C64 housing with keyboard and use that as a keyboard for my PC. Or maybe mount a Raspberry Pi inside to turn it into a working Linux computer. Or connect it to a tablet running a C64 emulator like C64.EMU .

[ As usual, I’m not the first to think about this and there is even a complete interface for sale: the Keyrah V2. Better (or worse..) there is even an Etsy shop that has Commodore and many other computers converted to USB keyboards. But that’s what I consider cheating. At least some hacking has to be done or it would be too easy ! My first thought was to use the Arduino Micro. While building my MAME cabinet I already discovered that this would have been the easiest way to implement a virtual USB keyboard.  On the biosrythm blog there is already a complete description on how to use Arduino to get the C64 keyboard to USB, but he is using the Duemilanove . ]

I picked up an empty C64 from ebay.de for €30 and bought a Arduino Pro Micro for only €7,- (who said hobbies have to be expensive?)

 The cable that sticks out on the right is the keyboard connector that used to be connected to the C64 motherboard.
First we obviously have to find out how the keyboard is actually wired. I found a neat diagram on the ‘WaitingForFriday‘ blog:

Corrected C64 Keyboard matrix and keyboard connector diagrams  
Great, but it presents and unexpected surprise: we will need 16 Input / Outputs for reading this matrix. And the Micro Pro only has 9 digital I/O pins. My first idea was to expand the number of I/O pins by using some shift registers but then I remembered I also had some PICAXE chips in my toolbox. The PICAXE is a standard PIC micro-controller, pre-programmed with a Basic interpreter which makes programming real simple.And the PICAXE 28X2 has 16 freely configurable I/O pins so that should work fine.
This chip even has all the I/O pins nicely laid out,making it easy to route the connector to the chip.
Some soldering will be necessary though to split out the connector in sections that will go to B0..B7

C0…C3 and C4…C7.

 Unfortunately this does not work. The PICAXE does not have any pull up or down resistors on its pins, so when no key is pressed they are all floating which results in random values.Adding a 10K pull up resistor to each input solves this problem immediately.
It’s still a lot of puzzling to detect the right keys, certainly in combination with the  left-shift, right-shift or Commodore key but you can find a complete working version of the PICAXE software at the end of this page.
But since the PICAXE lacks an USB output we still need the  Arduino Pro Micro to create a keyboard compatible output.
So the whole exercise has been a fun and useful learning experience, but in hindsight it would have been easier to use the Arduino Leonardo… After all, this is a Pro Micro, but with plenty I/O to implement everything on a single board.

 
'Commodore 64 Keyboard Decoder. Columns (A..H) connected to Port B. Rows (1..8) to port C
'Both ports have 10K Pull up resistor on each pin


main:
symbol ROWS = b1
symbol COLUMNS = b2
symbol ROW = b4
symbol COLUMN = b5
symbol KEY =b6
symbol CHECK_ROW = b11
symbol CHECK_COL = b12
symbol TEMP_SUB = b13
symbol TEMP_SUB1= b14
symbol SPECIAL_KEY_PRESSED = b15
symbol RIGHT_SHIFT = b16
symbol LEFT_SHIFT = b17
symbol CTRL =b18
symbol PREVIOUS_KEY =b19
symbol KEY_COUNT=b20
symbol KEY_DELAY = b21

PREVIOUS_KEY = 0
KEY_DELAY = 100
do ; Endless loop
let dirsC = %11111111 ' switch all pins to outputs
let dirsB = %00000000 ' switch all pins to inputs
let pinsC = %00000000 ' switch all outputs low
b1 = pinsB
let dirsC = %00000000 ' switch all pins to inputs
let dirsB = %11111111 ' switch all pins to outputs
let pinsB = %00000000 ' switch all outputs low
b2 = pinsC

b3 = NOT b1
ROWS = NOT b2
COLUMNS=b3

'sertxd("B1,B2: ",#b1," ",#b2,13,10)
'Check if Left Shift is pressed
CHECK_ROW = %00001000
CHECK_COL = %00000010
gosub CheckRowCol
LEFT_SHIFT = SPECIAL_KEY_PRESSED
'Check if Right Shift is pressed
CHECK_ROW = %00010000
CHECK_COL = %01000000
gosub CheckRowCol
RIGHT_SHIFT = SPECIAL_KEY_PRESSED
'Check if Right Shift is pressed
CHECK_ROW = %00000100
CHECK_COL = %00000001
gosub CheckRowCol
CTRL = SPECIAL_KEY_PRESSED


ROW = ncd ROWS
COLUMN = ncd COLUMNS
'sertxd("B1,B2,ROW,COL: ",#b1," ",#b2," ",#ROW," ",#COLUMN,13,10)
if ROW=0 or COLUMN=0 then goto reset_keycount
ROW = ROW-1
COLUMN = COLUMN -1
b0 = 8*COLUMN + ROW
if LEFT_SHIFT =1 OR RIGHT_SHIFT=1 then goto Shift_pressed

lookup b0,("1",8,"cr cq23wa~zse45rdxcft67ygvbhu89ijnmko0+pl,.:@-$*;/~=???",13,"?ffff"),KEY
goto Key_Pressed
Shift_pressed:
lookup b0,("!",8,"cr CQ",34,"#WA~ZSE$%RDXCFT&'YGVBHU()IJNMKO0+PL[@-$*]?~=???",13,"?ffff"),KEY
Key_Pressed:
'sertxd("KEY PRESSED!",#ROW," ",#COLUMN," ",#b0,":",b1,13,10)
if KEY = "~" then goto continue '~ marks an unprintable character (Only Shift is pressed)
if KEY = PREVIOUS_KEY AND KEY_COUNT < KEY_DELAY then goto count_keys
if KEY_COUNT <> KEY_DELAY then goto normal_delay
KEY_DELAY = 3
normal_delay:
KEY_COUNT =0
sertxd(KEY)
serout A.0,T9600_8,(KEY)
PREVIOUS_KEY = KEY
goto continue


count_keys:
KEY_COUNT = KEY_COUNT+1
goto continue
reset_keycount:
KEY_COUNT=0
KEY=0
PREVIOUS_KEY =0
KEY_DELAY = 30

continue:

loop ; next loop

CheckRowCol:
SPECIAL_KEY_PRESSED = 0
TEMP_SUB = ROWS and CHECK_ROW 'Check if a specific bit in ROWS is set
if TEMP_SUB = 0 then goto NotPressed
TEMP_SUB = COLUMNS and CHECK_COL 'Check if a specific bit in COLUMNS is set
if TEMP_SUB = 0 then goto NotPressed
TEMP_SUB = NOB ROWS 'Bit in ROWS and in COLUMNS found. Check how many bits in ROWS are set
if TEMP_SUB = 1 then goto no_bit_reset 'If it is just one bit, do not reset it
TEMP_SUB = NOT CHECK_ROW 'Invert all bits in the CHECK_ROW
ROWS = ROWS and TEMP_SUB 'AND it with the ROWS to reset the bit we just found
no_bit_reset:
TEMP_SUB = NOB b2
if TEMP_SUB = 1 then goto no_bit_reset_2
TEMP_SUB= NOT CHECK_COL
COLUMNS = COLUMNS and TEMP_SUB
no_bit_reset_2:
SPECIAL_KEY_PRESSED = 1
NotPressed:

return

My Claim to MAME. (Building MAME: Intro)

This is the first post to what hopefully is going to be a (small) series. For many years I always had in the back of my mind that one day I wanted to build a MAME cabinet. It started back in the days when this was a rarity and only a few people did such a silly thing. Building it was complicated and expensive. Nowadays it looks like there are thousands of middle-aged men around the world that  attempt to re-capture their youth this way, and parts, plans and building instructions are widely available. Hundreds of on-line shops sell every possible part you’d ever need and even complete cabinets. (just Google for ‘MAME Arcade Shop‘ and you ‘ll see what I mean)

But I want to keep the costs to a minimum by using parts I already have lying around.

The monitor

An old 15″LCD monitor that became surplus since everybody in my family now has it’s own laptop…
The computer
 Any old laptop, even with a broken screen, will do. I’ve some of these lying around at the office.Or I could even use my Raspberry Pi.

The cabinet

 Some leftover MDF board is still in my shed for years. Maybe it’s not enough for a full cabinet but it will get me started.
The controls
 I will need a joystick, some buttons, a ‘spinner’ (for playing Tempest) and a trackball. The trackball I already have. The joystick and buttons I had to buy, but they’re not overly expensive ( €35,- for a joystick and seven buttons). The spinner is a bit of an issue. It seems not to hard to make myself, and they are quite expensive to buy so that will be a project in itself.
The controller
 To connect all the controls to the PC you need some kind of interface. Again this can be bought, but I have a feeling this probably can be done with one of the USB powered micro controller boards I have lying around like the NetDuino, Arduino or Launchpad. Some leftover MDF board is still in my shed for years. Maybe it’s not enough for a full cabinet but it will get me started.
The controls
 I will need a joystick, some buttons, a ‘spinner’ (for playing Tempest) and a trackball. The trackball I already have. The joystick and buttons I had to buy, but they’re not overly expensive ( €35,- for a joystick and seven buttons). The spinner is a bit of an issue. It seems not to hard to make myself, and they are quite expensive to buy so that will be a project in itself.
The controller
 To connect all the controls to the PC you need some kind of interface. Again this can be bought, but I have a feeling this probably can be done with one of the USB powered micro controller boards I have lying around like the NetDuino, Arduino or Launchpad.

Fortunately there are ton of sites (mainly blogs like these) with examples and how-to’s. A few that I found very useful:
The Arcade Art Library – Where you can find all the graphics you need to create some good marquees and side art.
Project MAME– Some very good step by step instructions on how to build different types of cabinets. I did not use any of their design but there are some really useful hints and tips in there.
Build Your Own Arcade Controls (BYOAC) –  A general reference site with lots of info.
I Built An Arcade! – Great example of how to build a beautiful cabinet. Takes 13 months though…
How to build a bartop arcade – Another detailed how-to with some good ideas.
1UPArcade –  An amazing cabinet with a rotating control panel ! 

And finally:
What Is This Crap. – A showcase of how NOT to do it. (beware, contains strong language..)
The Games
By building a cabinet with a vertical monitor and just 4 buttons I have already limited the number of games that will be played on it. Which is fine with me since I prefer games from the seventies and eighties of which most were actually vertical platformers or shooters. Finding the games is easy, if you know where to look for. The best starting point I’ve found so far is the more than comprehensive MAME Database. This does not only list the games but has descriptions and screenshots. No downloads however since (as you may well know) games are usually still copyrighted and downloading ROMs is considered illegal. But once you know the name of the game you can just Google it to find the ROM. (don’t be surprise if you find some more ‘obscure’ sites with ads that are not directly suitable for kids…)

My Claim to MAME. (Building MAME: Intro)

This is the first post to what hopefully is going to be a (small) series. For many years I always had in the back of my mind that one day I wanted to build a MAME cabinet. It started back in the days when this was a rarity and only a few people did such a silly thing. Building it was complicated and expensive. Nowadays it looks like there are thousands of middle-aged men around the world that  attempt to re-capture their youth this way, and parts, plans and building instructions are widely available. Hundreds of on-line shops sell every possible part you’d ever need and even complete cabinets. (just Google for ‘MAME Arcade Shop‘ and you ‘ll see what I mean)

But I want to keep the costs to a minimum by using parts I already have lying around.

The monitor

An old 15″LCD monitor that became surplus since everybody in my family now has it’s own laptop…
The computer
 Any old laptop, even with a broken screen, will do. I’ve some of these lying around at the office.Or I could even use my Raspberry Pi.

The cabinet
 Some leftover MDF board is still in my shed for years. Maybe it’s not enough for a full cabinet but it will get me started.
The controls
 I will need a joystick, some buttons, a ‘spinner’ (for playing Tempest) and a trackball. The trackball I already have. The joystick and buttons I had to buy, but they’re not overly expensive ( €35,- for a joystick and seven buttons). The spinner is a bit of an issue. It seems not to hard to make myself, and they are quite expensive to buy so that will be a project in itself.
The controller
 To connect all the controls to the PC you need some kind of interface. Again this can be bought, but I have a feeling this probably can be done with one of the USB powered micro controller boards I have lying around like the NetDuino, Arduino or Launchpad.

Fortunately there are ton of sites (mainly blogs like these) with examples and how-to’s. A few that I found very useful:
The Arcade Art Library – Where you can find all the graphics you need to create some good marquees and side art.
Project MAME– Some very good step by step instructions on how to build different types of cabinets. I did not use any of their design but there are some really useful hints and tips in there.
Build Your Own Arcade Controls (BYOAC) –  A general reference site with lots of info.
I Built An Arcade! – Great example of how to build a beautiful cabinet. Takes 13 months though…
How to build a bartop arcade – Another detailed how-to with some good ideas.
1UPArcade –  An amazing cabinet with a rotating control panel !

And finally:
What Is This Crap. – A showcase of how NOT to do it. (beware, contains strong language..)

The Games
By building a cabinet with a vertical monitor and just 4 buttons I have already limited the number of games that will be played on it. Which is fine with me since I prefer games from the seventies and eighties of which most were actually vertical platformers or shooters. Finding the games is easy, if you know where to look for. The best starting point I’ve found so far is the more than comprehensive MAME Database. This does not only list the games but has descriptions and screenshots. No downloads however since (as you may well know) games are usually still copyrighted and downloading ROMs is considered illegal. But once you know the name of the game you can just Google it to find the ROM. (don’t be surprise if you find some more ‘obscure’ sites with ads that are not directly suitable for kids…)

Buiding the Box (Building MAME: The Cabinet.)

When looking at all available designs and previously built MAME cabinets you soon find out that there is not just one universal design. And actually if you take a closer look at all the original cabinets you’ll see they also differ a lot.

 I decided to take the ‘Defender’ design which is available as a Sketchup model. Imported it into the free ‘DesignSpark‘ solid modeller and just projected the side of the box  on the piece of MDF I had available. This also gave me the chance to make it less deep. Since my cabinet will be fitted with a slim LCD screen instead of a bulky monitor it can be a lot smaller than the original. From the model I created the following plan-view of the side:

From there its just a matter of transferring the design to the board and use a jigsaw to shape them.

It’s hard to saw straight lines using a jigsaw, so I first clamp on a piece of wood to align the saw. And when you just clamp two identical pieces of MDF together when you are sawing you get two perfectly identical sides.

Note that sawing two layers at the same time like this probably only works if you use 8 to 10 mm MDF. If you use it on thicker material it is very hard to keep the jigsaw exactly vertical and if it is slightly tilted your lower board will have a different size than the top one.

After I created the two sides I just estimated the optimum width by just holding the monitor next to one of the plates and finding good position. 50 cm seems like a good width so I just made the second MDF board exactly 50 cm wide. By doing this very carefully and making sure all corners of the board are now exactly 90 degrees it will be easy to create all front, top and rear surface plates.
And then we paint..and paint

and paint..and paint…

 Yes, two layers of MDF primer on each side is the minimum. Because MDF sucks… And that I mean literally. It just sucks up paint so for a good final finish you just have to primer it first.

Drilling the holes for the buttons. Using a 28 mm speed drill creates nice clean holes, but you must drill half way from one side, reverse the board and drill the rest from the other side.

Glue on the supporting blocks. I used a 20×20 wooden stick that I found in the shed. It’s painted wood so using wood glue is not optimal since that is supposed to be applied to unpainted surfaces. Using a Polyurethane based construction adhesive is better.
In the mean time I keep refining the 3D model. And it’s actually progressing faster than the real thing:

But after assembling the main parts it starts to look like real:

Next step would be to create the perspex cover for the control panel. I chose a standard 100×50 cm, 2mm thick perspex sheet which is available at almost every large hardware store. It was actually a coincidence that I chose 50 cm for the inner width of the cabinet but it’s very convenient now since the perspex only has to be cut to length. And cutting perspex appeared a lot harder than I expected. First I tried to saw it using a fine pitch wood-saw intended for cutting laminate flooring. That does not work. The cut is very irregular and pieces just tend to break off. Second I tried cutting it using a hobby knife. This might be possible but its very hard to get one straight cut. Even if you use a steel ruler as a guide the knife just runs off if you are not very careful. After creating the cut (it’s impossible to cut through the perspex) you can break it on the edge of a table. That does work but if the cut is pot too deep and not very straight you will get a very irregular edge with razor sharp points.
Finally used the blade  of a fine tooth hack-saw. That works better but it is essential that you carefully support both sides of the cut or the perspex will break.

Then the holes. This turned out to be even harder and it took me three attempts and a full panel of perspex before I finally had one that did not have cracks, or even completely destroyed edges. My tips for making holes:

Hole saw

– Use a vertical drill and push the drill very slowly. If you drill too fast the perspex will crack.
– Start every hole by drilling a small (3mm) hole in the centre. Then slowly increase the size of the drill but not more than 2 mm for every next step.
– Drill any hole larger than 10 mm using a hole-saw ! Trust me, any other drilling device (like a step-cone drill for example) will crack the perspex. This has one disadvantage. The arcade buttons require a 28 mm hole and this somehow seems to be a very uncommon size. So far I just found one set that has the 28 mm included.
– Support the perspex with wood and use a fresh piece for every hole so there is no hole in the wood under the perspex before you start the drilling.

CRACK !

 – Make sure you push down the perspex firmly and close to the drill. If you don’t, the perspex might just jump up and crack.
– Don’t drill too close to the edges. If there are holes near the edge of your control panel (like there are on mine) make the sheet larger, drill them first and then cut the sheet to size.
 

But finally with the inside painted deep-blue and the control panel covered with the perspex sheet it starts to look really good:

Creating the front bezel was actually very simple. First cut the perspex to size, place it in the cabinet and install the monitor so you can see were the screen is. Mark this on the perspex (I kept about 1 cm marging around the actual screen). Then (using a very sharp knife and a steel ruler) cut the protective foil and remove it on the edges. Then spray paint it a few times until the edges are really black. Make sure it really dry before removing the protective foil from the centre. And it looks really awesome when you look at it from the other side.

With the front-bezel installed, running LadyBug:

On the pedestal, with the top marquee installed:

It’s all about Control. (Building MAME: The Controller)

Using the Arduino as a MAME interface.

MAME software runs on a computer. And modern computers do not have any simple I/O pins any more .(remember the parallel port that used to be on every computer for connecting a printer ?) So to connect switches and joysticks you will need some kind of interface that translates switch actions to USB. Early MAME builders cracked open standard keyboards and hard wired their switches to the different keys. This worked, but was quite difficult. Especially low cost keyboards did not have easy to solder contacts or convenient connectors to hook up to. Nowadays the most common solution is a dedicated controller that has lots of easy connectible inputs and USB output that just pretends to be standard keyboard. Best known are the UltiMarc I-Pac , OptiPac or J-Pac. An even lower cost solution are the Xin-Mo controller boards (aroun US$25,-, including the wires).
But to keep the cost to a minimum I intend to use what I already have…

The cheapest solution would be to use my FunDuino UNO R2 board. ( A cheap Chinese Arduino clone that ships at US$13,- from DealExtreme)
It’s got 14 digital I/O pins so that should  be enough for an 8 way joystick + 7 buttons. (An 8 way joystick only has 4 switches). Since one of the buttons is just the ‘Start’ button so it will not need a fast response time I could also connect that to one of the analogue inputs and thus free 4 I/O pins for controlling additional stuff like lighting, sound or LEDs.
What I need is the Arduino to emulate a keyboard or to behave like a ‘HID’ (Human Interface Device). And if you know what to look for something like this is easy to find. Like on the blog of MitchTech. Now I did not immediately get the idea of this, until I realised that the Arduino board actually contains TWO different micro-controllers. One is the main controller (a ATmega328) that runs the Arduino ‘sketches’ and a second one (ATmega16u2) that just takes care of the USB communication from your PC to the main controller. And this communication controller is what we are re-programming to switch from a virtual COM port to a HID device.
First we will need a ‘DFU’ programmer. I use Windows, so I’ll use ‘FLIP‘ The procedure seems simple enough. Reset the Arduino, use FLIP to upload firmware. But I seem to have a problem with the reset. When I release the reset the board starts running the last sketch I’ve programmed it with, and it certainly does not show up as a new device. Which in turn is required so I can install the USB driver that FLIP needs. And of course I just overlooked something. When you have a non SMD Arduino board you should solder a resistor at the back. Yes, that is mentioned on the MitchTech page… (And it’s no longer required with the latest revision of the Arduino UNO)
I just assumed I had a SMD board since there are many SMD components on the top of the board. But it’s probably only so if the processor itself is a SMD version.
And indeed, when the resistor is mounted and we short circuit the two pins, left-top of the board, the unit shows up in the Windows device manager as a ‘DFU’ device. Left click on it, select ‘Update Driver’ and select the driver from the FLIP->usb directory. Then it shows up as an A90USB8. And when we unplug it and plug it back in it is again visible as the virtual serial port. 

Now we need to know what codes should be sent when a button is pressed. Which keys do we need to play MAME games ?
The full overview is on this page. And this is the selection of the ones I think I’ll need:

Key                  Function               HID Key  
5                    Insert coin            34
1, 2                 Start (players 1, 2)   30,31
Arrow keys (U,D,L,R) Move Joystick          82,81,80,79
Left Control         Button 1               Bit0
Left Alt             Button 2               Bit2
Space                Button 3               44
Left Shift           Button 4               Bit1
Z                    Button 5               29  
X                    Button 6               27
ESC (Escape)         Quits the game         41

(‘Bit0..Bit2’ marks a bit in the Modifier byte)

First I just used the MitchTech sample program. This just detects what pin is activated, sends a single key and then after 100 mS a ‘releasekey’ command. So if you press and hold a button you are sending 10 keydown / key-release commands per second. This works, but not very good. Most MAME games do not respond very well to a constant stream of key-presses. The movements often get a bit jerky, probably due to a regular key-buffer overload. Also it just sends one key at a time while the keyboard code does allow for multiple keys.
In my program I created a loop that checks every time which contacts are closed, find the keyboard code that has to be generated for that contact and add that to the keyboard message. Then only send the message itself when its different from the previous one. And when a key is released its code is forced to 0 so a key-release is only sent once. Also I use some analog inputs as extra inputs for buttons by just reading the voltage on that input. Note that these inputs are ‘floating’ so if they are left open the result may be unpredictable. You will need to add pull up or down resistors to the inputs.

So in the end the program looks a lot different but does exactly what I need:

MAME.ino (on my Google Drive)

Now what I love about software: you can re-configure the buttons and joystick at no cost after you wired them…

 I know most people use wires with crimp-on connectors for wiring their controls, but I just love soldering and for me this is much faster too. So I soldered all connections to the joystick and the plug on the FunDuino board. Here the buttons are not connected yet, but the black wire will serve as common ground for these.
Testing is a little hard since most normal software does not really show you if you pressed a Control or Shift key. But the ‘GhostKey’ program is an extremely simple way to test what code your keyboard is sending.
While testing this set-up with the actual buttons I noticed another problem. How do you insert a ‘coin’ to get the game started when you don’t have an actual coin-slot ?  

I decided to make the ‘Single player – start game’ button to double as a coin insert. That’s the benefit of having a programmable controller. Now it just checks the state of the ‘start game’ button and if it’s pressed for more than 2 seconds it sends key ‘5’ (Insert Coin) . But if you release it sooner it just sends ‘1’ (Single player start).

Wiring it was pretty easy. As shown on the right I screwed the Arduino to the bottom and glued a small breadboard next to it. This way it is fully reconfigurable and I can just add some pull-up resistors if needed. The only thing that worries me a bit is that the breadboard is upside-down and the wires could fall out, but that has not happened yet. And when everything works fine I can make a more permanent solution.

(Note: If you start out without a board and want to buy one it is probably better to choose the Arduino Micro since that has 20 I/O pins and  ‘mouse’ and ‘Keyboard’ commands built in) 

Ctrl Alt and….CRASH..
After a while I noticed that the system sometimes seems to crash while playing games that use both the A and B button. Some further investigation showed that it actually happened when pressing the buttons AND moving the joystick Left or Up. What actually happens is that you create the key combination Ctrl Shift and Left arrow, which is caught by the Intel graphics driver. So it just rotates the screen, or changes the resolution and (worse) throws you back to the main window. The solution was simple. Left click on the desktop, select ‘Graphic options’ and in the Intel graphics settings just disable hotkey support.