Elektronika MK-52 Vintage Soviet Calculator

General Industry News and Posts about Devices that Don't fit in the Other Catagories
Post Reply
admin
Site Admin
Posts: 146
Joined: 26 Dec 2023 13:05

Elektronika MK-52 Vintage Soviet Calculator

Post by admin »

Originally Posted by Administrator on Thu Feb 06 2020 20:55:13 GMT-0500 (Eastern Standard Time)

In this thread, I will post some tips, tricks and code for the Elektronika MK-52 Vintage Soviet/Russian Calculator.

Rendering of Elektronika MK 52
Rendering of Elektronika MK 52
Elektronika MK-52.jpg (137.37 KiB) Viewed 16379 times
Rendering of Elektronika MK 53


If you are reading this, you probably already know the basics of the Soviet-era Elektronika MK-52 vintage electronic calculator.

If not, here are is some info:
  • First off, you may have a tendency to read "MK-52" as "Mark 52".  This is not correct.  MK stands for Micro Kalkulator.  In Russian "C" is not pronounced 2 different ways as it is in English.  "C" is always "S" as in "certify", and K is always the hard C (obviously as in calculator). It's coincidence that it also looks like it could be read "Mark 52".
  • The MK-52 is a 1980's era Scientific Programmable calculator developed and made in the former Soviet Union.
  • It was the last of the true Soviet Scientific Programmable calculator designs. Calculators that followed it were clones of products available in the West -- usually Sharp or Casio -- with perhaps just a bit of "Russianization" -- i.e. Cyrillic key caps and character sets.
  • It was the first and only such calculator to feature internal EEPROM storage -- basically a "flash drive", although extremely limited by modern standards.  The EEPROM is separate from the volatile internal program memory and registers.  Registers and Program steps must be written to the EEPROM, and then read back to realize non-volatile memory.
  • The Elektronika MK-61 is essentially the same Programmable Calculator, but Lacks the EEPROM Storage, and is in a Vertically Oriented ("Portrait") instead of the MK-52's Landscape (Horizontal) Form Factor.
If you would like to try the MK-61/MK-52, but don't want to order one from a former Soviet Country, there is an online emulator here:
https://mk-61.moy.su/emulator.html
admin
Site Admin
Posts: 146
Joined: 26 Dec 2023 13:05

Re: Elktronika MK-52 Vintage Soviet Calculator

Post by admin »

Originally Posted by Administrator on Thu Feb 06 2020 20:58:00 GMT-0500 (Eastern Standard Time)

The Elektronika MK-52 has limited support for Hexadecimal characters, although with a strange character representation for hex values >9.  It's similar to what happens when you send a value >9 to a 7447 BCD display chip (but different specific characters)

Basically, the full "character set" for this calculator is 0123456789-LCГE_

For most of this text, I will be using "r" , which looks similar to the Cyrillic letter "Г" that sounds like a English "G" or "Ghe".  Also "_" is a blank. A space is printed -- not an underscore.

This leads to the phase "EGGOG!" which is how a Russian person would pronounce (perhaps exclaim) the displayed "Err0r".  Although to be clear, I'm not implying that any Russian today would actually exclaim EGGOG! unless they were a particularly geeky Russian that happened to be from the time of Vintage Elektronika Calculators. Writing out 0123456789-LCГE_ as Hex 0123456789ABCDEF You can see that "Err0r" is actually spelled out in the MK-52 using the hex number EDD0D.

Hex to MK-52 Character Translation Table:

Code: Select all

0123456789ABCDEF
0123456789-LCГE_
If we also use numbers such as 0 for "O", 1 for "I", and 5 for "S", we see that we can spell out a lot of English words.  For example, one could use "C0rrECr" as a recognizable "Correct" for successfully completing a "guess the numbers" game, or "C00L" for "Cool". Or the old calculator joke of  "80085" which can be read out as.... Well, you get the idea.

But how do we type these "words" into the MK-52?  It doesn't have a hex mode, and the keys with a...e marked under them refer to Registers R(a)...R(e), and cannot be used to enter those characters.

Here's an easy way to quickly store a "word" in a register:

Start with an "8", then decimal.
Continue with an 8 for every hex character, and a 0 for every "regular" (0 - 9) number.
Press Enter(B↑).

For example, to write "ERROR", as the calculator does, we would type:
8.88808, followed by Enter (B↑).

Again, start with an "8."
Continue with the normal values for regular (decimal) numbers (digits where we entered a "0" above, and the following for hex values >A, where 2=A ("-") 3=B ("L") 4=C("C") 5=D("r") 6=E("E") and  7=F(" ")

To continue our example of writing "Err0r", we would enter:
8.65505

Since we have to precede the values with "8.", we can make alphanumeric words of phrases with a maximum of 7 characters, including spaces.

Press K then the down carat (blue character above the /-/ key) to Logic "OR" the 2 values.

You should have the word you want, preceded by "8."  But don't worry, we can exploit one of the may "features" of this calculator to get only the text we want, and to get the period at the end.

For the example of writing "Err0r", we would have
8.Err0r   displayed.

Get rid of the "8." by taking the fractional part (Press K then {x}), which fortunately fails to convert the hex characters to a decimal number like almost all of the other functions do.

But now the display is kinda messed up.  The period is in the wrong place, and there is an -01 showing.

For the example of writing "Err0r", we would have
E.rr0r   -01    displayed.

No problem -- We can move the decimal (period) by raising the value to the number of characters.  Press BП
(EXP) followed by the number of characters.  Don't press Enter.

Since Err0r is 5 characters, we would enter:
BП  5   (BПis read as "Enter Power, it would be the EE -- "Enter Exponent" or the EXP key on a western calculator.)

Store it in a register of your choice:

X-П  (r), where r is the chosen register (0 - e).  This time we would use the a -- e keys printed under the respective keys to store it in a register location >9. Note that there is no register(f).

You should have the desired "text" Displayed (The display is the X Register) as well as in the Register you chose.

For the example of writing "Err0r", we would have
Err0r.   displayed, and stored in register 0.

Let's do another example:
To write "Cool", enter:

8.8008
Enter
8.4003
K OR
K {x}
B  4
X-П   0

"C00L" is displayed, and saved in R(0).

OK, so that's -- Well -- "C00L", but as soon as we turn the calculator off, we'll loose it.  How do we save it to EEPROM?

Next Post: Saving the characters we've typed.
admin
Site Admin
Posts: 146
Joined: 26 Dec 2023 13:05

Re: Elektronika MK-52 Vintage Soviet Calculator

Post by admin »

Originally Posted by Administrator on Thu Feb 06 2020 21:03:43 GMT-0500 (Eastern Standard Time)

In the last post I provided a simply way to enter values into the Elektronika MK-52 Calculator that look like English (or Russian) text. What if we want to save these values (or any value in a register) to the non-volatile EEPROM?

Let's also assume we have a small program (perhaps that uses the text) stored stating at 0000 in EEPROM.
Let's say it's less than 30 steps long.
We can start storing registers at the next "page" or location 32.

For this example, we'll only store the one register -- R(0), containing the value "C00L" (See previous post for entering this value into a register).

First we must ensure the area of EEPROM we want to use is "clean" or erased.

Move the "C ; 3 ; CЧ" switch to "C" ("Clear")
Move the "д ; п" (D - P) switch to "D" for "Data"

Enter the number 1003207 -- This is read as follows: 1 is any non-zero number, and is required. 0032 means start at location 0032 (so that we do not destroy the program that is lower in the EEPROM). 07 means store (clear) 7 bytes -- we only want to clear room for 1 register.

Press A-Up then Up-Down ;(Address, followed by the Read/Write key).

Note that this will also clear the register, so you may have to enter the text as described above, and store it in R(0) *after* you clear the EEPROM.

Move the "C 3 CЧ" switch to "3" (From the Russian word "записывать" meaning "to record", "to write down" or "to save")
Enter 1003207
Press A-Up, then Up-Down

You can check that "C00L" is saved by either clearing R(0) (storing ;0 in R(0)), or by turning the calculator off, waiting 30 seconds, and then turning it back on.

We re-load it to R(0) the same way:

Move the "C 3 CЧ" switch to "CЧ" (From the Russian word "считывать" "to read")
Enter 1003207
Press A-Up, then Up-Down

Then hitting
П - >X ; 0
Should recall "C00L." to the display.
admin
Site Admin
Posts: 146
Joined: 26 Dec 2023 13:05

Re: Elektronika MK-52 Vintage Soviet Calculator

Post by admin »

Originally Posted by Administrator on Thu Feb 06 2020 21:17:21 GMT-0500 (Eastern Standard Time)


Elektronika MK-52 Vintage Soviet/Russian Calculator

General Notes and hints:

It's a good idea to get in the habit of moving the "C  3   CЧ" switch back to "CЧ" ("Read") after every EEPROM operation.  This helps to prevent accidental loss of what is saved in the EEPROM.

------

To save all of the registers, save 7 * 14, or 98 bytes. Note that this will not store R(e), or the R(f).  I don't know how to store R(e), and as mentioned there is no R(f), so it cannot be stored.
For example, to clear enough room, starting at location 0032 for the contents of R(0) -- R(d):

Move the "C   3   C-Ch" switch to "C" ("Clear")
Move the "D   P" switch to D (which translates to "D" for "Data")
Enter the number 1003298
Press A-Up, then Up-Down  (Address, followed by the Read/Write key).

------

For this device, when we say wait 30 seconds between turning the calculator off, and back on, we mean it.  This calculator uses a VFD or Vacuum Fluorescent Display, which is actually a vacuum tube.  As with other vacuum tube devices, the tube employs high voltage.  If the HV capacitors are not allowed to discharge, turning the calculator back on can cause possibly damaging voltage spikes.  Wait *at least* 30 seconds.

------

Another good habit is pressing B/0 and CX if you stop to think for a moment or get confused.  B/0 resets the program counter to 0, and CX clears X.  This insures that subsequently pressing ПPГ ("PRG" -- or Program, Which is usually "LRN" or "Learn" on a typical western vintage programmable calculator) displays your program from the beginning, and C/П (Continue/Pause which would be R/S-- (Run/Stop) on a western device) begins executing a program from the beginning.  Obviously, this assumes you want to Clear X, and reset the Program Counter.  The contents of X will be lost.  You also may not want to do this if you are working with a program that begins someplace else other than the beginning of memory.
admin
Site Admin
Posts: 146
Joined: 26 Dec 2023 13:05

Re: Elektronika MK-52 Vintage Soviet Calculator

Post by admin »

Originally Posted by Administrator on Sat Aug 21 2021 21:08:52 GMT-0400 (Eastern Daylight Time)


I recently pulled my MK-52 out of it's storage box, and reinserted the separately stored batteries.

Doing so made me realize that I had never shared my "Dice Roll" program -- so without further delay, here's the code, in what is hopefully a clear mnemonic/pseudo code form:

Columns:
1.  Memory Location
2.  Opcode/content
3.  Key Strokes (This are the actual keystrokes to enter the program steps)
4. Comments

Note: Keystrokes are shown as Equivalent Western characters/Western Calculator Keys

Code: Select all

00  
01  6-  P->X (a)     4 Digit Seed must be stored in Register (a) -- Recall it.
02  22  X^2         Square -- Start of Middle Square Code
03  01  1
04  0C  EE
05  06  6
06  13  /           Divide by 1E6
07  35  {x}         Take the Fractional part
08  01  1
09  0C  EE
10  04  4
11  12  *           Multiply by 1E4
12  34  [x]         Take the Whole Part  -- End of Middle Square code
13  4-  X->P (a)     Store the New Seed
14  3L  RND         Random.  This is the actual Dice Roll
15  06  6             
16  12  *           Multiply by 6
17  34  [x]         Take the Whole part
18  01  1
19  10  +           Add 1
20  50  R/S         Stop
21  52  RTN         Goto 00 to run again.
Code Design:

The MK-52, and it's close cousin, the MK-61 have very poor random number generators.  For any given seed, the pattern of pseudo random numbers will repeat after only a few iterations, especially for a low value integer, like a dice roll.

In the code above, I use a "Middle Square" routine to generate a new seed for every dice roll.  By using this combination of 2 random number generators, it seems to be a fairly unpredictable dice roll.  It does however remain only pseudo random.  If you are sitting down at the gambling table with a particularly tough group of comrades, I'd suggest leaving your MK-52/MK-61 in your back pocket.  In that position, it may save you from a bullet as your head for the door, if you pull it out and try to use it instead of the dice they offer, it may get you a bullet.

Note that the code above generates only a single 6-sided dice roll.
Note also that I use the MK-52 notation for hex values, for example memory location 14 contains the opcode for RND, which is Hex 3B, however, I write it as the MK-52 displays it: 3L.

Enjoy.
admin
Site Admin
Posts: 146
Joined: 26 Dec 2023 13:05

Re: Elektronika MK-52 Vintage Soviet Calculator

Post by admin »

Originally Posted by Administrator on Thu Aug 26 2021 20:34:53 GMT-0400 (Eastern Daylight Time)
Updated and edited when re-posted.

Updated Dice Roll Program for the Elektronika MK-52.

In this version, the new seed is generated from the results of both pseudo random number generators, and not just the Middle Square routine.


Columns:
1. Memory Location
2. Opcode/content
3. Key Strokes (What you Actually Type to enter the program)
4. Comments

Code: Select all

00
01  6-  P->X (a)       4 Digit Seed must be stored in Register (a) -- Recall it.
02  22  X^2            Square -- Start of Middle Square Code
03  01  1
04  0C  EE
05  06  6
06  13  /              Divide by 1E6
07  35  {x}            Take the Fractional part (Removes the Left 2 Digits)
08  01  1
09  0C  EE
10  04  4
11  12  *              Multiply by 1E4
12  34  [x]            Take the Whole Part  (Removes the Right 2 Digits) -- End of Middle Square code
13  3L  RND            Random.  This is the actual Dice Roll
14  4L  X->P (b)       Store the result
15  01  1
16  0C  EE
17  04  4
18  12  *              Multiply by 1E4
19  34  [x]            Take the Whole Part.  This is the New Seed
20  4-  X->P (a)       Store the New Seed
21  6L  P->X (b)       Recall the Roll
22  06  6  
23  12  *              Multiply by 6
24  34  [x]            Take the Whole part
25  01  1
26  10  +              Add 1  (There is no '0' on a Dice)
27  50  R/S            Stop so that result is displayed.

If you have an MK 52, you can save this to the EEPROM so that you don't have to type it back in again each time after you turn off the calculator:

(Optional) - If you are not sure that the first part of the EEPROM is clean (clear) do the following:

Move the "C ; 3 ; CЧ" switch to "C" ("Clear")
Move the "д ; п" (D - P) switch to "P" for "Program"

We need to clear at least 27 bytes. For this example, I will assume nothing else is in the EEPROM, so we will start at location 0000
Enter 1000027 (Obligatory Non-zero single digit "1", Starting address "0000", Number of bytes to write "27")
Press A-Up then Up-Down (A^), then (^v)

If you know the EEPROM is clean in the desired area, Save the Dice Roll Program by doing:

Move the "C ; 3 ; CЧ" switch to "3" ("Write")
Move the "д ; п" (D - P) switch to "P" for "Program"
Enter 1000027
Press A-Up then Up-Down (A^), then (^v)

It's a good idea to get in the habit of Moving the "C ; 3 ; CЧ" switch back to "CЧ" ("Read") after each write to prevent accidental erasure next time the MK 52 is used.

Recall the Dice Roll Program:
Verify the "C ; 3 ; CЧ" switch is in "CЧ" ("Read")
Enter 1000027
Press A-Up then Up-Down (A^), then (^v)

Don't for get to put a new 4 digit integer seed in R(a) before running the program.
Then Press B/0 (Reset Program Counter)
and C/P (Run/Stop) to Roll the Dice.
Post Reply