Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 49 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
49
Dung lượng
204,5 KB
Nội dung
Understanding HPGL
Hewlett-Packard has found itself in the fortunate position of having creating two de facto standards
for output devices: HPGL (short for Hewlett-Packard Graphics Language) and PCL, short for
Printer Control Language. Although HPGL was intended for HP's line of pen plotters, variants have
found their way into inkjet and laser printers. PCL, on the other hand, is strictly used by HP for its
raster devices and is very slowly loosing favor to PostScript and Windows-based direct-GDI.
A Brief History of HPGL
HPGL is a command set embedded in the ROM of pen plotters to help reduce the work
required by applications programmers to create plotted output. HPGL uses two-letter
mnemonics as instructions for drawing lines, circles, text, and simple symbols. HPGL has
evolved over the years as HP added features to its line of pen, electrostatic, inkjet, and
laser plotters and printers.
However, there is one primary drawback to HPGL: it is bulkier than other plotting
languages, which means it takes longer to transmit an HPGL plot file than, say, a Houston
Instruments' DM/PL (short for digital microprocessor plotting language) plot file. To
overcome the limitation, Hewlett-Packard in 1988 introduced HPGL/2, which featured
"polyline encoding," a form of data compression that reduces the plot file size and, hence,
transmission time by two-thirds.
With HPGL being the de facto plotting standard, competitors inevitably include HPGL or
some similarly-named dialect in their plotter products. In addition, HPGL has become a
form of CAD drawing translation of last resort, since all CAD packages produce HPGL files
and several read the format.
Coordinate Systems
One irritant to HPGL is that there are two different coordinate systems in use. Small-format
plotters, including A- and B-size plotters, locate the origin at the lower-left corner; large-
format plotters, including D- and E-size plotters, located the origin at the center of the
media.
TIP: HPGL uses the plu (short for plotter units) as its form of measurement. There are 40 plu per
millimeter and 1,016 plu in one inch.
All plotting languages have two forms of limits: (1) hard limits; and (2) soft limits. The hard
limits are the limits beyond which the plotter cannot plot due to physical constraints. The
soft limits are usually imposed by the application software generating the plot file. Any part
of the drawing extending beyond the limits (hard or soft) is clipped (is not be plotted).
HPGL names the plot extents as P1 (the lower-left corner) and P2, the upper-right corner.
Reading An HPGL Plot File
A typical HPGL plot file consists mostly of ASCII characters with some control codes
thrown in. You can read the file with any text editor. Since the plot files tend to be written
as one long line (no CR or LF), it is helpful to have a text editor with no limitation on line
length.
To produce a sample HPGL file, configure a CAD package to plot to file using an HPGL
driver (possibly called "HP Plotter" or given a specific model number, such as HP7220 or
HP7586). Create a very simple drawing (a couple of lines), then plot the drawing to disk.
When you load a plot file into the text editor, it looks something like this:
Plot initialization data:
[Esc].(;.I81;;17:[Esc].N;19:IN;SC;PU;PU;SP1;LT;VS36;
Plot data:
PA12345,4567;PD;PA-2345;6789; et cetera
Plot termination data:
PU;PA0,0;SP;EC;PG1;EC1;OE;
Decoding the HPGL Code
HPGL consists of two kinds of instructions:
• 1 HPGL instructions.
• 2 Device-control instructions (or DCI, for short).
The most typical HPGL instruction is:
PA1234,5678;
The PA instruction moves the pen to absolute position (1234,5678) in plu coordinates. The
instruction has four parts to its syntax: PA is an HPGL command (in this case, to move the
pen).
1234 and 5678 are parameters (in this case, absolute coordinates).
, a separator (the comma) between two or more parameters.
; and a terminator (the semi-colon).
PA All HPGL instructions start with a two-letter mnemonic. For example, PA is the
abbreviation for Pen Absolute, a pen positioning command. Other common command
mnemonics include:
• PD for pen down
• PU for pen up
• SP for select pen
• VS for velocity speed.
1234 and 5678 Most HPGL instructions include one or more parameters to modify their
meaning. Here, 1234 and 5678 are the absolute pen coordinates in plu. Parameters of
other instructions are the pen number and plotter speed.
TIP: To use the default parameter of an instruction, simply leave out the parameter value.
, (separator) When an instruction uses more than one parameter, HPGL wants them
separated with:
• a comma ( , )
• a space ( )
• a plus sign ( + )
• a negative sign ( - ).
TIP: HP recommends use of the comma as the separator; only use the negative sign with negative
values.
; (terminator) To indicate the end of the instruction, you have the option of using a semi-
colon ( ; ) or nothing at all.
TIP: Use the semi-colon when you want to make the plot file legible to humans; use no terminator
to significantly reduce transmission time and file size.
Device-Control Instructions
HPGL uses device-control instructions to set up the plotter's hardware. These instructions
set up communications between the CAD software and the plotter, return plotter status
data, reset the plotter, et cetera.
Device-control instructions (DCI, for short) begin with the escape character (ASCII 27, or
1B in hex) shown as [Esc] in this tutorial. Text editors often show Escape as a left arrow
( <- ) or as Ctrl-Bracket ( ^[ ). A typical HP device-control instruction looks like this:
[Esc].N0;19:
The purpose of this DCI is to specify the Xoff (short for transmission off) trigger character,
which tells the plotter which ASCII character the CAD software expects to receive as the
Xoff character, as follows:
• [Esc]. (Escape followed by period) Alerts the plotter that a device-control instruction
follows.
• N This DCI specifies the Xoff handshake character.
• 0 Value of intercharacter delay.
TIP: The default value is zero; default DCI values can be omitted, as in [Esc].N;19;
• ; (separator) Separates DCI parameters.
TIP: The separator is optional for DCIs that don't use parameters.
• 19 The ASCII value of the Xoff character. ASCII 19 is DC3, a commonly-used value.
• : (terminator) Terminates the DCI.
TIP: DCIs with parameters must end with the colon ( : ); the terminator is optional for DCIs
without parameters.
Initializing the HPGL Plot File
A typical HPGL plot file consists mostly of ASCII characters with some control codes
thrown in. The plot initialization data (in this case, generated by AutoCAD R11) looks
something like this:
[Esc].(;[Esc].I81;;17:[Esc].N;19:IN;SC;PU;SP1;LT;VS36;
To make it easier to read, let’s reformat the data with one instruction per line:
[Esc].(;
[Esc].I81;;17:
[Esc].N;19:
IN;
SC;
PU;
SP1;
LT;
VS36;
[Esc].(; instructs the plotter to interpret data as HPGL and DCI instructions, rather than
plotting the data stream as literal text characters. This DCI has no parameters; [Esc].Y is an
alternative provided by HPGL.
[Esc].I81;;17: sets the parameters for Xon-Xoff handshake mode, with the following
parameters:
• 81; (Xoff threshold level) When 81 bytes remain free in the plotter buffer, the plotter sends
the Xoff instruction to the CAD software. Xoff tells the CAD software to stop sending data,
otherwise the plotter buffer fills up and data is lost. TIP: If the byte size is too large, HPGL
automatically reduces the size to one byte smaller than the plotterþs logical I/O buffer size;
use [Esc].Sn: to find the size of the buffer.
• ; (ommited parameter) Since the next parameter is missing, the plotter is able to differentiate
between Xoff/Xon and Enq/Ack protocols. TIP: You can substitute 0 (zero) for the ommited
parameter.
• 17: (Xon trigger character) After the CAD software stops sending data to the plotter, the
plotter uses the Xon trigger character to tell the software to continue sending data. ASCII 17
is DC3, the standard value. TIP: You can specify any decimal ASCII value between 0 and
126 and use as many as ten characters.
[Esc].N;19: was described earlier.
IN; (INitialize) Resets most of the plotter's functions to default settings, some of which
follow:
• Set linetype to solid (equivalent HPGL instruction is LT0;)
• Set plotting mode to absolute (PA;)
• Set chord angle to 5 degrees (CT;)
• Turn off user scaling (SC;)
• Recognize all HPGL errors (IM;)
• Set input window to hardclip limits (IW;)
• Set units to metric and pen width to 0.3mm (PT;)
• Lift pen (PU;) and move it within 600 plu of hardclip limits
TIP: Settings made on the plotter's front panel are not reset.
TIP: Recall that the semi-colon ( ; ) terminator is optional.
SC; (SCale) Scale the coordinate system to the plot's extents, P1 and P2; the default is no
scale (the CAD software handles the scaling).
PU; (Pen Up) Lifts the pen; optionally moves the pen to a new location.
SP1; (Select Pen) Selects a pen, #1 in this case.
TIP: HPGL automatically returns the current pen to its holder at the end of a plot.
LT; (Line Type) Selects the linetype and pattern length; the default is continuous lines (the
CAD software handles the linetype generation).
VS36; (Velocity Select) Selects the pen speed in cm/sec; optionally selects the pen by
number.
TIP: The pen speed is sometimes overruled by the setting of the pen carousel. HP suggests using a
slower speed to create a slightly thicker line (but at the expense of longer plot time).
An Introduction to HP-GL/2 Graphics
=========================================
What is HP-GL/2?
Vector graphics uses less memory than raster graphics, when being stored, as well as having a more
efficient Input/Output transfer of large images when printing, (it will print faster). When printing in
HP-GL/2, the printer will define points "a" and "b" then draw a line between them, in raster the
printer defines every point between point "a" and point "b".
HP-GL/2 History
HP-GL/2 was added to the PCL language in PCL Level 5, for LaserJet III family printers and is
supported in LaserJet 4 family printers with PCL Level 5 Enhanced. To print in HP-GL/2 you are
required to leave the PCL environment and enter the HP-GL/2 environment. Switching into and out
of HP-GL/2 requires only a few commands, and cannot be done through the front menu panel.
Some software applications may easily switch between the two modes as needed without affecting
performance.
Learning HP-GL/2
The best way to learn HP-GL/2 is to read the "Introduction to HP-GL/2 Graphics" in the PCL 5
Printer Language Technical Reference Manual for an overview of HP-GL/2. Then find the specific
commands you need in subsequent chapters. Reading through the examples, then trying to print
them using a text editor or programming language is the best way to learn HP-GL/2.
Absolute Arc Three Point (AT) Command
=========================================
The AT command is Absolute Arc Three Point, and draws an arc segment, using absolute
coordinates, from a starting point, through an intermediate point, to an end point. For more
information see the PCL 5 Printer Language Technical Reference Manual.
LEGEND: Ec = [Ctrl] [P] [Esc] in DOS EDIT
EcE Resets the printer.
Ec%0B Enters HP-GL/2 mode.
IN; Initializes HP-GL/2 mode.
SP1; Selects pen number 1 (black). Even though there is no physical pen, the SP command must
be used to enable printing.
PA1000,100;PD2500,100; Specifies (1000,100) as the starting location, places the pen down,
and draws a line to (2500,100).
PU650,1150;PD1000,1150; Lifts the pen up and moves to (650,1150), then places the pen down
and draws a line to (1000,1150).
PU650,450;PD1000,450; Lifts the pen up and moves to (650,450) then places the pen down,
and draws a line to (1000,450).
PU1000,100;PD1000,1500,2500,1500; Lifts the pen up and moves to (1000,100), then places
the pen down and draws a line to (1000,1500), then
draws a line to (2500,1500).
AT3200,800,2500,100; Prints an arc, starting at the current pen position (25,1500), passing
through (3200,800) and ending at (2500,100).
PU3200,900;PD; Lifts the pen and moves it to (3200,900), and sets the pen down.
AT3300,800,3200,700; Prints an arc, starting at the current pen position, passing through
(3300,800) and ending at (3200,700).
PU3300,800;PD3500,800; Lifts the pen to (3300,800) and then puts the pen down and draws a
line to (3500,800).
Ec%0A; Enters PCL mode.
EcE Sends a reset to end the job and eject the page.
Absolute Character Size (SI) Command
=========================================
The Absolute character Size (SI) command, specifies the size of labeling characters in centimeters.
For more information see the Updated PCL 5 Printer Language Technical Reference Manual. The
syntax for this command is as follows:
SI width, height; or SI;
LEGEND: Ec = [Ctrl] [P] [Esc] in DOS EDIT.
EcE Resets the printer.
Ec%0B Enters HP-GL/2 mode.
IN; Initializes HP-GL/2 mode.
SP1; Selects pen number 1, (black). Even though there is no physical pen,
the SP command must be used to enable printing.
PA700,3000; Enters absolute plotting mode and moves to (700,3000).
DT#; Defines the label terminator as the "#" character.
LBPrint#; Prints the word "Print" in the default font.
PA700,2000;SI1,1.5;LBPrint#; Moves to (700,2000); specifies an absolute character size of 1
cm wide by 1.5 cm high; prints the word "Print".
SI; Send SI with no parameters to return to the default size.
SD1,21,2,1,4,12,5,0,6,0,7, 4148;SS; Designates a 12 point Universe font and selects it.
PA 4000,3000;LBPrint#; Moves to (4000,3000) and prints the word "Print" in the 12 point
Universe font.
PA4000,2000;SI1,1.5;LBPrint#; Moves the pen to (4000,2000) and specifies a character size of
1 cm by 1.5 cm; prints the word "Print".
Ec%0A Enters PCL mode.
EcE Sends a reset to end the job and eject the page.
Anchor Corner (AC) Command
=========================================
The AC command positions the starting point of any fill pattern. By using this command you ensure
that the selected fill pattern is positioned as expected within the figure. For more information see
the PCL 5 Printer Language Technical Reference Manual.
LEGEND: Ec = [Ctrl] [P] [Esc] in DOS EDIT.
EcE Resets the printer.
Ec%0B Enters HP-GL/2 mode.
IN; Initializes HP-GL/2 mode.
SP1; Selects pen number 1, (black). Even though there is no physical pen, the SP command must
be used to enable printing.
PA3000,3000; Specifies absolute plotting and moves to location (3000,3000).
FT3,400,45;RR1000,1000;
ER1000,1000; Specifies a fill type of number 3 (parallel lines), with each line 400 plotter units (plu)
apart and set at a 45 degree angle. RR fills a rectangle using the current pen location as the lower
left corner, and a point 1000 plu to the right and 1000 plu up as the upper right corner. The ER
edges the same rectangle just filled.
PR1000,0;FT4,400,45;RR1000,
1000;ER1000,1000; Moves 1000 plu to the right, andselects fill type 4 (cross-hatch); then draws a
rectangle the same size as the first one, and fills it with the cross-hatch pattern just specified, then
edges it with the ER command.
PR1000,0;FT3,400,45;
RR1000,1000;ER1000,1000; Moves to the right another 1000 plu, and creates another rectangle of
the same size, then fills this one with the number 3 fill pattern again. Then edges the rectangle just
specified.
PA3000,1500;AC3000,1500;
RR1000,1000;ER1000,1000; Moves the pen to absolute position (3000,1500), and moves the
anchor corner to location (3000,1500). Fills a rectangle with the fill pattern selected (number 3 from
the command above), and
edges it.
PA4000,1500;AC4000,1500;
FT4,400,45;RR1000,1000, ER1000,1000; Moves to location (4000,1500) andspecifies the
location as the anchor corner. Selects fill type number 4 again, then fills, and edges a rectangle.
PA5000,1500;AC5000,1500;
FT3,400,45;RR1000,1000;
ER1000,1000; Moves to absolute location (5000,1500)and specifies that location as the anchor
corner, then selects fill type 3 again, and fills and edges another rectangle.
Ec%0A Enters PCL mode.
EcE Sends a reset to end the job and eject the page.
NOTE Due to space limitations these lines of code appear on more than one line. When entered into
the DOS editor they should appear on one line.
[...]... following example will be done using the DOS text editor EDIT Creating a File Using EDIT to Enter HP-GL/2 LEGEND: Ec = [Ctrl] [P] [Esc] in DOS EDIT 1 At the DOS prompt type EDIT HPGL2 .MOD and press ENTER This will create a new file called HPGL2 .MOD that you can save and use to enter HP-GL/2 mode whenever you want After you press enter, the EDIT screen will appear 2 The escape character in EDIT is done by pressing... escape character in your editor) 3 In EDIT the escape character is represented by a left arrow, in this example we will use "Ec" EcE Resets the printer Ec%0B Enters HP-GL/2 mode with the pen at the default HPGL/ 2 pen position (The lower left corner of the page) 4 Send these commands to the printer by selecting FILE, PRINT, Full Document and OK if you have a mouse -ORPress ALT, F, P, then ENTER You will now... buffer Input Window (IW) Command ========================================= In HP-GL/2 you can create a window where your image will print If your HPGL/ 2 commands move the pen outside of that window, the part of the image that is outside will not print The IW command or Input Window command will let you define this window where the image will print . HPGL Code
HPGL consists of two kinds of instructions:
• 1 HPGL instructions.
• 2 Device-control instructions (or DCI, for short).
The most typical HPGL. be plotted).
HPGL names the plot extents as P1 (the lower-left corner) and P2, the upper-right corner.
Reading An HPGL Plot File
A typical HPGL plot file