Author Topic: Saving a CSV File  (Read 14021 times)

jbryant87

  • Newbie
  • Posts: 11
  • I'm a llama!
    • View Profile
Saving a CSV File
« on: November 12, 2018, 03:51:43 AM »
I need to create and save a CSV file onto a network connected PC using an FX1616BA PLC

Now i have never done anything like this before so i dont even know where to start with the commands.
What i am trying to do is the following:

1. Create a file, the filename will be the value of dm[100] (MAN SERIAL)
2. take data from registers then save them to the CSV file eg>
dm[102] = "SERIAL NO1"
dm[103] = "SERIAL NO2"
dm[104] = "SERIAL NO3"
dm[105] = "RESULT1"

CSV file will look like this:

MAN SERIAL, INLET "SERIAL NO1", FILTER "SERIAL NO2", OUTLET "SERIAL NO3", LEAK RESULT "RESULT1, "TIME" , "DATE"

Is this something that can be done?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Saving a CSV File
« Reply #1 on: November 13, 2018, 08:21:23 PM »
Yes but you need to run a server software on your PC that can receive data from a connected TCP/IP device.

The simplest server for such an application would be the TLServer that you already have. You need to run the TLServer and the PLC would connect to the TLServer IP address and use the <REMOTEFS> tag.

You can refer to the sample program in "TestEthernet.PC6" that you can find in the following folder:

C:\TRiLOGI\TL6\usr\samples\Ethernet

The example can be found in Circuit #10 and a screen short is shown below.

If your PC has a PHP engine running you could also write a PHP script and wait for HTTP GET command sent by the PLC. The PHP script can then save the data to data file or even directly update to MySQL database. You can design your own message exchange format between you PHP script and the PLC. This is more advanced stuff but can be as powerful as you want them to be.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

jbryant87

  • Newbie
  • Posts: 11
  • I'm a llama!
    • View Profile
Re:Saving a CSV File
« Reply #2 on: November 20, 2018, 09:10:23 AM »
I have got this system working now using the TL Server software.

The only problem I can see with this is that I will need to install this on a customer server, and I can only find it paired with the full PLC program package.

Is there a way to get TL server as a stand-alone. Or can I use another piece of software such as FileZilla to do the same thing?
If using something like FileZilla will the command be the same?

Thanks in advance

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Saving a CSV File
« Reply #3 on: November 20, 2018, 02:47:05 PM »
I have used TL Server running on a customer's PLC for the purpose of having the PLC write directly to data logging files on the customer's PC.  I ran into issues with this approach and found that data was periodically lost between the PLC and TL Server.  

As you indicated that your are using a Fx1616BA PLC, you do have a big junk of memory that is optimized to allow you to create text files that are easily accessible via FTP (Filezilla ...).

I use the following TBASIC code to write the current system configuration out to file that is accessible via FTP:

Code: [Select]
' WriteSysConf - create system configuration file
'
PRINT #8 "<WRITE Z020.TXT>"               ' Open file
a = Status(2)
i = SysConf_I16                        ' index into EEPROM data

' #1 Configuration file identifier
'
PRINT #8 "<SystemSetup>";"\0d\0a";

' #2 Installation name
PRINT #8 Load_EEP$(SystemName_S);"\09Installation Name\0d\0a";

' #3 Tanks in use Binary map
'
a = Load_EEP(i) : i = i + 1
PRINT #8 "&h";Hex$(a,4);"\09Tanks in Use Map\0d\0a";

' #4..11 tank connection map for each filler
'
for n = 1 to 8
   a = Load_EEP(i) : i = i + 1
   PRINT #8 "&h";Hex$(a,4);"\09Filler #";str$(n);" Connection Map\0d\0a";
next

' the bulk of the code has been deleted as this is just an example
'
PRINT #8 "<EOF>";"\0d\0a";            ' End of file marker
PRINT #8 "</>"                     ' Close file


This file can be accessed remotely in a couple of ways:
  • FTP (FileZilla). My PLC is at 192.168.1.16

With FTP you can copy the file from the PLC, you can delete the file from the PLC and you can replace the file on the PLC.
  • Internet broszer. Enter "192.168.1.16:9080/Z020.TXT".  The contents of the text file will be displayed:


<SystemSetup>
Putney Garage   Installation Name
&h0007   Tanks in Use Map
&h0007   Filler #1 Connection Map
&h0000   Filler #2 Connection Map
&h0000   Filler #3 Connection Map
&h0000   Filler #4 Connection Map
&h0000   Filler #5 Connection Map
&h0000   Filler #6 Connection Map
&h0000   Filler #7 Connection Map
&h0000   Filler #8 Connection Map
<EOF>
[/list]

I use the FTP approach to manage 30+ PLC systems.  I use the same  PLC firmware for all 30+ systems. But, each is configured for the specific installation using customized ASCII configuration file(s).

Best Regards,

Gary D*ckinson