🏠 | RFID | ZPL |

Zebra Programming Language

Introduction

→ ZPL FAQ ←

Full ZPL manual on Zebra website. The manual is good and has examples included. The disadvantage of the original manual is that some relations are not visible for the beginners: → ZPL ←.

For better readability of my manal I will emphasize commands with bold font.

Parameters will be highlighted with different colors

Normal text and variables will remain usual

Basic Layout

^XA ^LH30,100 ^FO20,10^AD^FDWWW.AskQA.RU^FS ^FO20,60^B3^FDWWW.URN.SU^FS ^XZ

Comments

^XA - Indicates the beginning of ZPL code. Valid ZPL II format requires that label formats should start with the ^XA command and end with the ^XZ command.

^LH30, 100 - Label Home command. Sets the label home position 30 dots to the right and 100 dots down. The idea is to define this positon once and then use it as reference for other commands.

^FO20, 10 - Field Origin command sets a field origin, relative to the label home (^LH) position. ^FO sets the upperleft corner of the field area by defining points along the x-axis and y-axis independent of the rotation. In this example we move field origin with 20 dots to the right and 10 dots to the bottom from the position we defined by previous command.

^A - Defines the font.

In our example ^AD we choose font D. By default it is A. Real fonts that are behinds this A, B, C, D… values are stored in the printer's EPROM.

ZPL II allows to use letters A - Z and digits 1 - 9.

^FD - Field Data, defines the data string for a field. The field data can be any printable character except those used as command prefixes (^ and ~).

WWW.AskQA.RU - is a text that I used for this example. It should be printed on the tag's surface.

^FS - Field Separator

^FO20, 60 - Here we want to print a new field that has same 20 dot margin to the right - and 60 dot to the bottom so it is below our first field.

^B3 - Means that we want to print a Barcode in the following format: Code 39 (USD-3 Code, Code 3 of 9).

^FDWWW.URN.SU^FS - Same idea as in previous field + we will see it as barcode due to using ^B3 command in the previous line

^XZ - End of label.

Result

Preview of zpl ecnoded tag image from www.answerit.ru

Online generated layout preview

Example of a real layout

You can click on each parameter to read it's full description. Also you can simply scroll down this page.

^XA
^PW366
^CI28
^RW24,24,A2
^FS
^RS8,B10,200,3,E
^FS
^RB96,8,3,3,24,20,38
^FS
^RFW,E
^FD48,0,5,6438092,0,#Serial#
^FS
^FN3^RFR,H
^FS
^HV3
^FT8,24^A0N,26,26^FD#ProductCode#
^FS
^FO8,36^A0N,26,26^FB300,10,,100^FD#ProductName#
^FS
^FT8,105^A0N,26,26^FD#Quantity#
^FS
^FT130,105^A0N,26,26^FD#UnitOfQuantity#
^FS
^FT8,128^A0N,26,26^FDASK.QA
^FS
^FT134,128^A0N,26,26^FD#Serial#
^FS
^XZ

Comments

1) Parameters placed between hash symbol # or sometimes figure brackets { |- are sent to printer from server. You do not need to use it for printing «static» labels but in production tags are printed in large series and have some running numbers that printer recievs from server.

For example you can run a perl script with a сount-controlled loop that is increasing a serial number after new tag is succesfully printed.

#Serial#

2)

🔝

^XA

^PW366

Print Width

^CI28

Change International Font

^RW24, 23, A2

Read and Write Power Levels

24 - Read Power
24 - Write Power
A2 - (a) - RFID antenna element selection. Note - This parameter is valid only on the R110Xi4 printer. This parameter selects an antenna element from the printer's antenna array.
Accepted values: A1, A2, A3, A4, B1, B2, B3, B4, C1, C2, C3, C4, D2, D3, D4, E2, E3, E4, F2, F3, F4 (combinations D1, E1 and F1 are invalid)

A1 - is a lower (closer if you look at the printer) left corner. F4 - is a higher (further) right corner.

🔝

^RS8, B10, 200, 3,E ^FS

^RS - Set Up RFID Parameters

8 - (t) tag type. Gen 2 is the only tag type valid for Zebra R110Xi4, RZ400, RZ600 and RP4T printers.

Accepted values: 0 = None
1 = EPC Class 0
2 = EPC Class 0 Plus
3 = EPC Class 1 64-bit
4 = EPC Class 1 96-bit
5 = ISO 18000-06B
6 = Impinj Class 0 Plus
7 = ISO 18000-06A
8 = EPC Class 1, Generation 2 (Gen 2)
9 = ISO 18000-06B

Default value: 4
Because some countries restric the frequencies that can be used for RFID, not all tag types listed may be supported by your RFID printer. If you specify a tag type that is not supported, the printer will use the default value.

B10 - (p) Sets the read/write position of the transponder in the vertical (Y axis) in dot rows from the top of the label. Set to 0 (no movement) if the transponder is already in the effective area without moving the media.

This parameter sets the read/write position of the transponder in one of two ways: absolute mode or relative mode. For more information about these modes, see Setting the Programming Position Manually on page 19 of RFID Programming Guide 2 Manual.

Important: If a label format specifies a value for the programming position, this value will be used for the programming position for all labels untill a new position is specified or until the transponder calibration procedure is run.

Accepted Values:

Absolute Mode:
xxxx = 0 to label lenght (in dot rows). Move the media to the specified position xxxx on the label, measured in dot rows from the label top, before encoding. Set to 0 (no movement) if the transponder is already in the effective area without moving the media.

Relative Mode Forward:
Fxxx = F0 to Fxxx (where xxx is the label length in millimeters or 999), whichever is less). Move media forward, printing bitmap, for xxx millimeters before reading or encoding.

Relative Mode Backward:
Byy = B0 to B30 (in millimeters, 30 mm maximum). Move media backward for yy millimeters before reading or encoding. (Does not apply to the RP4T printer.)

Note: When using a backward program position, allow enough media or liner to ensure that the printer can back up the media wihout the leading edge disappearing under the printhead mechanism.

Default value:

F0 (which moves the leading edge of the label to the print line)

200 - (v) - length of void printout

3 - (n) - number of labels - The number of labels that will be attempted in case of read/encode failure. Accepted values: 1 to 10. Default value: 3

E - (e) - error handling - If an error persists after the specified number of labels are tried, perform this error handling action. Accepted values: N = No action (printer drops the label format causing the error and moves to the next queued label). P = Place printer in Pause mode (label format stays in the queue until the user cancels). E = Place printer in Error mode (label format stays in the queue until the user cancels). Default value: N

🔝

^RB96, 8,3,3,24,20,38

^RB - Define EPC Data Structure

96 - (n) total bit size of the field. Accepted values: 1 to n, where n is the bit size of the tag. Default value: 96

8,3,3,24,20,38 (p1 ... p15) - partition sizes - Specify each partition size. These must add up to the total bit size. Accepted values: 1 to 64 bit total bit size. Default value: 1.

Here we just showed that 96 bits are divided into six fields with 8, 3, 3, 24, 20, 38 bits respectively

This is a very important step because you should didvide EPC memory accordind to the standard you plan to use. In this example we are prining SGTIN-96 tag.

96 - lenght of EPC block. 8 - Header. 3 - Filter. 3 - Partition. 24 - Company Prefix. 20 - Indicator/Item Reference. 38 - Serial Number.

🔝

^RFW, E

^RF - Read or Write RFID Format.

W - (o) - operation - The action to be performed. Accepted values: W = write to the tag. L = write with LOCK (if supported by tag type). R = read the tag. Default value: W.

E - (t) - type - Accepted values: A = ASCII, H = Hexadecimal, E = EPC (ensure proper setup with the ^RB command). Default value: H.

🔝

^FD 48,0,5,6438092,0,#Serial#

It can be not clear from the first glance what are these parameters 48,0,5,6438092,0,#Serial# after ^FD . In the manual ^FD has only on parameter

(a) - data to be printed. Accepted Values: any ASCII string up to 3072 characters
Default Value: none - a string of characters must be entered.

Comments:

^FD is to be considered not as a separate parameter, but as a combination with ^RFW, E and ^RB96, 8,3,3,24,20,38

So we should read the following lines together:

^RB96, 8,3,3,24,20,38
^RFW, E^FD48,0,5,6438092,0,#Serial#

And keep in mind, that we are writing tag according to SGTIN-96 standard

Full Length HeaderFilterPartitionCompany Prefix Indicator/Item ReferenceSerial Number
96833242038
4805 64380920#Serial#

🔝

^FN3 ^RFR, H^FS

^FN - Field Number Description the ^FN command numbers the data fields. This command is used in both ^DF (Store Format) and ^XF (Recall Format) commands.

In a stored format, use the ^FN command where you would normally use the ^FD (Field Data) command. In recalling the stored fromat, use ^FN in conjunction with the ^FD command.

Format ^FN#

ParametersDetails
# = number to be assigned to the field. Accepted Values: 0 to 9999
Default Value: 0
"a" = optional parameter* Values: 255 alphanumeric characters maximum (a-z, A-Z,1-9 and space)
Default: optional parameter

Comments
The same ^FN value can be stored with several different fields.
If a label format contains a field with ^FN and ^FD, the data in that field prints for any other field containing the same ^FN value
For the "a" parameter to function as a prompt the characters used in the "a" parameter must be surrounded by double quotes (see example).

Example: The ^FN1"Name" would result in "Name" being used as the prompt on the KDU unit.

3 - Is a printer's memory block number. We can write data to one of 10 000 and then address to them to call data back.

In our example we could use any valid number instead of 3.

The important thing is to use the same block number with the ^HV command.

^RF - Read or Write RFID Format.
R - means that we are reading the tag.

This command allows you to read or write to an RFID tag.

Note: When using this command to read a tag, you may use a field variable to print the tag data on the label or to return the data to the host.

Printers That Support This Command: RXi, R110PAX4

Format ^RFo, t, b

o = operation - The action to be performed.
Accepted values: W = write to the tag, L = write with LOCK (if supported by tag type), R = read the tag
Default value: W

t = type - Accepted values: A = ASCII, H = Hexadecimal, E = EPC (ensure proper setup with the ^RB command)
Default value: H

b = starting block number - Accepted values: 0 to n, where n is the maximum number of blocks for the tag.
Default value: 0

🔝

^HV3

^HV - Host Verification

Description - This command is used to return data from specified fields, along with an optional ASCII header, to the host computer. The command can be used with any field that has been assigned a number with the ^RT command or the ^FN and ^RF commands.

Format ^HV#,n, h

# = field number specified with another command. The value assigned to this parameter should be the same as the one used in another command.

Accepted values: 0 to 9999
Default value: 0

In the previous command (^FN3) we used block number 3. So we use 3 (^HV3) here. THIS INFO NEEDs CONFIRMATION

n = number of bytes to be returned

Accepted values: 1 to 256
Default value: 64

h = header - Header (in uppercase ASCII characters) to be returned with the data.

Acceptable values: 0 to 3072 characters
Default value: no header

🔝

^FT8 ,24^A0N,26,26^FD#ProductCode#
^FT - Field Typeset

The ^FT command sets the field position, relative to the home position of the label designated by the ^LH. The typesetting origin of the field is fixed with respect to the contents of the field and does not change with rotation.

Note: The ^FT command is capable of concantination of fields.

Format: ^FTx,y, z

ParametersDetails
x = x-axis location (in dots) Values: 0 to 32000
Default: position after last formatted text field
y = y-axis location (in dots) Values: 0 to 32000
Default: position after last formatted text field
z = justification

The z parameter is only supported in firmware version V60.14.x, V50.14.x, or later
Values:
0 = left justification
1 = right justification
2 = auto justification (script dependent)
Default: last accepted ^FW value or ^FW default

The auto justification option may cause unexpected results if variable fields or bidirectional text are used with ^FT. For best results with bidirectional text and/or variable fields, use either the left or right justification options.
^FT8, 8^A 0N, 26, 26^FD#ProductCode#
^FT8,8

8 - отступ слева
24 - отступ сверху Field Typeset

Description The ^FT command also sets the field position, relative to the home position of the label designated by the ^LH command. The typesetting origin of the field is fixed with respect to the contents of the field and does not change with rotation.

Format ^FTx,y

ParametersDetails
x = x-axis location (in dots)Accepted Values: 0 to 32000
Default Value: positiono after last formatted text field
y = y-axis location (in dots)Accepted Values: 0 to 32000
Default Value: position after last formatted text field

Text The origin is at the start of the character string, at the baseline of the font. Normally the baseline is the bottom of most characters, except for those with descenders, such as g, y et cetera.

Bar Codes The origin is at the base of the bar code, even when an interpretation is present below the bar code, or if the bar code has guard bars.

Graphic Boxes The origin is at the bottom-left corener of the box.

Images The origin is at the bottom-left corner of the rectangular image area.

Examples available here

When a coordinate is missing, the position following the last formatted field is assumed. This remembering simplifies field positioning with respect to other fields. Once the firest field is positioned, other fields follow automatically.

There are several instances where using the ^FT command without specifying x and y parameters is not recommended:
  • when positioning the first field in a label format
  • at any time with the ^FN (Field Number) command
  • following an ^SN (Serialization Data) command


^A0N,26,26^FD#ProductCode#

^A - Defines the font.

In our case^A0 font 0 is chosen - parameter (f) - font name. Default font is A. Шрифты, которые соответсвуют этим буквам хранятся в EPROM принтера. ZPL II allows using letters A - Z and digits 1 - 9.

N - parameter o = font orientation. Accepted Values: N = normal, R = rotated 90 degrees (clockwise), I = Inverted 180 degrees, B = read from bottom up, 270 degrees
Default Value: the last accepted ^FW value or the ^FW default

26,26 - это высота (h) и ширина (w), заданные в точках. Examples available here

^FS

^FO8,36^A0N,26,26 ^FB300,10,,100^FD#ProductName#
^FO8, 36 - Field Origin, set the field 8 more dots to the right and 36 dots to the bottom, from the place defined by ^LH command.

^FB300,10, ,100

^FB - Field Block

Description The ^FB command allows you to print text into a defined block type format. This command formats an ^FD or ^SN string into a block of text using the origin, font, and rotation specified for the text string. The ^FB command also contains an automatic word-wrap function.

Format ^FBa,b, c,d, e
ParametersDetails
a = width of text block line (in dots) Accepted Values: 0 to the width of the label (or 9999)
Default Value: 0
If this value is less than font width or not specified, text does not print
b = maximum number of lines in text block Accepted Values: 1 to 9999
Default Value: 1
Text exceeding the maximum number of lines overwrites the last line. Changing the font size automatically increases or decreases the size of the block
c = add or delete space between lines (in dots) Accepted Values: -9999 to 9999
Default Value: 0
Numbers are considered to be positive unless preceded by a minus sign. Positive values add space, negative values delete space.
d = text justificationAccepted Values: L (left), C (center), R (right), J (justified)
Default Value: L
Last line is left-justified if J is used
e = hanging indent (in dots) of the second and remaining lines Accepted Values: 0 to 9999
Default Value: 0








^FS
^FT8,105^A0N,26,26^FD#Quantity#^FS
^FT130,105^A0N,26,26^FD#UnitOfQuantity#^FS
^FT8,128^A0N,26,26^FDASK.QA^FS
^FT9,128^A0N,26,26^FDASK.QA^FS
^FT134,128^A0N,26,26^FD#Serial#^FS
^FT134,128^A0N,26,26^FD#Serial#^FS
^XZ

Main Commands

RF

Preview ZPL

ZPL simulator to preview layouts

If you have any questions - feel free to ask in the comments section below

Share in social media: