I would like to save data in txt file for plotting by Matlab. Following code I am using but result is not that one I want I have shifted to right in each row:
PROGRAM PLC_PRG
VAR
hFile: DWORD;
szFilePath: STRING:= 'C:\ay.txt';
wNewLine: ARRAY[1..20] OF STRING;
(wNewLine:STRING;)
dwWritten:DWORD;
CloseFile: BOOL;
ay:STRING;
i: INT:= 1 ;
strString:STRING;
Lenght: INT;
SizeoFile: DINT;
END_VAR
pnn hat geschrieben:
you write to file var ay which doesn't contain CRLF, write strString instead
Hi,
Thanks for your reply, How can perform CRLF in CodeSys . I solved the problem with "CONCAT" and "$R$N". And now I have problem how to save data in 2 columns in excel file. In such way that if I could plot each column.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear All,
I would like to save data in txt file for plotting by Matlab. Following code I am using but result is not that one I want I have shifted to right in each row:
PROGRAM PLC_PRG
VAR
hFile: DWORD;
szFilePath: STRING:= 'C:\ay.txt';
wNewLine: ARRAY[1..20] OF STRING;
(wNewLine:STRING;)
dwWritten:DWORD;
CloseFile: BOOL;
ay:STRING;
i: INT:= 1 ;
strString:STRING;
Lenght: INT;
SizeoFile: DINT;
END_VAR
hFile := SysFileOpen(szFilePath, 'a');
WHILE (i <> 30) DO
END_WHILE
Lenght := LEN(strString);
(Close the Opened File)
CloseFile := SysFileClose(hFile);
SizeoFile := SysFileGetSize(szFilePath);
Result in ay.txt file I am looking for:
1
2
3
4
5
6
...30
RESULT I GOT:
you write to file var ay which doesn't contain CRLF, write strString instead
Hi,
Thanks for your reply, How can perform CRLF in CodeSys . I solved the problem with "CONCAT" and "$R$N". And now I have problem how to save data in 2 columns in excel file. In such way that if I could plot each column.
put a comma in between the columns so it will be a CDF
and check your string length strstring:string(3);