PC Interfacing a GameBoy Camera using PIC18F4620 microcontroller

PC Interfacing a GameBoy Camera

Here’s another past project of mine from a couple of years ago. At that time I was looking for a low-res camera for simple robotics image processing, and all I had experience with was PIC (12, 16, and 18) microcontrollers. So I didn’t really get to work on the images real time (not enough RAM or speed, and I could not find any suitable SRAM around at that time). I think I’ll revisit this project later on using my new TI Stellaris Board.
GameBoy Camera
The system consists of a GameBoy Camera (Mitsubishi M64282FP Image Sensor with hardware image processing), an ADC0820 high-speed ADC to convert analog pixel values to digital (the sensor outputs pixels as 2.0V p-p analog values), a LM385-2V5 2.5V micropower voltage reference IC, a PIC18F4660 for processing the digital values to send them later on to a PC via the serial port (or USB with a RS-232 – USB converter).The PC part of the project is a program (uses OpenGL to display the received image, the height of the pixels change according to brightness to have a fake 3D effect) written on Borland C++  Builder. I also still have the simple test programs written in Processing (brightness tracking, etc.). All will be attached.

Step 1

PC Interfacing a GameBoy Camera

Since the code and the schematics are self explanatory, and the datasheet for the MCU and the image sensor are rather informative, I’m not going to get into much theory here (as always, questions are answered). Here’s the flowchart of the system, which explains what’s going on.  Ignore the USART part (old version), registers are set up from the MCU 🙂 And an animated GIF image showing brightness tracking done with this camera in Processing.The first thing to do before you start is to create a suitable connector for the camera (after opening the cartridge structured box with a tri-wing screwdriver and disconnecting / removing the camera from the main structure). I attached a picture of the pinout, so many people used this image, so I don’t know who to give the credit (here’s one http://www.seattlerobotics.org/encoder/200205/gbcam.html). I used an IDC-10 connector to connect it to my old PIC board (from another project).In the next step we’ll be looking at the schematics and how the system actually functions.

Step 2

schematics and how the system actually functions

This is the card connected to my old PIC board. Since I had one laying around, I just made an expansion card to it for this project.
PORTC of the PIC is used for communicating with the camera, PORTD is dedicated to the 8-bit ADC output, and PORTB is used for the ADC’s CS and servos, which I didn’t really manage to control at that time (I tried observing pixel values on the fly, finding the brightest first pixel’s coordinates with a small formula, and adjusting the servo angles in accordance). Servos just went crazy, and I lost patience 😐

The LED’s are for displaying board power and frame capture. The schematics are a bit tangled since I didn’t care much about pin labeling then (to quickly create the PCB), so please have patience. I’m not going to attach the PIC board schematic and PCB files (but please pay attention to the pictures for pin orientation), since it’s basically a 40-pin PIC board with a crystal, and all the ports are connected to IDC-10 connectors.

The pinout of the M6428FN connector in the schematic is as follows, so you can make a simpler adapter / connector for the camera as you see in the picture:

1- GND

2- Vout to ADC (Image data in analog)

3- Bit-bang XCK for SIN, RESET, LOAD, and START (and 10 KHz PWM with 50% DC to get the pixel values), also triggers ADC
conversion for each pixel value (74HC14 inverts this signal for the ADC to start the conversion), after a successfull read, ADC sends and interrupt to the PIC, and the PIC sends the digital value to its USART, which finally goes to our PC.

4- LOAD signal to camera (Parameter Register Set Enable)

5- START signal to camera (Start Image Sensing)

6- VCC (all the analog and digital power)

7- SIN signal to write the regs on the camera (Parameter Data Input)

8- RESET signal to camera (Reset Parameter Registers)

9- READ (Image) signal from camera

10- GND

For more info on these pins, please refer to the image sensor datasheet attached on the next steps. You’ll understand the schematics better when you read the comments in the code files.

Step 3:

Step 3

Finally here’s a picture of the project in the prototype stage and its final look in a box with a USB 5-pin CP2102 module serial converter (good for getting rid of MAX232 interfaces needed for PC serial ports) and a crappy LED board for the unused port on the PIC card. The cam image was low quality due to breadboard noise, and when I moved the system to a PCB with huge ground planes, the quality went up to 6-bits from 4-bits. Attached are the Hitech PICC18 firmware, Borland VC++ code and executable (plus sample movie you can play by selecting the last frame as you open a movie on the executable, use the mouse buttons to zoom in and out, the rest should be easy to understand), schematics and PCB files in Proteus Isis / Ares, PCB in PSD format, Processing test codes, and the necessary datasheets. Here’s also a video of mine (720p) to show you the PC side of the project in action with one of my own tracks as background music. Happy soldering to all 🙂

Source: PC Interfacing a GameBoy Camera using PIC18F4620 microcontroller


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.