Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Export data with the Trend API

PVermeulen
2018-02-19
2020-10-03
  • PVermeulen - 2018-02-19

    Goodmorning,

    I don't know if i'm posting it in the right topic, so if so! Sorry for that.
    Just started a few weeks ago with Codesys so my experience is still quite basic.

    Is it possible to export the data from the Codesys trending to CSV file with the Trend API Example?

     
  • pruwetbe - 2020-09-28

    Hello,

    I am searching on the same subject.

    I found yesterday some example from the codesys store using the visutrendstorageAPI to read the file.
    This tools are creating an output to the console in a csv form but I did not find how to redirect these content to a csv file,
    The function to read value exists in the library and the utility to create CSV exists too, (also available on the store)
    So it is possible but not immediate...

    Did you already combine them to create an export tool program.

     
  • Morberis

    Morberis - 2020-09-28

    The easiest way that I know of to log data to a csv file is to make use of the datalog manager.

    You can also write something in visual designer to convert the sqlite file to csv but... that's more of a pain.

     

    Last edit: Morberis 2020-09-28
  • pruwetbe - 2020-10-01

    Thanks for your feedback.
    I tested also the possibility to explore Sqllite file using a standard SQLite browser that has the export to CSV capacity.
    This quite easy except that the format for logging floating point value in the SQLite is Dint .
    The consequence is that the CSV file will be very big.
    So I will check datalog manager capacity in the next days.

    My idea would be in this case to log filtered value of my signals with a longer sampling time.

     
  • pruwetbe - 2020-10-01

    I checked the datalog manager... this is a nice flexible tool but I don’t know the standard tools that can use such file for plotting some curve , I continue to investigate.

     
    • Morberis

      Morberis - 2020-10-01

      For plotting it on the PLC or on a computer?

      It might be worth your time to talk to Codesys support.

       
  • pruwetbe - 2020-10-01

    To plot on a computer...
    There are plenty of tools to plot curve from CSV file where the first coutume is the time stamp and other column give value for each tag
    Here the datalog create on line for each log with timestamp, value, tag, type, group... ... and the recording is based on deadband for analog value
    I think I could probably find some solution with some python.
    I will try this datalog soon.

     
    • Morberis

      Morberis - 2020-10-01

      You can set in the DatalogStorage_CSV module what symbol(,;: etc) indicates the start of a new column. When you import the CSV file into excel it asks what symbol indicates a column seperation. So if you pick that same symbol in both steps you'll get your data in multiple columns for easy graphing etc.

       
  • pruwetbe - 2020-10-01

    Yes but my problem was that more the way the data logged are saved.
    The most standard CSV flat file have the tag name on the first line and then values for each tag on each line with time stamp as first colum
    I will try to use the ac datalog but I need first to find how to add the application composer menu to be able to add the datalog in the device hierarchy

     
    πŸ‘
    1
    • Morberis

      Morberis - 2020-10-01

      Ah. First add the ac_datalog library, then hit alt+2 to bring up the module window. After that add the datalog manager, datalog channel, then datalog storage.

      You pick which application it is being deployed to in the datalog manager under the deployment window.

       
  • pruwetbe - 2020-10-02

    It is strange that our last message is not displayed here.
    Anyway , thanks to your help , I finally catch where to add the ac datalog library ...
    then did the module
    Add the HMI display statistic
    Search where to connect the HMI data...
    Find a example project in a other conversation Here on datalog
    Discovered how to generate the config using AC that create the objects in the application and add program and tasks..
    And finally got the datalog working...

    I also discovered that I can trigger a save of all data every x ms in the channel configuration so I hope that the data will be grouped in the CSV file on one line.

    I also finallly catch how the trend storage api is working but could not succeed in reading more than one the 3 data that are recorded...

    So It is a good progress...
    Thanks for your help again

     
  • pruwetbe - 2020-10-03

    Hello,
    I understand now where my missing message were. i was answering at the starting message rather than the last...
    So Datalog is working now.
    I discovered that the HVAC library i am using has internally some logging group that must be configured but in a separate channel to avoid saving continuously all functions blocks parameters.
    So i created a separate channel for logging these on event (change only) in a sqlite file
    Also, for some reason i ignore, all parameters from my programs FB using HVAC FB from library where also logged without need to specify them individually.

    But even when saving on a predefined cyclic time, the csv file format is still the same (one line for each tag)
    I join one extract file.
    So i still need some query tools to reformat this file to a traditional CSV graphing tools.
    I can do this with some python script and it will be easier here because all tags have the same timestamp but if some body knows standard free tools for tracing from event log csv file, i would be so happy.

    Trace also allows to save data on CSV file but the data are also grouped tag by tag and i could not succeed in storing them from my codesys app running on RPI up to now.
    The joined file was from Trace example project downloaded from forge shared project and running on control win.

     

Log in to post a comment.