Akram Louati
Level-1
- Beiträge
- 5
- Reaktionspunkte
- 0
-> Hier kostenlos registrieren
Hi,
I'm a new user of the Beckhoff plc. I'm trying to communicate with a device using the serial communication by sending a string. I'm using the library tc2.SerialCom and twincat 3. I created a function block as follows:
and I did the the Background communication in the main program as follows:
The parameter Busy is false but nothing is coming to the device. What could be the reason for that?
Thank you in advance.
I'm a new user of the Beckhoff plc. I'm trying to communicate with a device using the serial communication by sending a string. I'm using the library tc2.SerialCom and twincat 3. I created a function block as follows:
Code:
FUNCTION_BLOCK FB_SerialCom
VAR_IN_OUT
TxBuffer : ComBuffer;
END_VAR
VAR
Send_String :Sendstring;
END_VAR
VAR_OUTPUT
bSendBusy : BOOL;
eSendErrorID : ComError_t;
END_VAR
Code:
Send_String(
SendString := '%R1Q,9027:1.0,1.0,0,1,0\r\n\n',
TXbuffer := TxBuffer,
Busy => bSendBusy,
Error => eSendErrorID);
and I did the the Background communication in the main program as follows:
Code:
PROGRAM MAIN
VAR
stIn_PcCom AT %I* : PcComInData; (* linked to the port in the TwinCAT System Manager *)
stOut_PcCom AT %Q* : PcComOutData; (* linked to the port in the TwinCAT System Manager *)
TxBufferPcCom : ComBuffer;
RxBufferPcCom : ComBuffer;
(* background communication with the PC COM port device *)
fbPcComCtrl : SerialLineControl;
bPcComCtrlError : BOOL;
ePcComCtrlErrorID : ComError_t;
END_VAR
Code:
fbPcComCtrl(
Mode := SERIALLINEMODE_PC_COM_PORT,
pComIn := ADR(stIn_PcCom),
pComOut := ADR(stOut_PcCom),
SizeComIn := SIZEOF(stIn_PcCom),
Error => bPcComCtrlError,
ErrorID => ePcComCtrlErrorID,
TxBuffer := TxBufferPcCom,
RxBuffer := RxBufferPcCom );
The parameter Busy is false but nothing is coming to the device. What could be the reason for that?
Thank you in advance.
Zuletzt bearbeitet: