You are on page 1of 6

AN00128-000 – Mint based HPGL

Related Applications or Terminology


Supported Controllers
■ XY positioning
NextMovePCI 5
■ Tangential knife cutting
NextMoveBX II
5
■ Plotting NextMoveST 5
■ Routing NextMoveESB 5
NextMoveES 5
Overview
MintDriveII 4
The HPGL interpreter (Hewlett Packard Graphics Language)
demonstrates the power and flexibility of the MintMT programming Flex+DriveII 4
language when combined with the latest generation NextMove
controllers. FlexDriveII 4
HPGL is an industry standard protocol used in plotters and printers.
In industry it is used in many applications such as vinyl and cloth
cutting, glue laying, routing and laser cutting. HPGL is a very simple
Relevant Keywords
ASCII based protocol that is executed on the fly. An example of VECTORA/VECTORR
HPGL is:
CIRCLEA/CIRCLER
PR100,200;PU;
KNIFE
This will move the X axis 100 units, the Y axis 200 units and when
completed, move the pen (or knife or router) to the up position. CONTOURMODE

HPGL output can be generated from many applications, such as


CorelDraw and Adobe Illustrator and as such makes for a low cost solution, without the need for
expensive drawing tools.

An HPGL interpreter has been written in the Mint language. This not only demonstrates the power
and flexibility of the Mint programming language, but also allows HPGL to be tailored to your
application.

The HPGL Command Set


The Mint HPGL interpreter supports a subset of the HPGL command set that is suitable for
applications such as cutters and routers. For a complete reference to HPGL and HPGL/2 download
the PDF file at
http://h20000.www2.hp.com/bc/docs/support/SupportManual/bpl13211/bpl13211.pdf.

The following HPGL commands are supported:

© Baldor UK Ltd 2004 1 of 6


AN00128-000 Mint based HPGL.doc
Command Format Parameter
AA Arc Absolute AA x,y,c (,d); x: X center coordinate
Draws an arc with absolute coordinates y: Y center coordinate
c: Center angle
d: ignored
AR Arc Relative AA x,y,c (,d); x: X center coordinate
Draws an arc with relative coordinates y: Y center coordinate
c: Center angle
d: ignored
CI Circle CI r (,d); r: Radius
Draws a complete 360 degree circle. d: ignored
DF Default DF;
- Sets plotter to absolute coordinates
(PA;)
- Sets pen speed to default setting (32
cm/sec)
EA Edge Absolute EA x,y; x: X absolute coordinate
Draws a rectangle using absolute coordinates y: Y absolute coordinate
ER Edge Relative ER x,y; x: X relative coordinate
Draws a rectangle using relative coordinates y: Y relative coordinate
IN Initialize: IN;
- Performs a DF; command
- Performs a Pen Up (PU;) operation
- Clears any errors and sets the third bit
of the status byte
OA Output Actual OA;
OE Output Error OE;
Outputs error code, which conform to the
following bit pattern:
0 Unrecognized command set
1 Wrong number of parameters
2 Unusable parameter
3 Unused
4 Unused
5 Unused
6 Unused
7 Unused
OS Output status OS;
0 Pen Down
1 Unused
2 Unused
3 Initialized (cleared by OS)
4 Unused
5 There is an error (cleared by OE)
6 Unused
7 Unused
PA Pen Absolute PAx1,y1(,x2,y2,…); xN and yN are absolute values.
Sets absolute coordinates and moves the XY axes PA;
to the absolute values if given
PD Pen Down PD; xN and yN are coordinate values.
Move the pen down. Move the XY axes if PDx1,y1(,x2,y2,…); The absolute and relative values
coordinates are given. PA/PR determines if the XY are determined by the PA/PR
values are interpreted as absolute or relative commands.
values.
PR Pen Relative PRx1,y1(,x2,y2,…); xN and yN are relative values.
Sets relative coordinates and moves the XY axes PR;
to the relative values if given
PU Pen Up PU; xN and yN are coordinate values.

© Baldor UK Ltd 2004 2 of 6


AN00128-000 Mint based HPGL.doc
Move the pen up. Move the XY axes if coordinates PUx1,y1(,x2,y2,…); The absolute and relative values
are given. PA/PR determines if the XY values are are determined by the PA/PR
interpreted as absolute or relative values. commands.
SP Select Pen SPn; n: Pen number between 0 and
Selects a pen. The default action will change the SP; 10. Action will be custom
XY velocity (VS) to the value set by the VS designed within the MintMT
command. Default is 32 cm/sec. program. Default action is to set
Other actions can be programmed by MintMT. the velocity as defined by the VS
command.
VS Velocity Select VSv(,p); v: Velocity value. Usually set in
Sets the XY velocity in units of cm/sec. Default is units of cm/sec.
32cm/sec. If p is given, assigns the velocity
value to the pen number (1 to
10). See SP.

Accepting Files
The HPGL interpreter will accept raw ASCII data that makes up the HPGL file.

IN;
VS57,1;
VS32,2;
VS32,3;
VS32,4;
VS32,5;
VS32,6;
VS32,7;
VS32,8;
SP7;
PU-1004 2919;
PD-868 3067;
PD-868 3067;
PD-867 3068;
PD-866 3069;
PD-864 3071;
PD-863 3072;
PD-861 3074;
PD-860 3075;
PD-858 3077;
PD-857 3079;
PD-855 3080;
PD-854 3082;
PD-852 3083;
PD-851 3085;
PD-849 3087;

When the commands are received, they are immediately executed. This allows files of unlimited
size to be processed.

Serial Buffer and Handshaking


The NextMove controllers do not have any form of handshaking when accepting characters over
the serial port. This presents a problem with HPGL, where files can be of unlimited size. This
problem is overcome by implementing software handshaking in Mint. This is achieved with the
Mint task SerialBufferTask. The task continuously polls the serial buffer (read using INKEY) for
any characters. If the Mint serial buffer starts to get full, an XOFF command is sent over the serial

© Baldor UK Ltd 2004 3 of 6


AN00128-000 Mint based HPGL.doc
buffer. It is down to the host application to receive this XOFF character (ASCII code 19) and stop
sending characters. When the serial buffer starts to empty, an XON character (ASCII code 17) will
be issued. This is a signal for the host application to start sending more data.

The size of the Mint serial buffer has been set at 1024 characters, but this can be increased within
the bounds of the available memory on the controller.

Z Axis Control
The HPGL interpreter can be configured for different applications such as:

• Pen plotter

• Router

• Tangential knife cutter

• Glue laying

• Laser cutting

Since the HPGL interpreter is written in Mint, it is a case of modifying the source code to suit the
application. Some predefined Mint macros have been created to assist:

zOUTPUT Z axis is controlled by a digital output

zKNIFE Z axis controls a tangential knife

zMOVE Z axis is controlled by an axis, allowing different Z positions to be achieved

The type of axis control for Z is configured in the DefaultHPGL subroutine.

The Pen or Z axis is controlled by the use of the PD (Pen Down) and PU (Pen Up) commands. The
HPGL interpreter supplied sets and clears Output 7 in response to the PU/PD commands.

The action taken by the PD/PU commands can be altered by modifying the code in the
subroutines MovePenUP and MovePenDown.

Customizing the HPGL Interpreter


The HPGL interpreter is supplied as MintMT source code and is fully customizable to suit the
application. All sections of code that can be modified are marked with the comment:
‘**UC

Open the Mint editor in the Mint WorkBench and press Ctrl-F for find. Enter **UC in the search
box to locate all sections of customizable code. Each of the User Code (**UC) sections are
described:

**UC 1
User code section 1 defines which digital output controls the pen. This is defaulted to output 7.

© Baldor UK Ltd 2004 4 of 6


AN00128-000 Mint based HPGL.doc
**UC 2
User code section 2 defines the scaling used to convert the velocity parameter (set by the VS
command) to units of cm/sec. The default value is 100.

**UC 3
User code section 3 defines the Z position values. This is set in user units and determines the
maximum and minimum position values for the Z axis. These parameters are only used if the Z
axis is a driven axis.

**UC 4
User code section 4 defines the axis numbers for the X, Y and Z axes, as well as the tangential
knife.

**UC 5
User code section 5 defines the Z axis control. Remove the comment for the Z axis control
required.

**UC 6
User code section 6 defines the action taken on a PU (Pen Up) command. This is coded to set an
output (defined in UC 1), or move the Z axis to a defined position (defined in UC 3).

**UC 7
If the Z axis has been defined for tangential knife control, this line of code needs to be
uncommented.

**UC 8
User code section 8 defines the action taken on a PD (Pen Down) command. This is coded to set
an output (defined in UC 1), or move the Z axis to a defined position (defined in UC 3).

**UC 9
If the Z axis has been defined for tangential knife control, this line of code needs to be
uncommented.

**UC 10
User code section 10 is the Knife event. This is called when a knife changes status. In order to
add this code to the MintMT program, remove the /* and */ from the source code.

**UC 11
User code section 11 defines what happens in the event of an error. The OnError handler should
be customized to suit the application.

© Baldor UK Ltd 2004 5 of 6


AN00128-000 Mint based HPGL.doc
Commissioning
It is important to fully commission the NextMove controller and set the gain terms and I/O
configuration. Once commissioning is complete, the parameters should be uploaded to the
StartUp block in the Mint program. This is achieved from the Tools->Upload Parameters menu.

The axes will also need to be datumed or homed. This will depend upon the configuration of the
X, Y and Z axes. This operation can be performed in the StartUp block, or alternatively executed
in the HPGLInterpreter subroutine.

Debugging
The variable Debug has been defined to allow some simple debugging. If this is set to _TRUE,
various messages will be displayed during the execution of the HPGL file.

© Baldor UK Ltd 2004 6 of 6


AN00128-000 Mint based HPGL.doc

You might also like