PROGRAM MAIN
VAR
(* BC8150
Example with 1 x KL2xx4 *)
(* programming address is for example 11. If the address switch 10 then use the PLC project the RS232 interface.
Then is it not possible to debug the PLC project. A restart is not necessay*)
ReadSlaveAddress:ReadSlaveAddress;
FBComOpen:FB_COMPortOpen;
FBComClose:FB_COMPortClose;
COMConfig: ST_COMConfig;
iHandle: INT;
END_VAR
ReadSlaveAddress(
bRead:=TRUE ,
bBusy=> ,
bError=> ,
iErrorId=> ,
iSlaveAdress=> );
IF NOT ReadSlaveAddress.bBusy THEN
ReadSlaveAddress(bRead:=FALSE);
END_IF
COMConfig.BaudRate :=38400;
COMConfig.dwMode:=0;
COMConfig.eCommPort:=COM1;
COMConfig.eDataBits:=EIGHT_DATABITS;
COMConfig.eParity:=EVEN;
COMConfig.eStoppBits:=ONE_STOPPBIT;
IF ReadSlaveAddress.iSlaveAdress =10 THEN
FBComClose(
bClose:=FALSE);
FBComOpen(
bOpen:=TRUE ,
stCOMConfig:=COMConfig ,
bBusy=> ,
bError=> ,
iErrorId=> ,
iHandle=>iHandle );
IF NOT FBComOpen.bBusy THEN
IF NOT FBComOpen.bError THEN
Serial;
OUT.0:=TRUE;
END_IF
END_IF
ELSE
FBComOpen(
bOpen:=FALSE);
FBComClose(
bClose:=TRUE ,
iHandle:=iHandle ,
bBusy=> ,
bError=> ,
iErrorId=> );
IF NOT FBComClose.bBusy THEN
Out:=0;
END_IF
END_IF