Dot matrix printer
Dot-matrix printing
What is the materiality of dot-matrix printers?
Producing graphics and layout produced with text!
BUT. Computers don’t actually work with text.
Computers are calculators that work with numbers only.
This means that any kind of input to the computer and any kind of output from the computer exists as numbers somewhere in between.
To explore the layers and complexities of these encoding and decoding processes, dot-matrix printers are great to work with.
Turning the printers on
Taking an exploratory approach...
- Pick one printer
- Print the self-tests of the machine
- Print the menu with the current settings
Now, let's try to talk with printer from a computer.
- Connect to the printer, you can follow the #Howto section below.
- Once you are connected, print some words or plain text files from the command line. See which command works for you:
$ echo "hello" > /dev/usb/lp1 $ echo "hello" | lp $ lpr hello.txt
What language does the printer speak?
Let's zoom into the text we just sent to the printer...
To do so, we will switch to Python and send commands from there.
First we send a hello.
msg = "hello"
# Linux/OSX?
printer = open("/dev/usb/lp1", "w")
printer.write(msg)
printer.close()
# Windows/OSX
import os
printer = open("tmp.txt", "w")
printer.write(msg)
printer.close()
cmd = "lpr tmp.txt"
#cmd = "cat tmp.txt | lp"
os.system(cmd)
Here, we are sending hello
to the printer... so the character h, e, l, l, o.
What is special about these machines, is that you can not only send letters like these, but you can also send special printer commands that change the behavior of the printer.
And in order to type these characters, like a line feed character (LF), we use an 💀encoding system💀...
One famous one... is... ASCII.
$ ascii
But the printers do not speak 100% ASCII, each of them speaks their own language.
To find their language... we need to dive into their manuals.
Dot-matrix printers @ XPUB
OKI Microline 320
- owner: XPUB
- status: does not work (possibly hardware issue)
- connect to the printer: USB-A → centronics cable (you can find this one either in the office or XML, it's black)
- user manual: File:45690101EE1 ML320 UG EN 128084.pdf
- driver: https://www.oki.com/us/printing/support/drivers-and-utilities/dot-matrix-printers/62411601/
Test report 5 Feb 2025:
Joseph and Manetta tried to get this printer to work, we changed the settings to match the NEC printer, but this did not help.
Current intuition is that it is a hardware issue.
NEC PINWRITER P60
- borrowed from: Varia? Silvio?
- status: works
- connect to the printer: USB-A → centronics cable (you can find this one either in the office or XML, it's black)
- user manual: (cannot find it...)
- comprehensive support document: File:Pinwriter p6-specification.pdf
- maintenance guide: File:P60_SM_NEC_EN_text.pdf
- links: https://www.vclab.de/paperware-inventory/pinwriter-p60-p70-verdammt-nah-am-laser/# (protected with password...)
This printer has 21 pins. One is broken, you can see it.
In the back there are magnets, one for each pin, and when the electricity hits the magnet, the pin is being activated or not.
There are 2 rows of pins, one is slightly shifted (you can see it!), which makes the resolution higher. It is divided into 2 rows, because there is no mechanical space to have so many pins so narrowly next to each other in one row.
The printer works with 80 columns.
NEC PINWRITER P20
- brought to XPUB for this trimester by: Joak
- status: works
- connect to the printer: USB-A → centronics cable
- user manual: File:Pinwriter p2000p2x-manual.pdf
- links: http://www.digitanto.it/mc-online/PDF/Articoli/105_122_127_0.pdf
Running the self test: see page 5 in the manual (page 13 in the pdf)
Printing the menu with current settings: see page 17 in the manual (page 25 in the pdf) [SELECT + Power on]
Citizen Swift 90e
- brought to XPUB for this trimester by: Joak
- status: works but bumpy, see comments below
- connect to the printer: USB-A → centronics cable
- user manual: File:Citizen-swift-90-user-manual.pdf
- datasheets: File:Citizen-swift-90e-datasheet.pdf
- technical sheet: File:Citizen-swift-90-technical-sheet.pdf
The printer works, but the continuous paper feed (for the paper with holes on the sides) is a bit slippery, so you need to help the printer a bit sometimes. If you use the external paper feed adapter and work with A4, it's much smoother.
Did manage to print test pages and the menu! But did not manage to change the settings in the menu... the printer gives an error.
How to print test pages? See page 29 in the manual: Printer Self-Tests.
How to print the menu? See page 25 in the manual: Making A Print Out Of The Printer’s Default Settings.
More info on codepages? See page 32 in the manual: Codepages - International Characters.
Sending printer control commands works when you use the build-in Epson FX1170 emulation (found this in the technical sheet). See Epson FX1170 manual chapter 8 "Command Summary" for a listing of special commands.
Star SG-10
- brought to XPUB for this trimester by: Joak
- status:
- connect to the printer: USB-A → centronics cable
- user manual: File:Star-SG-10.pdf
- links: https://www.msx.org/wiki/Star_SG-10
The language in the manual is funny, very conversational :).
You can switch between character sets, "modes" and character pitch (size) using the dip switches. See page 133 in the manual.
Dot-matrix printing in practice
There is a way to speak to these pins individually.
A driver translates the pixelated image into the pins of the printer. Here you can find dithering strategies to convert an image into a type of image that could be printed on the dot-matrix printer. So dithering was a technical limitation. These days, it's often an aesthetic choice, which is different.
Before was the daisy wheel printer (close to typewriter), but with the dot-matrix printers you can make your own characters. Which helped to promote it and sell it internationally. Other character cards were also distributed, with fonts etc, which you could load into your printer.
There was not one fixed character set for all dot-matrix printers.
You send a character as ASCII, and depending on which font is loaded, it is printed.
Some ASCII characters are not printable, like the bell or the esc key. To send it, you need to send it as ASCII but translate it from another encoding system on your computer, for example with Python, and send it to the print in hex.
The user manual lists all the possible special commands that can be used.
To switch to italic for instance on the NEC P60, you need to send esc
and 4
.
To get the esc key in hex in Python: chr(27)
which returns '/x1b'
, etc.
There are also special commands to control the individual pins (!).
Each printer comes with a different set of special commands, different character sets and different fonts.
Howto
Printing on OSX
Using CUPS:
- Connect the printer with the USB cable
- Install the printer with CUPS, go to http://localhost:631 in your browser and select Administration → Add printer
- Select "Unknown" in the Local Printers section
- You can add a "name" and "location", mostly for yourself, so you can find the printer back later.. "connection" should say something like: usb://USB2.0-Print/
- For "make" (which is the manufacturer) you select "Generic" and for "model" you select "Generic Text-Only Printer", click "Add Printer"
- Your printer is installed!
- Now go to "Printers" and select your printer
- Now make this printer your default printer: click on "Administration" and select "Set as server default"
- You can now send files to the printer with:
$ lpr myfile.txt
or$ echo "hello" | lp
Backup option, without CUPS:
- Connect the printer with the USB cable.
- Go to System Settings → Printers → Add printer
- Select the USB one (the printer will start to print stuff, don't worry, you can ignore this)
- Choose "General PostScript printer" (even though this is not true!)
- Make the printer your default printer
- You can now send files to the printer with:
$ lpr -o raw myfile.txt
or$ echo "hello" | lp -o raw
Printing on Windows
lpr
should be available on Windows, so it's worth trying to add the printer through the system settings, make it your default printer, and use lpr to print- To install a generic text-only printer, you can follow these steps. If these do not work, you can follow these, but choose a local USB connection, not a network connection.
- (Backup: this is a guide to print to a line printer from Windows)
- (Backup backup: https://mendelson.org/windowsrawprint.html)
Once installed, you should be able to send files to the printer with:
> lpr myfile.txt
But! This only prints files, not output of commands like echo
.. But maybe there is a way.. this might work, it looks like it's worth a try:
Claudio's notes
First things first, I used the "CITIZEN Swift 90e" printer. On Windows I had multiple unexpected errors but after all Joseph helped and we did not end up using lpr but we used the Out-Printer command.
and the final commands were:
cat yourfile.txt | Out-Printer
or to write directly a string avoiding using a file:
"The text you want to print" | Out-Printer
Printing on Linux
Search for the printer by running this command with the USB cable unplugged and plugged:
$ ls /dev/usb/
Mine appears at: /dev/usb/lp2
Then send stuff to the printer by using > /dev/usb/lp2
, so for instance:
$ echo "hello" > /dev/usb/lp2 $ cat hello.txt > /dev/usb/lp2
Or, if you install the printer with CUPS and make it the default printer on the system (see above at OSX section), you can use:
$ cat hello.txt | lp $ lpr hello.txt
ASCII art
jp2a
lightweight tool to convert images into ascii, written by Christian Stigen Larsen
https://web.archive.org/web/20200517095853/https://csl.name/jp2a/
$ jp2a
- Linux:
$ sudo apt install jp2a
- Mac:
brew install jp2a
- Windows: https://www.samgalope.dev/2024/10/24/how-to-use-jp2a-for-creating-stunning-ascii-art/#aioseo-on-windows
Examples
Testing the PINWRITER P60 (during SI26)
linefeed = chr(10)
tab = chr(11)
italic = chr(27) + chr(4) # does not work
linespacing_big = chr(27) + chr(48)
linespacing_small = chr(27) + chr(50)
superscript = chr(27) + chr(83) + chr(0)
subscript = chr(27) + chr(83) + chr(1)
condensed = chr(27) + chr(15)
spacing_wide = chr(27) + chr(32) + chr(127) # 0 - 127
loop_start = chr(27) + chr(86) + chr(255) # 0 - 255
loop_stop = chr(27) + chr(86) + chr(0)
# printer = open("NEC_PINWRITER_P60", "w")
printer = open("/dev/usb/lp2", "w")
# printer.write("hello\n")
printer.write(loop_start + "hello " + loop_stop)
# printer.write("hello\n")
printer.close()
Pruning Station with Irmak and Aglaia (SI19)
The magic of scanner, OCR and dotmatrix printer
Python script to scan a page from a book, apply OCR (optical character recognition) and print it on the dot matrix printer.
import os
print("starting the pruning process")
scanning = "sudo scanimage --resolution 300 --mode color -o image.png"
os.system(scanning)
os.system("tesseract image.png text.txt -l eng")
fantasyname = open("text.txt.txt" , "r")
fantasyname = fantasyname.readlines()
for line in fantasyname:
line = line.split(" ")
for l in line:
if l!="" or l != ['\n', '\r\n']:
print(l)
os.system("echo '"+l+"' > /dev/usb/lp0")
Related links
- CUPS background story on Wikipedia
- Command-Line Printing and Options, about
lpr
andlp