{"id":1359,"date":"2016-03-27T15:44:01","date_gmt":"2016-03-27T19:44:01","guid":{"rendered":"http:\/\/biosrhythm.com\/?p=1359"},"modified":"2022-11-24T10:59:47","modified_gmt":"2022-11-24T15:59:47","slug":"rs-232-for-commodore-pet","status":"publish","type":"post","link":"https:\/\/biosrhythm.com\/?p=1359","title":{"rendered":"RS-232 for Commodore PET and Dialing a BBS over WiFi"},"content":{"rendered":"\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_3474-1.jpg\" rel=\"attachment wp-att-1371\"><img loading=\"lazy\" width=\"768\" height=\"1024\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_3474-1.jpg\" alt=\"Commodore PET running WordPro Four Plus.\" class=\"wp-image-1371\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_3474-1.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_3474-1-225x300.jpg 225w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_3474-1-600x800.jpg 600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><figcaption>Commodore PET running WordPro Four Plus.<\/figcaption><\/figure>\n\n\n\n<p>I&#8217;ve owned a Commodore PET* 8032 for a few years now. I&#8217;ve been able to download and run many different programs for it, like WordPro you see above. But one thing always remained elusive. I&#8217;ve long wanted to connect it to a standard RS-232 device and use it as a terminal. The PET&#8217;s classic shape, green monochrome monitor, and 80 column display all lend itself perfectly as a terminal.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Like it&#8217;s much more popular successors, it too lacked proper RS-232 UART hardware. Adding a modem meant you either had to purchase a IEEE-488 enabled modem (Commodore made the 8010), purchase an add-on board for your PET, or use the existing parallel user port to &#8220;bit-bang&#8221; RS-232 serial signals. The later is exactly what the Commodore VIC-20, C64 and C128 do&#8211; simulate RS-232 on user port pins by the CPU rapidly turning outputs on and off. They even have KERNAL ROM code (albeit broken at high speeds) that did the RS-232 handling for you.<\/p>\n\n\n\n<p>The PET lacks this ROM code but it can added to drive RS-232 TTL signals over the user port. I found two methods that did this&#8211; a commercial product and a freeware one.<\/p>\n\n\n\n<p><strong>Before we continue, please&#8211; if you attempt any of this, make sure you understand the difference between RS-232 TTL level signals (0v to +5v) and proper RS-232 level signals (-13v to +13v or more). <em>Connecting proper RS-232 level signals to your PET will damage your computer and make you sad.<\/em> <a href=\"https:\/\/www.sparkfun.com\/tutorials\/215\" target=\"_blank\" rel=\"noopener\">See this explanation for SparkFun about the differences in RS-232 levels<\/a>.<br><\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>The first was McTerm which was produced by Madison Computer. I knew of this company since I owned their McPen lightpen system for the VIC-20 and C64 but I didn&#8217;t know their pedigree went that far back. It was sold as three parts&#8211; software on floppy, a ROM chip that had to be installed inside the PET, and a user port cable that connected to the RS-232 device. <a href=\"http:\/\/cbm8bit.com\/8bit\/commodore\/disk-image\/0835a42444509eb9e585f6d400397c0f\" target=\"_blank\" rel=\"noopener\">I located the software and the ROM online<\/a> [<a href=\"http:\/\/biosrhythm.com\/misc\/SOFT ROM MASTER-01-76f6f9.d64\">local cached copy<\/a>] but I&#8217;ve never actually seen the user port cable before so this was going to be challenging.<\/p>\n\n\n\n<p>The first step was to create the ROM using an EPROM. On the PET 8032, the ROM slot is UD12 which maps to memory location $9000. The ROM code was only 2 Kbytes but I only had 4 Kbyte EPROMs. That&#8217;s OK, I just filled the other half with 0xFF. The next problem was the PET ROM slot expected a 2532 style pinout but my EPROM was a 2732 which has a slightly different pinout. Luckily, this can be overcome by <a href=\"http:\/\/www.verrua.org\/pet_repair\/index_file\/image014.jpg\" target=\"_blank\" rel=\"noopener\">making an adapter carrier to swap the 3 of the pins around<\/a>. <a href=\"http:\/\/www.verrua.org\/pet_repair\/\" target=\"_blank\" rel=\"noopener\">This site was useful<\/a> in creating the adapter so I won&#8217;t go into that here. (Note: There&#8217;s two adapters on that site, make sure you&#8217;re building the 2732 -&gt; 2532.)<\/p>\n\n\n\n<p>Next was the software, which was easy enough to transfer to a 1541 floppy disk that can be read with the IEEE-488 enabled Commodore 2031 Single Floppy Disk drive. I put it as the first item on the disk so the &#8220;shift-run\/stop&#8221; trick will load and run the first item on the disk.<\/p>\n\n\n\n<p>Finally, I needed to figure out how to make the cable. I was going to need to test the user port pins to locate which ones the program was using. I examined how the VIC-20 and C64 do RS-232 over the serial port first. Immediately, I found that pins B and C were tied together for receive (RX). Pin C is PA0 which is a GPIO pin and B is \/FLAG2 which I believe is for an interrupt. This makes sense since you want to immediately begin processing incoming data as soon as possible. The PET user port pin B is CA1 is is also for an interrupt. I had a hunch it may be used the same way.<\/p>\n\n\n\n<p>To test the pins, I tied pins B and C together and connected to a <a href=\"https:\/\/www.adafruit.com\/products\/70\" target=\"_blank\" rel=\"noopener\">USB RS-232 TTL adapter<\/a>. I used a terminal program called <a href=\"http:\/\/freeware.the-meiers.org\/\" target=\"_blank\" rel=\"noopener\">CoolTerm<\/a>, set the baud rate properly and tried sending characters. Nothing. I then tried B and D. Nothing. I kept trying until I landed on B and F. This <em>DID<\/em> give me something on the PET screen. It wasn&#8217;t correct, but it was receiving <em>something<\/em>.<\/p>\n\n\n\n<p>I repeated this hunting for the transmit (TX) pin but this time only on a single pin. I found pin H was being using for transmit but again, it wasn&#8217;t recognizable characters from the PET but something was being transmitted.<\/p>\n\n\n\n<p>Next I wanted to troubleshoot the characters not being displayed right. First thing was maybe it was the wrong number of data or stop bits or even parity. I tried many different combinations: 7n1, 7e1, 8e2, etc. None of them seemed to make a different. Typing the alphabet &#8220;abcdef..&#8221; seemed to return the alphabet but in seemingly reverse order with some other characters interspersed.<\/p>\n\n\n\n<p>I decided to get the scope out and look at the differences between the USB RS-232 and PET signals. I decided on the &#8216;0&#8217; character since it&#8217;s the same for ASCII and PETSCII just in case that might be part of the problem. Below is a comparison of the two.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9123-1.jpg\" rel=\"attachment wp-att-1373\"><img loading=\"lazy\" width=\"1024\" height=\"1024\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9123-1.jpg\" alt=\"Top is a Mac and USB Serial TTL cable. Bottom is a Commodore PET transmitting via user port on pin H.\" class=\"wp-image-1373\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9123-1.jpg 1024w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9123-1-150x150.jpg 150w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9123-1-300x300.jpg 300w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9123-1-768x768.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9123-1-800x800.jpg 800w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Top is a Mac and USB Serial TTL cable. Bottom is a Commodore PET transmitting via user port on pin H.<\/figcaption><\/figure>\n\n\n\n<p>Immediately you can see the issue. The Commodore PET is using a logic low for false and logic high for true (which I&#8217;ve learned is called &#8220;non-inverse&#8221;). Standard RS-232 TTL signals are &#8220;inverse&#8221; of this using logic high for false and logic low for true. This would explain what I&#8217;m seeing since the bits are reversed. I connected the pins through a 7404 inverting IC to invert the singals to and from the PET.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9138-1.jpg\" rel=\"attachment wp-att-1374\"><img loading=\"lazy\" width=\"768\" height=\"1024\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9138-1.jpg\" alt=\"Commodore PET 8032 and inverting circuit.\" class=\"wp-image-1374\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9138-1.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9138-1-225x300.jpg 225w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9138-1-600x800.jpg 600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><figcaption>Commodore PET 8032 and inverting circuit.<\/figcaption><\/figure>\n\n\n\n<p>This yielded partial success. I was now able to send characters to the Commodore PET.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9126-1.jpg\" rel=\"attachment wp-att-1375\"><img loading=\"lazy\" width=\"1024\" height=\"508\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9126-1.jpg\" alt=\"Commodore PET displaying Hello World message sent from a Mac over RS-232.\" class=\"wp-image-1375\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9126-1.jpg 1024w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9126-1-300x149.jpg 300w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9126-1-768x381.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9126-1-840x417.jpg 840w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Commodore PET displaying Hello World message sent from a Mac over RS-232.<\/figcaption><\/figure>\n\n\n\n<p>Sending characters from the PET to the USB RS-232 TTL adapter revealed that it was setting bit 7 high. If bit 7 was set low, it would be working fine. I&#8217;ve still yet to figure this out. If you have an idea, leave a message in the comments.<\/p>\n\n\n\n<p>I later found in the BASIC code of McTerm on line 1070 was a way to use inverted RS-232 which does work without the inverting circuit.<\/p>\n\n\n\n<p><code> 1070 sysa    :rem ***** use a for regular modems, a+36 to invert<br>\n<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>The second method was found in <a href=\"https:\/\/archive.org\/details\/transactor-magazines-v3-i06\" target=\"_blank\" rel=\"noopener\">Transactor Magazine issue 3 volume 6<\/a>. It included a type in terminal program (simply called &#8220;Terminal v11&#8221;) and simple instructions for building a user port cable. I believe this program was created by <a href=\"http:\/\/www.bbsdocumentary.com\/photos\/045punter\/\" target=\"_blank\" rel=\"noopener\">Steve Punter, who also created the only known BBS program for the Commodore PET<\/a>. Being a type-in freebie in a magazine, it wasn&#8217;t as full featured as McTerm but it does do automatic PETSCII\/ASCII translation and has file transfers using an early version of the Punter protocol. It is locked to 300 baud however.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/data.jpg\" rel=\"attachment wp-att-1383\"><img loading=\"lazy\" width=\"874\" height=\"690\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/data.jpg\" alt=\"Commodore PET Terminal type in program.\" class=\"wp-image-1383\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/data.jpg 874w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/data-300x237.jpg 300w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/data-768x606.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/data-840x663.jpg 840w\" sizes=\"(max-width: 874px) 100vw, 874px\" \/><\/a><figcaption>A portion of the Commodore PET Terminal type in program.<\/figcaption><\/figure>\n\n\n\n<p>Next up was the software. I really didn&#8217;t relish the idea of reliving that part of my childhood and typing all of those DATA statements. Modern technology to the rescue in the form of a <a href=\"http:\/\/www.onlineocr.net\/\" target=\"_blank\" rel=\"noopener\">free online OCR service<\/a>. Much to my surprise, this service worked extremely well. I did have to process each column of code separately by extracting each from the PDF as a JPG. The most OCR errors were in the BASIC program but it was still dramatically lower than what I expected. Between the two ML programs with the DATA statements, those <em>only had a single error!<\/em> I later found <a href=\"http:\/\/cbm8bit.com\/8bit\/commodore\/disk-image\/d4ddebb845d2ddd484f4d4953645dae1\" target=\"_blank\" rel=\"noopener\">version 12 of Terminal was available here<\/a> [<a href=\"http:\/\/biosrhythm.com\/misc\/sb046580-84bcb6.d64\">local cached copy<\/a>].<\/p>\n\n\n\n<p>This time, the PET user port pins were listed. Pins B and L are for RX and pin C is for TX. I swapped my user port adapter cable around to match this pinout, ran the signals through the inverter circuit and tried it. Immediate success in both directions!<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9140-1.jpg\" rel=\"attachment wp-att-1376\"><img loading=\"lazy\" width=\"768\" height=\"1024\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9140-1.jpg\" alt=\"Commodore PET and MacBook Air communicating over a RS-232 serial connection.\" class=\"wp-image-1376\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9140-1.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9140-1-225x300.jpg 225w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9140-1-600x800.jpg 600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><figcaption>Commodore PET and MacBook Air communicating over a RS-232 serial connection.<\/figcaption><\/figure>\n\n\n\n<p>Now that I have a working RS-232 cable and software for the PET, we can put it to use. I connected it to a SparkFun ESP8266 breakout board. This board connects over WiFi and can <a href=\"http:\/\/www.lemon64.com\/forum\/viewtopic.php?t=57035\" target=\"_blank\" rel=\"noopener\">support a standard Hayes modem AT command set with the right firmware<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9145.jpg\" rel=\"attachment wp-att-1378\"><img loading=\"lazy\" width=\"1024\" height=\"668\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9145.jpg\" alt=\"ESP 8266 wired to Commodore PET user port edge connector through a 7404 inverter circuit.\" class=\"wp-image-1378\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9145.jpg 1024w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9145-300x196.jpg 300w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9145-768x501.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9145-840x548.jpg 840w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>ESP 8266 wired to Commodore PET user port edge connector through a 7404 inverter circuit.<\/figcaption><\/figure>\n\n\n\n<p>With this adapter, I&#8217;m able to &#8220;dial&#8221; into BBS systems that are accessible via IP. One such board is <a href=\"http:\/\/bbs.fozztexx.com\/\" target=\"_blank\" rel=\"noopener\">Level 29<\/a> which is run by <a href=\"https:\/\/twitter.com\/fozztexx\" target=\"_blank\" rel=\"noopener\">@FozzTexx<\/a>.<\/p>\n\n\n\n<p><code>ATDT bbs.fozztexx.com:23<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9149.jpg\" rel=\"attachment wp-att-1379\"><img loading=\"lazy\" width=\"768\" height=\"1024\" src=\"http:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9149.jpg\" alt=\"Commodore PET dialed into Level 29 BBS over WiFi.\" class=\"wp-image-1379\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9149.jpg 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9149-225x300.jpg 225w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2016\/03\/IMG_9149-600x800.jpg 600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><figcaption>Commodore PET dialed into Level 29 BBS over WiFi.<\/figcaption><\/figure>\n\n\n\n<p>So, was non-inverted RS-232 TTL a standard 30 years ago since two separate terminal programs used it? When did inverted RS-232 TTL become the standard?<\/p>\n\n\n\n<p>So, until I can figure out what&#8217;s wrong with McTerm transmitting with bit 7 set, use Terminal instead and you can use RS-232 on your PET.<\/p>\n\n\n\n<p>*Actually, Commodore dropped the PET moniker shortly after they introduced the line and changed it to just CBM. The name PET just fits better I think.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve owned a Commodore PET* 8032 for a few years now. I&#8217;ve been able to download and run many different programs for it, like WordPro you see above. But one thing always remained elusive. I&#8217;ve long wanted to connect it to a standard RS-232 device and use it as a terminal. The PET&#8217;s classic shape, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/1359"}],"collection":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1359"}],"version-history":[{"count":23,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/1359\/revisions"}],"predecessor-version":[{"id":2133,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/1359\/revisions\/2133"}],"wp:attachment":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}