Close
0%
0%

Terminal-BASIC programmable calculator

A poket-to-laptop size microcomputer/programmable calculator, based on Arduino DUE and Terminal-BASIC

Similar projects worth following
This is an attempt of creating the autonomous pocket-to-laptop size device, based on Arduino-DUE and Terminal-BASIC interpreter, which can be used as BASIC programmable calculator or microcomputer. I/O devices include 480x320 TFT display and custom matrix keyboard.

This project is inspired by the nostalgia for portable devices like USSR "Электроника МК-90" and Texas instruments TI-92.

END USER REQUIREMENTS (An Ultimate Hacking Machine):

o Retro look and feel. PWR, HALT and STEP flappers, anyone?

o Low power consumption: able to function (on-and-off, calculator mode) for a couple of weeks from the set of batteries. In a continuous run, at least 20 hours of operation from the full charge.

o Rechargeable LiPo batteries as an option.

o Instant on (unlike most Raspberry Pi systems).

o Good reliable keyboard with positive tactile feedback (no membranes!)

o RPN in calculator mode, with lots of engineering functions available. The original MK-90 and MK-85 did not support RPN.

o Micro text editor, for taking meeting notes and such.

o Programmable in a flavor of BASIC (HP or B3-34 fake Assembly languages are too outdated). The programmed functions immediately available in the RPN mode, but should be stored on SD (unlike HP35s, battery removal is not the end of the world).

o Dual precision for floats.

o Can interface with a normal PC:

   a) by wired and/or Bluetooth serial port, e.g. like Terminal-BASIC,

   b) by SD card,

   c) by injecting keystrokes into the PC (for example via Arduino Micro),

   d) by impersonating a dumb terminal (for Linux systems).

Keyboard Sthematic.pdf

Hardware Keyboard. It interfaces via J1: 1 VDD (3 to 15 Volts are OK, the logic level will change correspondingly) 2 KBD RESET 3 KBD CLOCK 4 KBD READ 5 LED RESET 6 LED CLOCK 7 ARDUINO RESET 8 GROUND J2 is for connecting additional buttons or other devices: 1 VDD (pass-through from J1) 2-11 COLUMNS 0-9 12 ROW 7 13 ROW 8 14 GROUND

Adobe Portable Document Format - 148.43 kB - 10/11/2019 at 06:41

Preview
Download

  • 1 × <A href="http://www.sycelectronica.com.ar/semiconductores/CD4520.pdf">CD4520</A> Dual Binary Up Counters (CMOS)
  • 1 × <A href="https://www.jaycar.com.au/medias/sys_master/images/9229013286942/ZC4017-dataSheetMain.pdf">CD4017</A> Decimal Counter (CMOS)
  • 1 × <A href="https://www.jaycar.com.au/medias/sys_master/images/9305894125598/ZC4051-dataSheetMain.pdf">CD4051</A> 8 to 1 Mux-Demux (CMOS)
  • 4 × 3mm LEDs Any type/color
  • 4 × Resistors: 330R - 2.2k The actual value depends on the LEDs used. Limit each channel current to 2.5 mA or less.

View all 10 components

  • ESP32 Mockup Completed

    ptrav4 days ago 1 comment

    Finally got the working mockup running. Currently the hardware includes:

    • ESP32 dev module
    • Arduino Micro Pro
    • SD card reader
    • BW LCD with a software LED control
    • Hardware keyboard (a working mockup so far; the Chinese PCB manufacturer entered wrong delivery address, so the parcel is back to China)

    The LCD part can be easily removed from the primary board - it is held attached by a header.



    Power consumption in this configuration:

    • Input at 4.96V (WiFi, BT off in all tests)
    • The LCD screen LED is fully on (75 Ohm resistor) 103 mA
    • The LCD screen LED is fully off (but the LCD is running) 98 mA
    • The LCD screen is off (ESP32 and Micro Pro running) 94 mA
    • The LCD screen is off, Micro Pro off (ESP32 running) 82 mA
    • The total power is wherefore 500 mW, and two 5000 mAh batteries will last 2*5*3.7/0.5 = over 3 days of continuous operation.

    I have also compared this to the power consumption of Arduino Mega 2560 with a TFT 480x320 color screen and an SD card (see the video in the Project Log 01). Two different Mega we used: "Classic" and "OSEPP" (in brackets).

    • Input at 4.96 V (BASIC is running)
    • With TFT connected: 108 (118) mA, 550 mW - this is comparable to the BW LCD system, but no keyboard injection capability.
    • With TFT removed : 22(32) mA, 125 mW.

    I could not find an elegant way of disconnecting/managing the TFT power and the TFT backlight as it is mounted on a shield.

    Obviously, Mega with a BW LCD would make a decent calculator with about 30-50 mA consumption, which equates to one month of a continuous running! Unfortunately, this system has only 4-byte arithmetic, no real-time clock, no WiFi, etc.


    The calculator connects to the PC in three ways:

    • Via ESP32 USB - for programming ESP32 and direct operation of Terminal BASIC via VT100
    • Via Arduino Micro USB - for programming Arduino and impersonating a wired keyboard (still writing code for this - should be an INJECT keyword in BASIC)
    • Via BT or WIFI of ESP32 - have not tested software yet, but the hardware is OK - BASIC now has a SET WIFI_NAME, SET WIFI_PASSWORD, NETTIME() keywords, and so you can set time from the network or make a table clock in BASIC.

    The Terminal BASIC on ESP32 is working... kind of. I have replaced the capitalized keywords with a lower-case. 

    The SD card code is not compiling properly as the ESP32 and the Arduino libraries are different - still working on it. The hardware is fully operational, and I am able to run independent tests:

    The Terminal BASIC is seemingly having a hard time working with double-precision numbers on ESP32. This program calculates a factorial in integers:

    Now replacing r% with r - for 4-byte floats:

    Finally, we replace "r" with "r!" ("!" stands for long reals) results in busted stack!

    Next: debugging Terminal BASIC on ESP32!

  • Specific System Requiremens

    ptrav01/05/2020 at 06:42 0 comments

    Overall design notes.

    Hardware:

    The main processor is ESP32 WROOM 32U. For the final version can possibly source a board with an in-built LiPo charger, such as GeeekNet https://www.seeedstudio.com/GeeekNET-ESP32-Development-Board-p-2945.html For now, the testing board is more conventional DevKitC.

    ESP32 has been selected for two reasons. Firstly, it has excellent low-power features, allowing to save the battery. Secondly, the processor provides double-precision FP computations, which is essential for an engineering calculator. ESP32 can communicate to the PC via its USB port, WiFi and Bluetooth, so BASIC can be used from a PC terminal emulator - for, example, the user may want to enter and debug a complex routine by using the conventional keyboard and the big screen. The same USB port is connected to the LiPo charger / power supply (or will be using different ESP32 boards in the future - have not decided yet).

    The main processor is connected to 4 peripheral devices via its primary SPI bus: the SD card reader, the 128x64 LCD display (may consider a different display although), the keyboard and the power controller. The latter allows the ESP32 to manipulate the LCD back-light, thus reducing the power consumption. It also controls the power supplied to the Arduino Micro Pro. The keyboard provides a hardware Reset button, which is needed to load programs into the ESP32.
     
    The primary use of the Arduino Micro Pro is to impersonate a conventional keyboard/mouse for a PC (for example, for a text injection). The processor is connected to the ESP32 via Software Serial. Via the same interface, the ESP32 can send commands for a single-tone sound generation, such as beeps and simple melodies. As an alternative design, the LCD display back-light LED may be driven via the Arduino Micro Pro PWM output.

    Software:

    1. BCL interface. In true tradition of retro calculators, this should be a comprehensive BASIC-system. All file system manipulations and other functions should be accessible from the BASIC command line (BCL). For example, to change the calculator mode from Radians to Degrees, the user switches into the BCL and types something like SET ANMODE DEGREES. To change the calculator precision and output pattern to scientific with 4 decimal places, one types, for example, SET NUMODE SCI4  The arithmetic expressions can be evaluated directly from the BCL, for example, ? 1e13/SIN(45) immediately evaluates into 1.175e+13. PRINT HUMODE returns the numeric code for the SCI4 constant: 14 (or rather 1.4e+01 as we requested a scientific format). Naturally, all standard BASIC commands should work in BCL as expected, e.g. 10 PRINT 1e13/SIN(45) returns OK and inputs the program line into the memory. The user should be able to use arrows to scroll the screen up and down beyond the 8-line boundary. At least 40 lines should be supported. Text selection and Copy/Paste function should be supported.

    To make the system more practical, several additions to BCL are essential.

    2. RPN interface. The screen displays three positions of stack: X, Y, Z. The total stack capacity should be about 20, plus an additional slot for the previous X value. The buttons should work as expected for an RPN calculator, e.g. pressing <1>, <9>, <.>, <7> results in X displaying "19.7". Then, pressing <Enter>, <2>, results in X displaying "1.970e+01" (remember, we are in sci-4 mode) and Y displaying "2". Pressing </> results in X displaying "9.850e+00". The previous X slot contains 2.000e+00. The RPN interface should be accessible from the BASIC programs. For example, the user wants to implement a program for calculating roots of a quadratic equation:

    010 SET RPNLABELS "C (input)", "B (input)", "A (input)"
    020 HALT RPN
    030 A = RPNSTACK(2)
    040 B = RPNSTACK(1)
    050 C = RPNSTACK(0)
    060 D = B*B - 4*A*C
    070 SET RPNSTACK 2, D
    080 IF D < 0 GOTO 130
    090 SET RPNSTACK 0, -(B+SQRT(D))/A/2
    100 SET RPNSTACK 1, -(B-SQRT(D))/A/2
    110 SET RPNLABELS "Root 1", "Root 2", "Discriminant"
    ...
    Read more »

  • Hardware Mock-up Completed

    ptrav10/24/2019 at 03:45 0 comments

    Full hardware mock-up is now operational (yes, it is damn ugly).

    The current mock-up version is based upon:

    (1) Arduino MEGA 2560

    (2) Arduino MEGA SRAM shield (my PCB is modified for 56k RAM instead of 32 in the original version) https://hackaday.io/project/21561-arduino-mega-2560-32kb-ram-shield

    (3) Arduino SD card reader; this version is for Uno, but runs on Mega with pins 10-13 using Soft SPI (library mods by David Mellis). Note that the standard SD library will not work if the classic Uno shield is transplanted to MEGA:

    https://github.com/ptravnik/Retro_CALC/tree/master/SD2

    (4) Piezo speaker on line 9

    (5) Hardware keyboard on lines A0-A4. The driver is here (check the Morse code example!):

    https://github.com/ptravnik/Retro_CALC/tree/master/HWKbd

    (6) LCD screen 128x64 pixels on SPI. The driver is U8g2 from Oli Kraus (it writes Cyrillic and other character sets):

    https://github.com/ptravnik/Retro_CALC/tree/master/U8g2

    The keyboard PCBs have been ordered from https://www.elecrow.com/ Apparently they have been already manufactured and are in the mail. Hopefully I will have something less ugly in a couple of weeks. The order files are here:
    https://github.com/ptravnik/Retro_CALC/tree/master/HWKbd/KiCAD

    All hardware has been tested and fully operational. Now the next step: LCD terminal and RPN calculator part.

  • Hardware Keyboard: Working Prototype

    ptrav10/11/2019 at 06:31 1 comment

    I have completed the keyboard design. The current version has 60 buttons (one is hardwired to the controller Reset).

    The display so far is a Black-and-White 128x64 low-power Black-on-Blue LCD (Note that the original MK-90 has exactly that resolution, but the screen is much larger). This is a quick rendering for comparison:


    An alternative version would be with something like <A href="https://ru.aliexpress.com/item/32900230382.html?spm=a2g0o.productlist.0.0.74332b554sPNai&algo_pvid=9cab2e0a-fd50-41b0-bcb1-1507db69df45&algo_expid=9cab2e0a-fd50-41b0-bcb1-1507db69df45-16&btsid=be79cb74-3b32-40fb-b934-aadc62349cf5&ws_ab_test=searchweb0_0,searchweb201602_9,searchweb201603_55">LG320240</A>, but they are very costly. 

    The keyboard is assembled on a 140x95 mm mock-up board (the actual PCB size will be 100x70).  The electronics and the Arduino Mega driver are working, Now need to decide how to assign the letters...

    The schematics is attached in the PDF file.

    The keyboard will have 6 rows and 10 columns, 59 buttons in total (#60 is used for reset). It is operated via a 3-line interface not very dissimilar to SPI: setting RESET high brings the counters to the initial state, then CLOCK is cycled 59 times and SIGNAL reads the status of 59 buttons (HIGH means "pressed"). The CMOS 4017 decade counter addresses 10 rows and a combination of a 4520 binary counter and a 4051 analogue mux connects the rows. The clock signal is sent to the 4017. Upon reaching back to zero after 10 pulses, the ripple signal from the decimal counter advances the 4520 to the next row. Because only one button is connected between the mux and the decimal output at any given time, diodes at the buttons are not required. Any number of buttons can be pressed  simultaneously (the number of your fingers - and toes - is the technical limit) - they will all register .
     
    The second half of the 4520 octal counter drives 4 LEDs to show the keyboard status (or could be used from the Basic to do some creative blinking).  One button is hardwired to ESP32 reset.

    In the stand-by mode the keyboard consumes less than 10 uA (micro-amp).  Each LED consumes about 1200 uA if lit.

    Upon the PCB completion and testing I will put the KiCAD files on Github.

    The next big design question: "To brick or not to brick?"

    MK-90 is, well, a "brick". Another status symbol, MK-52, is a "wedge" (an so are B3-34!):

  • Thoughts on matrix keyboard

    Andrey Skvortsov05/06/2019 at 16:09 0 comments

    Here is a first variant of matrix keyboard. I choose 5x9 size as the smallest suitable to support full cyrillic charset and digits on separate keys (33+10).

    It will use 2 shift keys: the red shift and the blue shift, which state will be indicated by the 2 LEDs of corresponding colors.

  • Simple structure

    Andrey Skvortsov04/03/2019 at 11:41 0 comments

    First prototype will consists of minimal number of modules:

  • Firmware is almost done

    Andrey Skvortsov03/31/2019 at 23:59 0 comments

    The firmware is a Terminal-BASIC with UTFT output driver.

    Things to be done includes support for double precision floating point arithmetics (DUE has double reals unlike 8-bit AVRs). and driver for a matrix keyboard of 45 - 48 keys.

View all 7 project logs

Enjoy this project?

Share

Discussions

ptrav wrote 10/11/2019 at 07:22 point

The next big design question: "To brick or not to brick?".

The original MK-90 is a "brick". The original MK-85 is a "brick" (although a very slim one).

The original MK-52 is a "wedge" (picture in the gallery) MK-51

And so are the MK-61, B3-34, Texas Instruments and HP.

  Are you sure? yes | no

ptrav wrote 06/25/2019 at 03:06 point

Hi Andrey,

I am planning to build something similar to MK-90 with a steno capability for taking notes.

I tried to build your Terminal BASIC from the source, downloaded from the Sourceforge, the make_sketch.sh writes: "no directory libarduinoext". How to get these files?

Regards,

Pavel

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

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