Get xxx[Configuration]-entries for display in a visualization

Hi Community,
I am looking for a way to display static settings from a configuration of an object in a visualization.
I use IF3 interface as Ethernet/Modbus master and would like to display the master IP address from “X20CP1584.IF3[Configuration]” in the visualization.

I would also like to visualize the IP address of a connected Modbus slave, which I have configured with ModbusTcp_any[Configuration].
All this information is saved in the “Hardware.hw” xml file:
Connector Name=“IF3”
Parameter ID=“Operation” Value=“EthOnly”
Parameter ID=“EthernetMode” Value=“Manual”
Parameter ID=“InternetAddress” Value=“192.168.210.30

Is there any library function for extracting this information into a PV which i can use for visualization? Or can I read it i any way from the “Hardware.hw” xml file itself?

I have the same wish for a profinet connection: Can I read out things like “station name” and ip addresses assigned to the devices by the IOController ( X20 IF10E1_1) at runtime?

Any help appreciated, kind regards
Albert

Hi Albert,

The easiest way to get the PLC’s IP address is with the CfgGetIpAddr function block in the AsArCfg library. I’m not sure if a similar approach is possible for Modbus or Profinet devices, so hopefully someone else has an idea here.

If you want to read the full hardware configuration file, that is also possible. The “Hardware.hw” file is used only by Automation Studio. Once the project is transferred to a target, the information from this file gets put into an “arconfig” file. This file can be read or modified at runtime using the AsIOMMan library (or mappIO). If you wanted to get information that’s not available via another function block (similar to CfgGetIpAddr), you could read the arconfig data with AsIOMMCopy by copying it into a data object and parsing the data object. The information will be formatted very similarly to the “Hardware.hw” file.

Hi Marcus,
thanks for this first information. I have looked into the provided example for the AsIOMMan functions (which uses AsIOMMRemove() and AsIOMMCreate() FunctionBlocks). In the example the two data objects “config1” and “config2” must already exist in the AutomationStudio project.
When i use AsIOMMCopy() to copy the current “arconfig” into a new data object, do i have to create this (empty) data object (e.g. “myCfgInfo”) also in advance in AutomationStudio?
i have tried this code:

/* copy “arconfig.br” from target /
AsIOMMCopy_Mod.enable = 1; /
enable /
AsIOMMCopy_Mod.pModuleName = (UDINT) “arconfig”; /
name of the *.br module which should be copied /
AsIOMMCopy_Mod.pNewModule = (UDINT) (UDINT)“myCfgInfo”;
AsIOMMCopy_Mod.memType = 2 ;// USERROM (USER FLASH)
AsIOMMCopy_Mod.option = 1;
/
Call FBK */
AsIOMMCopy(&AsIOMMCopy_Mod);

… i always get this error 30177 “iommERR_DUPOBJECT” (Module already exists with this name).
Is this new data object copied into the User flash (memType = 2)? so can i watch the content of this data object anywhere in AutomationStudio?

And the next challenge for me: How can I parse the data object and search for an entry such as ‘Parameter ID=“IpAddress” Value="192.168.210.10”’
search?
Is DatObjRead() and some string-compare-functions the right tool for this?

Or would it be easier to use mappIO for my problem?

Many thanks for a few more tips,
Best regards, Albert

Do I have to create this (empty) data object (e.g. “myCfgInfo”) also in advance in AutomationStudio?

I don’t think you can create a Data Object in advance, or else you’ll get error 30177. It looks like the AsIOMMCopy function block is expecting to create a new data object in the memory area specified, so you’ll have to pick a new name that doesn’t already exist.

Is this new data object copied into the User flash (memType = 2)? so can I watch the content of this data object anywhere in AutomationStudio?

It can be copied to different locations depending on what you set. If you copy it to the USERROM, you can see it in the Online->Compare Software menu in Automation Studio. Then you can copy it to your local project using “Load from Target”:

For parsing, I think DataObjRead makes the most sense. This will read the data object into a STRING variable that you can parse. Since the data is in XML format, you should be able to use AsXml for this. mapp IO is useful for changing the configuration at runtime, but it doesn’t provide any functions for parsing the arconfig file unfortunately.

Here’s a simple sample project I made to grab the data and put it into a local STRING variable:

ReadArConfigTest.zip (138.6 KB)

While everything you’re asking for is in the arconfig file, it will take a little bit of effort to get it out. But this approach will allow you to get anything you may need.

1 Like

See also the I/O setting Generate the AR configuration modules as simple data object:

1 Like

Hi Marcus,
Thank you very much for your valuable advice. I was able to make some progress and, for example, read out the configured IP address of a ModbusTCP_any slave (in my example “192.168.210.33”) by parsing the XML data (see attached example). However, there are still some questions open for me:

If I manually trigger the FB AsIOMMCopy, it works the first time, but with further attempts i get the error [30177] (Module already exists with this name).

One idea was to remove the config if it already exist. I have tried it with AsIOMMRemove(), but here i get error 30175 (Incorrect module type).
A change of the memory type from doUSRROM to doUSRRAM does not work either.

So how can a solution (copy the arconfig into a global XML-String) look like that works automatically after every restart?

Next question:
I am missing some information in this dataobject (see file “myIOcfg.br” in the CP0482 folder of my project): I have configured the IF3-Powerlink-interface for Modbus(Master)-operation with IP adrress “192.168.210.20” Where is this information stored? It is not in the XML Data.

Do you have a suggestion how i can synchronize my two programs (readCfg and XMLcfgReader), so that i don’t have to trigger anything manual? (The XML parser must wait until the data are available) What elegant method can i use here?

And a last question:
in your example you used code like this:
IF fb_DatObjInfo.enable AND fb_DatObjInfo.status = ERR_OK THEN
but i had to change this to
IF fb_DatObjInfo.enable AND fb_DatObjInfo.status = 0 THEN
(replaced ERR_OK by value 0), otherwise my code did not work as expected.
Can you explain this?

ReadArConfigAndParseXml.zip (275.9 KB)
some Info to this example: In the CP0482-configuration first you must trigger task readCfg by setting ‘copyCfg’ to TRUE. This will copy all data into a global string (in XML fomat). Afterwards, in XMLcfgReader you have to set reader.cmd.doAutomatic to TRUE. This will parse the XML and searches for the entry of the ModbusTCP_any ipadress.

Thanks again for your great support!

Hello Corne Geerts;
also thanks for this advice. Can you tell me where i can see those data objects when i check the box? Should i see the file ‘CfgData.br’ anywhere in my project-filesystem or in AutomationStudio after a rebuild?

You make the changes in your project. You change the name of Cfg and Iom files and do a build.


The files are located in the folder\Temp\Objects\Config1(AS_CPU_PATH)\AS.
You can move these files with windows explorer to a package in your logical view of your AS-project.
Then you repeat these steps for the second configuration, with different names.
The created data objects have to added/deployed to the cpu.

Sample package :
IOMMan.zip (1.9 KB)

Glad I could help! Corne’s solution will also work (and means less code) as long as your configuration settings won’t change during runtime. If the settings are changed and the data object is not updated then the configuration settings you use could be incorrect. In general there’s a tradeoff between static settings and runtime based settings.

  • If settings aren’t changed at runtime, they’re known and therefore using them is easier
  • If settings are changed at runtime, this adds flexibility but also complexity

To answer your questions:

So how can a solution (copy the arconfig into a global XML-String) look like that works automatically after every restart?

I have a couple of ideas here:

  1. Use memory type doTEMP. I expect this gets erased for the next restart
  2. AsIOMMRemove will not remove the data object. This is for removing the arconfig itself. You can remove the data object with the DatObjDelete function block on startup to ensure the old data object is gone.

I am missing some information in this dataobject (see file “myIOcfg.br” in the CP0482 folder of my project): I have configured the IF3-Powerlink-interface for Modbus(Master)-operation with IP adrress “192.168.210.20” Where is this information stored? It is not in the XML Data.

Unfortunately, I’m not seeing it either. It’s possible that this information isn’t available in the exported file. In that case you could either use IF2 (Ethernet interface) as your modbus master, or use the CfgGetIpAddr function block for this information.

Do you have a suggestion how i can synchronize my two programs (readCfg and XMLcfgReader), so that i don’t have to trigger anything manual? (The XML parser must wait until the data are available) What elegant method can i use here?

The only way to transfer data between programs is with global variables. I would recommend creating an Interface structure for each program that contains Commands, Parameters, and Statuses. Each program should have a state machine that processes Commands and Parameters and outputs Statuses, but only if the program is ready to do so. Then, when you’re done exporting the config object, you can set the global command which triggers a read of the object. Another idea is to create a manager program which watches over both programs and triggers both processes when desired.

in your example you used code like this:
IF fb_DatObjInfo.enable AND fb_DatObjInfo.status = ERR_OK THEN
but i had to change this to
IF fb_DatObjInfo.enable AND fb_DatObjInfo.status = 0 THEN
(replaced ERR_OK by value 0), otherwise my code did not work as expected.
Can you explain this?

ERR_OK is a constant that is defined as zero in the “runtime” library. I’m surprised this isn’t working since the runtime library is used in most projects but using the literal 0 should work just the same.

Hi Albert, it looks like you found solution for you topic, do not you? can you marked the reply that makes you the most? or create for us short summary of your final solution?