Com Port Reset in TwinCAT3

Join Date
Nov 2018
Location
West Harrison, Indiana
Posts
1
Hello all,

I'm working with TwinCAT3 and using RS232 communication via a CX5120 CPU with the optional RS232 port. I'm able to send and receive data and have no issues with the RS232 setup. However, there are always characters in the FIFO register that are sent whenever I send my first byte to the connected hardware.

So I'm trying to do a ComReset to reset the hardware buffers. Does anyone have a clear example of how to do this? I have seen the Beckhoff example, but it doesn't seem to easy to follow, especially since pointers are used. See below:

VAR_INPUT
Execute : BOOL;
pComIn : POINTER TO BYTE <---(This doesn't tell me much)
pComOut : POINTER TO BYTE <---(Not sure I'm using pointer correctly)
SizeComIn : UINT;
END_VAR
VAR_OUTPUT
Done : BOOL;
Busy : BOOL;
Error : BOOL;
ErrorID : UDINT;
END_VAR

I have tried to use this example, but I'm definitely doing something wrong, because it never clears the hardware buffer. It certainly compiles ok, but there is still something I don't quite understand about how to use it correctly.

If there is anyone out there that could help me with a clear example, I would greatly appreciate it!

Thanks!
 
Last edited:

Similar Topics

I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
6
Views
134
I need to recommend a PC to replace a customer's old Windows 7 computer. The only thing I need to think through is the serial com port to...
Replies
21
Views
686
i have a dell laptop with a real com port host OS is windows 10. Running VB 6.1.42 I cannot get the serial port to configure in VB. Please Help...
Replies
10
Views
1,024
Hey guys, Setting up my new laptop on windows 11. Got all my software working in Ethernet/IP. Now i'm trying to connect into older PLC running...
Replies
10
Views
1,336
Hi everyone, I am an electronics technician that have been given a tutorial, and I would like some help: I have to interface a microcontroller to...
Replies
3
Views
1,463
Back
Top Bottom