Projects‎ > ‎

Building a Portable Video Game Console

Some time ago, I've decided to build a portable video game console from scratch. I’m not an Electronic Engineer. I’m a computer guy, but I enjoy a lot playing with electronic projects in my spare time. So, it is important to keep in mind that I did this project just for fun and without any pretension of building a powerful video game console.


Given I don’t have much free time, this project took several months to be finished. In this article I present an overview of the project. You can find, at the end, the necessary documentation to build your own video game, if you wish. Feel free to send me your questions, comments, etc. (samir.araujo {at} gmail.com)

Ok, lets get to the point. I’ve started this project by building a macro architecture of the video game and then I’ve prototyped each element of that architecture, in order to reach the best (in my understanding) design.
Macro architecture

Figure 1 - Macro Architecture


The macro architecture is composed by the following modules:
  • CPU - (Micro controller) Parallax Propeller 32bits 80MHz
    • Memory - 32KB Ram
  • Video - 4 cogs of the CPU are dedicated to the video
    • 3.2” LCD 16bits Color B5-G6-R5 - with 16MBits VRam
  • Parallel2Serial - external 8bits input device port
    • It is possible to connect a joystick to that port
  • Clock - An Real Time Clock (RTC), given the micro controller doesn’t have an internal clock
  • Sound - 1 cog of the CPU is dedicated to the sound
  • Expansion Card - SD card Slot
  • Network - Bluetooth
  • Touchscreen - Resistive touchscreen

So, the CPU is a Micro controller Parallax Propeller. It has a 32bits CPU and runs at a speed of 80MHz (in this project). It has 8 cogs or 8 independent processing units. Each cog can handle 20MIPS (while running at 80MHz), which results in a power of 160MIPS, considering all the 8 cogs running in parallel.
Parallax Propeller Architecture

Figure 2 - Parallax Propeller Architecture


The video display is a general purpose 3.2” LCD module - 16bits color, with a built-in controller. The module also comes with a Memory Card (SD) slot, a Touch Screen mechanism and 16MBits of VRAM.

A parallel-serial shift register (74HC165) was used to configure an external input general purpose port. During the tests, an Atari joystick was attached to that port and used as an alternative controller.
The chosen uController doesn’t have much peripherals and it also lacks an RTC clock. That way, an additional DS1338 chip (RTC) was included in the project. A real time clock is important to do several tasks, like controlling the dates and times of each file, stored into the memory card.

Two pins of the uController were reserved for a stereo sound schema. None specific circuit or chip was used to build a sound module. It is a basically a software controlled sound mechanism. One cog of the uController executes a process which can generate several types of sound waves (Square, Sine, Triangle, Noise, etc.)

As mentioned before, the LCD module has a built-in SD card slot. The CPU controls its interface using the SPI protocol. That way, any SD card, formatted with FAT16 Filesystem can be used on the video game.

In order to allow the gamers having a multiplayer experience, a network device was added. A Bluetooth module can connect two or more devices and establish a serial link among them. So, multiplayer games can be developed, expanding the way of using the video game.

The main way of interacting with the video game is through the touchscreen interface. The LCD also comes with a built-in touchscreen mechanism. It provides a very straightforward way of interfacing with any CPU, based on hardware interruptions.

A circuit overview

Schematics areas

Figure 3 - Project Schematics and its main areas


  1. Reset Circuit - Responsible for synchronizing the reset time of each component
  2. Bluetooth module - Used for establishing serial communications between two or more devices
  3. Clock (RTC) circuit - A general purpose Real Time Clock
  4. Expansion input port - Offers a way of reading things from external devices (i.e. Joystick)
  5. EEPROM - A 32KBytes EEPROM for the firmware (24LC256)
  6. Programming interface - An interface to program and debug the firmware, besides writing the EEPROM
  7. Multiplexers - Set of electronics switches that selects, via software, which peripherals should be activated
  8. LCD Module and uController - The LCD connector interface and the Parallax Propeller
  9. Sound Circuit - A filter and a headphone jack, connected to 2 pins of the uController
  10. Battery + Switch key circuit - Powers the circuit


Accessing multiple peripherals with just a few pins

One of the more difficult problems was to interface a CPU with just 32 pins to 7 peripherals. 19 pins were dedicated exclusively, for performance reasons, to the video module. 16 for the colors and 3 for the controller interface. Another 2 pins were dedicated to the stereo sound interface. So, the remaining 11 pins had to interface the other 5 peripherals. There weren’t enough pins to create a dedicated interface with each of the peripherals. So, the solution was to use multiplexers.


Figure 4 - How PO3B20A is configured


Four Potato PO3B20A high bandwidth multiplexers of 4 independent 1x2 channels solved the problem. Figure 4 shows how the multiplexer is configured and how it switches the signals internally.


The reset circuit


Why it is necessary to have a reset circuit if the uController already has a builtin
PoR? Well, lets get back to the pins restriction subject. Each multiplexer requires that a signal is applied to its SEL pin in order to control its internal switches. There are not enough pins, in the uController, to do that. Besides, it is important to say that the uController uses 2 pins to read the firmware from the EEPROM while resetting. After that, the EEPROM is not used anymore.

Considering the above scenario, it was designed a reset circuit that, during the reset time, activates the EEPROM and after that switches to another device and keeps that way until another reset occurs.

 
Signal analysis

Figure 5 - Reset signals: green = uController reset signal; yellow = Multiplexer signal


That behavior was achieved by designing a temporal circuit that keeps a multiplexer (mux) switched to the EEPROM until the reset process of the CPU is not finished. The green line, in Figure 5, represents the signal applied to the uController reset pin. 1 makes the uController work properly and 0 resets it. The yellow line is the signal applied to the multiplexer selector pin. 1 enables the EEPROM and 0 enables a second multiplexer.

How the video game works

From a very basic programmer perspective the most important aspects of how to program the videogame are to know how to program to the Parallax Propeller and to know how to access each peripheral through the uController pins.
The first aspect can be solved by studying the uController documentation and by training a lot. So, lets check the second one.

Pins address configuration:
PIN Function PIN Function PIN Function PIN Function
0 LCD Bit 0 Blue 8 LCD Bit 3 Green 16 LCD CMD 24 Mux 3 Input 3
1 LCD Bit 1 Blue 9 LCD Bit 4 Green 17 LCD Write 25 Mux 3 Input 2
2 LCD Bit 2 Blue 10 LCD Bit 5 Green 18 LCD Reset 26 Mux 3 Input 1
3 LCD Bit 3 Blue 11 LCD Bit 0 Red 19 Audio Left 27 Mux 3 Input 0
4 LCD Bit 4 Blue 12 LCD Bit 1 Red 20 Audio Right 28 Mux 1 Input 3
5 LCD Bit 0 Green 13 LCD Bit 2 Red 21 Mux 4 Selector 29 Mux 1 Input 2
6 LCD Bit 1 Green 14 LCD Bit 3 Red 22 Mux 3 Selector 30 Mux 1 Input 1
7 LCD Bit 2 Green 15 LCD Bit 4 Red 23 Mux 2 Selector 31 Mux 1 Input 0


Where
LCD CMD: Changes the IO pins (color pins) behavior. When 0 the data will be interpreted as LCD controller commands. When 0 the data will be interpreted as pure data (colors, values, etc).
LCD Write: From low to high will be interpreted as a fire command and the IO pins will be accessed by the LCD controller
LCD Reset: Only used for Resetting

Mux 4 Selector: Switches between the Bluetooth module [0] and the RTC (Clock)[1]
Mux 3 Selector: Switches between the SD Card slot [0] and the Multiplexer 4[1]
Mux 2 Selector: Switches between the Touchscreen [0] and the External Input port[1]
→ Mux 1 Selector: Switched by the reset circuit; Switches between the EEPROM[0] and Multiplexer 3[1]. If you want to keep the Mux 1 switched to the EEPROM, you can use the Jumper 0.

Complete pin configuration to access each device


Bluetooth
uController PIN MUX 1 PIN MUX 3 PIN MUX 4 PIN Device
31 SEL=0 Y0 → 0|0 Y0 → 0|1 Y0 → 0|0 UART TX
30 SEL=0 Y1 → 1|0 Y1 → 1|1 Y1 → 1|0 UART RX
29 SEL=0 Y2 → 2|0 Y2 → 2|1 Y2 → 2|0 *MODE
22 - SEL=1 - -
21 - - SEL=0 -

* High = AT command mode; Low = normal transparent data mode


Real Time Clock
uController PIN MUX 1 PIN MUX 3 PIN MUX 4 PIN Device
31 SEL=0 Y0 → 0|0 Y0 → 0|1 Y0 → 0|1 SCL
30 SEL=0 Y1 → 1|0 Y1 → 1|1 Y1 → 1|1 SDA
29 SEL=0 Y2 → 2|0 Y2 → 2|1 Y2 → 2|1 Square Wave Out
22 - SEL=1 - -
21 - - SEL=1 -


SD Card Slot
uController PIN MUX 1 PIN MUX 3 PIN Device
31 SEL=0 Y0 → 0|0 Y0 → 0|0 Data out
30 SEL=0 Y1 → 1|0 Y1 → 1|0 Clock
29 SEL=0 Y2 → 2|0 Y2 → 2|0 Data in
28 SEL=0 Y2 → 2|0 Y2 → 3|0 Chip Select
22 - SEL=0 -
21 - - -


Touchscreen
uController PIN MUX 2 PIN Device
27 Y0 → 0|0 Clock
26 Y1 → 1|0 Data In
25 Y2 → 2|0 Data Out
24 Y3 → 3|0 Interruption
23 SEL=0 -


External Input port
uController PIN MUX 2 PIN Device
27 Y0 → 0|1 Clock
26 Y1 → 1|1 Clock Inhibitor
25 Y2 → 2|1 Data in
24 Y3 → 3|1 Load
23 SEL=1 -


Firmware

There is a driver for each peripheral. Third party code was used to compose some drivers, for instance the SD card. They were written in Assembly, for performance purposes. You can find at the Reference section (at the bottom of this article), a package which contains some drivers and demonstration programs.

The code you will find inside that package is experimental, as the project itself. You can hack it the way you wish. I'll try to improve the code and write new demos as soon as I have more free time.

Conclusions

This project was a very exciting and challenging experience for me. It allowed me to better understand several low level aspects of software development. Obviously it was very important to improve my hardware development skills. I enjoyed a lot working on this project and I hope you have enjoyed it too! :)

Some Videos and Photos

 

The making of portable video game console

 

Basic game demonstration

 

External device interface

 

Memory Card Demonstration

 

Hardware Overview

 

Bluetooth Demonstration


Real Time Clock (RTC) Demonstration




 

Audio Demonstration












The components Bottom View
Top View Prototyping

Creative Commons License
Portable Video Game Console by Samir Araujo is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

References

Project Schematics - Bitmap Format

List of components - Netlist

Datasheets:

Micro controller Parallax Propeller
LCD Touchscreen controller ADS7843
LCD Flash memory S71271
Real Time Clock DS1338Z
Potato Semiconductor Multiplexer PO3B20A
Parallel to Serial Shift Register 74HC165
Timer chip LM555
EEPROM 32KBytes 24LC256

Code:

Drivers and some demos (alpha)