Close
0%
0%

Toy BASIC Computer

BASIC Programming Language on a PIC18F26K22

Similar projects worth following
Essentially a single-chip BASIC interpreter implementation w/RS-232 interface and 256KB of program storage. It's powered from a USB port, but the I/O interface is old-fashioned RS-232.

This project pretty much worked in reverse from how one would normally do a design. Normally, you'd select the processor (and other hardware) based on the required functionality. In this case, I had some spare processors and so defined the functionality to match the hardware limitations.

The schematic is quite simple & straightforward. Note that the PIC's PORT A is unused (shown connected to J4 in the schematic), so could be used for digital input or output if someone wanted to add appropriate statement code.

The PCB is laid out with ExpressPCB, using their MiniBoard service. I have Eagle, I could have used it & made the PCB smaller and cheaper to buy in small quantities, but I hate it so I only use it when I have to (i.e., someone is paying me to use it). It uses a mixture of surface mount and trough-hole parts. The ICs are all surface mount with the exception of the voltage regulator. That's mostly because I had some TO-92 regulators on hand, so it saved a few cents in parts cost.

The PDF file has the documentation for the project, including the details of the dialect of BASIC that it supports. Note that I did NOT use Tiny BASIC, which seems to be very popular for projects of this nature. It's a complete, from-scratch implementation designed to make maximum use of the limited RAM in the PIC processor.

Source code is in the ZIP file. It is licensed under GPLv3.0

Sample Programs.zip

Sample BASIC programs: BATNUM, CALENDAR, HAMMURABI, PRIMES, SLOTS, WUMPUS

x-zip-compressed - 7.69 kB - 06/03/2017 at 02:54

Download

gpl-3.0.txt

Software license

plain - 34.97 kB - 06/02/2017 at 20:06

Download

Toy BASIC.zip

Source code & MPLAB project files

x-zip-compressed - 319.07 kB - 06/02/2017 at 19:08

Download

Toy BASIC.hex

Firmware HEX file

hex - 80.46 kB - 06/02/2017 at 18:44

Download

TBasic.pcb

PC Board Layout (ExpressPCB file)

pcb - 20.62 kB - 06/02/2017 at 18:34

Download

View all 7 files

  • 1 × LP2950-3.3 3.3V Voltage regulator
  • 1 × PIC18F26K22 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × SST25PF020B Memory ICs / FLASH Memory
  • 1 × SP3232 Interface and IO ICs / Multiprotocol Transceivers
  • 1 × Micro USB connector

View all 14 components

  • Hardware Flow Control

    Steve Toner08/06/2019 at 19:11 0 comments

    Hooked one of these up to a Cadetwriter at VCF West and found out a couple of things:  (1) The Cadetwriter doesn't like to operate at 300 baud & (2) the hardware flow control I implemented is incomplete at best.

    I tried it at 300 baud initially because I knew the Cadetwriter only prints at 15cps.  I was not aware that it can run at high baud rates and has quite a bit of output buffering.  Well, it turns out that the processor they use in the Cadetwriter (Teensy 3.5), though it claims to operate at 300 baud, is actually off by something like 200% at that selected rate.  We switched to 9600 and it worked fine.  Except we had to disable hardware flow control on the Cadetwriter because it implements it properly and the Toy BASIC Computer doesn't.

    I had to think back about what I was trying to accomplish when I created this thing...

    Background: When I was developing this originally, I was using HyperTerminal on a laptop as the interface.  This let me write BASIC programs and save them on the hard drive of the laptop and then load them into the Toy BASIC Computer before the flash memory was implemented.  But the Toy BASIC Computer couldn't keep up with the input from the laptop.  This is the result of the compilation process that takes place when you hit Return after entering a line of code.  To save RAM (of which there is very little on the PIC processor) and improve runtime speed, keywords are converted to a byte code and stored in memory that way.  Anyway, this resulted in my having to implement some form of flow control on the inbound side.  I didn't bother with the outbound side.

    Of course, I had forgotten all this when I was configuring the Cadetwriter.  I remembered that I had implemented hardware flow control, so told it to use RTS/CTS flow control.  And it didn't work.  Until we disabled flow control, then everything was happy :)  Oh, and I also found out there are actually two kind of hardware flow control (apparently the standard was changed somewhere along the line), both of which the Cadetwriter implements.  RTS/CTS is the original, now obsolete standard while RTR/CTS is what is in use today.  So it's possible that if I had selected RTR/CTS instead of RTS/CTS when I configured the Cadetwriter it would have worked...

    "The nice thing about standards is that you have so many to choose from." - Andrew Tannenbaum



  • Demonstration Video

    Steve Toner06/21/2017 at 15:55 0 comments

    Here's a demonstration video :)

  • The Prototype

    Steve Toner06/20/2017 at 03:08 0 comments

    btw, here are photos of the prototype. It easily fits on a Busboard BR1. The only part that is not available as a thru-hole part is the flash memory chip, which needs an adapter. So if you want to build one but are put off by having to make a PCB for it, this is the simple solution (provided you can read a schematic and know how to solder).

    Wiring is done with wire-wrapping wire. I have some pre-cut lengths that I bought as a package around 1980 (!) - still haven't used them all up. But you can just get a spool and cut them to custom lengths...

    The two empty sockets are for testing the DAC as an audio output. It's easy to generate triangle waves. Passed through a low-pass filter, they don't sound horrible.

View all 3 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates