The text of a manual · part 20 of 24
CV-700 Series User's Manual: High-speed, High-accuracy, Color Vision System, pages 191 to 200
Pages 191 to 200 of 232
The original document is the PDF (2.6 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Keyence CV-070
Page 191
Chapter 8
RS-232C Interface
8.2 Connection Connection with a PC Connect the CV-701(P)/751(P) to a personal computer using a special cable OP27221 (Cable length: 3 m) ■ Connection
PC
25-pin D-sub connector
Ferite core
OP-25057 for 9-pin connector I/O
OP-27221 (Cable length: 3 m)
O VIDET OU
RA
ME
CA
2
■ Pin assignment
■ Wiring (special cable)
CV PC side CV side
1 2 3 4 5 6 7 8
25-pin
9-pin
SD (TXD)
2
2
3
SD (TXD)
RD (RXD)
3
3
2
RD (RXD)
SG (GND)
4
7
5
SG (GND)
4
7
RS (RTS)
5
8
CS (CTS)
6
6
DR (DSR)
8
1
CD (DCD)
20
4
ER (DTR)
181
8
Page 192
Chapter 8
RS-232C Interface
8.3 Commands and Data Formats This section describes the commands and data formats used for RS-232C communication.
8.3.1
Commands in PROGRAM mode Send “O0 [Cr]” to the CV-701(P)/751(P) to stop operation. Tips
After writing data, send SS [Cr] to the CV-701(P)/751(P) to save the settings. If the power is turned off without saving the settings, the setting data will be lost. ● Reading the program number The current program number is sent back to the PC. Command
P R cr
Response
NUM P R , NUM 1 2 cr
NUM: Program No. (00 to 15) ● Writing the program number The current program is changed to the number specified with the PC. Command
NUM P W , NUM 1 2 cr
Response
P W cr
NUM: Program No. (00 to 15)
Error
E R , P W , #1 #2 cr
● Reading output settings The current output data selection (judgment result, number of pixels, measured value of edge detection, X coordinate, Y coordinate, correlation ratio, and rotation angle) is sent back to the PC. The initial settings for all data are 0.
8
Command
A R cr
Response
NUM NUM NUM NUM NUM NUM A R , NUM 0 1 2 3 4 5 6 cr
Data 0: Output setting of judgment result (0: OFF, 1: ON) Data 1: Output setting of number of pixels (0: OFF, 1: ON) Data 2: Output setting of the measured value of the INS mode (0: OFF, 1: ON) Data 3: Output setting of X coordinate (0: OFF, 1: ON) Data 4: Output setting of Y coordinate (0: OFF, 1: ON) Data 5: Output setting of correlation ratio (0: OFF, 1: ON) Data 6: Output setting of rotation angle (0: OFF, 1: ON)
182
Page 193
Chapter 8
RS-232C Interface
● Writing output settings Select the output data (judgment result, number of pixels, measured value of edge detection, X coordinate, Y coordinate, correlation ratio, and rotation angle). The writing of output settings can be set in the environmental setting menu. ➮ See page 149.
Command
NUM NUM NUM NUM NUM NUM A W , NUM 0 1 2 3 4 5 6 cr
Response
A W cr
Error
E R , A W , #1 #2 cr
● Reading the setting data The setting data (all data except for the registered screen) for the current program number is sent back to the PC. The setting data can be saved in the PC. Command
S R cr
Response
Data Data ... Data Data CheckS R , Data 2 1238 1238 sum cr 0 1
Checksum range: Data 0 to Data 1239 (1240 data) Data 0 to Data 1239: Binary data Calculation is not necessary for the checksum. ● Writing the setting data The setting data (all data except for the registered screen) is written to the current program number. The stored setting data can be written from the PC to the CV701(P)/751(P). Be sure to save the data using the SS [Cr] command after writing. Command
Data Data ... Data Data CheckS W , Data 2 1238 1239 sum cr 0 1
Response
S W cr
Checksum range: Data 0 to Data 1239 (1240 data) Data 0 to Data 1239: Binary data
8
Calculation is not necessary for the checksum. Error
E R , S W , #1 #2 cr
● Reading the environmental setting data The environmental setting data for the current program number is sent back to the PC. The setting data can be saved in the PC. Command
Response
S A cr Data Data ... Data CheckS A , Data 2 83 sum cr 0 1
Checksum range: Data 0 to Data 83 Data 0 to Data 83: Binary data Calculation is not necessary for the checksum.
183
Page 194
Chapter 8
RS-232C Interface ● Writing the environmental setting data The environmental setting data is written to the current program number. The stored setting data can be written from the PC to the CV-701(P)/751(P). Be sure to save the data after writing. Command
Data Data ... Data CheckS B , Data 2 83 sum cr 0 1
Response
S B cr
Checksum range: Data 0 to Data 83 Data 0 to Data 83: Binary data Calculation is not necessary for the checksum. Error
E R , S B , #1 #2 cr
Note: The environmental setting includes the white balance adjustment. When setting two or more CVs, be sure to select the optimal white balance value for each CV. ● Reading the registered screen The image data for the registered screen is sent back to the PC. Data for one line is sent in a single communication. To read the whole image, the transmission is repeated to read the data from line 0 to 485. Command
NUM NUM B R , Cn , NUM 1 2 3 cr
Response
Data ... Data Data CheckB R , Data 0 1 510 511 sum cr
Checksum range: Data 0 to Data 511 (512 data) Data 0 to Data 511: Binary data Cn: Camera No. NUM: Line No. (Line 0 to 485) of image data Calculation is not necessary for the checksum. ● Writing the registered screen The stored image data in the PC is written to the CV’s registered screen. The screen registration is saved when writing of image data of LINE 0 to 485 is completed.
8
Command
NUM NUM Data ... B W , Cn , NUM , Data 1 2 3 0 1 Data Data Check-
510 511
Response sum cr
B W cr
Checksum range: Data 0 to Data 511 (512 data) Data 0 to Data 511: Binary data Cn: Camera No. (CAM1: 1, CAM2: 2) NUM: Line No. (Line 0 to 485) of image data Calculation is not necessary for the checksum.
184
Page 195
Chapter 8
RS-232C Interface
● Reading the input screen The stored image saved in the CV is sent back to the PC. Data for one line is sent in a single communication. To read the whole image, the transmission is repeated to read the data from line 0 to 485. This operation is enabled during the transmission with O0 [Cr]. Command
B I
NUM NUM , Cn , NUM 1 2 3 cr
Response
B I
Data ... Data Data Check, Data 0 1 510 511 sum cr
Checksum range: Data 0 to Data 511 (512 data) Data 0 to Data 511: Binary data Cn: Camera No. (CAM1: 1, CAM2: 2) NUM: Line No. (Line 0 to 485) of image data Calculation is not necessary for the checksum. Note: When incorrect commands are sent, the error message is sent back. The error message is defined as below.
E R ,
, #1 #2 cr
∆: Command character ● Reading the saved screen The stored image of the registered screen saved in the CV is sent back to the PC. Data for one line is sent in a single communication. To read the whole image, the transmission is repeated to read the data from line 0 to 485. Command
NUM NUM B N , NUM , NUM 0 1 2 3 cr
Response
Data ... Data Data CheckB N , Data 0 1 510 511 sum cr
Checksum range: Data 0 to Data 511 (512 data) Data 0 to Data 511: Binary data NUM0: Registered screen No., NUM1/2/3: Line No. of image data (Line 0 to 485) Calculation is not necessary for the checksum.
8
● Reading the window number The current window number is sent back to the PC. Command
U R cr
Response
U R , NUM 1 cr
NUM: Window No. (1 to 8)
185
Page 196
Chapter 8
RS-232C Interface ● Writing the window number The current window number is changed to the number specified with the PC. Command
U W , NUM 1 cr
Response
U W cr
NUM: Window No. (1 to 8) ● Registering the screen Save the image captured with the camera as the registered screen. Command
D NUM 1 cr
Response
D NUM 1 cr
NUM: 0=CAM1 and CAM2, 1=CAM1, 2=CAM2 ● Saving the setting data The setting data is saved in the CV’s internal memory. When the power is turned off without sending this command, the setting data for RS-232C will be lost. Command
S S cr
Response
S S cr
● Changing to RUN mode The CV-701(P)/751(P) is switched to RUN mode.
8
186
Command
R 0 cr
Response
R 0 cr
Page 197
Chapter 8
8.3.2
RS-232C Interface
Commands for CompactFlash memory Send the commands to access the CompactFlash memory. The commands are available while the CV is in program mode with O0 [Cr]. ● Reading the setting data and registered screen Read the setting data and image data of the specified file from the CompactFlash memory. The 16 programs stored under the specified file are written to the CV, overwriting all current programs. Command
NUM NUM C S , NUM 1 2 3 cr
Response
C S cr
NUM1 to NUM3: File No. in the CompactFlash memory ● Reading the environmental setting data Read the environmental setting data into the CV from the CompactFlash memory. Command
NUM NUM C C , NUM 1 2 3 cr
Response
C C cr
NUM1 to NUM3: File No. in the CompactFlash memory Note: The environmental setting includes the white balance adjustment. When setting two or more CVs, be sure to select the optimal white balance value for each CV. ● Reading setting data for one program Setting data for only one program is sent to the CV from the CompactFlash memory. Command
NUM NUM C 1 , NUM , a1 a2 , b1 b2 cr 1 2 3
Response
C 1 cr
8
NUM1 to NUM3: File No. in the CompactFlash memory a1 to 2: Program No. to be read in the file, b1 to 2: Program No. where the read program will be written to the CV. ● Writing the saved screen The image data of the saved screen is written on the CompactFlash memory. Command
C N cr
Response
C N cr
When the CompactFlash memory is full, an error message will be sent. Important: Make sure not to insert or eject the CompactFlash memory while access to the CompactFlash memory is made.
187
Page 198
Chapter 8
8.3.3
RS-232C Interface
Commands in RUN mode Send [R][0][Cr] to the CV-701(P)/751(P) to switch it to the RUN mode before using the following commands. ● Trigger Input a trigger signal Command
T 1 cr
Response
T 1 ,
Numerical value data cr
T G ,
Numerical value data cr (with external trigger)
(Numerical value data: Depends on the output data setting. Refer to the “Output data format” on page 189.) ● Re-outputting data Output the latest processing result data again. Command
M 0 cr
Response
M 0 ,
Numerical value data cr
(Numerical value data: Depends on the output data setting. Refer to the “Output data format”.) ● Stopping Stop the operation of the CV-701(P)/751(P)
8
188
Command
O 0 cr
Response
O 0 cr
Page 199
Chapter 8
8.3.4
RS-232C Interface
Output data format The data formats available with the AW commands are listed below. The available data for output is limited depending on the measurement mode. Data format
PROGRAM mode
EDGE
PATT
EDGE
INS+POS 1.
❍
❍
±00000.000 ±99999.999 000 100 –180 + 179
❍
❍
❍
❍
STAIN
❍
POINT 8.
❍
COUNT
±00000.000 ±99999.999
EDGE NO.
❍
PITCH
❍
GAP
❍
INNER
❍
OUTER
PATT
❍
GRAVITY
❍
❍
0 (acceptable) 1 (unacceptable) 000000 243840
AREA
No. of pixels
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
❍
INS 7. 2.
X coordinate 2, 4. Y coordinate 2, 4. Correlation ratio Rotation angle 3.
REL. POS 6.
❍
Output item
Judgment result
ABS. POS
INS/TRG
ARE/CON 5.
Normal mode
❍
❍
❍
❍
❍
1. In the INS+POS mode, the output format of the INS measured data is the same as that for INS/ TRG, and the format of the position adjustment is the same as that for ABS.POS. 2. When the edge detection mode is set to either the X- or Y-axis direction only, the coordinate of the other axis is not output. 3. The output is disabled when the rotation angle is not used. 4. The coordinate output is fixed to “sign + five-digit integer +decimal point + three-digit fraction”. 5. The data output is stopped when the CONT input is short-circuited in the ARE/CON mode. 6. REF WND (reference window) uses the absolute value for judgment or data output. The other windows use the difference from the REF WND. 7. The output format for INSPECT output varies as follows depending on the measurement mode. • OUTER, INNER
Measured dimension
• GAP, PITCH
Measured dimension (Maximum and minimum values)
• EDGE NO
Number of detected edge
• COUNT
Counted number
• POINT
Color extraction condition of each point
• STAIN
Measured value
• GRAVITY
Detected X and Y coordinates, angle of principal axis
Measured dimension
±00000.000 ±99999.999
Number of edges
±00000.000 ±99999.999
Counted number
±00000.000 ±99999.999
8
8. Each digit represents the condition of color extraction as follows: 0: Background color, 1: Detected color, 9: Unassigned (Example) 01019999
189
Page 200
Chapter 8
RS-232C Interface Example To output the number of pixels in “Window 1” and “Window 2”:
1 2 3 4 5 6 , 0 0 1 0 0 0 cr
Window 2 has 1,000 pixels.
Window 1 has 123,456 pixels.
Order of output data • • •
WO1 processing ➞ WO2 processing ➞ ... ➞ WO8 processing [cr] The judgment output and pixel output are given only for the windows with settings assigned. [,] is output as a separator between data.
Example When WO1 and WO3 are set in “AREA” mode: (1) If the output data is selected as [1][0][0][0][0][0][0] (the judgment output for WO1 to WO8), the output data is as follows.
1 , 0 cr WO3:OK (Acceptable) WO1:NG (Unacceptable)
(2) If the output data is selected as [1][1][0][0][0][0][0] (the judgment and pixel output for WO1 to WO8), the output data is as follows.
1 , 1 2 3 4 5
, 0 , 0 0 1 0 0 0
No. of pixels in WO1
No. of pixels in WO3
WO1:NG (Unacceptable)
cr
WO3:OK (Acceptable)
Example When WO1 and WO2 are used in “ABS.POS” mode: If the output data is selected as [0][0][0][1][1][1][1] (X and Y coordinates, correlation ratio, rotation angle):
+ 0 0 1 4 2 . 0 0 0 , - 0 0 3 6 3 . 0 0 0,0 9 2
8
X coordinate of WO1
Y coordinate of WO1
Correlation ratio of WO1
+ 0 0 5 , + 0 0 3 9 2 . 0 0 0,+ 0 0 5 0 . Rotation angle of WO1
X coordinate of WO2
0 8 9 , + 0 0 8 cr
Correlation ratio of WO2
190
Rotation angle of WO2
Y coordinate of WO2
0 0 0