please dont rip this site

ESC Printer Control Language

by Bob Dring ^

Also:

1 Introduction to this document

I had some problems with printing dimensionally accurate stuff on an Epson printer that it was never meant to do.  {ed: related to using Inkjet printers to directly print etch resist onto copper clad stock for PCB production} I ended delving deeply into its ESCP2 printfiles and I want to preserve the results for others.

We all stand on the shoulders of others to get a better view and I would like to thank the programmers responsible for the Gimp and Gutenprint open source project for their work. Also thanks to the members of the Yahoo Inkjet PCB Construction newsgroup ^.

2 Introduction to ESCP2

Epson printers have been around a long time from the early dotmatrix ones up to the latest inkjet Photo ones. The early printers actually printed characters and needed some special control codes to set the printer internal fonts etc. This was the birth of the ESC format which has been added to continueously to handle every printer since. This includes the ones that today that only really print an image of the text.

Epson wanted to send the control codes to the printer in a way that you couldn't see on the page so they allowed the printer to swallow and action such commands provided they were prefixed by a special unprintable character, it was the Escape character, decimal 27 hex or 1B. This is how the printing format got its name, later versions became known as ESCP2. In those early days the Epson printer manual had a complete section listing what ESC commands you could send to the printer and what they did. The manual showed that the letter following the ESC character was used to signal the function of the command to the printer. The function letter was followed by any numeric parameters required, like 1 for 'on' and 0 for 'off'. There seems to have been an early attempt to make the commands memorable by using a letter that was connected with the function, ESC G for example is used for setting the Graphics mode. As the remaining letters were assigned by Epson to more functions, many had to be the unmemorable or even unprintable characters. Documenting of the ESC functions is now done easier by using the function byte as a number rather than a character. The hexadecimal representation is popular but decimal is also used. For example the 'G' function now becomes ESC 0x47 in hexadecimal.

In more recent times Epson are more coy about ESC commands and probably don't see the need for anyone to meddle at that level anymore. There is also probably some sound marketing reason that they don't want to share around the newer ESC commands.

3 The ESCP2 File

Most people today have never seen a print file. But one is made any time that the operating system is used to print something. The file goes straight to the printer and all its traces are deleted. There are ways to create a print file to examine but they may be operating system specific. Generaly there is some means provided to 'print to file'. It should be noted that the printfiles are manufacturer specific and that they are created only to suit the intended printer.

Sending data to a printer today is an easy task to do but down at the lowest levels it takes a lot of data and this could slow down the measured print speed mentioned in the printer specification. ESCP2 implements a few schemes to reduce the impact of this. The actual commands are never needed to be read and understood by a human so they are made as terse as practical, but that doesn't speed thing up much. Making the files into a binary format, however reduces the file size considerably. Finally the big blocks of image data that are now used almost exclusively lend themselves to worthwhile data compression.

4 Command Formats

Generally speaking the ESC commands fall into two format types. Most of the older ones that are still used today cover functions like resetting the printer in preparation to print and similar actons that still have some relevence. These commands are each of a fixed length but one command may be a different length to another. These legacy commands used up a lot of the ESC character combinations that were available and as time passed Epson started to be more thrifty to stave off the day when they could no longer find a new free one to use. The newer commands start the same way with one of the now precious unused older type It's the ESC '(' command but now it is followed by a sub command character that allowes 256 more commands to be encoded for the cost of that one ESC '(' command. The newer sub commands have an imbedded byte count field that allows every command to have its own or even a choice of lengths.

5 Command Types

There are 4 categories of commands. One type is for 'general control' of the printing functions like the reset just mentioned or the undirectional/bidirectional printing option. Another category are commands that involve 'paper settings' like the page length or what location an image is to be put on the page. A third type contains the actual 'image data' blocks. Since the printer doesn't have enough memory to hold a complete image at one time, several image data blocks are used with each containing a band of the total image. Finally, there are the undocumented 'REMOTE 'commands that have evolved into a private way in which the Epson driver can access the workings of the printer like selecting the paper source or checking the ink levels.

6 Command parameters

Many ESC commands have numeric parameters. For example, the previously mentioned Graphics ESC 0x47 command has a 0(zero) or a 1(one) with, in this case, the meaning 'off' and 'on'. The early Epson printers used Intel processors to handle the received ESC commands as well as controlling the printing mechanism. The ESC numeric parameters are expressed in the 'little endian byte' form that is most easily handled by this Intel hardware. It is likely that there is no longer a need to do this today but for compatibility reasons it has been retained. It must be stressed that all parameters are not numbers and so are not affected. The actual image data is an example of this.

Little endian byte format explanation

Single byte parameters
Single byte are not affected. A 0x12 parameter is simply a 0x12 byte in the ESC command.

Double byte parameters
Double bytes are reversed. A 0x1234 parameter is 0x3412 in the ESC command.

Quad byte parameters
Quad bytes are also reversed double bytes . A 0x12345678 parameter is 0x34127856 in the ESC command. Quad byte parameters are a more recent innovation in ESCP2. They are needed to cope with the large parameters that are used with high resolution printing

As clarification of the above. A double byte parameter, perhaps representing a really small page width, of 0x0008 has the value 0x0800 in the ESC command.

See also:


file: /Techref/language/ESC.htm, 7KB, , updated: 2011/5/11 16:07, local time: 2024/11/18 22:31,
TOP NEW HELP FIND: 
18.217.209.164:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/Techref/language/ESC.htm"> ESC Printer Control Language</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .