Transmit files from PLC to PC

Hello, 

I am new to CXA_FileAsync with FB IL_FileWriteAsync for datalogging, are there any function block or possible to automatically transfer the data logged csv files from ctrlX to my PC every hour?

Warmest regards,

Best reply by LiuPengfei

Hi,

Here is asimple demo code, maybe helpfull for you.

Declaration:

 

PROGRAM IL_FTPPut_Test
VAR
	fbFTPPut : IL_FTPPutAsync;
	fbFTPPutFile : IL_FTPPutFileAsync;
	
	filebuf: STRING(5000) := 'asdasd$R$N12312312$R$Npoipoi$R$N';
	sendlen: UDINT;
	
	itestcase: INT;
END_VAR

 

Implementation:

 

fbFTPPut();
fbFTPPutFile();

CASE itestcase OF
1: // put string
	fbFTPPut.Address := '192.168.1.101';
	fbFTPPut.Login := 'MyPcUserName';
	fbFTPPut.Password := '';
	fbFTPPut.RemoteFile := 'ftpsavefile'; // existing file
	fbFTPPut.ValueAdr := ADR(filebuf);
	fbFTPPut.NoOfBytes := IL_LEN(adr(filebuf));
	sendlen := fbFTPPut.NoOfSendBytes;	
	fbFTPPut.Execute := TRUE;

	IF fbFTPPut.Done THEN
		fbFTPPut.Execute := FALSE;
		itestcase := 0;
	END_IF
	
2: // put fie 
	fbFTPPutFile.Address := '192.168.1.101';
	fbFTPPutFile.Login := 'MyPcUserName';
	fbFTPPutFile.Password := '';
	fbFTPPutFile.RemoteFile := 'ftpcoty.scope'; //300kB
	fbFTPPutFile.LocalFile := ADR('_cnc/xy_2.scope');
	sendlen := fbFTPPutFile.NoOfSendBytes;	
	fbFTPPutFile.Execute := TRUE;

	IF fbFTPPutFile.Done THEN
		fbFTPPutFile.Execute := FALSE;
		itestcase := 0;
	END_IF

END_CASE

 

 

View original
5 replies