Teletype & Linux TL330 System     2012 - 2014    Pictures


Custom TTY-Link Device

Linux.org

For the Teletype Data Terminals to communicate with more modern machines, I had to solve some issues, such as . . .

First, I tried to solve these issues on the Linux computer by having a gentleman in Slovakia (located through Elance), create a new Linux Line Discipline that could be attached to a Serial device via the Kernel.  This gentleman, one of the developers of git, made a valiant effort, but soon this approach started getting messy, and we were not going to be able to solve all of the above issues.  So, I then started looking at solving this using hardware.  I envisioned having a microcontroller in-line with the serial cable to handle all the Teletype aspects, without the computer upstream ever realizing it was talking to a Teletype.

Elance

I didn't have the skill to do the hardware myself, so I had to find help.   First, I made a local posting on Craigslist, but that generated no responses.   Elance is a one of the largest sites designed to match people with projects, so I decided to try it again, and posted this...

Looking for hardware expert to guide me in creating a hardware solution that will allow mapping of ASCII codes in a serial RS232 link, both directions. I would like to use the Arduino microprocessor prototype board, if possible, with an extra board for whatever else we need to make this work. Dealing with fairly slow baud rates. I have a strong software background, but limited hardware knowledge. I have worked with the Arduino before.

I want this to be 'light-switch' simple to operate. You plug in two serial cables into the device, plug in power, and everything starts working.

I'm am prepared to do the leg work, get the board made, etc, but I need someone to review my plans, suggest various hardware solutions and tradeoff's, let me draw it up, you review it, make changes, I redo it, I build a prototype, you recommend a PC board house to make the board, I stuff the boards. And that's it.

This worked good, generating 20+ responses from India, Pakistan, Russia, Bulgaria, and a handful from the US.  The Bulgaria type responses were coming in at $10/hour, and the US ones at $30 to $80 / hour.  One guy was 5 miles from our home, so I asked if he'd meet, and we met at the local McDonalds . . .

The local Engineer agreed to help, and he then designed a circuit from my 2 page functional description.  He used DipTrace, and sent me the schematic in DipTrace's file format.  DipTrace was a new program to me.  It is a professional PCB design tool program ($800), that does schematics, printed circuit board layout, component design, and a component footprint pattern editing.  DipTrace had a free, non-commercial use, 300-pin limit, version, which allowed me to view the files.  The Engineer also created a 'one of' single layer printed circuit board to test his design.

DipTrace was a program way beyond my capabilities at this point, but it was interesting to see that it had design properties for 100,000 different electronic parts, and you could just 'drag and drop' them onto your design.

Next, I needed to order the parts listed by the Engineer, with the Digi-Key part names.  This made it easy for me to visit Digi-Key's web site, and order two sets.  Digi-Key is one of the largest electronics suppliers.  Their site was easy to use, they didn't gouge on shipping, and they let me order quantity 1 parts, costing as little as 16 cents.  The cost for two sets of parts was $36 + $5 shipping.

To better understand the circuit and the process in general, I built up a working prototype on a piece of plywood, and some prototype breadboards I had around the house.  First I printed out the schematic from DipTrace, then wired up each wire line it showed.

Here is the prototype, ready to be turned on.  Took me about 12 hours to build this board, including the woodwork, and cutting the angle brackets to hold the DB9 and power connectors steady.  Took me a while to find nuts at the local hardware store that would fit the DB9 screw posts.  Turns out they were 3m Metric nuts.

Then I realized I had to get the ATmega328P-PU chip out of the prototype, to burn the bootloader software into the micro-processor's memory, and it was under a bunch of wires.  So I had to re-route all the wires around the chips.

 Okay, that's better.

Next I burned the bootloader into the Atmel ATMEGA328P-PU chip's memory.  This makes it easy to download the software for the TTY-Link device over and over again, as I develop it.  Fortunately the main Arduino website, Arduino.cc, had good instructions on how to wire up a bootloader 'burn-in' board, using the Arduino Uno as the controller for this step.

Then I met again with the hardware Engineer at the local McDonalds, to go over aspects of the design.  I wanted to understand it better, before I started to program the device using the C programming language and the Arduino software tools.  Thank you McDonalds, for providing a nice meeting place.

First I wrote some code to do 110 baud in software, using no interrupts, for asynchronous send and receive, under the Arduino umbrella, and was able to get it to work great, in fact amazingly well.  I calculated that the ATmega328P running at 16MHz, could do 150,000 instructions during each bit at 110 baud, and my code might take 500 instructions at most.

 
This Is Not Working...

Then I looked at the PC communications side of the equation and my plan to use the standard Arduino serial connection to the Linux PC, started to fall apart.  First the UART on the ATmega328P only had a three character buffer, and the Arduino Serial function only provided a 128 character buffer.  It also had no Clear-To-Send, Request-To-Send, Data-Terminal-Ready, and Data-Set-Ready signals.  So if you type a command, that outputs 1000 characters, you're going to loose almost everything.  So after having worked with the Arduino platform for a couple weeks, I decided to look into scrapping all the Arduino stuff, and just write code directly for the ATmega328P processor.  Essentially starting all over.

I asked around and learned that the Atmel Studio 6 Integrated Development Environment (IDE) was the way to go.  It was the official development environment from Atmel for their chips.  So I downloaded the 600MB Studio 6 software, and installed it.  Then I ordered the Atmel AVRISP mkII In-System Programmer (ATAVRISP2) from Singapore for $34 + $19 shipping.  This device would allow me to program the ATmega328P chip directly from the Atmel Studio 6 environment.

Turns out the Atmel Studio 6 environment was 10 times better than the Arduino environment, which hindered you with all the handholding they did, but it was more complex and I was going to need help...

So I looked for a book to help me, and found this book on Amazon: The Atmel AVR Microcontroller: MEGA and XMEGA in Assembly and C (with Student CD-ROM).  It was just published, January 2013, so it was up to date.  Thank you Professor Han-Way Huang.

Here, a month later, I finally have the wired prototype now communicating with a terminal, over the embedded UART, via direct C++ code in the Atmel microcontroller.  No more Arduino mess.

Why did it take me a month just to get a skeleton send and receive program working?  First, I didn't know my way around the Atmel Studio 6 environment, I helped my son with his Science Fair Project, and some issues took me a week to resolve, working a couple hours in the evenings, such as an RS232 voltage issue I was having.

I had to show this Atmel Studio 6 program, as it is so well thought out, once you get to know it.  It took me a week to figure out that the green arrow was how you downloaded your code.  The arrow is the Debug button, and I was looking for a download button, not knowing they were one and the same.  I later told my wife, and she said, "Well everyone knows that in a Microsoft Visual Studio development environment, you click the green arrow to download."  I didn't get that memo :-)

The cool thing is, it takes about 2 seconds to download and start running your program in the Atmel microcontroller chip.  So you can make a change, and 2 seconds later, see the results.

 
Continue to . . .     TTY-Link Progress

 

 
 
Copyright (c) 2014-2015 John Whitney   -   801 815 9265   -   john at johnwhitney dot com   -   Utah, USA