{"id":1016,"date":"2017-10-17T15:37:55","date_gmt":"2017-10-17T13:37:55","guid":{"rendered":"https:\/\/willem.aandewiel.nl\/?p=1016"},"modified":"2021-02-26T11:23:48","modified_gmt":"2021-02-26T10:23:48","slug":"kim_tapedevice","status":"publish","type":"post","link":"https:\/\/willem.aandewiel.nl\/index.php\/2017\/10\/17\/kim_tapedevice\/","title":{"rendered":"Solid State Tape Device for the (micro)KIM"},"content":{"rendered":"\n<p>[ 25,356 keer bekeken \/ views ]<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/KIM-1_add_small.jpg\"><img decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/KIM-1_add_small.jpg\" alt=\"KIM-1 Add\" class=\"wp-image-1026\"\/><\/a><\/figure><\/div>\n\n\n\n<p>In 1976 I bought my first computer. That was at a time when there was no internet, there where no PC or Apple\u2019s! Computers where meant for big company\u2019s like insurance compagnies and multi nationals. No one had a computer at home. It was the time of the Homebrew Computer Club and Byte magazine. I had a Byte magazine subscription and at a certain point there was an advertisement in it from MOS-Technology for a single board computer called the KIM-1.<\/p>\n\n\n\n<p class=\"has-blue-color has-light-gray-background-color has-text-color has-background\"><a href=\"https:\/\/willem.aandewiel.nl\/index.php\/2021\/02\/19\/a-32kb-memory-expansion-board-for-the-microkim\/\">Also read my post about a 32kb Memory Expansion for the microKIM<\/a><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/MOS_KIM-1_small.jpg\"><img decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/MOS_KIM-1_small.jpg\" alt=\"KIM-1 SBC\" class=\"wp-image-1030\"\/><\/a><\/figure><\/div>\n\n\n\n<p><br>If I remember correctly, I, one-way-or-an-other (remember, there was no internet, no email, no PayPal. only had <em>The Yellow Pages<\/em> and a <em>Phone Book<\/em> from the city of Amsterdam), found a distributer in the Netherlands where I ordered this piece of magic.<br><\/p>\n\n\n\n<!--more Keep on reading-->\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/microKIM_small.jpg\"><img decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/microKIM_small.jpg\" alt=\"\" class=\"wp-image-1039\"\/><\/a><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Much later, in 2016,I went to the <a rel=\"noopener noreferrer\" href=\"http:\/\/www.applemuseum-nederland.nl\/\" target=\"_blank\">Apple Museum Nederland<\/a> in Orvelte and that visit was a trip down memory lane.<br>Searching the net I found there are quit a lot of Apple&nbsp;][ emulators and replica\u2019s, but there was also a KIM-1 replica, called the microKIM. I bought the <a rel=\"noopener noreferrer\" href=\"http:\/\/www.brielcomputers.com\/wordpress\/?cat=24\" target=\"_blank\">microKIM<\/a> as a kit from Vincent Briel but due to some missing and some wrong parts (mainly a 65C02 processor that did not comply with the timing of the original 6502 processor and the microKIM design) it took me almost a year and the help of <em>Timothy Alicie<\/em> (who had a solution for the timing problem) and <em>Jac Goudsmit<\/em> to get the microKIM working.<br><br>The microKIM is as close to the original as possible. There are some differences in the hardware due to the unavailability of some parts and newer parts that are more capable than the parts that where available in the 1970\u2019s. Vince designed a RS232 interface as a replacement for the original TTY interface. So you can connect the microKIM to a computer with a &#8220;<em>RS232 to USB<\/em>&#8221; cable and program the microKIM from a terminal program (I use CoolTerm).<br>From a software point of view the extra RAM (5 kilobyte in stead of 1 kilobyte) and the absence of the first timer at address $1704 (5,6,7) are important. Only the timer at address $1744 (5,6,7) is available which you have to take into account if you want to use a program written for the original KIM-1.<br>To get \u201c<em>the real vintage feeling<\/em>\u201d I wanted to design a \u201csolid state\u201d cassette interface that \u201cworks\u201d like a real cassette recorder. With the original KIM-1 it was possible to store more than one program on a cassette tape and by keeping track of the tape-counter (writing it down on the cassette) one could position the tape at the start of a particular program, punch in some magic numbers on the KIM-1, press the \u201cGO\u201d button to start the tape-loading program and then press the \u201cplay\u201d button on the cassette recorder. Some squeezing sounds (like the one you might know from the early modems) later and after a few minutes the program was loaded into the KIM-1.<br>Recording was similar with some other magic numbers and pressing the \u201crecord\u201d and \u201cplay\u201d button on the cassette recorder simultaneously.<br>A program is recorded to tape using two frequency\u2019s; <em>3.623 Hz<\/em> and <em>2.415 Hz<\/em> to convert \u20181\u2019 and \u20180\u2019 bits to a pulse-train.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/PulseTrain.png\"><img decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/PulseTrain.png\" alt=\"\" class=\"wp-image-966\"\/><\/a><figcaption>page E-3 of the KIM-1 User Manual<\/figcaption><\/figure><\/div>\n\n\n\n<p><br> <\/p>\n\n\n\n<p><br><big>Decoding the pulse-train<\/big><br>I tried to let the ESP8266 decode this pulse train but the timing is too tight to decode the train into bits and also be able to convert the bits in bytes and store them to a file. So I fell back to the mighty little ATtiny85 processor to convert only the pulse train to \u20181\u2019 and \u20180\u2019 bits and feed the bits to the ESP8266 for further handling. The duration of one bit takes 7.452 milli seconds.<br>To distinguish between a \u20181\u2019 or \u20180\u2019 bit the ATtiny only has to record the duration of the change in frequency from long- to short- and from short- to long-pulses. It starts a timer at the moment the pulse duration changes from approx. 414 \u00b5Seconds to 276 \u00b5Seconds. The timer stops at the moment the pulse changes back to ~414 \u00b5Seconds.<br>If the duration is shorter than 3.726 milli seconds it has found a \u20181\u2019 and makes the output pin High and if the duration is longer than 3.726 milli seconds it has found a \u20180\u2019 and it makes the output pin Low.<br>To load a program from the <em>Tape Device<\/em> to the KIM we can skip the modulation to the 3kHz and 2kHz frequency\u2019s and simply feed the one\u2019s and zero\u2019s to the KIM.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright is-resized\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/sony-cassette-recorder-player.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/sony-cassette-recorder-player.jpg\" alt=\"\" class=\"wp-image-995\" width=\"233\" height=\"183\"\/><\/a><\/figure><\/div>\n\n\n\n<p><br><big>Design Goals<\/big><br>The Tape Device user interface must consist of the four buttons found on every cassette recorder. A \u201cfast rewind\u201d, \u201crecord\u201d, \u201cplay\u201d and \u201cfast forward\u201d button (on the real cassette recorder there also is a \u201cstop\u201d button but we won\u2019t use that button in this design).<\/p>\n\n\n\n<p> <\/p>\n\n\n\n<p class=\"has-text-align-left\"><br>Because of the today\u2019s possibilities and state of technology we can store a large amount of program\u2019s on a small device so we need a way to present to the user where we are on the \u201ctape\u201d but we can present more than just a tape-counter. Wouldn\u2019t it be nice if, besides the tape-counter, there was room for a description of the program and maybe the start address to run the program from. And because a large number of program\u2019s can be stored on this device it would also be nice to be able to write-protect a program so it can\u2019t accidentally be overwritten.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright is-resized\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/Wemos-D1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/Wemos-D1.png\" alt=\"Wemos D1 mini\" class=\"wp-image-965\" width=\"174\" height=\"224\"\/><\/a><\/figure><\/div>\n\n\n\n<p><br>I have chosen to use a ESP8266 processor on a small board from Wemos (the <em>Wemos D1 mini<\/em>). From the EEPROM memory of the ESP8266 about 3 Megabytes is used as a filesystem to store programs.<br>This Wemos D1 board has an USB port to program the ESP8266 and that port can also be used as an interface to a computer, which we will use to enter a <em>description<\/em> to a program and to make the program <em>Read Only<\/em> or <em>Read\/Writable<\/em>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft is-resized\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/SD1306.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/SD1306.jpg\" alt=\"SD1306 OLED\" class=\"wp-image-964\" width=\"226\" height=\"169\"\/><\/a><\/figure><\/div>\n\n\n\n<p> <\/p>\n\n\n\n<p>For the display the SD1306 with an I2C interface is perfect. This picture shows that as sequence $07 (it&#8217;s a hexadecimal number) a program with the description &#8220;chessClock&#8221; is stored. The program is &#8220;Read Only&#8221; and the start address is $0200.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The KIM is a 5 volt device and the ESP8266 is a 3.3 volt device (the ATtiny can be both, but we power it with 5 volt) so to connect signals to one-another, <em>level shifters<\/em> are necessary. N-Channel MosFets are ideal suited for this task.<\/p>\n\n\n\n<p class=\"has-blue-color has-light-gray-background-color has-text-color has-background\">Version 2.0 of the firmware and the hardware is out! It is better, faster, nicer, more user friendly! <a href=\"https:\/\/willem.aandewiel.nl\/index.php\/2021\/02\/20\/digital-tape-recorder-for-the-kim-1-and-clones\/\">Read all about it<\/a>!<\/p>\n\n\n\n<p><br>This is the hardware design:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/KIM_TapeDevice.jpg\"><img decoding=\"async\" src=\"https:\/\/willem.aandewiel.nl\/wp-content\/uploads\/2017\/10\/KIM_TapeDevice.jpg\" alt=\"\" class=\"wp-image-962\"\/><\/a><\/figure><\/div>\n\n\n\n<p><br>The software for the ATtiny and the ESP8266 can be found on <a rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/mrWheel\/KIM_TapeDevice\" target=\"_blank\">GitHub<\/a>.<br>And here you find a short demo of the KIM Tape Device:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/www.youtube.com\/watch?v=R_zD5T_khKs\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Design of a Solid State Cassette Tape Device voor de KIM-1 and microKIM <a href=\"https:\/\/willem.aandewiel.nl\/index.php\/2017\/10\/17\/kim_tapedevice\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":963,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,143,10,11],"tags":[26,35,47,63,70,98],"class_list":["post-1016","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer","category-esp8266","category-firmware","category-hardware","category-kim","tag-attiny","tag-cassette","tag-esp8266","tag-kim","tag-microkim","tag-tape-device"],"views":25356,"_links":{"self":[{"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/posts\/1016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/comments?post=1016"}],"version-history":[{"count":6,"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/posts\/1016\/revisions"}],"predecessor-version":[{"id":6392,"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/posts\/1016\/revisions\/6392"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/media?parent=1016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/categories?post=1016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/willem.aandewiel.nl\/index.php\/wp-json\/wp\/v2\/tags?post=1016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}