The text of a manual · part 8 of 14
BL-180 Series User's Manual, CCD Bar Code Reader: Chapter 4 Serial Communication (RS-232C/RS-422A), pages 53 to 60
Pages 53 to 60 of 109, from BL-180 Series User's Manual, CCD Bar Code Reader
The original document is the PDF (568 KB). 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 BL-180 and Keyence BL-185
Page 53
Chapter 4 Serial Communication (RS-232C/RS-422A)
Page 54
4.1 Serial Communication
4.1 Serial Communication The BL-180 communicates with the PC via the RS-232C serial port. This enables you to change the BL-180’s settings from your PC.
Communication Types The BL-180 provides the following two communication types: Data communication Sends read bar code data from the BL-180 to the PC. Command communication Changes the BL-180’s settings by sending a command from the PC to the BL180. All communication is performed using ASCII codes.
4.1.1 Communication Setup Configure the setup for BL-180 and the PC before attempting serial communication. Setup of BL-180 Set the following parameters for the BL-180 using the setup software. Baud rate, Data bits, Parity, Stop bit, Communication protocol, Header/Delimiter, Read error code PC setup Based on the BL-180’s settings, set the communication parameters on the PC using the “Ports” setting in the Windows Control Panel. Note
The following communication parameters are the default settings for the BL-180: Baud rate: Data bits: Parity: Stop bit:
9600 bps 7 bits Even 1 bit
Set the PC according to the above settings before attempting communication. The BL-180 is set, temporarily, to the default settings for 5 seconds after the power switch is turned on. When the current settings of BL-180 is not certain, send the command “SSET” and a [CR] to the BL-180 from your PC with 5 seconds after power-up. This causes the BL-180 to remain at its default settings and you can communicate with the BL-180 at the default settings. For information on checking the BL-180’s current settings, see “Details on Parameter Setting Commands” on page 52. For information on changing the above communication parameters see “Description of Parameter Setting Commands” on page 53. Data communication can be performed with the current parameter settings even for 5 seconds after the power is turned on. Note
46
All commands should be entered in all uppercase characters. The BL cannot accept lowercase characters.
Page 55
4.2 Details on Data Communication
4.2 Details on Data Communication 4.2.1 Communication Protocols(Hardware handshaking) The BL-180 supports the following four handshaking protocols.
No Handshaking The BL-180 sends read data to the PC without using any handshaking protocol.
Read data
PASS/RTRY Handshaking After sending the read data, the BL-180 waits for a response from the PC. The response is either a PASS command or a RTRY command.
Read data
Response (PASS
C R
, RTRY
C R
)
The PASS command (quit) indicates that the PC has successfully received one data packet. The BL-180 then prepares for the next data transmission. The RTRY command (request to re-send) indicates that the data was not transmitted successfully. The command is a request to the BL-180 to re-send the data. The BL-180 sends the same data again and then waits for the response. After the BL-180 once receives PASS, the BL-180 sends back no data even if RTRY is sent to the BL-180. The BL-180 can continue to read while waiting for the PASS command. The data is stored in the BL-180’s transmission buffer (For the capacity of the transmission buffer, see page 48). If the amount of stored data exceeds the capacity of the transmission buffer, the BL-180 sends back <Header>OVER<Delimiter> to the PC, and clears all data stored in the transmission buffer. For more information, see “Capacity of Transmission Buffer” on page 48. Note
The BL-180 can receives other commands while waiting for the PASS command. In this case, the BL-180 sends back an immediate response (e.g. OK). When the SSET command (see “4.3.3” on page 52) is sent to the BL-180 while the BL-180 is waiting for the PASS command, the BL-180 clears the data stored in the transmission buffer, and enters the setting mode.
ACK/NAK Handshaking The ACK/NAK handshaking uses ACK (06H) and NAK (15H) instead of PASS and RTRY used in the PASS/RTRY handshaking, respectively. With these protocols, the BL-180 sends back different characters, but performs the same operation.
47
Page 56
4.2 Details on Data Communication RTS/CTS Handshaking When the PC’s RTS (BL-180’s CTS) signal turns off, the BL-180 becomes ready for data transmission. When the PC’s RTS signal turns on, the BL-180 starts data transmission. When the PC’s RTS signal is off, the BL-180 can still read. In this case, data is stored in the BL-180’s transmission buffer (see 4.2.2 below). If the amount of stored data exceeds the capacity of the transmission buffer, the BL-180 sends back <Header>OVER<Delimiter> to the PC, and clears all data stored in the transmission buffer. Note
The RTS/CTS handshaking cannot be used for RS-422A communication. The RTS/CTS protocol can be used together with other handshaking protocols. When the PC’s RTS signal is off, the BL-180 does not sends back a response to the PC.
4.2.2 Capacity of Transmission Buffer The BL-180’ s transmission buffer can store 400 bytes (400 characters). The number of characters stored in the transmission buffer for each data packet is the number of characters in the data (including additional data such as the number of decoding match count) plus an additional five characters indicating the data’s attributes. When multi label reading mode 2 or 3 is used, these five attribute characters are added to each data packet. Example 1 When the number of bar code digits is 10 (with no additional data) 400 ÷ (10 + 5) = 26 The transmission buffer can store 26 pieces of data. Example 2 When the number of bar code digits is 20 (with no additional data) 400 ÷ (20 + 5) = 16 The transmission buffer can store 16 pieces of data.
4.2.3 Read Data Format Set the data format of the Header and Delimiter, respectively. Header
Read data
Delimiter
With the setup software, the following formats can be selected. Other than the following formats, you can freely set up to 5 characters. Header ESC (1BH)/STX (02H)/None Delimiter CR (ODH)/CR (ODH) LF (OAH)/ETX (O3H)
48
Page 57
4.2 Details on Data Communication 4.2.4 Read Error Code If the BL-180 fails to read a bar code, the B-500 sends back a read error code. The initial setting of the read error code is as follows: Header
ERROR
Delimiter
The read error code can freely be changed (within 8 characters). The BL-180 can be set to send no error code (see page 38).
49
Page 58
4.3 Command Communication
4.3 Command Communication The BL-180 includes commands to directly operate the BL-180 (direct control commands) and the commands used to change or confirm the BL-180’s settings (parameter setting commands).
4.3.1 Setup of Direct Control Commands Communication procedure Command
Response
1. Send a direct control command from the PC to the BL-180. 2. After receiving the command, the BL-180 sends back an OK response and executes the required operation. When the read operation control command or test mode control command is sent to the BL-180, the BL-180 sends back no response. 3. When an incorrect command is sent to the BL-180, the BL-180 sends back no response. Note
LF can be added after the command being sent. In this case, however, LF is not added to the response data. When ESC is inserted before the command being sent, characters in the BL180’s command receiving buffer are cleared. If the BL-180’s command receiving buffer contains erroneous characters due to data transmission error during communication, add ESC to the command being sent.
Note
50
For command communication, set the time duration between transmission of each character (byte) to up to 30 seconds. If this duration exceeds 30 seconds, the BL-180 cancels the received characters.
Page 59
4.3 Command Communication 4.3.2 Explanation of Direct Control Commands The following describe direct control commands in details.
Read operation control This command specifies the data read timing. [LON]
Trigger on Command: LON Response: None
[LOFF]
Trigger off Command: LOFF Response: None • Even when the read operation is controlled with these commands, the BL-180 performs the same operation as with the trigger input (see page 10 to 12). • “Trigger input: on” corresponds to LON, and “trigger input: off” corresponds to LOFF. • The BL-180 starts read operation on receipt of LON and stops it on receipt of LOFF. • When a bar code can be correctly read and the read data has already been set, you need not send LOFF. • The command characters can be freely changed (within 8 characters).
Test mode control Starts or quits the test mode. [TEST1]
Reading rate check Command: TEST1 Response: None
[TEST2]
Tact check Command: TEST2 Response: None
[QUIT]
Resetting test Command: QUIT Response: None • After using the test mode, be sure to reset it.
OK/NG output control Directly turns on/off the OK/NG output. This enables you to easily check wiring. [OKON]
Turning the OK output on Command: OKON Response: OK
[NGON]
[ALLOFF]
Turning the NG output on Command: NGON Response: OK Turning the OK/NG outputs off Command: ALLOFF Response: OK
51
Page 60
4.3 Command Communication Clearing transmission buffer [BCLR]
Clears data stored in the transmission buffer. Command: BCLR Response: OK
Shift to setting mode [SSET]
Enters the setting mode (see page 51). Command: SSET Response: OK
4.3.3 Details on Parameter Setting Commands The following describes how to change the BL-180’s settings through command communication. You can use the setup software to change the BL-180’s settings instead of these commands.
Communication Details 1. Send the direct control command SSET to the BL-180. The BL-180 will shift to setting mode. After successfully executing the command, the BL-180 sends back an OK. 2. After the BL-180 shifts to setting mode, send the command (setting change command) corresponding to the item to be changed to the BL-180. After successfully executing the command, the BL-180 sends back an OK. If an error occurs with this command, the BL-180 sends back ERRnn. (nn sttands for error code numbers.) 3. To confirm the current settings, send a setting confirmation command. After successfully executing the command, the BL-180 sends back an OK. If an error occurs with this command, the BL-180 sends back ERRnn. 4. To save the current settings in the EEP-ROM, send SAVE to the BL-180. Once you save the settings in the EEP-ROM, the BL-180 will start with these settings when the BL-180 is turned on next. After successfully executing the command, the BL-180 sends back an OK. If an error occurs with this command, the BL-180 sends back ERRnn. 5. To quit the setting mode and perform the normal bar code reading, send SEND to the BL-180. After successfully executing the command, the BL-180 sends back an OK. If an error occurs with this command, the BL-180 sends back ERRnn. Note
[LF] can be added at the end of the command being sent. In this case, however, [LF] is not added to the response data. When [ESC] is added before the command being sent, characters in the BL-180’s command receiving buffer are cleared. If the BL-180’s command receiving buffer contains erroneous characters due to a data transmission error during communication, add [ESC] to the command being sent.
Note
52
For command communication, set the time duration between transmission of each character (byte) to up to 30 seconds. If this duration exceeds 30 seconds, the BL-180 cancels the received characters.