CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Wed Jan 22, 2020 10:21 pm

All times are UTC+01:00

Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Aug 25, 2019 10:21 am 

Joined: Tue Apr 09, 2019 2:31 pm
Posts: 9
Using Raspberry Pi, I can receive sensor values ​​using SPI and Ethernet communication.

But I want to save the received value as a file that can be opened in window instead of being stored in codesys (just like '.txt' or .excel').

Is there a way to do it?

Best regards

PostPosted: Mon Aug 26, 2019 9:15 am 
Frequent User
Frequent User

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 176
for built in function see ... n=
or for managing the file format by yourself see ... =

PostPosted: Sat Aug 31, 2019 6:21 am 

Joined: Sat Apr 15, 2017 6:24 am
Posts: 12
I have a simple csv log program use caa.file and systime library.No additional license required.
   sTemplateFileName:FILE.CAA.FILENAME:='C:/Log/template.csv';//template csv head
   xEnable: BOOL;
   arData:ARRAY[1..10] OF REAL;


CASE iState OF
   0://get act date
      IF xStartRecord THEN
         udiResult := SysTimeRtcConvertUtcToLocal(udiUtcTime, udiUtcTimeLocal);
         sFileWriteName:=CONCAT('C:/Log/',RIGHT(DATE_TO_STRING(dtDate),10));//<- need change
         IF udiUtcTimeLocal <> 0 THEN
   10://open act file or create file
      fileOpen(xExecute:=TRUE,sFileName:=sFileWriteName,xExclusive:=FALSE,eFileMode:= File.MODE.MAPPD);
      IF fileOpen.xDone THEN
         iState:=50;//have file
      ELSIF fileOpen.xError THEN
         iState:=20;//no file,create it
   20://create file
      fileCopy(xExecute:=TRUE,sFileNameDest:=sFileWriteName,sFileNameSource:=sTemplateFileName,xOverWrite:= TRUE);
      IF FileCopy.xDone OR FileCopy.xError THEN
   50://generate string
      //write data
      //act local time
      udiResult := SysTimeRtcConvertUtcToLocal(udiUtcTime, udiUtcTimeLocal);
      //add string
      FOR i := 1 TO iDataSize DO
         IF i <> iDataSize THEN
         ELSIF i = iDataSize THEN
   60://write to file
      IF fileWrite.xDone THEN
      ELSIF fileWrite.xError THEN
         iState:= 32767;
         FileWrite(xExecute:= FALSE);
   70://write delay
      IF ton_Delay.Q THEN
      ELSIF xStopRecord THEN
      IF FileClose.xDone OR FileClose.xError THEN

Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00

Who is online

Users browsing this forum: Andreas Kehrer, I-Campbell and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited