Reading string from CSERI-4 channel (using RS-232) in CODESYS

I am using a GRV-EPIC-PR2 with CSERI-4 connected to an ultrasonic welder over RS-232.

Every time the welder runs a cycle, a string of weld parameters is sent over RS-232 which I am able to see in Node-RED with a Serial In node. However, I want the information in the string (which I will parse in CODESYS) to be available as tags in Igntion Edge so am going the CODESYS route instead of Node-RED. I know that there is a way to communicate between Node-RED and CODESYS, but I eventually plan to onboard other PLC-based machines through CODESYS so I would like to remove Node-RED from the loop and keep this as simple as possible.

I have the EPIC-PR2 and CSERI-4 configured in CODESYS, however I am wondering where I can actually map the string sent to a channel on the CSERI-4 to a variable in CODESYS.

The Mapping tab doesn’t show much. I’m guessing there is more I need to do in my program to configure the RS-232 channel on the serial module and read anything meaningful from it, but I’m not sure where to start and I haven’t found much in Opto training other than communicating with digital I/O modules.

I know nothing about the serial module, so hopefully there’s someone else that can chime in. However, there are a couple examples on CODESYS Forge and the CODESYS Store for communicating with serial ports:

If all else fails, you could use MMP to write the string to a scrachpad location (from NodeRed) that could then be read in CODESYS using the MMP Function Blocks - that seems a little “Hacky” though.

1 Like

This may be the same example project, but it also provides the documentation in the codesys help site.

If you are using Node Red and want to send/receive information from Node Red, you would use the OPC-UA Node in Node Red and configure the Symbol Configuration object in Codesys. The first half of our online training section on Codesys OPC-UA connectivity covers this.

1 Like

Thank you Garrick.

Looks like the newest version of node-red-contrib-opcua is incompatible with my version of Node.js (v14.20.0). I found the most recent version of node-red-contrib-opcua that is compatible with v14.20.0, however it does not have the OPC-UA Client node which I believe I’ll need for this application.

Is it possible to update the version of Node.js that’s on the Epic?

I posted a link to a forum post on installing legacy nodes, which you need to do with the OPC-UA Node.

1 Like

I went to the version history for node-red-contrib-opcua and kept walking back a version until I found the most recent version that was compatible with Node.js v14.20.0.

However the older version of node-red-contrib-opcua is missing the OPC-UA - Client and OPC-UA - Server nodes.

@matt.karee Your first post makes a good point of not wanting to use Node-RED just to read the serial data and pass it to Codesys.
I suggest that you don’t spend any more time trying to install the opcua node as you should be able to shut down node-red totally (for this application at the very least).

1 Like

Makes sense, I will go the CODESYS route then.

Do you know if I can treat the CSERI-4 serial channels in CODESYS like I would treat a serial COM port?

I’m looking at this Serial COM example and not seeing how this would apply for the CSERI-4 but I probably just need to do more research on serial communication in general.

You can find the codesys port numbers under System->Serial Devices in groov Manage:

you can then configure that in Codesys:

Then it is just calling the functions in your code, depending if you are using STL, FB, LD…


3 Likes