Jump to content

csv 512 bytes per line


Recommended Posts

Hi David,

SD card is divided to "chunks" of 512 bytes and each write is to such chunk. If you want to make your log more "memory effective", you can define a vector of 256 MI and then add each new record to this vector. When the vector is filled as close as possible to 509 bytes (the system needs 2-3 bytes for its purposes!) you will copy it as one delimited line to Excel. As each real line has its own <CR><LF>, when opening the file in Excel you will not feel in any way the result of "compressing".

If you need more help with performing this idea, let me know.

Link to comment
Share on other sites

  • 7 years later...
  • MVP 2021
15 hours ago, HexMan said:

More than 190 bytes per row for nothing!

Actually, more like 446 bytes wasted.  If you want to be more efficient you can pack more data into your block before you write it.

But the 512 bytes per write number is hard coded in the operating system.  If you have a 4 GB card, that's something like 7.8 million writes.

Does it really matter? How often are you writing the data?

Joe T.

Link to comment
Share on other sites

The problem is, rather, download the file (by RS232) or the treatment in Excel. Effectively it is not a storage issue.

One of the solutions can be to generate monthly CSV files, although I have not yet found the way to concatenate a string with a numeric value, export201806, for example.

If you have any ideas, I appreciate it.

Greetings and thanks again.

Link to comment
Share on other sites

  • MVP 2021

Check out the string tools - 

image.png.9ecc21975fb750a9a4f6e1fc6a5e6b0f.png

Remember that Unitronics stores both numbers and strings in MI registers.  If you have the string "export" stored in hex form in MI 3000.. 3002, you can use the Num To ASCII function to covert your numbers to string blocks.  If you point the output of the block at MI 3003 you will inherently concatenate it.  You can check your work with a little-known feature of Visilogic - the the bottom there is the Memory tab.  It can be set up to view strings in real time, although each line is limited to 32 registers.

image.png.f1a8943ece0ebb588a4101f95412316b.png

You can concatenate other strings by using the Vector copy block to move them into different locations in a continuous register block.  This is low-level compared to other programming languages, but PLCs never were designed to be string manipulators.  Just know it can be done.  If you post your code with specific questions we can help.

Joe T.

Link to comment
Share on other sites

Concept OK, but...

I don´t have "export"  stored in MIs, I use "export" in a block, as you can see:

1.PNG.82054e809224d6c6b168c6533adfe2b7.PNG

I don´t know how I can  put "export" in MIs, and them how use these MIs in the "File Name" field.

Thinking in the 8 character restriction may be a good idea generare a "20180606" for CSV name. If I put SI33, SI38 and SI38 in consecutive MIs, I can use It?

 

 

 

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...