[GreenKeys] sending a signal to a teletype (Virgil Bierschwale)
Brent Jones
gijones at clear.net.nz
Wed Sep 4 18:07:02 EDT 2013
-------- Original Message --------
Subject: Re: GreenKeys Digest, Vol 116, Issue 2 - sending a signal to a
teletype (Virgil Bierschwale)
Date: Wed, 04 Sep 2013 18:46:09 +1200
From: Brent Jones <gijones at clear.net.nz>
To: greenkeys at mailman.qth.net
Hi Virgil
Using a Raspberry Pi to send data to a Teletype is not that hard.
I don't know about your particular machine but if it uses current loop
then it's fairly straight forward.
Being from New Zealand our early electro / mechanical teleprinters were
mostly by Creed Co in England.
I have managed to get a Creed Model 75
(http://www.baudot.net/creed/docs-alan-hobbs/creed-model-75.pdf) to
receive from a Raspberry Pi.
The Creed 75 is a 5 Bit current loop machine that tends to be set for 50
Baud although different gearing can change this speed.
Some models come with a two speed gear box.
From a programming point of view the software is easy to develop.
The main thing is by default the Raspberry Pi uses the serial port we
need as a console port which stops it being used.
However by altering some settings in the boot files you can take control
of it for your programs.
There are plenty of pages that show you how to do this.
*A sample program*
A simple program written in Python can let you easily send data to the
teleprinter.
Below is the listing of a simple test program I have created.
#!/usr/bin/python
import serial
import time
def convert(plain):
# search for character amongst possible Baudot character and return the
Baudot value letters return as correct
# value figures are returned as value + 31
# If character not found in list return -1 as value
baudot =
{'A':3,'B':25,'C':14,'D':9,'E':1,'F':13,'G':26,'H':20,'I':6,'J':11,'K':15,'L':18,'M':28,'N':12,'O':24,
'P':22,'Q':23,'R':10,'S':5,'T':16,'U':7,'V':30,'W':19,'X':29,'Y':21,'Z':17,'
':4,'0':53,'1':54,
'2':50,'3':32,'4':42,'5':47,'6':52,'7':38,'8':37,'9':55,'-':34,'%':44,'@':57,'$':51,'(':46,')':49,
'?':56,'.':59,':':55,'/':60,',':43,'=':61,'+':48,"'":36}
plain=plain.capitalize()
try:
return baudot[plain]
except:
return -1
#Set serial port for 50 Baud, 5 Bits, No Parity, 2 Stop Bits
ser = serial.Serial('/dev/ttyAMA0', baudrate=50,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.FIVEBITS
)
# write Letters shift 3 times to teleprinter to make sure motor is up to
speed if using Autostart
ser.write(chr(31)+chr(31)+chr(31))
# send two character returns and a line feed so we always start on the
left of a new line
ser.write(chr(8)+chr(8)+chr(2))
while 1 :
# send two character returns and a line feed for each line we are
printing
ser.write(chr(8)+chr(8)+chr(2))
test = "abcdefghijklmnopqrstuvwxyz 1234567890-%@$()?.:/,=+'"
# try and find a Baudot equivalent for each ASCII character in the
string
for x in test:
value = convert(x)
# if the ASCII character doesn't have a Baudot equivalent print a
'?'
if value == -1:
value = 56
# if the characters is from the Figures set output a Figures
shift code then the charcter we want
if value >31:
ser.write(chr(27)+chr(value-31))
else:
# # if the characters is from the Letters set output a Letters
shift code then the charcter we want
ser.write(chr(31)+chr(value)
Please note this is just a very basic program that can be improved and
expanded on.
For example for every character printed the appropriate Letter / Figure
shift code is sent before the character.
This gives the teleprinter double the work load. In normal operation
you would probably use a flag system so
the Figure / Letter shift is only sent when not already in the
appropriate mode for the next character to be printed.
*Hardware description
*There are many ways to do the physical interfacing between the
Raspberry PI and a Teletype I have found the use of a high
speed relay the easiest.
I chose this method because the driving circuit design is independent of
the power supply voltage needed to drive the Teletype loop.
Because in New Zealand the Post Office used double current switching we
need to use a +- power supply.
But my idea should also work on a single current device.
I chose to use two NPN transistors to drive the relay coil.
I could have possibly used just one PNP.
But as I have already proved the circuit on an Arduino driving a
teleprinter 7 days a week in a museum situation for the last 4 - 6 Months
I thought I would stick with it.
I decided that as the Mark current ( -V with respect to ground ) would
be on the line constantly I would put this through the relays normally
closed contact to minimise wear. Note that in this case the output is
taken from the common contact on the relay.
As the Pi puts out a Mark as a High signal and a space as a low I use
the first transistor to invert this. The second transistor then takes
this signal and
turns on the relay when it sees a High signal. The second transistor
also helps separate the PI from possible feed back from the relay. (
note that's not quite a technical way of putting it for the purists).
On a double current loop system the standard specified voltages are +-
80 volts.
But I have found that a teleprinter will operate with as low as 20 volts.
Originally I powered the Pi separately from the supply used for the
teleprinter.
But now I use a 16Vac alarm plug pack.
I generate +- 33V via a full wave doubler circuit.
For the Pi I rectify the 16Vac signal with a bridge rectifier.
After smoothing I use a Linear 7805 drop in replacement to get the 5V.
I made up a PCB that has power supplies on separately. The relay,
transistors etc. are mounted on another PCB that plugs directly on the Pi's
GPIO header.
The 5 Volts for the PI is feed directly into the two 5 V pins on a Ver 2
board.
The power supply ground is feed to the three ground pins.
So far I have had no problem with reliability although I used a too
small rated bridge rectifier for the %V so it gets warm.
I'll upgrade this on my next board.
I hope this gives you some ideas Virgil.
Later
Brent Jones
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qth.net/pipermail/greenkeys/attachments/20130905/389ee7b3/attachment.html>
More information about the GreenKeys
mailing list