Electronics project notes/Thermal printer notes
| These are primarily notes|
It won't be complete in any sense.
It exists to contain fragments of useful information.
I once got thermal printers (Point of Sale style, typically for receipts) to play with, so here are my notes.
The wiring and signaling can be slightly specific to a model, so read the manual.
I have a serial printer (Parallel also exists, and transport via USB and ethernet is similar).
In my case, Having Ground, Rx, Tx, and a single hardware flow control pin ('my buffer is full, pause please') was enough.
Keep in mind this may be the +15V/-15V variant of serial. If you want to connect to TTL level (0-5V) serial port you'll need a MAX232 or similar.
Higher port speeds are nice if you want to print fine bitmap graphics not-very-slowly.
ESC/POS is a standard from Epson, with a series of revisions. Some commands are new, some outdated, so not all ESC/POS printers support everything.
Characters special in some way:
- Many commands start with ESC (0x1B),
- a bunch with GS (0x1D)
- a few with FS , relating to non-volatile memory
- LF (0x0a) and FF (0x0c) have similar but specific meaning depending on whether the printer is in standard or page mode
GS V m GS V m n
- 0 or '0' - full cut (if supported)
- 1 or '1' - partial cut
- 65 - feed n lines according to current pitch, then full cut
- 66 - feed n lines according to current pitch, then partial cut
If the cutter is after the print head, cutting without movement would cut off perhaps three lines of of what we just printed. This is why some feed is part of the command (you could of course manually feed too, if you want more control).
If cutting is not supported, the feed-and-cut commands still feed.
When you mix text, bit images, barcodes (and variants, such as double-height text),
...there are various well-defined details to how these will be printed alongside (or not) and how far they will extend horizontally and vertically. Read the standard :)
ASCII is typically printed as-is.
Non-ASCII is typically handled through codepages.
You can also often define your own character set.(verify)
Line wrapping is applied automatically (though for e.g. receipts it may be less messy if you can avoid this).
Be aware of potentially different handling between:
- regular text
- magnified text
- HRI (Human Readable Interpretation), the text under a barcode
- chinese characters
Magnification: GS ! n n is two nibbles, for horizontal and vertical where. Bitwise:
- 0000 for 1, though to 0111 for 8
- 1000-1111 undefined
Standard mode and page mode handling of text
- Standard mode prints lines, that is, it acts when it sees a LF character in the text data
- Page mode buffers incoming text data, but does not act until it gets
- ESC FF (print and stay in page mode)
- FF (print and switch to standard mode)
- There are a few commands that are ignored, completely or selectively, in one of the modes
- In most cases it's fairly obvious (e.g. switching to the already active mode, printing bit images in page mode)
- in other cases it is more interesting, e.g setting text direction
Switching between the modes:
- ESC L: switch to page mode
- ESC S: switch to standard mode (presumably clear page mode's leftover buffer(verify))
Print region, direction
ESC W - set margin ESC T - set print direction
Bit graphics(0x )
- now obsolete, but is typically still supported
- takes data from
- useful for one-time use
Download bit images
- sets current download image
- prints current download image
- Useful for e.g. store logo
- Size restrictions:
- x in 1..255 (units of 8 dots)
- y in 1..48
- (x*y) must be <= 1536
- So, for example, if the print width is 576 dots, x=72, so y must be <=21
Download bit images are meant for re
Status and such
- ESC @ (0x
- Clears the print buffer, download bit images
- Retains reception buffer, DIP settings, macros, NV bit images,
- leaves the printer in standard mode