Using the GameBoy Camera module

 

The GameBoy shown with a Camera Module.    The Camera can be found quite cheaply on eBay or even at a boot sale.

 This Camera Module was sold by Nintendo around 1992, it can produce mono images at 128 x 128 resolution and it has recently been adopted by robotic enthusiasts as a means of providing cheap robot vision.

 Only the top part of the Camera Module is required, this contains a Mitsubishi M64282FP image sensor (data sheet available on the web). 

 The normal Interak screen resolution is 80 characters by 24 lines (as used for CP/M).
But the Interak can make use of programmable graphics because the top half of the character generator data is held in RAM. (The lower half is held in EPROM) This allows any image to be built in a matrix of 8 x 10 pixel dots.

Therefore to obtain an image resolution of 80 x 48 a number of programmable graphics are used to give an actual 3840 pixels, with each pixel composed of 8 x 5 dots. This means that only 48 lines of the 128 x 128 image sensor pixels are read into RAM (6K) – the rest are ignored. Then when the data is shifted to screen memory only 80 bytes of each line are read - the last 48 bytes are skipped. The area of 80 x 48 used, out of the total of 128 x 128, is about 23% of the captured image.

The number of programmable graphics required depends on the number of shades of gray chosen. The number rises exponentially as the square of the number of shades required - i.e. 4 programmable graphics would be required to produce an image of black and white only - Black/Black, Black/White, White/Black and White/White. But to produce an image having 5 shades of gray 25 graphics are required - this is the number I have chosen for now. This will produce a very low-res image but is sufficient for some programs.


This is the "eye" part of the GameBoy camera connected to the computer interface. There are 9 wires which have to be disconnected from a small connector and then joined to a suitable cable such as a ribbon cable. The signals are  +5V, Start, Sin, Load, Reset, CLK, Read, Vout, and Gnd.

Initially I started to make up an interface circuit using only TTL IC’s, this would be possible but I found that the circuit was becoming large and untidy.

 The basic requirements are :

1. A serial output port to send data to the camera registers.
2. An output port to send control signals to the camera.
3. An input port to receive camera signals.
4. An A to D converter to read the analogue voltage signals from the camera and send as 8-bit data to the Interak.

As the PIC 16F887 has an A to D converter and several ports it seemed simpler to use this IC. In addition it meant that the PIC could control the camera while the Interak was processing the data into a grayscale image.

A number of processes have to be carried out to obtain an image from the Image Sensor.

First the sensor registers have to be set from data held in software to define the image properties.
The computer then sends a Start signal to the PIC (STCAM) this signal is a very brief pulse from the Interak which was not always picked up by the PIC. I have added a pulse stretcher (IC3 - 555) to correct this. The PIC sends Start to the CAM synchronized with the clock and also switches on the 'Image Sensing' LED - the sensor will start to scan the view it has at the next rising edge of the Clock.
While image sensing is in progress the Read signal will be set low.

When sensing is complete READ will be set high. This is the signal to start reading the image data which is produced as 16K analogue voltages. They are sent on the Vout pin in a voltage range which has been set previously in one of the image sensor registers. (e.g. 0-2V) This is synchronized with the Clock signal.
Each analogue voltage (Vout) determines the value of each pixel as a different shade of gray.
These voltages are converted to digital values before being sent to the computer.

The image sensor will continue to acquire images (2nd frame, 3rd frame etc.) if left, but the current software will capture one frame then reset and repeat. This keeps the computer in control.
As each converted analogue voltage is sent the PIC will send an Interrupt signal to the Interak. The computer responds by reading the data at the input port and storing it. Then an RETI instruction (return from interrupt) will return the program to a HALT instruction where it will wait for the next interrupt.
There is no need for an acknowledge signal from the Interak as the PIC is slow by comparison. I have kept the PIC slow by using an external 4MHz crystal (pins 13 & 14). This gives an internal clock of 1MHz.
The 16F887 also has a programmable internal oscillator which can provide a range of clock frequencies.

The above description is one way of achieving a graphic image from the GameBoy camera. This may not be the most efficient in terms of chip-count or software but it does work. The current software will take a picture approximately once a second. This allows time to view the image and then (by pressing a key) save it if required.


Images displayed    80 x 48   x 5 shades of gray
 ---------------------------------------------------------------


   Here is a photo taken of the Interak monitor display.
   It shows the computer keyboard as seen by the GameBoy image sensor.

   click picture to view large image.

 


  This image is a screen dump of a hand
  which shows the individual pixels more clearly.

  click picture to view large image.


 

The following is documented software and hardware information

  CP/M Z80 assembler listing.     PIC16F887 PicBasicPro listing     Schematic

Back to Home Page