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

DataLogging for analysis on Excel

2016-07-26
2021-11-29
  • pinal.baraiya - 2016-07-26

    Hello There,

    I am using CodeSys V3.5, SP8, Patch 2.

    In my project we need to log the data like pressure, temperature, hours, etc. in CSV format for analysis on microsoft excel later on.

    Is there any sample program available for reference to log these kind of data. My all data are UINT or INT.

    if someone can point me the function and/or library for the same, then also it will be helpful.

    Is there anything available on Codesys Store?

    Thanks in advance.

     
  • learnetk - 2016-07-26

    Hi,
    you could use the CSV Utility from the store, but that costs. Else you could use the Oscat library
    for Excel logging.

     
  • pinal.baraiya - 2016-07-27

    Hello Learnetk,

    Thanks for your reply, where can i get this OSCAT library?

    Thanks,

     
  • wollvieh

    wollvieh - 2016-07-27

    hi.
    i use my own csv writer.
    actually i work with codesys v3.5.SP9.Patch1.

    sample file which was written with the codesys :

    my program, which is running on windows 8.1 sysrem with the codesys control win3 :
    maybe you'll have fun with that stuff.....

    there are 3 kind of people : the good, the bad, and the ugly.

    IMG: sample.JPG

    test_csv.project [114.43 KiB]

     
    • m0nkeyd - 2021-11-29

      Hello,

      I'm trying to run you project to understans how it works. I am running codesys V3.5 sp12 Patch7 in simulation but no Test.csv file is created. Do you have any idea?

      Thank you in advance

       
    • m0nkeyd - 2021-11-29

      Hello,

      I'm trying to run you project to understans how it works. I am running codesys V3.5 sp12 Patch7 in simulation but no Test.csv file is created. Do you have any idea?

      Thank you in advance

       
  • pinal.baraiya - 2016-07-28

    Hello wollvieh,

    First of all a huge thanks for the sample program. i will go through it and will try to utilise the same.

    Meanwhile, i am using Codesys V3.5, SP8, Patch 2.... so when i opened your program, it was opened incompletely, i am right now, downloading V3.5, SP9... and will see if i could open it correctly.

    thanks again,

     
  • Anonymous - 2016-09-12

    Originally created by: barkamharikrishna

    HI,
    it is very easy Task
    just use sysfile library functions
    step1 : sysfileopen : it is open required csv file or creates automatically new file with name you give if file does not exist
    step2 : sysfilewrite : writes all the data in to .csv file.
    step3 : sysfileclose : Close the file once writing is done in step2.

     
    • m0nkeyd - 2021-11-29

      Hi,
      are you sure that "sysfileopen" creates automaticcaly a CSV file? It is not written in the documentation.

      Thanks

       
    • m0nkeyd - 2021-11-29

      Hi,
      are you sure that "sysfileopen" creates automaticcaly a CSV file? It is not written in the documentation.

      Thanks

       
  • mehrobot - 2016-11-20

    Hi, you guys sems to know your stuff so I'm hijacking this thread hoping to get educated.
    I'm somewhat a newbie in codesys, more advanced excel manouvers and programming in general so please be patient with me.

    I'm looking for a way to get real time data from Codesys V3.5 SP8 Patch 1 into Excel 2016 so I can plot graphs to analyze my process.

    I've tried using DDE interface by typing:

    =CODESYS|'C:\Codesys\Projects\Myproject.project'!PLC_PRG.value

    into an empty spreadsheeet but all I get is the error message:

    "Remote data not available, another program has to start to access the data" (or something like it, translated from my native language)
    "do you want to start the program CODESYS.EXE?"
    [Yes][NO] (yes)
    "CODESYS.EXE cannot be run. The program or its components are damaged or missing"

    I've also sucessfully manage to retrive data from the OPC Server to the Matrikon OPC Explorer-client but I just don't know where to go from there.

    I don't understand how to use the sysfile library. I think I would need a example project or a tutorial to understand how to use it.

    Also I've tred to open wollvieh's .csv writer and like pinal.barayia I get a bunch of error codes. Also I'm not sure if creating a .csv file would help me get real time data into excel?

    How would you solve my problem? Or can you please point me in the right direction?

    Thanks in advance!

     
  • Anonymous - 2016-12-02

    Originally created by: barkamharikrishna

    Hi mehrobot,
    it is easy to get real time data to ur code by below program

    // Getting all the RTC data in to programmable data
    SysTimeRtcGet(pResult := u32_pResult);
    SysTimeRtcConvertUtcToDate(u32_dwTimestampUtc,d_Date);
    u32_Utcdata := SysTimeRtc.SysTimeRtcGet(u32_pResult);
    SysTimeRtc.SysTimeRtcConvertUtcToDate(u32_Utcdata,ti_Alldata);
    now to save ur real time to into Excel is moreeasy

    step 1 : create new .csv file .
    2. write ur real time to the Excel ..
    example
    t_handle := SysFileOpen(szFile := s_filename_Inst ,am := SysFile.ACCESS_MODE.AM_APPEND_PLUS,pResult := ADR(t_error));
    SysFileWrite(hFile := t_handle,pbyBuffer := ADR(S_WriteBuffer),ulSize := len(S_WriteBuffer),pResult := ADR(t_error));
    SysFileClose(hFile := t_handle);

    in above example variables are used in program. please use that lib and work ...

     
  • SpeedyG - 2018-03-19

    I know it's a long shot, @wollvieh or anybody who can help:

    Zitat:
    i use my own csv writer.
    actually i work with codesys v3.5.SP9.Patch1.

    First of all, thank you @wollvieh for your code! I tried to make it work (now with Codesys V3.5 SP11 Patch 3 + (32bit)) and so far I've solved all the errors and fixed the libraries so I can start it in simulation mode. When I start the simulation, the program starts generating the numbers, but no file is created. I invested quite some time, searched the internet and asked my colleges and so on, but no one new the solution to this. I'm just a beginner so far and I'm running out of options. If you could help me solve this, it would mean a great deal to me!

    Thank you in advance,
    SpeedyG

     
  • SpeedyG - 2018-03-20

    Zitat:
    so I can start it in simulation mode

    That might be my fault from the beginning. It doesn't run yet, but I think in simulation it never could work I guess...

     
  • eschwellinger

    eschwellinger - 2018-03-20

    yes,
    you could just Login to the local plc -> Control Win (start the plc in the tasktray - Project to be updated to this plc type)

    BR
    Edwin

     
  • SpeedyG - 2018-03-20

    It would be nice, if it would be that easy.^^ When I want to start the program, I get the following error message:
    Exception [ProcessorLoadWatchDog]occured in App=[all], Task=[all]Β 

    Any suggestions? The Internet/forum doesn't say much about it...

    Thx!

     

Log in to post a comment.