The Rockwell AIM 65 was one of the early 6502 based computers of the 70s. It had a 20 character display, a little thermo printer and a fairly big keyboard. Standard memory was 1k or 4k. More details can be found on the "old computers" page. A lot of software was available on ROM. I never had an AIM 65. They were popular a bit before my time actually. But I always liked the barebone look of it.
The design is ideal to rebuild with the standard Arduino components we have today.Prepare the prototype shield
Solder the PS2 keyboard socket on the outer side of the prototype shield. Then connect the wires. My layout is to use pin 2 of the Arduino for the PS2 clock and pin 3 for the PS2 data line. Pinouts and instruction can be found following this link https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html. My very messy experimental prototype looks like this
Please make sure that you get the pinout right. PS2 keyboard can be fried easily with the wrong polarity. Download the PS2 library.
Paul Stoffregen's PS2 library is supplied through the Arduino IDE for download. The latest version is 2.4. This library has a bug in handling keymaps with altgr keyboard maps like German. I fixed the bug in my fork if the library https://github.com/slviajero/PS2Keyboard. Paul has included the fix also in his source but the code from the Arduino IDE still may be the old one.Mount and connect the LCD display
Stefan's BASIC supports I2C and directly attached 20x4 LCD displays. For my first prototype I used a display with a parallel interface which leads to a lot of cables and breadboards. I2C is the better option. Still, the parallel display code is still in the interpreter as it is also used for LCD shields.
Connect the I2C and voltage wires to the Arduino. I used a small breadboard because I want to use the I2C interface not only for the display but also for the other sensors.
The upper two connectors are ground and 5V. This goes to the prototyping shield and the respective sockets. SDA and SCL are connected to PINs 20 and 21 of the Arduino MEGA.Put everything together and upload the software.
Put the prototype board on the Mega, plug in the PS2 keyboard and the USB cable. I mounted everything on a plywood board screwing the MEGA on its little plastic bed on the board.
Load the BASIC interpreter into the ARDUINO IDE. You need the sketch https://github.com/slviajero/tinybasic/tree/main/IoTBasic from my repo https://github.com/slviajero/tinybasic including hardware-arduino.h and basic.h. Make sure to load the PS2 library in the Arduino library manager. I recommend to use my patch from https://github.com/slviajero/PS2Keyboard. It adds a keyboard.peek() method which is needed for some features of the BASIC interpreter.
Set the following language settings at the beginning of IotBasic.ino the code. The control which language features are included.
#define BASICFULL #undef BASICINTEGER #undef BASICSIMPLE #undef BASICMINIMAL #undef BASICTINYWITHFLOAT
The MEGA has more than enough flash for the full BASIC language set.
In hardware-arduino.h there are the hardware settings. Set
#undef USESPICOSERIAL #define ARDUINOPS2 #define DISPLAYCANSCROLL #define ARDUINOLCDI2C #define ARDUINOEEPROM #define STANDALONE
We want a system with EEPROM support (ARDUINOEEPROM), PS2 keyboard support (ARDUINOPS2), an I2C display (ARDUINOLCDI2C) and full scroll support of the display (DISPLAYCANSCROLL). The last setting STANDALONE causes the BASIC interpreter to use the display and the keyboard as default input and output devices after startup.
Next set the PS2 pins. This is done a little further down. Set the values according to the hardware layout. Data pin can be any pin here. IRQ pin needs to be an IRQ ready pin of the MEGA.
#define PS2DATAPIN 3 #define PS2IRQPIN 2
If you want to use a different layout modify the code in this section. The code has a German keyboard hardwired as default. Search and change the line
keyboard.begin(PS2DataPin, PS2IRQpin, PS2Keymap_German) accordingly.
Upload your program.
Enjoy typing in your first BASIC commands. There is 6k of BASIC memory possible with an Arduino MEGA 256 with this language set. Enough for a few fun projects. Please read the wiki for details on this BASIC dialect including test and demo programs.
Look also into this tutorial for more info on BASIC on Arduino.Add a printer
There is a large number of small thermal printers on the market, all very similar to the one originally used in the AIM65. These printer have serial TTL and RS232 interfaces. They need a lot of power and cannot be attached to the Arduino 5V lines. An additional 9V power supply with at least 2A current is needed. Specs of these printers typically look like this https://github.com/slviajero/tinybasic/blob/main/misc/ThermalprinterSpecs.pdf. Identify the right pinout can be a bit of a hassle.
Connect the TX line of the printers serial port to the RX of Serial1 on the Arduino. This is pin 19. Connect RX of the printer to pin 18. Also connect the ground of the printer to ground on the Arduino. Power to the printer is connected to the external power supply via the separate power lines.
Recompile the BASIC interpreter adding the setting
in the hardware section of the code. This activates the Serial1 interface of the Arduino and assigns it the the BASIC device number &4. Standard baudrate is 9600 which is very common for these printers.
PRINT &4, "Hello World"
should work now. Single bytes can be sent to the printer using PUT
PUT &4, 10
The I/O channel works bidirectionally.
GET &4, A
collects a byte from the printer. This can be helpful as the printers have bidirectional communication protocols.Add SD card storage
In the BASIC interpreter, SD card support is activated when compiled with
Connect a small SD card interface
to the SPI port of the Arduino. For an ATMEGA 2560 MOSI is pin 51, MISO pin 50 and CLK pin 52. I use pin 53 - the default slave select of the SPI port - to activate the SD card reader. Add a small pre formated SD card with FAT12 filesystem and you are good to go.
This is how the entire system looks like now:
Note that after boot it reports only 4096 bytes of free BASIC memory. The buffers of the SD card interface use 900 bytes. This is not surprising as the block size of SD cards is 512 byte.
SAVE should work now once you insert a preformated SD card. Details on the file command can be found here SD card commands.
There is a number of clock modules on the market for Arduino projects. I have integrated the DS3231 library with EEPROM into the BASIC interpreter. The devices look like this
They can be cabled to the I2C port which is also used for the display. My prototype has the clock mounted directly behind the display
I don't use the standard RTC libraries from Adafruit as they bring a lot of functionality that the BASIC interpreter has anyway. Instead of the BASIC uses uRTCLib and uEEPROMLib. Both can be downloaded in the Arduino IDE or directly from the github repos below.
Compile the BASIC interpreter with
and load it into the Arduino.
A special array @T() is now available in BASIC: @T(0) - seconds, @T(1) - minutes, @T(2) - hours, @T(3) - day, @T(4) - months, @T(5) - year, @T(6) - weekday, @T(7) - temperature. Except temperature all array elements are read/write.
A little clock program using the array would look like this
10 CLS 20 PRINT @T(2);":";@T(1);":";@T(0) 30 PRINT @T(3);"/";@T(4);"/";@T(5) 40 PRINT "Temp:",@T(7)/100 50 DELAY 1000 60 GOTO 10
The 4k EEPROM module of the clock appears as an extension to the build in EEPROM. An Arduino MEGA256 should show 8k EEPROM space after startup. The first 4k is the build in EEPROM of the microcontroller and the second block is the clock's EEROM. The clock EEPROM is very slow as all access needs to go through the wire interface.More stuff to come
I integrated RF2401 radio and I am working on Ethernet for this system to make it a small base station for IoT.Libraries used
uRTClib from the Arduino IDECosts
This project is really low cost. The most expensive component is the MEGA 256 with 35 Euros. The display including I2C adapter is 10 Euros. SD card, SD interface and clock cost another 10 Euros. A PS2 keyboard can be bought at Ebay for 10 Euros. With 75 Euros all in all you have a working computer.Final words
Why a BASIC based Arduino homecomputer? Because it was fun to build it. And an interpreter language is many advantages. One can test circuitry and IoT with it without the need to reflash the Arduino for every change.
BASIC has grown much beyond the features described in this project. In the meantime it has Wire, many different displays, networking and can power bigger computers. I also ported most of the Arduino example library for it.
If you are interested in this, please follow any of these links
All the standard examples from the Arduino library are in my repo.