How do you connect the SIMATIC MV320 and SIMATIC MV340 hand-held barcode readers to a serial CP340 or CP341?
This entry is valid for the hand-held barcode readers below:
- SIMATIC MV320
- SIMATIC MV340
The SIMATIC MV320 and MV340 hand-held barcode readers have the following interfaces:
To connect the SIMATIC MV320 and SIMATIC MV340 hand-held barcode readers to a serial communications processor (CP340 or CP341) the must have an RS232 interface.
Communication between CPU, serial CP and the hand-held barcode reader is performed via the function blocks of the serial CP and the ASCII protocol.
Below we describe how to parameterize the serial CP and which function blocks you call in the user program of the S7-300 CPU to read in and evaluate the data of the hand-held barcode reader.
The following configuration software is required to parameterize the serial CP340 or CP341:
- STEP 7 V5.3 or higher
- PtP Param: Entry ID 27013524 includes the latest version of the configuration software PtP Param for downloading.
Parameterizing the serial CP
In the SIMATIC Manager you open the hardware configuration of the SIMATIC S7-300 station. In the hardware catalog you select the serial CP, the CP341, for example. Drag-and-drop these to a slot in the rack of the S7-300 station.
Double-click the CP341 in the rack to open the Properties dialog of the CP341.
In the Properties dialog of the CP341, you switch to the "General" tab. Click the "Parameter..." button to start the PtP Param configuration software and the CP341.
Select the ASCII protocol. Then double-click the envelope icon representing the protocol to open the "Protocol" dialog and make the protocol-specific settings.
In the "Protocol" dialog you select the "ASCII" tab. Select the values for speed and character frame so that they match the parameters of the hand-held barcode reader. Example:
- Baud rate: 9600 bits/s
- Data bits: 8
- Stop bits: 1
- Parity: none
Click the "OK" button to apply the settings and complete parameterization of the CP 341.
Save and compile the configuration of the S7-300 station. Then load the configuration into the S7-300 CPU.
Close the Hardware Configuration.
Calling function blocks in the S7-300 CPU user program
In order to receive the data of the hand-held barcode reader via the CP 341 in the S7-300 CPU, you call the function block FB7 "P_RCV_RK" in the user program of the S7-300 CPU.
The FB7 "P_RCV_RK" is located in the "CP PtP" library in the folder "CP 341 > Blocks".
In the SIMATIC Manager you open the "CP PtP" library with the menu "File > Open".
In the "Open Project" dialog you switch to the "Libraries" tab.
Select the "CP PtP" library and click the "OK" button.
Copy the FB7 "P_RCV_RK" from the library and insert it in the block in your S7 program.
In this example the call of FB7 "P_RCV_RK" is in FC100. FC100 is called cyclically in OB1.
Set the EN_R input of the block permanently to "TRUE" so that the CP 341 can receive data at any time.
The data received from the hand-held barcode reader is stored in data block DB24.
The outputs NDR, ERROR and STATUS are required for the job evaluation and are only valid in the same cycle.
The output "NDR" is for showing that new data has been received and stored in DB24. If the read job does not complete successfully, the output ERROR = 1 is set and the output STATUS has the error information.
If you are using a CP 340, you call FB2 "P_RCV" in the user program in order to receive the data from the hand-held barcode reader via the CP 340 in the S7-300 CPU. The FB2 "P_RCV" is located in the "CP PtP" library in the folder "CP 340 > Blocks".
The download includes the "CP341_HE40T.zip" project.
Copy the "CP341_HE40T.zip" file into a separate directory and then start the file with a double-click. You then use STEP 7 to open and process the unpacked project data.
CP341_HE40T.zip (10712 KB)
Detailed information about the serial CPs and the SIMATIC MV320 and SIMATIC MV340 hand-held barcode readers is available in the manuals in the following entries:
|SIMATIC S7-300 Point-to-Point Connection; CP 341 Installation and Parameter Assignment||1117397|
|CP 341 Getting Started for Commissioning||1188622|
|SIMATIC S7-300 Point-to-Point Connection; CP 340 Installation and Parameter Assignment||1137332|
|SIMATIC CP 340 Getting Started for Commissioning||12108826|
|SIMATIC Ident Hand-held Barcode Readers SIMATIC MV320 and SIMATIC MV340 Operating Instructions||78905254|
|SIMATIC IDENT Machine Vision Systems SIMATIC MV340 System Manual 2012||61909865|
The screens and downloads in this FAQ response were created with STEP 7 V5.5 SP2 HF1 and PtP Param V5.1 SP12.