How can you send or receive data via the serial interface in WinCC Runtime?
This entry describes how you can send and receive data via the serial interface of your PC in WinCC. For example, in this way you can read in the data of a barcode scanner.
You need the Microsoft Communications Control (mscomm32.ocx) for communicating via the serial interface. However, no liability is assumed nor guarantee granted for the use of third-party ActiveX controls.
The sample scripts have been created in VBS using the following WinCC tags and objects:
- "Connection" - Binary Tag
- "Buffer" - Text tag 8-bit
- "Output" - Text tag 8-bit
- "Main.pdl" - WinCC picture
- "MSComm1" - Microsoft Communications Control, V6.0
You can download the sample scripts here to make things easier:
Scripte_CommPort.zip ( 1 KB )
|1||Insert the "Microsoft Communications Control"|
Insert the control in a WinCC picture. There are no further settings to make. However, you should note that you can only use the function of the control if it is located in an active picture.
|2||Open and parameterize CommPort|
The following VB script shows how you open a port of the serial interface:
The following VB script shows how you close an open port of the serial interface:
|4||Read out the read buffer (receive data)|
The following VB script shows how you read data out of the receive buffer:
The following script sends a string via the serial interface: