Beckhoff serial communication

hapetter

Member
Join Date
Feb 2009
Location
Kristiansand
Posts
58
Hi.

I have an application where Im going to read and write commands to/from a laser sensor. The sensor has RS232 serial interface. How can I read and write to the sensor using TwinCAT?

Ex. of a command I like to write:

Set Sample Interval​
2-8 bytes ASCII Code: S <Interval>
(20 <= Interval <= 9999999)
Default: 200000 (5 Samples/second) Input switch code: 8<Sample Rate

Code>

How to implement in TwinCAT?

Best Regards
Hans Pettersson
 
Hi.

I have an application where Im going to read and write commands to/from a laser sensor. The sensor has RS232 serial interface. How can I read and write to the sensor using TwinCAT?

Ex. of a command I like to write:


Set Sample Interval
2-8 bytes ASCII Code: S <Interval>
(20 <= Interval <= 9999999)
Default: 200000 (5 Samples/second) Input switch code: 8<Sample Rate
Code>

How to implement in TwinCAT?

Best Regards
Hans Pettersson


Hi,

There is a library called "Serial communication" which contains block for sending and receiving data over a serial interface.

Have a look in the help files, there are examples showing for both plc control and system manager.

 
You will need to purchase a license for the serial libray.

I have not used the EL6002 and it looks like it is not actually available yet. I have used the EL6001 and it is fairly easy to implement your own code. I created my own function block that I use. In the attached code is the function block SerialCommFB that I used with the EL6001. Feel free to use it.
 
A free library. Cool.

How can I get lib from twincat? Do I copy the file into PLC lib folder?
The other files there is .lib and not .library?

Thanks!

Best Regards
Hans Pettersson
 
A free library. Cool.

How can I get lib from twincat? Do I copy the file into PLC lib folder?
The other files there is .lib and not .library?

Thanks!

Best Regards
Hans Pettersson

Hi,

The file you are to download for TwinCAT has the extension *.lib, I think you downloaded the wrong file.

See picture for how to insert an additional library.
Off topic: I sent you a PM regarding another topic.

TwinCAT.jpg
 
Archie,

So you don't use TwinCAT serial library in the example you sent me?

I could not se the function block "SerialComFB" graphical symbol in Main program?

When I look into TwinCAT dokumentation then talks about beckground task for line control and so on. It seems to me you dont use this principle?

You have to excuse me for these newbe questions. I trying to learn the structured text language as well...

Best Regards
Hans Pettersson
 
So you don't use TwinCAT serial library in the example you sent me?
Hans

That code does not use the Beckhoff serial library.

I wanted something a little simpler that I could import into other projects easily. I have only used it up to 9600 baud, so I'm not sure if it has limitations on baud rate since it runs in the main task.

I removed all the excess code and attached a sample that shows the function block being used in ladder. This should be a little easier to follow.
 
Hello Archie,
I have gone through the SerialCommExample code, you are not using ComLib.lib for serial communication.
I am trying to talk to PC_COM_PORT? Please can you help me in changes I need to do in the project you provided, because I dont have EL6001 hardware!
 

Similar Topics

Hi all, I am currently migrating from Windows 7 system to Windows 10 using the CX5130-0155 controller with an RS232 interface but, found a...
Replies
4
Views
2,410
Hello guys! If anybody has any experience with serial communication in TwinCAT with Beckhoffs PLCs, would be really helpful. I Have: - CX2020...
Replies
9
Views
5,017
Hi, i'm a newbie in PLC world and i'm trying to do project.I have a BX3100 of Beckhoff and i want to connect a scale through the KL6001...
Replies
0
Views
3,090
Hi Guys, I have a Beckhoff CP6607. It has 2 ethernet ports, 2 usb ports, and a serial port. I am trying to connect it to a Scheider VSD, an...
Replies
2
Views
3,975
Hi. Have anyone experience with Beckhoff serial communication library? Best Regrads Hans Pettersson
Replies
0
Views
2,554
Back
Top Bottom