Introduction: Handheld BASIC Computer

This Instructable describes my process of building a small handheld computer running BASIC. The computer is built around the ATmega 1284P AVR chip, which also inspired the silly name for the computer (HAL 1284).

This build is HEAVILY inspired by the amazing project found here and the SuperCON BASIC Badge.

The computer runs a modified version of TinyBasic, although much of the software is based on the project by dan14. You can of course follow this Instructable, or even better, improve on it since I made a few mistakes.

For this project, I also created a manual. It mentions some bugs and specifics for the chosen monitor but most importantly, it has the list of BASIC operations.

After this was published, I made a video showcasing the project.

Step 1: Parts I Used

For the main IC:

  • ATmega 1284P
  • 16MHz Crystal
  • 2x 22pf Ceramic Capacitor
  • 10KΩ Resistor (For reset pull up)
  • 4-pin button (For reset)
  • 470Ω Reistor (For composite video)
  • 1kΩ Resistor (For composite video sync)
  • 3-pin jumper (For video signal)
  • Passive Buzzer

For keybaord control:

  • ATmega 328P (Like the ones used in the Arduino Uno)
  • 16MHz Crystal
  • 2x 22pf Ceramic Capacitor
  • 12x 10KΩ Resistor (For reset pull up and buttons)
  • 51x 4-pin button (For the actual keyboard)

For power:

  • L7805 Voltage Regulator
  • 3mm LED
  • 220Ω Resistor (For LED)
  • 2x 0.1µF Electrolytic Capacitor
  • 0.22 µF Electrolytic Capacitor (You could substitute this 0.22 and one 0.1 for one 0.33. I've also been told that the values doesn't really matter, but I'm not great with capacitors)
  • 2x 2-pin jumper (For power input and for main switch)

GPIO (Maybe add a couple more grounds):

  • 7-pin Jumper
  • 2x 8-pin Jumper
  • 2-pin Jumper (For 5V and GND)
  • 3-4-pin Jumper (For Serial Communication)

Non-PCB:

  • 4" LCD Display with Composite Video (Mine had an input voltage between 7-30V)
  • 3D printed holder for display
  • Some sort of switch

Step 2: The Circuit

The circuit isn't very pretty and much of the main IC-region is inspired by dan14. That being said, it is a pretty straight forward Arduino on a Breadboard-circuit. The keyboard is a simple grid and is controlled by the ATmega328. The two AVR chips communicate via the UART Serial pins.

Both an image and my Eagle-files are attached and will hopefully be enough to recreate the circuit. If not, feel free to inform me and I'll update the Instructable.

Step 3: The PCB

The PCB is 2-layered and created using Auto Route (Oh, what an a**hole!). It has buttons and power indicator LED in the front and the rest on the back. I had my PCB made with JCL PCB, and they did an amazing job with it. The files needed to recreate the PCB should be in the Eagle-files from before.

I would suggest that you redesign the PCB, as I have some things I would like to have done differently. If you like my design, I still have (as of writing) four unused boards that I'm more than willing to sell.

The board has four drill holes that I have used for mounting the LCD Display.

Step 4: Uploading the Code

Both the 1284 and the 328 of course need code and the code I used can be found here: https://github.com/PlainOldAnders/HAL1284 under ArduinoSrc/src. I simply used the Arduino IDE for modifying and uploading the code but before that can be done, you'll need to burn bootloaders on the ICs:

ATMega328:

This one is easy, in the sense that there's a lot of support out there on how to burn a bootloader and upload code to this IC. I usually follow this guide, mostly because I keep forgetting the specifics.

The code for the 328 (under ArduinoSrc/keypad) is fairly simple. It totally relies on the Adafruit_Keypad-master-library. In case anything changes about the lib, I've included the version that I used on my github-page under ArduinoSrc/lib.

ATmega1284:

This was a bit difficult for me when I first got the IC. I started out by getting the bootloader from here, and followed the install-guide. To burn the bootloader, I simply did the same thing as with the 328 and got help from here. For both ICs I just used an Arduino Uno for both burning the bootloader and uploading the code (removed IC from Arduino Uno when uploading).

The code (under ArduinoSrc/HAL1284Basic) is much too complicated for me but I was able to modify some parts of the code:

I added a couple of commands (those marked with [A] in the manual.pdf), and I also changed other commands:

Tone: The tone command just used Arduino's tone-function before, but when using the TVout library, this caused the buzzer to not work properly. I changed it to use TVout's tone-function, but this means that the tone pin HAS to be pin 15 (for the atmega1284)

Serial Communication: Since the keyboard is DIY, it uses serial communication for reading the characters. Since the atmega1284 is used here, there are two available serial communication lines, and when "sercom" is enabled, the code also allows for writing via the serial port (from a computer or whatever).

Resolution: The monitor used for this project is pretty dumb, and a small resolution is needed, or else the picture flickers. If a better monitor is used, I would suggest that you change the resolution in the setup function.

Step 5: Assembly

With the code uploaded and the PCB and parts ready, it's now time for assembly. All the parts I used were through hole, so the soldering wasn't too difficult (as opposed to the badass-SMD-soldering-fellas out there). The monitor was fastened to the four drill holes in the PCB with a 3D printed holder. If another monitor is used, the four drill holes can hopefully be used for mounting this.

The monitor holder used here, is also designed to house a toggle switch (connected to the "switch" jumper on the PCB) and the three control buttons for the monitor. The holder is fastened with plastic M3 bolts and spacers.

For the power plug I used a JST PCB connector, although a slick barrel jack would've been a bit more smooth. To power the board, I switched between a 12V power supply or three 18650 batteries in series. A smoother cowboy than myself could probably design a slick battery holder for the board.

Step 6: Bugs and Future Work

Arrow Keys: The Arrow-keys were put accidently and don’t serve much function. This makes navigation difficult

File I/O: There exists File I/O capabilities but these are not implemented. To combat this, the HAL1284Com software is able to upload files to the board. It is also possible to upload to the EEPROM.

PEEK/POKE: PEEK and POKE are untested, and I’m not sure what the addresses are.

Break: Break (Esc) has sometimes been messing with the entire code, when in infinite loops.

Pin 7: The PWM pin 7 can be difficult when trying to DWRITE High or AWRITE 255. It works fine with AWRITE 254.

Idiot: It would be ideal to also be able to upload via UART1 but upload is only possible via UART0, so upload will have to be done by extracting the main IC. The Screen and Voltage Regulator 5 gets a bit too hot when running for a long time.