A couple of weeks ago Jan came to me and asked me if I could build a special kind of twitter wall. At our company CoreMedia we do an Open Space every 3 months or so. This time we had a Hacking Day as well, so we needed something special. After throwing some ideas around, we came up with a twitter client that should print out tweets with an electric typewriter. A short google showed, that that has been done already (of course!). See it at oomlout.
But that couldn’t stop us. Jan scanned ebay for a nice electric typewriter and found a Commodore SQ 1000. It was in really good condition, probably rarely used. It worked as advertised.
Take it apart
First step is to take it apart. That reveals a small PCB and the connections of the keyboard. Later I realized that I hadn’t to open up the keyboard itself, because there is nothing of interest in there. It is a simple keyboard matrix.
The big chip on the right is a SEC microcontroller. The smaller chips should be there for driving the barrel etc. but I haven’t investigated that. The green foil in the middle is the connection to the keyboard. Actually there are two connections, each with 8 lines, one for the rows, one for the columns to form a matrix.
I decided, that the easiest way to simulate key presses was by shorting the switch of the desired key. I soldered two 8 line cables to the solder joints on the bottom side of the PCB. Actually there were 12 lines on one of the connectors, but 4 of these lines are used to drive LEDs for caps lock and power.
How does it work
Putting everything back in to place I tried to understand, how the keyboard matrix works. Very helpful was this tutorial, that connects a keypad to an AVR.
All 16 lines are directly connected to the controller, no external pull-up or pull-down resistors. As already said, the 16 lines are arranged to form a 8 by 8 matrix, giving 64 possible key codes. 8 lines are supplying 5V (called out) and the other 8 lines are low (called in). The controller then cycles through all out lines, pulling it down, one at a time. Then it checks if one of the in lines is pulled to low to identify the pressed key.
To simulate the key press I have to wait for low on a specific out line and then pull one of the in lines low. I used my oscilloscope to see what’s really going on. It turns out that the controller scans for key strokes with 87 Hz. Every line is low for about 150 us. I used the Arduino to record the sequence and calculate how wide the low phase is. When I would find a low on line 1 of the out line, I could use it as trigger and compute when the other lines would be pulled down. That way I would only use a single wire (and Arduino input) to detect the out line.
To set a specific in line to low I am using a 74HC595, a shift register with tristate output. The tristate is nice, because if it is disabled, the keyboard is fully functional as if the Arduino is not connected at all.
Here is everything connected on a breadboard. On the left is a standard Arduino with an Ethernet Shield.
On the right is the shift register. In the middle is a pull up resistor connected to line 1 of the out lines. That is used to be able to “see”, when the line goes down.
The software part to connect to twitter is straight forward. I used the twitter search API to pull tweets that contained the word #cos09, which was the hashtag used at the CoreMedia Open Space. The query is executed every 60 seconds and the query string looks like this:
Parsing the json formatted response is a bit ugly, mostly because memory is very limited on the ATmega168. After fetching and parsing a complete response, the max_id is stored and used for the next query. That way only new tweets are printed.
So far everything worked well, except the hash sign (#), the @ and … umlauts (*sigh*). The hash sign is not available because it only accessible by pressing the code key simultaneously, which is not possible with the current setup. The @ is not available at all, I simulate it by the sequence O-backspace-a. Umlauts are missing because … I’m lazy.
Final twitter wall setup
This is the setup as twitter wall. On the right is a video camera, recording incoming tweets and displaying them via a projector on the wall. The notebook is only bridging WiFi to Ethernet.
After all, the retro twitter wall was fairly successful. People stood around with a smile, tweeting with their iPhone, waiting for an intense “rattatatat rattatat …”.
Here is another action shot, taken by Jörn.
Very nice. Back in the Eightees, I used a ZX81 to connect it to a mil teletypewriter in a similar way. And to a commercial 120-char-wide Centronics Matrixprinter with a 230V/110V transformer, all operating in my living room. Noisy. Very much looked like your breadboard.
Can you compare the shift-register approach you took on this project with the 4051-multiplexer approach taken by oomlaut?
I’m a bit of a newbie at this but here is what I am able to observe: The 4051-multiplexer approach doesn’t seem to be concerned at all with sensing the scanning. However, that comes at a cost of the increased part count of 2x 4051’s to connect the full keyoard matrix (vs the 1 shift register you use here).
Conversely, the shift register reduces the part count, but that comes with the requirement to measure the scanning frequency of the keyboard encoder in advance such that the timing of the out-line lows can be captured in the software. The wiring of the full matrix might still need to be done in order to measure the scanning interval on the out-lines, even though only one of the out lines is used in the final implementation.
Curious to know your thoughts…
your analysis is absolutely correct.
I chose the shift register mostly because I had no multiplexers at hand ;)
You can even drop the shift register if you have enough pins on your controller.
It’s more or less a matter of taste, which route you go.
Hellp. My son and I built the typewriter controller that you talk about using a shift register, but the code you posted is for a multiplexer. Do you still have the code for a shift register installation?
Thank you for sharing your great work.
my code uses a shift register (74595). The oomlout example uses a multiplexer.
Comments are closed.