Modbus TCP slave port 502

Hello.
I have an B&R X20CP1483-1 (processeur x86 100 MHz, Automation Runtime V3.06).and I would like connect home assistant to it.

Does someone know what I have modified to open port 502 ?

I tried some setup but until now I can’t have a success TCP port 502 connection.

My automation system manages the lights and power outlets in my home. Everything is working very well at the moment, but I am just missing communication on port 502 as a slave :frowning:

My setup is fairly basic, consisting of a CPU X20CP1483-1, 7 input cards X20DI9371 , 18 output cards X20DO4649, and 1 analog output card X20AO4622. I use Automation Studio V 3.0.90.22 SP4. Automattion Runtime V03.06 Visual Components 3.73.4

have the project and can easily share it privately with the person who can help me. If necessary, I can provide any other information available in Automation Studio.

Thanks in advance.

Regards

Fred

Hello @Frederick_Montulet.
Is the PLC a Modbus Master?

The default port is 502, not 520.
If your PLC is the master, you need to configure ModbusTcp_any in the physical view. Here you can set up all settings, port number including (B&R Online Help)
Don’t forget to enable Modbus communication at the ETH of the PLC (B&R Online Help)

Hello, my bad the right port is well 502. I will try to follow your instruction this evening. I’ll keep you in touch. Thanks

Hi,

you mentioned home assistant.

I personally don’t use HA, but from what I know HA is a ModbusTCP master, that means the PLC has to be a slave.
Unfortunately, the AR integrated ModbusTCP slave was introduced with AR 4.08, which is not availiable for X20CP1483-1 (this PLC was discontinued before AS/AR 4 was released).
So there’s no integrated ModbusTCP slave available.

The’re at least one open-source user library implementation for ModbusTCP on AR out there on Github, but it’s for Automation Studio 6 in the actual version. Earlier releases were based on AS4 or even AS3, so maybe you will have a look to that?

Best regards!

Hello @alexander.hefner ,
Thank you for the valuable information, even though it is unfortunately not the news I was hoping for.
Indeed, to communicate with HA, my CPU needs to be a slave,
I fully understand that my hardware is old and that this complicates matters.
As a B&R expert, what solution would you recommend?
1/ Is there any way to configure my old CPU as a slave on port 502?
2/ If that isn’t possible, could I consider simply replacing my CPU with a newer model to gain this functionality—without having to replace all the I/O modules?
If so, which model should I buy, and what is the price range?
Another question: could controlling my CPU using version 6 of Automation Studio get around this?
Or does the problem lie solely with the CPU itself, which doesn’t support this function?
One last question: do you have a contact I could call to discuss my project?
Thanks in advance,
Frederick

Hi Tomas,

Thanks for your reply.

I need to have my CPU a slave, not a master.

Do you have an idea how I could do this ?.

Regards,

Fred

1.) based on information from Alex before, you can not configure your old CPU as a modbus slave. Maybe you can use user library, but this needs from you little bit of search and some level of programming skills.

2.) update to newest AS and newer HW would be for sure option. Generally updaing project to newer AS is possible, if you do not use some legacy libraries or additional legacy hw. New AS can be used with trial version, newer PLC e.g. * X20CP1484-1 (just example, without knowing project) is always connected to cost. You can find out used one on ebay. If you buy new one, you will get a support as well. But for home automation is always question if is it worth it.

Hi @Frederick_Montulet ,

the questions aren’t easy to answer as I don’t know your projects content, complete hardware configuration, AS version you’re using, your level of expertise of the B&R system, a.s.o.
But I think I can at least give some more hints (hopefully :wink: ).

In principle: yes, but only by using the mentioned open-source library implementation for ModbusTCP which supports ModbusTCP master and slave.
The version of this library to use depends on what Automation Studio you use right now.

As additional information: the X20CP1483-1 is still supported up to the newest AS4 version, which is AS4.12.
If you haven’t used AS4.x until now, to use this PLC in an actual setup some prerequisites have to be fulfilled:

  • Automation Runtime 3.06 isn’t longer available for download → you have to use one of the last available AR versions for this PLC → last one is AR I3.10.
  • You need to download and install AR 3.10 separately, as it’s not in the default installation of AS4.12 included. Can be downloaded here for X20CP1483-1, has to be installed then by AS4.12 Tools → Upgrades → Local
  • the existing project itself has to updated to AS4 also, if not already in that version. The prerequisites and way to update it depend on the existing version of the project (is it already AS4, is it already >= AS4.3, is it still AS3.x or even older?)
  • When creating a new / additional hardware configuration in AS4.12, the “show legacy elements” function in the hardware catalogue needs to be activated to find the PLC

with this prerequisites, the PLC can be projected with AS4.12.

But, as we already clarified: the missing integrated ModbusTCP slave is not an Automation Studio, but an Automation Runtime topic → as no Automation Runtime >= V4.08 exists for the X20CP1483-1, we can’t get this functionality as embedded solution independent of using AS4.12: we still have to use then the open source implemention!

Any more actual X20 PLC, for example PLCs starting with Product code X20CP15xy, 35xy, 16xy, 36xy, all X20EMxyxy and all X20CP04xy support AR versions >= 4.08 (please note: 4.08 is also quite old, it’s just the first version supporting ModbusTCP slave internally. Always use the latest AR version availalbe when starting something new). The X20x5yz models are just supported up to AS 4.12 too, the others are supported by AS6 also (but AS6 is not mandatory to get the ModbusTCP slave, AS4 + AR4 would be still enough).

As I don’t know the project background, it’s hard to say which family would be needed if upgrading, because that depends strongly on the number of IOs, drives, the visualization, and many more things. But as we’re talking about a Home Assistent interface, I assume we’re talking about building automation? If yes, and if it’s not a complete office complex, I think even one of the smaller PLCs out of the Compact-S familiy (X20CP04xy) could be suitable.
About pricing I haven’t any information, I’m sorry. But some B&R components are also available at RS Components (https://www.rs-online.com/), so could have a look there.

No, every PLC with an Ethernet Inferface and a (enough) actual Automation Runtime has this functionality.

So, after that much text, what’s my final recommendation? :wink:

If you have some programming experience with the B&R system, I would try to follow the open source library approach first, before thinking about new hardware.

If possible, I would try to upgrade the project to AS 4.12, if it’s already right now is using at least AS4.3. If not, I would at least try to integrate the sources of this library and build the suitable library container around as source libraries aren’t so different between AS4 and AS3 for example (or trying to use an older release then V2.00, maybe the sample / sources there already fit to your used AS version → the runtime version 3.06 you use imply that you have at least some AS3.x version in use).

I can’t do real tests because of missing hardware and infrastructure, but I had a quick look into the sources and they are quite general → means, that the implementation is using mostly standard functions who were available also in earlier versions of AR.
In my simple test scenario, I used release version 2.00 of the library, opened the demo project of this release, created a AS4.12 configuration with an X20CP1483-1 using AR I3.10, and it compiles without error (of course, there has to be done then some more programming, but mainly just around feeding and retreiving data from the ModbusTCP buffers provided by the library to your own process variables).

Best regards!

To start with, I’d like to try the external library solution to use port 502. I don’t have programation skills, but I’m passionate about home automation. I can carry out clearly described tasks and replicate existing code for other devices. If I’m given the code to place in VAR or CYCLIC for exemple, I’ll be able to do it. Thanks for the help, in any case.

Hello Alexander, thank you very much for taking the time to reply.

Your information is clear and precise.

I have updated the post description to include the requested details about my setup; that should help clarify things for you.

“My setup is fairly basic, consisting of a CPU X20CP1483-1, 7 input cards X20DI9371 , 18 output cards X20DO4649, and 1 analog output card X20AO4622. I use Automation Studio V 3.0.90.22 SP4. Automattion Runtime V03.06 Visual Components 3.73.4”

As you might expect, I’d like to start by trying the solution using the external library to see if it works. I don’t have programming skills, but if I’m guided step-by-step, I’m capable of implementing the code. Do you think you could help me, or point me toward someone who could?

Do I have to change the Automation Runtime version from 3.06 to 3.10 and AS 3.06 to AS 3.10 to implement this solution?

Is there a risk that my installation might stop working afterwards? And if that happens, could I revert to the old configuration using AR 3.06?

If I were to upgrade the CPU, I understand that I would need to choose a model featuring at least AR 4.08. Given the models mentioned and the fact that I only need a connection on port 502, which model do you think would be the most suitable ? Still X20CP04xy ?

Best regards,

Frederick

Hi,

I’m really not sure if I can help, as my available timeframes to do so aren’t that big … but I hope the topic is not an urgent one (am I right?), so maybe within the coming months / “between the years” there could be a chance, so at least I think I could try … but to be honest, I can’t guarantee anything (especially as I’m not familiar with Home Assistant, so I don’t know if the’re special requirements that the slave has to fulfill).

And integrating the library is just one topic - we need to understand, that after having this functionality in the project, the work just begins → the “mapping” of the process variables to Modbus registers has to be done, therefore not only code is neccessary, but also knowing at least some basics about the ModbusTCP protocol like “what are coils, what are registers, which data has to be read, which hast to be written”, and so on.

ModbusTCP is just a protocol, but is not defining the content → there’s for example no “standard” where a light switch, a relay and so on has to be located in the IO image, just some basics like “if it’s a analogue value, registers have to be used, if it’s a digital value, coils have to be used”.
And it makes no difference if we’re using the library approach or the Automation Runtime integrated ModbusTCP slave → in both variants, the “real data content” has to be configured and setup right for every datapoint (either by programming, or by configuring/mapping).

→ Those background infos aren’t showstoppers in my opinion: but in the end, I just wanted to mention it so that it’s clear, that there’s no functionality like “after opening the slave port, the data model of the PLC / IOs is already defined and known”, independent of which PLC / AR / implementation is used.
Additionally, I wrote that info also because of the home automation background as I know, that the’re often protocols / dedicated devices used which have such functionality (a pre-defined data model).

Okay, as long as we don’t know exactly how to proceed, I would stay with everything as it is! About the AS3.0.90 version → that means that you have also a AS3.0.90 license? I’m just asking because even if you have one, a new installation of this AS3.0.90 would not work anymore as the license servers needed to activate this version are shutdown years ago.

Not mandatory, but maybe it would make sense to use the last version available (also maybe for Visual Components). An maybe some last AS 3.0.90 version is needed to maintain the project in future.

But before thinking about all that upgrade stuff, first we have to check if we get the library “back to AS3.0.90” … I think so, but I’ve to try first because this step is cruical to get a clear impression if we can follow this way.

We can never rule it out to 100%, but if we make some baby-steps in AS and AR version, I think the risk of failure is nearby zero. And yes, as long as we have a backup we can go the step back.

From what you’ve wrote about the hardware setup: yes, I still think this would be possible.

I’ll send you additionally a private message about that topic.

Best regards!

Hello.

My project obviously isn’t urgent.

I’m taking it one step at a time, and the first step for me is having access to the PLC via port 502. Once that’s sorted out, I’ll be able to start configuring Home Assistant—which I’m not familiar with yet, but I’ll learn as I go.

So, for the moment, I’m stuck at this port 502 stage :frowning:

Regarding crash recovery: If I understand correctly, the runtime version is stored in all my project files. So, if I install AS version 4 and update the runtime to version 4, and—unfortunately—my installation stops working, I will still be able to reload the original version using AS version 3. Is that right?

Hi,

as long as you don’t loose your original project sources and additionally keep the AS3.0.90 version installed, then yes you can go back to the “old” project.

AS3 and AS4 can be installed in parallel, and to keep your old project untouched, I recommend to also keep the old AS installed. The reason is, that with AS4.x the AR version 3.06 is not delivered (you can just get AR versions 3.09 & 3.10 with Automation Studio 4.12), and 3.06 it also not available via download (as far as I’ve seen). So you should take care not to loose the AR 3.06 installation, and this means from my knowledge to keep the AS3.0.90 installation.

Best regards!

Understood—the two projects really need to be kept separate. In that case, I can have one project in AS 3 and another in AS 4. The AR version is saved in one of the project files. That’s reassuring news. :slight_smile:

You have a PLC with a CF card, so you can create a backup image or generate a second testing CF card with your “testing and playing”. The goal you are trying to achieve needs some level of expertise and knowledge. You can either upskill yourself or maybe ask a freelancer to help you. Maybe even here? The community can connect people, but without guarantee or taking responsibility.

My CPU does indeed have a CF card. However, I don’t quite understand its purpose, given that I load my project from the PC. What do you recommend for backups? Should I simply copy the card’s contents to my PC, or should I buy a new card and copy the contents of the first one onto it?

I hope that by gathering information, doing research, and talking to experts, I’ll be able to improve my skills. That said, I won’t be able to manage this on my own, so I’m open to any offers of help from the community. With today’s technology, distance is no longer an obstacle; a remote connection is all that’s needed to assist me.

Hi,

the CF card is more or less the “harddisk of your PLC”. Everything you’re transferring with AS to the system is stored on the CF.

Please note: never remove or plug the CF card if the PLC is powered! It’s not hot-plug capable and would damage the system.

For backup, B&R provides a tool called “Runtime Utility Center” these days. As I remember, with AS3 it was called “PVITransfer”.
This tool can create and restore an image of the CF card. I can’t send screenshots right now, as I’m not at my PC. But the tool should be already installed together with Automation Studio.
To create and restore images, you need an USB CF Card Reader that is supported native by Windows (no driver installation needed by the card reader), but nothing very special.

About a 2nd CF card: B&R doesn’t prohibit the ise of 3rd party CF cards, but cannot guarantee that they are working properly. I’ve seen both in past: cards working without any issue, and cards don’t working or don’t working reliable.
But right now you don’t need a 2nd CF card, but having an image of the CF is a good idea before changing software.

As soon as I have the possibility to do, I’ll add some screenshots.

BG!