Kendrion Kuhnke Automation GmbH
2-port RS232
417
17 May 2021
Sample Program
The example below illustrates how a program works. It does not use library available for the communication
module.
Visit Kendrion Kuhnke's Product Finder to download a sample project and the library.
Link:
http://productfinder.kuhnke.kendrion.com
Run your development environment (e.g. CODESYS) to set the interface parameters, including the baud
rate, parity, stop bits, etc.
Refer to section Object Dictionary. The settings are applied when PreOp turns into SafeOp.
Running SDO components to make changes in state Operational will therefore have no effect.
Transfer Data:
Initial state:TxCounter = 0
TxCounterCon = 0
TxComSwitch = 0 -> COM1, TxComSwitch = 1 -> COM2
TxNrOfMsg := 6;
TxData1[0] = `H`
TxData1[1] = `e`
TxData1[2] = `l`
TxData1[3] = `l`
TxData1[4] = `o`
TxData1[5] = ` `
Increment TxCounter by 1:
TxCounter = 1
TxCounterCon = 0
Slave module accepts data (into a an out-data queue). TxCounterCon = TxCounter acknowledges.
(Data has not necessarily been transferred yet, though. Use COM_TxBusy to check the data
transfer.)
TxCounter = 1
TxCounterCon = 1
TxNrOfMsg := 4;
TxData1[0] = `W`
TxData1[1] = `o`
TxData1[2] = `r`
TxData1[3] = `l
TxData1[4] = 'd'`
Increment TxCounter by 1:
TxCounter = 2
TxCounterCon = 1
Slave module accepts data. TxCounterCon = TxCounter acknowledges.
TxCounter = 2
TxCounterCon = 2
Receive Data:
Initial state:RxCounter = 0
RxCounterCon = 0
The module increments RxCounter by 1:
RxCounter = 1
TxCounterCon = 0
RxComSwitch = 0 -> COM1, RxComSwitch = 1 -> COM2
RxNrOfMsg := 4;
RxData1[0] = `T`
RxData1[1] = `e`
RxData1[2] = `s`
RxData1[3] = `t`
If RxSync is enabled (object 2010 DataSync = RxSync), the module will not be allowed to send the
next set of data until you set RxCounterCon = RxCounter. If RxSync is disabled, the module will
send data without checking RxCounterCon.
RxCounter = 1
RxCounterCon = 1