You are on page 1of 5

Reading and processing of barcodes with SIMATIC

S7-CPU and serial CP 340

Barcodes are a fast, simple The procedure starts when a

Service & Support


and efficient way of recording barcode is read into the S7-
data. CPU. To avoid losing any data,
it is temporarily stored in a
We often have the problem in
ring buffer (FiFo) in the CPU.
automation technology that
barcodes have to be read into When the user requests data,
a logic control using very it is transferred on the FiFo
different types of scanner, principle from the ring buffer
frequently made by different to a defined user interface for
manufacturers. As the reading further use.
process is so fast, data has to
With the help of the graded
be buffered in the control
documentation structure you
system and output again on
can familiarize yourself with
request in chronological or-
the application functions as
der. If an error is made, the
required, start them referring
user must be protected from
to the step-by-step instruc-
data loss.
tions, or adapt the annotated
The combination of SIMATIC encoding elements to your
products and barcode scan- own requirements. You are
ners of different manufactur- given step-by-step instruc-
ers is an excellent solution to tions for changing the pa- www.ad.siemens.de/support
this problem. The set-up is rameters of the S7 hardware
completed by application components and the scanners
software developed specially (the types we use).
for this purpose.
It is a simple matter to adapt
It is based on an infrastruc- the application to scanners of
ture that is independent of the various types and manufac-
type of scanner used or the turers by changing the pa-
manufacturer, and it can read rameters or reconfiguring the
barcodes of different charac- code supplied.
ter lengths. Using the
SIMATIC CP 340 (PtP link)
barcodes are transferred via
RS232C to the S7-CPU.

Applications
The quickest way to
the best solution
The infrastructure

To transfer the barcodes to The CP 340 prepares the S7-CPU with CP 340
the S7-CPU there is a CP 340 RS232C signals coming from
in the central rack (for point- the scanner and transfers
to-point link-up). This is inde- them via a backplane bus to MPI RS 232
pendent of manufacturer, i.e. the S7-CPU. PG/PC
various types of scanner (with
In this application a fixed
RS232C interface) by all
reputable manufacturers can barcode scanner by SICK and ... Fixed or hand
scanners by
various
manufacturers
be linked using this module. a DATALOGIC handscanner Fixed barcode scanner Handscanner

were connected to the CP LASER

340. Barcode

The procedure

The procedure described code) is stored in the ring


S7-CPU below is part of the applica- buffer until it is asked for.
Header
tion software supplied.
Data request/
(Date/time User Read barcodes output
interface Each barcode read passes via
Payload data string (DB3) Data is requested using a
the CP 340 to the C7-CPU freely selected trigger event.
(barcode)
where it is stored to begin The default event for this is
with in the receive block (DB setting an input at the digital
1). input module. But you can
Data requested
From there it is transferred
by trigger configure any trigger event
automatically to a ring buffer
event quite easily.
(FC40) (DB2) and temporarily stored
there. This ensures that data The request automatically
is not lost even at high read starts a routine in S7-CPU,
Data record speeds. If the read frequency which finds the data record in
Data record Ring buffer of the scanner is so high that the ring buffer on the FiFo
(DB2) data is overwritten in the ring principle. This is then given
Data record
buffer, you are informed by an you for further processing
error bit (an output parameter with its own date and time.
of FC 1), and if you use the You are given access to it in
default settings supplied, this another data block acting as
Payload data string Receive the user interface (DB3).
starts an LED in the digital
(barcode) block
(DB1) output module blinking. Automated mechanism
To give the barcode a unique Co-ordination of the barcodes
Backplane bus
identification, when it enters in the ring buffer (storage and
the ring buffer it is given a adding of header) and the
CP 340
header containing a date and data output on request is
managed automatically by the
time stamp. This header to-
application software supplied.
RS 232C gether with its payload data
(bar-
Scanner

Barcode
User interface

The user interface (DB3) gives The date and time refer to the
you the characters of the moment when the barcode
barcode requested. But re- was written to the ring buffer.
member: there is only ever The data is in bytes 2 and 3
one data entry in the user (month/day), the time consists
interface at a time. The pay- of bytes 4-7
load data is always output (hour/minute/second/hun-
with a marker and the date dredth of a second).
and time.
The payload data is output as
The user is ensured that it is a a string with the length set at
complete data record by the 254. This length can be modi-
presence of the marker "D"
fied by the user at any time.
(byte 0).

Documentation structure

A1 As well as the software application software devel- Section B takes you step-by-
Applikationsbeschreibung blocks needed to make up the oped and the main specifica- step through the installation
whole application, you will tions. and start-up of the applica-
A2
Funktionsmechanismen also get detailed documenta- tion.
tion. This is divided into four
Section A2 describes the Section C, containing the
main parts.
B functions of all the compo- annotated code elements, is
Step-by-Step
nents in detail. If you want to of interest if you want to take
start up the application and the software and expand or
test it first using step-by-step adapt it to your set-up.
C
Programmcode
instructions, you can skip
Section A2.
Technical specifications

Main performance specifications


Parameter Number / size Comments
Cycle time 51 ms Max. value measured (worst case) for the complete
procedure without other CPU load
Ring buffer size (DB2) 300 bytes (default) Can be modified (max. size is CPU specific, e.g. CPU
315-2DP: 16 KB, CPU 314: 8 KB)
Organization of ring buffer On the FiFo principle FiFo: FIFO (First in first out).
Number of barcodes that can be stored in Depends on number of characters in barcode e.g. 12 barcodes (if 1 barcode consists of 13 charac-
buffer ters)
Reaction if ring buffer overruns Error message via bit output on FC40, which by Must be acknowledged by user, by default by setting a
default prompts an LED on the output module to blink bit at the digital input module
Size of user interface (DB3) 264 bytes (default)
Number of barcodes in the user interface At any one time: max. 1 record Record from ring buffer on FiFo principle
Number of scanners operable simultaneously 1
Scanner alternatives you can connect Various types (with RS232C interface) by all the
standard manufacturers

Hardware components used


Component Type MLFB / Order number No. Alternatives
Power Supply PS307 6ES7 307-1EA00-0AA0 1
CPU CPU 314 6ES7 314-1AE04-0AB0 1 To make this application work, you can use
various other components (e.g. other
Digital input module SM 321 6ES7 321-1BH01-0AA0 1 CPUs). Please refer to catalog CA01.
Digital output module SM 322 6ES7 322-1BF01-0AA0 1 We have used the scanners listed (of which
you can only use one at a time) as test
Communications processor CP 340 6ES7 340-1AH01-0AE0 1
machines. But in general all commercially
SICK barcode scanner CLV 410-0010 1015421 (SICK) 1 available scanners can be used.
DATALOGIC DLL 5110-M1 handscanner 902251000 (Fa. DATALOGIC) 1
barcode scanner
DATALOGIC-RS232.9 Pin cable CAB362 (with DLL5110) 90A051330 (DATALOGIC) 1
PG 740 PII/III or similar PC PG 740PIII 6ES7 742-2AC20-0AA0 1

Software components used


Component Type MLFB / Order number No. Alternatives
STEP7 V5.1 6ES7810-4CC05-0YX0 1
SICK Software CLV Setup V3.0 SICK 1 Needed for SICK CLV scanner
Windows NT V4.0 SP5 Microsoft 1 Windows 95/98

Downloadable elements
Topic Contents Description
Reading and processing of barcodes with Documentation 67 pages including:
SIMATIC S7-CPU • Introduction to barcodes
and serial CP 340
• Description of installation and operating principles
• Step-by-Step instructions
• Diagrams
Code (STEP7) BarcoCP: Load memory: 5.6 Kbytes, user memory: 3.7 Kbytes
• FB P_RCV (receive function block for CP 340)
• DB 99 (instance DB of FB P_RCV)
• FC 1 (monitors ring buffer overspill)
• FC 40 (ring buffer management)
• DB 1 (receive block for barcodes)
• DB 2 (ring buffer storage)
• DB 3 (user interface, allows access to data in ring buffer)
Applications
with the SIMATIC
Card

Applications are available in the Customer Sup-


port online shop: www.ad.siemens.de/support
To download applications, you need your
SIMATIC Card. It also enables you to take ad-
vantage of other offers on the Internet or from
Customer Support.
The SIMATIC Card is available in three sizes:
200, 500 and 1000 units.
The following units are deducted from your
SIMATIC Card balance when you download the
application.
• Reading and processing of barcodes with
SIMATIC S7-CPU and serial CP 340
150 Units
Get your SIMATIC Card like this
Apply to the responsible person in your local
Siemens branch or order the SIMATIC Card
online with a credit card:
www.ad.siemens.de/support
You can use your card and PIN number
immediately and take advantage of all the
services we offer.

Applications
System Utilities

Siemens AG Functions & Samples


Automation & Drives (A&D)
Postfach 4848
D-90327 Nürnberg
Copyright © Siemens AG, 2000
Siemens Aktiengesellschaft
Subject to change without notice
ST/AP/B2/PS AS.CS.ME 10/2001
Made in Germany

You might also like