Dot matrix printing: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 34: Line 34:


The printer works with 80 columns.
The printer works with 80 columns.
==Citizen Swift 90''e''==
[[File:Citizen-swift-90-printer.jpg|300px]]
* '''brought to XPUB for this trimester by''': Joseph
* '''status''': works, see comments below
* '''connect to the printer''': USB-A → centronics cable
* '''user manual''': [[:File:Citizen-swift-90-user-manual.pdf]]
* '''datasheet''': [[:File:Citizen-swift-90e-datasheet.pdf]]
The printer works, but the paper feed rolls are a bit slippery, so you need to help the printer a bit sometimes.
Did not manage to print the demo. Neither the menu.


==Dot-matrix printing in practice==
==Dot-matrix printing in practice==

Revision as of 10:38, 10 February 2025

OKI Microline 320

Oki-microline-320.png

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

Screenshot from 2025-02-05 13-35-48.png

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.

Citizen Swift 90e

Citizen-swift-90-printer.jpg

The printer works, but the paper feed rolls are a bit slippery, so you need to help the printer a bit sometimes.

Did not manage to print the demo. Neither the menu.

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.

Printing on OSX

Using CUPS:

  1. Connect the printer with the USB cable
  2. Install the printer with CUPS, go to http://localhost:631 in your browser and select Administration → Add printer
  3. Select "Unknown" in the Local Printers section
  4. 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/
  5. For "make" (which is the manufacturer) you select "Generic" and for "model" you select "Generic Text-Only Printer", click "Add Printer"
  6. Your printer is installed!
  7. Now go to "Printers" and select your printer
  8. Now make this printer your default printer: click on "Administration" and select "Set as server default"
  9. You can now send files to the printer with: $ lpr myfile.txt or $ echo "hello" | lp

Backup option, without CUPS:

  1. Connect the printer with the USB cable.
  2. Go to System Settings → Printers → Add printer
  3. Select the USB one (the printer will start to print stuff, don't worry, you can ignore this)
  4. Choose "General PostScript printer" (even though this is not true!)
  5. Make the printer your default printer
  6. You can now send files to the printer with: $ lpr -o raw myfile.txt or $ echo "hello" | lp -o raw

Printing on Windows

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. To do so, there are options:

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

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

Pruning Station in progress

See: How_do_We_Library_That???#Pruning_Station_with_Irmak-_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