How to write to tag from a file in the user directory?

Hi there,

I’m trying to figure out how to write data to Ewon tags which is read from a file in the Ewon user directory.

Currently I’m logging data from a PLC using historical logging, and saving it to a .CSV file in the usr directory of the Ewon. I then want the PLC to validate the data before deleting it so I can confirm that the Ewon has received the correct data. My thinking currently is to read the data from the file and writing it to a tag value which I can then use on the PLC side to compare.

Can anyone please shed some light on how to do this with the Ewon? I’m using an Ewon Flexy 205 with a Siemens PLC.

Thank you in advance.

This is something that you should be able to do, but it may be a little complicated. Will it always be the most recent value that you’re trying to validate? If that’s the case you could probably do something where you parse the historical log to grab the second most recent line (I believe the first line is just the header showing what the parameters are) and then look for the section of that line that has the value you want. Then you could take that parsed value and write it to a tag.

https://techforum.ewon.biz/thread-418.html

Hi Tim

Thank you for the quick response!

It will most likely not always be the most recent value. Currently the .csv file contains maximum 10 lines of logged data and I need to compare each tag in each line with the correct corresponding tag in the PLC (each line contains about 10-12 tags).

I’m still quite new to the Ewon programming, so it might take me a while to work through the examples you suggested. But I will get back to you soonest once I’ve figured out how to use it for my application.

You’re welcome, if you have any questions on the code above let me know

Hi @Tim_hms

So I’ve managed to write code which reads from a .csv file in the usr directory, and then writes those strings to a tag. The problem I have now is that the ewon is very slow when writing the tags. When I run the program without writing the tags, the execution is quite fast. But when I include the section of code which writes the strings to the tags (total of about 14 tags), it is very slow - sometimes even makes the ewon lose connection.

What could be the reason for this? I’m currently only writing the tags (all tags are string data type) from one line in the .csv file, but I’m aiming to write a maximum of 10 lines. So I would definitely need much faster writing to tags.

try putting a print statement in your code during the section where it’s doing the writes. If it seems like there’s a lot of prints to the console you might be running into an issue where the code is looping and you’d need to make some edits