This instructable will document and explain how to build a simple 8 bit basic computer system based upon an Arduino Mega and a simple cheap TFT display. I wanted to create an easy to build and cheap computer using only standard parts. What makes this 8 bit basic computer other than most of the currently available designs?
Let’s take a look at the specifications:
- 8 bit ATmega processor at 16 Mhz;
- 8 K internal ram (4 K basic, 1 K heap, 3 K system);
- 4K + 32 K Eeprom storage (9 banks);
- SD card load and save of program and data;
- Efficient use of sram space because program code is tokenized;
- Extended basic language with graphics support;
- 27 real number variables (doubles) and math functions;
- 27 dynamic stings and string functions;
- 4 types of dynamic arrays (double,word,byte and bit);
- 320 x 240 pixel display with 512 colors;
- Fixed (8 x12) font giving 40 characters a line by 20 lines;
- USB (PS2) keyboard supported;
- 32 free programable I/O pins (back row of the Arduino Mega);
- 3D printable case, STL files can be downloaded.
This instructable will show you how I build it, because it’s all standard components, you could design your own version, make the case out of wood, leave the SD out witch will give you 512 bytes of extra sram, add other devices using SPI or I2C, the design is very universal to use and extend. I wrote the basic interpreter myself after a look at Tinybasic (and was very disappointed) and I wrote a complete redesign with my own ideas and optimizations in it. You can download the full code at my website, if you got any remarks, improvements of suggestions I would be glad to hear them and improve the code.
Step 1: So What Components Do You Need?
- 1 Arduino Mega (I use a cheap clone);
- 1 2.2" SPI TFT display moduke 240 x 320 ILI9341;
- 2 SPI 5v to 3v3 level convertors;
- 1 AT24C256 Serial EEPROM Module;
- 1 Arduino Uno prototype board;
- 1 Female to female header cable;
- 1 Female USB connector;
- 1 Passive piezo buzzer;
- 2 4k7 resistors;
- 1 200 ohm resistor for the ld;
- 1 40 pin header connector male;
- 1 40 pin header connector female;
- Several colors of wire to connect te components on the prototype board;
I use a lot of cheap clones myself, if you want quality components and for
instance no driver problems with the Arduino board you can buy the original parts, The touch interface of these cheap TFT modules are so bad that I don't use it, so you can also order a even cheaper one without touch chip. I use 2 boards of 4 line level convertors, I believe there are also single board 8 lines convertors available. I use a standard (Arduno Uno, because of the size) prototype board because its easy to use, you can also use a normal PCB experiment board. The buzzer MUST be passive to use it as a speaker. I use female header connectors to place the level convertors and the eeprom module on the board, you do not have to do this, it would save space and money, but its not that easy to replace a part and easier to solder the wires on the board if no boards are in the way. .
Step 2: Putting It All Together.
Most of the times when I build a project I first build it on a breadboard to see if everything is working the way I was expecting. I did all the testing so you could skip this stage. I solder the pins of the eeprom module and the level convertors on the component side so I can place them upside down on the prototype board. You can place the components in any convenient order, the only thing that needs to be in a specific place is the USB connector if you want to use the original 3D printed housing
Step 3: The Whole Diagram
This diagram may seem a little confusing but it’s hard to make a diagram of all the connections between standard components. I will try to explain it, I did not draw all the power and ground lines, first I push the header pins on the Eeprom board, the converter boards and find a spot (in the center) on the prototype board that leaves space for the wiring. Then I find a good area to place the male headers for the connection of the wires to the display board. Then I solder them to the board and make all the power connections to keep things organized. I use black wire for the grounds, red for the 5V lines and orange for the 3V3 lines. On the convertor boards you only need to connect one of the ground lines, they are internally connected on the board.
In the top left you will see the USB connector for the keyboard. This is a a standard female USB connector, the outer pins are the power pins, the two other pins are the data+ and data- pins. I make use of the fact that a regular USB keyboard has a "fallback" mode to PS2 mode (a simple serial protocol) that can be easily interpreted by the Arduino processor. This "fallback" will occur when both data pins are connected to the plus 5 voltage trough a "pullup" resistor. This explains the two 4k7 pullup resistors. USB pin 2 is data and must be connected to pin 2 of the Arduino and USB pin 3 is the clock that must be connected to pin 3 of the Arduino. It is important that the keyboard CLK is on pin 3 because of the interrupt routine to read the keyboard codes
The Eeprom module on the left bottom is a standard I2C device and can be connected to A4 and A5 of the Arduino. On the Mega these are not the standard I2C pins, but I use a very simple software I2C with a very low memory footprint to use these pins.
The piezo buzzer must be a passive kind and can be connected between the ground and pin 8. The pin is software defined, you could use any other pin.
The connection of the display is a little more complicated as the display lines are all 3v3 (although the power of the display is 5V with an onboard power regulator) so we have to convert all the lines from 5v to 3v3 and backwards using small convertor boards, These boards have a Hv (High voltage) and a Lv (low voltage) side, the Hv side will be connected to the Arduino, the Lv side to the display. These convertors are bidirectional so they will work both ways. I use the SPI signals from the connector in the middle of the Arduino Mega, there is also an extra power and ground pin on this connector. Connect te Mosi, Miso and Clk pins to the convertors and connect the Lv side to both the display and the SD pins. The other lines like the chip select lines, the reset pins are connected to the Arduino Mega d5 to D10 pins to the Hv side and the Lv side to the display and SD card connector.
Once you have connected everything, test all the connections with a multimeter, I usually have at least one bad solder spot that looks like a good connection, but it isn't and you could be searching forever after you completely assembled everything. Also check for short circuit with the multimeter, before applying power to the boards.
Now it’s time to test everything and load the software.
Step 4: The Software
When I started this project I was planning to use a Arduino Nano and as much standard libraries as possible. I found out (as many times before) that the memory footprint of a lot of standard libraries is very high, they often have far more functions then I need and sometimes do not offer all the functions that I need. I wrote a lot of small libraries myself, for instance a simple I2C library that does not take up a lot of memory and only has a few functions. I also wrote the library for the display and the keyboard, to only have the functions that I need with a minimum memory footprint. The Arduino Nano was to limited so halfway the project I changed to the Arduino Mega with far more I/O pins and 8 K of ram. The only external library I now use is the SDcard library that is standard in the Arduino IDE package. If you unzip the files in a Arduino project directory, you should be able to compile it for an Arduino Mega board and upload it. I provide the complete sourcecode (please leave my name in) and you can modify or extend it to your need. The latest version (1.0.1) of the software package can be downloaded at my internet site: https://www.heinpragt.com/techniek/arduino/arduino_basic_computer.php in the download section. In the Arduino sketch folder there is also a (Word) document with the documentation of the basic language.
On my website you can also download a set of STL files for a 3D printer to print the case that I designed for my version. This case has the mount points for the display and has the connector at bottom of the Arduino Mega on the outside to connect external devices.
Simple example basic program
10 REM PROGRAM TO CONVERT FROM FAHRENHEIT TO CELSIUS
20 INPUT "Temperature in Fahrenheit";F
40 PRINT "Temperature in Celsius is : ";C
Step 5: Known Issues
- The TFT display does not support hardware scrolling in the horizontal position so I had to create a software scroll.Because of the small memory buffer the scrolling is rather slow. My advice is to use the screen area and avoid scrolling if possible.
- The case will schrink a little after a while making the part come apart too easy, I drill little holes in the case were the parts overlap and use very small screws (1 mm) to hold everthing close together.