Dear ctrlX Community!
We would like to connect several Keyence scanner to ctrlX Core via USB RS232 adapter.
I successfully sent and received data in node-RED (with /dev/ttyUSB0 path), but we need to use this solution in PLC runtime.
I tried to open the serial port with SysCom library without any success.
Is there any possibility to handle the USB RS232 adapter in the PLC environment?
Thanks in advance!
Solved! Go to Solution.
After the V1.14 update, we tried to set the following parameters to plc_system.cfg:
portnum := COM.SysCom.SYS_COMPORT1;
This solution works with Codesys PLC runtime on Raspberry Pi, but no success on ctrlX.
Is there any chance to step forward in this question?
update, it is not yet possible to use it.
We are working on it, most likely it will be available in the next version 1.16 from august on.
we implemented the support from version 1.16 on.
Find here some example code.
PROGRAM PLC_PRG VAR result : Syscom.RTS_IEC_RESULT; handle : Syscom.RTS_IEC_HANDLE; settings : Syscom.SysComSettings; bDone : BOOL; arByte : ARRAY[0..99] OF BYTE; udiReturn : UDINT; iState : INT := 0; END_VAR
settings.sPort := SYS_COMPORT1; settings.ulBaudrate := SYS_BR_4800; settings.byParity := SYS_NOPARITY; settings.byStopBits := SYS_ONESTOPBIT; CASE iState OF 0: IF NOT bDone THEN handle := Syscom.SysComOpen2( pSettings:= ADR(settings), pSettingsEx:= 0, pResult:= ADR(result)); bDone := TRUE; iState:= 10; END_IF 10: udiReturn := Syscom.SysComRead( hCom:= handle, pbyBuffer:= ADR(arByte), ulSize:= SIZEOF(arByte), ulTimeout:= 0, pResult:= ADR(result)); END_CASE