This project is inspired by the nostalgia for portable devices like USSR "Электроника МК-90" and Texas instruments TI-92.
A poket-to-laptop size microcomputer/programmable calculator, based on Terminal-BASIC
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
This project is inspired by the nostalgia for portable devices like USSR "Электроника МК-90" and Texas instruments TI-92.
Mockup3_Top_Cover.dxfCAD file for top cover cutting. Optimized for 1/8" end-mill.AutoCAD DXF - 289.02 kB - 12/04/2020 at 06:38 |
|
|
Mockup3_Screen_Cover.dxfCAD file for screen cover cutting. Optimized for 1/8" end-mill.AutoCAD DXF - 27.17 kB - 12/04/2020 at 06:38 |
|
|
Pin assignment.txtCurrent pin assignment for the device mockup.plain - 923.00 bytes - 03/07/2020 at 07:45 |
|
|
Pin assignment - keyboard.txtExternal electrical interfaces for hardware keyboard.plain - 347.00 bytes - 03/07/2020 at 07:45 |
|
|
RetroCalculator_Mockup2.pdfMost current schematics for mockup hardware. Includes SD card reader, 128x64 montchrome LCD and Micro Pro as a keyboard injector. Refer to pin assignment file.Adobe Portable Document Format - 48.81 kB - 03/07/2020 at 07:25 |
|
|
Last two weeks I spent on hardware development. According to the requirements, the calculator should be able to keep precise time in DS3231 Real-Time Clock (RTC) and wake up from deep sleep at the predefined moment. The final schematics looks as following:
The wake-up signal is taken from the DS3231 SQW pin and send into a NOT element of 4069. The DS3231 is obtained in form of ZS042 breakout board - it is easier than soldering a surface mounted chip with many pins. The modifications on the ZS042:
(1) Mandatory - cut the top right leg of 4.7k 4-resistor assembly 1 - without it, the DS3231 will be able to keep the line up if VCC is off. Note that pin 3 (INT/SQW) is simply a MOSFET to GND - essentially an equivalent of a momentary switch to ground.
(2) Mandatory - remove 200 Ohm resistor in the battery charging circuit. Because the board is powered by VCC=3.3V, it is useless anyway, but may be a battery hazard if using with 5V supply.
(3) Optional - remove 1k resistor in the power LED (this reduces power consumption from 1.9 to 0.3-0.5 mA).
The chip programming magic is done earlier by Mike Yakimov - the author of https://github.com/myak555/Not_So_Tiny_Not_So_Basic - and available at https://github.com/ptravnik/Retro_CALC/tree/master/MK2090_Peripheral_Controller
#include <Arduino.h>
#include <Wire.h>
#include "RTCData.hpp"
//I2C Slave Address
#define DS3231_SLAVE_ADDRESS 0x68
// Default control - battery oscillator ON and Alarm 1 DISABLED
#define DS3231_CONTROL_DEF 0x04
// Default control - battery oscillator ON and Alarm 1 ENABLED
#define DS3231_CONTROL_ALR 0x05
// Default status - all clear
#define DS3231_STATUS_DEF 0x00
class DS3231_Controller{
public:
bool firstRun = true;
uint8_t lastError = 0;
uint8_t wakeupStatus = 0;
void begin();
bool isRunning();
void setDateTime( DS3231_DateTime datetime);
DS3231_DateTime getDateTime();
DS3231_Temperature getTemperature();
void setWakeUp(DS3231_Alarm alr);
DS3231_Alarm getWakeUp();
private:
uint8_t _getRegister(uint8_t address, uint8_t n=1, uint8_t *data=NULL);
uint8_t _setRegister(uint8_t address, uint8_t n, uint8_t *data=NULL);
};
Now it was time to move to the power supply and the power management proper.
It has been discovered that none of the cheaper ESP32 boards have sleep power below 150 uA (see the excellent video with Andrew "Guy-With-The-Swiss-Accent" Spiess). The two boards I've tested personally - ESP Dev Module 1 and LoLin - both have the deep sleep power at about 3 mA (3.7 V connected to Raw).
Neither board has the battery discharge protection. The Lolin is capable of charging a LiPo cell, but the current for two 18650 seems insufficient. Neither board has the battery protection in case the voltage drops below 3.0V, so a separate battery main switch is needed. If you forgot to turn it off... well, the cells will be dead.
So came the proposed schematics.
The logic is as following:
If the Arduno program gets locked for some reason, the user can press reset button SW3 (or the optional external SW1). During the reset, the pin A2 momentarily goes low, which causes U3 to disconnect, - and the entire system is off.
If the system is powered via Arduino or ESP32 USB, the power board is protected by diode D4. Pressing the power switch has no effect - the system stays on. The system can be independently charged through 0362a. If the user pulls the USB plug off while the system is on, the power supply should pick up gracefully (not tested yet).
If the system is off, and DS3231 alarm goes off, the effect is the same as if the user presses the power button, only the signal is coming via diode D7 instead of D1. Note that the RT clock has its own small lithium cell.
If the system is on, and DS3231 alarm goes off, the system remains energized.
The power up and shutdown code is as following:
#include <Arduino.h>
class SelfShutdown{
public:
void init( uint8_t PortKey, uint8_t PortHold);
inline bool isPowerPressed(){ return digitalRead(_portKey) == HIGH;};
void shutdown();
private:
uint8_t...
Read more »
The final keyboard version has been completed. The only remaining task is to design and laser-cut the top cover.
Over 70 application functions have been implemented so far.
The full list is here.
For instance, if you want to compute an average, it is easier than on HP-35s!
Given: In the dance class of 10 students, the heights were measured at 147, 152, 165, 163, 168, 163, 175, 166, 170, and 167 cm.
Find: The mean height and its standard deviation in the class.
clear sum
, <Enter>
(a shortcut is <F1>
, <A>
, which displays clear
)sum 147
, <Enter>
sum 152
, <Enter>
<F1>
, <S>
After entering all 10 numbers, the display shows:
N____________________10
StDev________ 8.30261003
Mean______________163.6
Sum updated____________
>_
Answer: the average height of the class student is 164 cm (68% of samples are in the interval of 164±9 cm).
Given: In the dance class as above, assume normal distribution and fair representation of the school population.
Find: (1) Probability the next class participant is taller than 175 cm. (2) Interval of heights for 95% of the school population.
prob(175)
, <Enter>
1
, <Enter>
, <Arrow Down>
, <->
. The calculator displays: 8.48665622e-002.1
, <Enter>
, 0.95
, <->
, 2
, /
, probit
,<Enter>
.probit( 0.975)
, <Enter>
.Answer: (1) the probability to find a student taller than 175 cm is 8.5% . (2) In the school, 95% of the students are in the interval between 147.3 and 179.9 (or 163.6±16.3) cm in height.
In the calculator, variable names may start with a letter or an underscore (_
) and can further contain letters and numbers, such as: My_variable
, _my_other_variable
, _my_other_variable2
, Catch_22
.
As in the standard BASIC, the variable type is defined by name ending.
The_Ultimate_Answer = 42
.%
is a 64-bit sighed Integer: The_Ultimate_Answer% = 42
.$
is a string: The_Ultimate_Answer$ = "42"
.a!
designates a double-precision real. For the Calculator BASIC, these additional types are not yet implemented, and probably will not be - most of the time engineering calculations require double precision anyway.BASIC supports 4 variable arrangements:
pi = 3.1415926
.Fibonacci%[0] = 0 : Fibonacci%[1] = 1 : Fibonacci%[2] = 1
.ROT[0,0] = cos(a) : ROT[1,1] = cos(a) : ROT[1,0] = -sin(a) : ROT[0,1] = sin(a)
.The_Ultimate_Answer$ != "42"
evaluates to FALSE, The_Ultimate_Answer$[0]
evaluates to "4".The following variables are always available (in the final version will be more):
If the SD card is inserted, during a power-down all standard and user-defined variables are stored on the card in the file named /_RPN_SaveStatus.bin Upon the power-up, the calculator is automatically restored to the state just before the power-down. If the card is not present during power-down, all user-defined variables and other settings are lost. Upon the power-up, only the standard variables will be present and will be initialized with defaults.
This allows keeping separate working environments on different SD cards. Or, in some cases, it is important to have no stored environments on the calculator - for example, for math exams.
The current variable space is defined in Variables.hpp as VARIABLE_SPACE = 32000 bytes.
Variables are placed in the variable space as following:
Then:
Or:
Or:
Quick-and-dirty video for the current project status:
Finally the keyboard PCBs have arrived from China.
For the keyboard, it is the final design. The size is 60x100 mm, and the intended position is to the right from the screen:
(The screen itself is still in the mock up stage). The keyboard has 4 LEDs and 60 switches - the one on the bottom left is a hardware power switch. All LEDs and keys can be accessed independently - in theory all 59 switches can be closed at the same time and will register.
The keyboard driver board sits below. A header for Arduino Micro Pro is provided, in case the keyboard is used as a standalone unit for PC.
Currently the driver board and the keyboard are connected by a header; the production version will be soldered.
The RPN calc can now impersonate a keyboard and a 3-button mouse, injecting keystrokes into a PC. Mouse pointer movements and mouse wheel from the calculator to the PC are also supported. With a dumb terminal, the RPN understands both the RPN and an Algebraic inputs:
The documentation is started at the project Wiki: https://github.com/ptravnik/Retro_CALC/wiki
Next: programming a File Manager!
I have continued debugging the hardware mock-up. The fundamental target was to program a simple RPN calculator UI with 6 operations plus a number of scientific functions. The integration with BASIC will come later, after all the hardware components are finalized.
New Pro Micro clones with 3.3V processors have arrived, so the logic level conversion is no longer necessary. See the new wiring diagram in the file section.
Files are uploaded to https://github.com/ptravnik/Retro_CALC (its a proof-of-concept code, use with caution!)
Two problems have been hit so far. Firstly, the real-time clock of ESP32 is not very precise in the sleep mode; thus an external RT clock module is required in the future. Secondly, the sleep current of this particular Dev board is 15 mA, while in running (no WiFi) - 55 mA. Need to troubleshoot it a bit further.
Currently the mockup looks a bit neater and can run from standalone power. Can you take it to the math exam?
The current functionality fully operational and tested:
(1) Hardware keyboard (a mock-up so far), with CP1251 code page support;
(2) LCD power manager, with PWM control and sleep capability;
(3) LCD driver with fancy LCD font, resembling Electronika MK-90;
(4) Sleep mode and wake-up by a hardware button;
(5) RPN calculator UI.
The font looks like this:
Or in Russian:
The current functionality implemented, but not fully tested:
(6) Serial connectivity to Arduino Micro Pro;
(7) SD card reader.
The deferred / not yet implemented functionality:
(8) Beeper;
(9) LiPo charger / battery;
(10) Independent RT clock.
The hardware is running a simple RPN calculator interface. The operation is as following:
o The calculator can be operated by either the hardware keyboard or a serial port terminal.
o The display is composed of 2 parts: the upper depicts the RPN stack, the lower is for entering commands.
o Enter numbers as normal, e.g. 123, 123.456, 123.456e89, 123.456e-89 etc. "E7" or "e7" stand for "10 power 7". Buttons <DEL>, <Backspace>, <Home>, <End>, <Left>, and <Right> should work as expected.
o Besides the entry as above, the following is allowed: 123k, 123M, 123c, etc. The letter is an "engineering multiplier": f="e-15", p="e-12", n="e-9", u="e-6", m="e-3", c="e-2", d="e-1", k="e+3", M="e+6", G="e+9", T="e+12", and P="e+15".
o Upon entering a number, press <Enter>. If the number in the entry line is valid, it is processed into the X-register, if not - ignored. Upon entering the number in stack, all the values shift by one position. The current stack is 20 numbers.
o Alternatively, press an operation button <+>, <->, <*>, </>, <^>, or <+/->. If the number in the entry line is valid, it is processed into the X-register, if not - ignored. Upon this, an RPN operation on stack is performed. Division by 0 causes an error, which can be cleared by pressing <ESC>.
o The available math functions: sin, cos, tan,
sqrt - square root,
sq - square,
exp - e power x
sign,
inv - computes 1/x
hex - converts x to hexadecimal (rounds to integer first)
o Stack manipulation functions:
prev - previous X (shortcut: PGUP),
swap (shortcut: DOWN),
push, pop,
roll (shortcut: PGDN)
previous entry (shortcut: UP)
#scr status - updates status label
#scr labelx - updates label X
#scr labely - updates label Y
#scr labelz - updates label Z
o Screen power and brightness:
#scr off - puts screen to sleep
#scr on - wakes up screen
#scr+ - increase brightness
#scr- - decrease brightness
Can your next DIY programmable calculator do the same? :) This is Arduino DUE, hope ESP32 and even ESP8266 will be ready soon.
Finally got the working mockup running. Currently the hardware includes:
The LCD part can be easily removed from the primary board - it is held attached by a header.
Power consumption in this configuration:
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).
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:
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!
Create an account to leave a comment. Already have an account? Log In.
Very interesting!!
What about OUT PEEK POKE operators fot work with I|O ports of MCU ?
Thank you for your interest.
PEEK and POKE are in the development plan, but neither is implemented yet.
OUT - is it a dialect? As far as I/O ports go, everybody invent their own names - I am not aware of any standard so far. For the IO ports, there are commands/functions:
AREAD(port, range, low, high): Analogue read from port, calibrated between low and high as a real.
AREAD%(port): Analogue read from port as an integer (returns 0-4095 or 0-1023).
AWRITE, port, value: Send PWM to port.
DMODE port, value, pullup: Set port to digital read or write.
DNOTONE: Stops playing sound. Note the speaker is attached to Micro Pro and not to ESP-32, this is to reduce processor overhead and save pins.
DREAD(port): Digital read from port.
DTONE frequency, duration, wait: Play sound.
DWRITE port, value: Set port high/low. This is probably the analog for "OUT".
KBDLEDS <value> - sets the hardware keyboard LEDs: 0-15 - from all 4 LEDs blank to all 4 LEDS lit. If value >= 16 or negative, the LEDs indicate Shift, Lang, F1 and F2.
Note we also have three commands:
INJ - converts the content of RPN stack X into a number and "types" it to PC as if the calculator is a USB keyboard.
INJECT "<string>" - "types" the string to PC as if the calculator is a USB keyboard.
INJECTF <filename> - "types" the file content to PC as if the calculator is a USB keyboard.
Potentially there will be also a mouse manipulation function.
PEEK\POKE\OUT\IN - it's a zx-spectrum BASIC commands
PEEK \POKE read write of cell memory
IN\OUT - read \write port I\O
Of course, you can do any operator instead of these.
It also successfully implements command input, with the click of a button, you do not need to type each operator character by character.
This speeds up input by 10 times at least.
https://sun9-33.userapi.com/c855324/v855324776/24ae1a/lUW4dFRqk8E.jpg
The original ZX Spectrum keyboard has 10x4 grid of buttons. This could be easily implemented with the hardware keyboard by not soldering the top and the bottom rows.
IN and OUT instructions only make sense if the processor distinguishes between memory space and I / O space. That is true with the Z80 that has a MREQ signal to access memory and IOREQ signal to access I/Os because memory and I/Os addresses are overlapping. In the 80's many computers were based on Z80 or similar architecture so IN and OUT instructions were necessary. You find them on ZX80 or TRS80 and many others.
This BASIC is tailored for the Arduino DUE that is using an ARM processor that has only one address space so you can access any mem or I/O with PEEK and POKE.
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)
And so are the MK-61, B3-34, Texas Instruments and HP.
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
If you plan to work with source tree, you need to clone the repositories, mentioned in README from my bitbucket page:
https://bitbucket.org/terminalbasicteam/terminal-basic/
https://bitbucket.org/starling13/libarduinoext/
https://bitbucket.org/starling13/tvoutex/
https://bitbucket.org/starling13/libutft/
https://bitbucket.org/starling13/libsdcard/
https://bitbucket.org/starling13/libps2uart/
https://bitbucket.org/starling13/libps2/
Optionally, if you use Linux, you may clone
https://bitbucket.org/starling13/posixcpp/
https://bitbucket.org/starling13/libarduinoemulator/
and make Linux build for debug and test.
Become a member to follow this project and never miss any updates
I like it.