JAMMA_AVR2 PCB project

Updated 30/8/24

Here's another retro computing project, with a bit of a twist. It's not a replica of a vintage computer, this one is based on modern hardware but contains all the elements of an early home computer: programmable in BASIC, RS232 connectivity, standard definition analog (greyscale) composite video or 16 colour RGB.

The system is AVR-ChipBasic2 which was developed by Joerg Wolfram between 2006 and 2015 to run on a single ATMega644 microcontroller IC with minimal, mostly passive supporting electronics (see link below). A tiny, standalone computer kit based upon the same firmware operating system and similar hardware was also produced as recently as 2023, known as the CB2 Micro by sv3ora (see link also below)

Both of the systems above feature analog RGB colour graphics using a SCART interface which was popular in Europe but seldom seen in Australia so it seems worthwhile to create a new PCB for the system with an alternate RGB interface. Although I have a couple of CRT TVs (and one LCD TV) which include a SCART input I mainly use these for consoles and for testing arcade PCBs on the test bench. It occurs to me that the AVR system would also work with an early RGB computer monitor (Commodore 1084 etc.) or even a standard resolution arcade monitor.

As I've already resolved to design a new PCB for the system, why not add a JAMMA standard edge connector to one side for power input, speaker out and RGB/Sync to connect to an arcade monitor or even run within a JAMMA wired arcade cabinet? I can also include provision to read some of the JAMMA control inputs via the system's parallel port so that games or other programs could use input from joystick and buttons.

So far so good, the only problem is I'm not up to speed with any current PCB design software and usually just build one-off projects on prototype board. This one requires connectors with special footprints as well as the JAMMA style edge connector so is not suited to stripboard construction. Apart from that, designing a PCB will allow multiple boards to be produced rather than just one prototype.

The circuit design is straight from the jcwolfram.de site (link below) so it is only the PCB layout which I'm designing myself. My thanks to Joerg Wolfram for the software design as well as hardware circuit examples. Beginning with the minimal circuit I have gradually found space on the PCB to accommodate many of the optional components and features shown in the examples on his 'hardware' page.

The PCB itself begins as a blank canvas, its dimensions determined by a 56 pin (2 x 28 way) JAMMA edge connector along one side which gives an overall length around 115mm. In the other direction I've set a nominal size of 99mm as I believe 100mm or more in either dimension may cause a jump in price with some PCB manufacturers. If I can fit the required components within that space there will be no need to go beyond that size anyway.

The recommended process for using the PCB design tools (I'm using EasyEDA in this instance) is to draw the circuit diagram, assigning component numbers and interconnections then transfer that to a PCB workspace using included (or created) PCB footprints for each device. Then the component footprints are arranged on the PCB workspace and interconnections routed automatically using a set of design rules for track width etc. That is usually followed by editing where required to address any routing problems or track interference issues.

I can see how this method, especially for complex circuits with many interconnections would make the process quicker and simpler but for such a small circuit with one main component and, being used to manually laying out circuits on prototype board (using graph paper!) it seems easier to place the component footprints onto the PCB workspace and route the connections manually. Next time I will try the other approach, with a larger circuit...

10/8/24

JAMMA_AVR2 PCB project

Designing a PCB for the AVR-ChipBasic2 circuit was a great learning experience. I made (and hopefully corrected) a number of beginner errors, since receiving the first batch of PCBs I've noticed a couple of incorrectly marked components on the silk screen layer but hopefully the connections will be correct and the boards useable without needing to go straight to Revision 2.

There are just a couple of minor alterations to the circuit to provide for JAMMA connection including red and yellow LEDs to indicate the presence of +5V and +12V power supply rails, the +12V if present powers an LM386 low power audio amplifier to provide a speaker output with trimpot for volume control. The 8 bit parallel I/O signals have also been routed to Player 1 control inputs on the JAMMA connector and provision added for a bank of pullup resistors to suit the normally open, common ground control panel switches.

The only surface mount component which I've added to the PCB is a micro USB socket so the board can be powered from a common USB phone supply when not connected to JAMMA wiring. As the PCB has not been tested I will populate the circuit in stages beginning with the minimal hardware to operate the ATmega644PA (or 1284P) microcontroller with 20MHz crystal, PS2 keyboard port, AV composite (grey scale) video and low level audio outputs.

JAMMA_AVR2 PCB project

I've provided a footprint for a 2 way DIP switch to select 50Hz / 60Hz video standard and combined or separate Horizontal / Vertical sync (combined sync is always used at present). Alternatively a 2x2 pin header can be fitted instead of the DIP switch and jumpers used to select 60Hz video or separate sync.

The other connection initially included is the 10 pin boxed header, SPI connection for programming the Microcontroller operating system. In this case I've found that my TL866 EPROM programmer can also handle the ATmega644PA (or 1284P) ICs so will preinstall the software before fitting the IC to its 40 pin socket on the PCB.

Having done that and powering on with a USB power supply I get - nothing. No sync on the composite input of my NEC TV monitor. As usual I have my oscilloscope handy and viewing the video output there is a signal with what look like sync pulses and even some video information but the frequencies seem completely wrong. Expecting horizontal sync to be around 15kHz, the signal I'm viewing looks more like just a few hundred Hertz.

JAMMA_AVR2 PCB project

After some reading I learn that the ATmega ICs are highly configurable with options for internal or external crystal oscillator and clock dividers, selected by some configuration bytes which must also be correctly set when programming. Another attempt, this time setting the recommended configuration into the config programming tab gives a result. Returning the micro controller IC to the PCB, powering on produces the startup dialog and pressing space bar takes us to the desktop screen.

Now we're getting somewhere! The system runs and responds to keyboard input although the 'Y' and 'Z' keys are reversed for the 'DE' keyboard layout (and some other differences) compared to 'US' which is also the standard keyboard layout for Australia. There is a binary program which will change the default layout from 'DE' to 'US' so this is the first issue which needs to be addressed by loading, then running the 'kbd_us.bin' program.

JAMMA_AVR2 PCB project

There are 8 slots for programs, either BASIC or binary and the only occupied slot, P5 contains the serial loader program which is used to load or save programs via RS232 to an external computer running terminal software. So the logical next step is to populate the part of this PCB which contains the components for the serial interface.

The RS232 standard which has its origins in the era of electro mechanical teletype machines, specifies a negative and positive Voltage for its 'mark' and 'space' ( 1 or 0 ) states. Although some more recent devices will accept 0 - 5V TTL levels a correct signal should have a range of -3V to +3V or more. To create a negative Voltage the AVR circuit includes a 'charge pump' using an oscillator output from the ATmega IC via 2 diodes and capacitors to create a negative supply of about -4 Volts.

JAMMA_AVR2 PCB project

In this photo I've added all of the components between the micro controller and DB9 serial interface connector. It's also necessary to select the 'config' page from the desktop screen, set Serial speed to 2400 Bps, Line end to CR+LF (for Windows systems), Serial In/Out to simple and Serial Input to PD1. The terminal software at the computer end should be set for 2400 Baud, 8 bits, no parity, 2 stop bits and no flow control.

JAMMA_AVR2 PCB project

Having made those settings and powering the PCB on the serial loader program attempts to connect to the terminal; it appears to be receiving keystrokes from the terminal (S to request status, Q to quit etc.) but the terminal does not seem to be receiving data from the AVR circuit. Checking the serial port Tx output with my oscilloscope I'm expecting to see a signal which ranges between positive and negative Voltages but the negative component does not appear to be present.

When I exit the serial loader program, pressing space then escape to return to the desktop screen the charge pump circuit appears to run correctly but when the serial loader program runs the oscillator output which is required to generate the negative Voltage is idle. It appears that may be a bug in this version of the operating system so I will try an alternate method of loading the program file from the desktop screen, selecting program slot P1 then CTRL and F3 to receive the program via the serial port.

JAMMA_AVR2 PCB project

That works fine and the SETKBD-US- program now occupies program space P1. Pressing F4 to run the program changes the default keyboard layout to US. The program only needs to be run a single time as the default layout has been updated so having done that the program can be removed by pressing CTRL and F4 to free up program slot P1 for another program.

To create a new program the editor can be opened by pressing F1 and BASIC commands typed in but for the moment I'll try loading one of the example programs from the AVR project page, saving the program as a text file then receiving that via the RS232 terminal by pressing CTRL and F3 within the program editor screen. The program loads, can be saved to the current slot by pressing F2 and run by pressing F4.

JAMMA_AVR2 PCB project

This program is 'Eatman', a pacman style game and a good example of the system capability as it uses the full program space, about 3k Bytes per program slot. It may be possible to accommodate larger, more complex programs by incorporating cross-program subroutines which are reportedly possible within the AVR-Chipbasic2 operating system.

With a small edit to the BASIC program it should be possible to adapt the game to accept input from JAMMA joystick and buttons rather than keyboard but first, let's add the few components to see the system in colour rather than shades of grey.

12/8/24

My PCB for the AVR-Chipbasic2 computer is working with no major issues so far. The system boots up, accepts input from keyboard, loads programs via its RS232 interface which run with grey scale graphics and sound. The next section of the PCB to assemble and test is the RGB 16 colour output. There aren't many components to add, just some resistors as RGB video is already present at the outputs of the micro controller IC.

JAMMA_AVR2 PCB project

In addition to the R, G, B and Sync contacts on the JAMMA edge connector I've placed a 6 pin header for RGB video to suit a 15kHz computer monitor or SCART TV. The main difference between the signals at those points is the sync. For a SCART TV there is no separate input for sync, it uses the composite video input as the sync source for an RGB signal so the sync level only needs to be about 0.3 Volts.

For the JAMMA interface an arcade monitor would normally be connected, just the combined Horizontal and Vertical sync pulses are used and a higher level is also ideal. In this case I have just taken the signal from U1 pin 19 but with hindsight, should have added some resistance between that point and the sync contact on the JAMMA connector. Although the direct connection would work it doesn't provide any protection for the Micro controller IC in the case of a short circuit on the video cabling etc.

JAMMA_AVR2 PCB project

So I'm adding a resistor between the IC and the JAMMA sync output, at least 470 Ohms should be OK but I will try 1k Ohm, hopefully the sync signal will still be sufficient for an arcade monitor. The resistor could be fitted to the solder side of the PCB but I've placed it on the component side to remind me, to incorporate that into any future revision of the PCB. I've also cut the original track on the solder side just before the sync contact on the JAMMA connector.

JAMMA_AVR2 PCB project

OK, having done that it's time to see the results. I'm using a cable connected to the 6 pin header initially with the RGB input of my NEC TV monitor, the next step will be to test the JAMMA connections. It looks great, the desktop screen springs to life with glorious, 4 bit colour.

JAMMA_AVR2 PCB project

With bright colours, the function key assignments along the bottom of the desktop screen stand out nicely. The 5 coloured labels represent Escape and F1 - F4 keys, holding the CTRL key provides a second set of functions for the keys. Adding labels to the keyboard with corresponding colours for the 5 softkeys would help to access the functions easily.

JAMMA_AVR2 PCB project

Above is the Eatman game, now showing in colour. There was an issue loading the game from the terminal via RS232 with some incorrect characters received. I think the ANSI formatting of the text file may have been the cause so need to resolve that, meanwhile I just edited the program to correct the errors and saved the changes.

Apart from the example programs on the jcwolfram.de site there are several games and programs available on the qrp.gr site (links for both below) Thanks to sv3ora for the software resources on that site including the original 'setfree' game below.

JAMMA_AVR2 PCB project

This one is a horizontal scrolling shooter with a Defender / Scramble vibe. The game is fairly minimal compared to arcade versions but another good example of the capabilities (and limitations) of the AVR ChipBasic system. Pretty impressive for a micro controller IC which was never intended to operate as a standalone system, running BASIC.

JAMMA_AVR2 PCB project

The next step will be to populate the PCBs parallel I/O section and test the JAMMA interface.

15/8/24

My first attempt at designing a PCB using EasyEDA, for the AVR Chipbasic2 Micro computer appears to be a success. The core system is up and running, all that remains is to populate the peripheral sections of the PCB and test the various ins and outs.

The parallel I/O uses a bank of 8 x 180 Ohm resistors for current limiting to protect the outputs of the ATmega IC and a DB25 socket connector which was the LPT standard printer interface prior to USB. I don't have a parallel printer to test it with at present but fitted the connector anyway, you never know...

JAMMA_AVR2 PCB project

My main reason for adding the resistors is to utilise the 8 bit parallel inputs to detect switch closures on the JAMMA interface for player controls. I've routed bits 7..0 to Player 1 coin, start, Joystick up, down, left, right, buttons 1 and 2. As an alternative to detecting a coin I've included a header so bit 7 can be connected to the 2 player start switch via a jumper link.

To turn a switch closure (to ground as per the JAMMA standard) into a logic level transition a pullup resistor is required for each bit. I've included the footprint for a 9 pin, 8 x 10k Ohm resistor network and routed the common pin to another header so the resistors can be configured either as pull ups or terminations to ground.

I chose quite a high resistance value so the pull up resistors would hopefully not interfere with the data if the parallel data bits are used as outputs. as an extra measure I'll fit a socket for the resistor network so it can be unplugged if required. The pins on the resistor network are flat and not very sturdy so instead of using a turned pin socket strip I'll use a dual wipe 18 pin IC socket which has been cut in half.

Connecting the PCB, this time to my JAMMA bench test lead rather than USB power supply and separate RGB cable, the board powers up as expected. Both +5 and +12V LEDs illuminate although the +12V supply is otherwise unused as yet. To test the JAMMA control inputs via parallel I/O I'll just write a minimal program, saving it to the empty position P3.

JAMMA_AVR2 PCB project

In this system DIR stands for DIRection and $00 sets all bits as inputs. the IN statement can read individual or grouped bits, $1FF selects the full byte. The program runs, just displaying the result on screen in a continuous loop, scrolling as each new result is added. Testing each input and combinations the result changes from 255 for all inputs open through to 0 for all closed.

Each input carries a binary value from 1 for bit 0 (P1 button 2) to 128 for bit 7 (Coin1 / 2P start) - all work as expected with no wires crossed. Pressing CTRL-C on the keyboard exits the program. At this stage that is enough just to confirm the inputs are working, later I'll attempt to adapt some of the example programs to use joystick / button inputs and eventually write some new programs which can be navigated using JAMMA controls rather than keyboard.

Next we'll move on to populate another section of the PCB, for the speaker output. This utilises an LM386 low power amplifier IC with minimal external components, a 10k trimpot for volume control and Electrolytic capacitors for +12V supply filtering and output coupling. In addition to the JAMMA connections I've included a 2 pin header for speaker output.

JAMMA_AVR2 PCB project

The circuit is straight from the LM386 datasheet, I've included footprints for additional components to increase the amplifier gain but in practice they are not required, the nominal gain of 20 for the basic circuit is ample. At normal level the sound is fine but turning the volume up there is a noticeable hum which doesn't appear to be coming from the power supply, more likely crosstalk from the video circuit.

I'll need to investigate that and see if I can find a way to reduce the hum on the speaker output but for the moment it is OK. I did attempt to avoid any ground loops on the PCB, using a separate ground path for the audio circuit. To see if it makes the symptom better or worse I try linking the audio and video ground tracks together but it makes no noticeable change so I'm fairly sure the hum is not a supply or grounding issue.

The only part of the circuit left to populate is the I2C bus connection and on board EEPROM positions so we'll add those now, finishing the build process. The ATmega644PA and 1284P have some internal EEPROM space where data such as high score tables can be saved but using their I2C bus external serial devices and EEPROMs can be accessed. I've used the circuit examples provided on the jcwolfram.de site to include positions for two serial EEPROMs on board.

JAMMA_AVR2 PCB project

The serial EEPROMs can be type 24C64 to 24C512 and I've initially fitted one 24C512, 64k Byte EEPROM to the position with address 0, the empty socket is address 1. The EEPROMs can contain data rather than program information and are accessed using the XPOKE and XPEEK statements. They could also be preprogrammed with data and, with relatively large amounts of storage I can imagine these containing large arrays and even pre-rendered bitmap data which can be transferred to screen within a simple program routine.

At this stage I'm not familiar enough with the specific version of BASIC used by the system to properly utilise the resources but some initial ideas include a program to generate simple test patterns on screen, using a menu selection controlled by joystick and buttons. Such a program could be set to autoload on startup, alleviating the need for a connected keyboard. Most of these useful patterns are simple combinations of geometric lines, shapes and colours which could be easily produced by a basic program or even loaded directly from EEPROM.

So with the assembly complete the PCB appears to be working correctly, the next stage is to learn the finer points of the AVR-Chipbasic2 programming language and write that test program, maybe some simple arcade style games.

30/8/24

I've assembled and tested my first PCB design which incorporates a JAMMA standard edge connector with the open source AVR Chipbasic2 computer (a link to the original project page for that system is included below). The system is up and running, basic checks of the input and output interfaces including the JAMMA standard video output and control inputs show all working as expected.

It's time to learn the specifics of the BASIC programming language included with the Chipbasic2 system, there is a complete BASIC reference as well several example programs contained within the linked pages below. To begin with I'll try a simple exercise to load some of the mini game example programs and edit the BASIC commands to replace keyboard control inputs with joystick and button controls via the JAMMA / Parallel input port.

That turns out to be pretty straightforward, replacing KEY( ) statements with IN( ) commands where appropriate so the next step is to attempt to create a new program from scratch. My initial thought was to write a test program to use in a JAMMA wired system which could generate RGB test patterns as well as check control inputs, speakers etc.

Test patterns are fairly straightforward being composed of geometric lines, shapes and colours and a simple menu system would allow the program to be controlled by joystick and buttons without the need for a connected keyboard. The system can be set to autorun one program on startup.

With each program space limited to 95 lines of BASIC code I thought the menu as well as the routines to draw the patterns wouldn't fit into a single program slot so I began writing two separate programs, one to draw the patterns and then effectively do a screen dump to the on board serial EEPROM and a second program to create a menu and then transfer the selected pattern from EEPROM to screen.

Although each BASIC program space is only about 3k Bytes one 8 pin serial EEPROM can contain up to 64k of data, ideal for complete graphic images. As it turned out with a bit of trimming the entire program could be squeezed into one slot anyway so the patterns can be selected from the menu and generated on the fly. There was just enough room at the end to add a simple button test which plays a unique tone for each of 8 control inputs.

I've included a link below to a video of the first version running on my test bench RGB monitor. I selected 60Hz as most standard definition arcade monitors run at that rate though my PAL TV/ monitor isn't exactly set up for that standard. The same program will also run at PAL / 50Hz frequency, with an increased border area.

Being written in Basic it's quite simple to add or change the program to suit a specific requirement. I'll attach a text copy of my Test Pattern Generator program here to show the very concise (and fairly easy to learn) version of BASIC employed by the system. There is also a version of the program which is operated by keyboard rather than JAMMA control inputs and should be useable with the original AVR Chipbasic2 and CB2 Micro systems.

tpg_jamma.txt JAMMA Test Pattern Generator v1 BASIC program listing

tpg_rgb.txt RGB Test Pattern Generator v1 BASIC program listing

JAMMA_AVR2 PCB specifications

Made 2024
CPU Microchip ATmega644PA or 1284P @ 20 MHz
RAM 4kByte (644PA), 16kByte (1284P) (expandable via parallel I/O)
FDD None
Ports JAMMA, Serial RS232, Parallel, I2C, SPI
O/S AVR-ChipBasic2 by jcwolfram.de
Display 16 colour, 30 x 23 characters displayed
Sound Mono (notes in 2 tones, noise)
Monitor Monochrome composite or RGBs, 15kHz
Keyboard PS2 standard keyboard port
Speakers Mono speaker out, max 1W approx @8 Ohms

Web Resources (External Links) -

AVR-ChipBasic2 - www.jcwolfram.de

CB2 micro - SV3ORA website cb2.qrp.gr

CB2 Microcomputer channel - YouTube

JAMMA Test Patterns using AVR Chipbasic2 OS - YouTube

Top of Page


All images and text on this website are Copyright.

Contact: jbtech at telstra dot com

Home