BK8x00 - FB Slave COM-Port

With this function block, the PC (TwinCAT or KS8000) can be connected with the BXxxxx via the serial interface. The PC acts as the serial master, and the BXxxxx emulates a BK8x00 with the aid of the function block.

BK8x00 - FB Slave COM-Port 1:
Function block FB_BX_BK8X00_SLAVE

VAR_INPUT

stCOMConfig      :ST_COMConfig;
byAddress        :BYTE;
byLenDataOut     :BYTE;
byLenDataIN      :BYTE;
ptDataOut        :POINTER TO BYTE;
ptDataIN         :POINTER TO BYTE;
WDTime           :TIME;

Legend

stComConfig: Structure for selecting the COM parameters
byAddress: BX8x00 address 1-98 (0 and 99 are reserved)
byLenDataOut: data length in [BYTES] (only even numbers are permitted, i.e. 0, 2, 4, ...)
byLenDataIn: data length in [BYTES] (only even numbers are permitted, i.e. 0, 2, 4, ...)
ptDataOut: is connected with ADR and data out  
ptDataIn: is connected with ADR and data in
WDTime: error message if no new data are received within the watchdog time (0 ms disable WD)

VAR_OUTPUT

bError       :BOOL;
iErrorId     :WORD;
Input_Len    :BYTE;

Legend

bError: error bit
iErrorId: Error number
Input_Len: number of data that were received

Return parameter iErrorId

Meaning

0

No error

1

Watchdog error, if greater than 0 ms (WD disable if 0 ms)

100dec

Error during opening of the COM port

101dec

Error during sending of data

103dec

Internal receive buffer overflow

104dec

Data exceed the PLC buffer capacity (more than 500 bytes)

105dec

Data cannot be copied into the PLC buffer

200dec

CRC error

Hardware

RS232 communication PIN assignment

BX COM 1 RS232

BX COM 2 RS232

PC COM interface

2

8

2

3

7

3

5

5

5

RS485 communication PIN assignment

FB settings: When using the RS485 connection it is important that the stCOMConfig variable is set to 1 and that the COM2 interface is selected.

BX COM 2 RS485

PC COM port (e.g. RS485 card W&T #13601, 2-wire, without echo, automatic) 

1

1 - 2 bridges

6

6 - 7 bridges

ST sample program for BXxxx

BK8x00 - FB Slave COM-Port 2: Download (sample file)

System Manager file for TwinCAT as master. As shown in the figure, a Bus Coupler with Bus Terminals is configured. In this case, the type and number of Bus Terminals determines the data length. In principle, the type of Bus Terminal is irrelevant. Sample:

BK8x00 - FB Slave COM-Port 3:
Communication features

Required material:

bk8x00_salve.prx