CV-X Outputting - String Data EIP
CV-X Outputting - String Data EIP
TECHNICAL GUIDE
String Data Output using EtherNet/IP
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
The below example shows a 2D code readout result and how the data is output to the PLC using
EtherNet/IP as a default with each decimal ASCII character output to a 32-bit data result. The CV-X lists
the data locations in groups of bytes (8 bits):
Sending one character to each DINT can be inefficient, especially when dealing with a large amount of
data. This technical guide shows how to consolidate the characters and convert them to a string in the
PLC (Using Allen-Bradly Control/CompactLogix type PLC).
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
After the code reading tool (1D, 2D, OCR) has been setup on the CV-X program. The next step would be
to add the necessary calculations. Calculations can be added from the “Mathematical Operations”
category in the tool list of the CV-X series.
In a calculation, the measured results of the reference tool are added by selecting “Measured Value”
from the calculation menu.
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
The setup for 1D or 2D code readout would be very similar to the OCR, but the nomenclature would be
slightly different. The menu below shows how to find the measured values from a code reading tool.
The calculation uses some basic math functions to shift the characters over by 8, 16 and 24 bits to
combine 4 characters to one single 32 bit answer. Since the calculation has three answers (ANS0, ANS1,
ANS2), 12 characters are combined in this script.
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
In the above, ANS0 is the first 4 characters, ANS1 is the next 4, and ANS2 is the last 4. More calculations
can be added as necessary, following this same method, depending on how many characters are being
read by the code reading tool.
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
Double-click here!
This text edit window is only available when using the simulator, it is not available when programming
directly on the controller or connected to the controller using the CV-X Vision Terminal software.
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
In this setup, the first 4 characters will be output to Result Data 1, the second set of 4 characters to
Result Data 2, and the 3rd set of 4 characters to Result Data 3. The number of characters will be output
to Result Data 4. All of these output results are 32-bit values or DINT on the AB PLC. As seen below, the
character results in the DINT appear as a very large number, but when copied or moved to a “STRING”
tag, they will be converted correctly.
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
A “COP” command is used to copy the DINT data from the Data Results into the “STRING” character
location. The command will automatically take the DINT data and put it into the correct number of SINT
tags. In our case, 1 DINT will copy to 4 x SINT (4 characters per DINT).
A screen shot of the actual PLC program for this set up is shown below. The Result Data starts at
“I.Data[12]” as “TEXT.DATA[0].” The length should be the number of SINT’s (characters) to be copied.
This should be set to the maximum number of characters being used (12 in this example). The number
of characters detected are copied to TEXT.LEN, so the string tag will only convert the character that
were actually detected by the inspection tool.
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.
Reference Only
www.visionsystem.com
Copyright© KEYENCE CORPORATION. All rights reserved.