Jump to content

Write table to SD with date stamp?


Recommended Posts

  • MVP 2023

Hi again all,

 

V130. I am having trouble writing a different name for each consecutive save of a complete data table to the SD card.  I want to do the write as a new file, not an append.

 

I have a large logging data table that is written to every minute, 24/7.  I am then running "Write Data Table to SD" once every 24 hours, so that I will end up with just over 2 months worth of individually named logs on the SD before it reaches the 64 limit, alleviating the current need for me to log on every day to upload the table direct.  I can thus do a remote upload of all of them every 2 months, and then clear things out ready for the next lot.

 

I transact the write ok, but I cannot get a new, separate file being written, it is always overwriting the old one. I can do an append but this is not what I want.  I want to label each new udt save on the SD card with the date/month. I am storing SI32 into an MI.  I select DT (1) as the SD folder and the MI as .udt file name.  I suspect that the problem is either:

 

a). the sometimes strange ways RTC info is derived/stored in PLCs, or

B). is related to the advice "Note that if the name comes from an MI, the function copies a vector 8 bytes long, or until it finds a 'null' character."

 

Perhaps things are reaching a null character before any actual numbers come up, and so the write is being told to go to the same name (no name?) so it overwrites the existing.  Given the varying nature of how the numbers in SI32 work for different dates, I am scratching my head a bit as to how to get this to work.

 

No doubt the solution is really simple, but my brain is stuck in a "dumbo" loop which we all get from time to time, and emerge from smacking our head going stoopid, stoopid, stoopid!  All suggestions gratefully received!

 

cheers,

Aus

Link to comment
Share on other sites

  • MVP 2023

I have better luck with with creating .csv files on the SD card for large data sets, one line at a time.  Make sure you change the delimiter to "0D" (carriage return) in the definition block.

 

Look at the Examples - V570_SD_Card_demo.vlp subroutine 4 for logging and Main:Net 2 for how to create a time and date string.

 

Joe T.

Link to comment
Share on other sites

  • MVP 2023

Thanks Joe, will do, but I have played with the RTC to ASCII conversions and didn't have any luck.  I will have another go using the example as my guide as it seems the way to go and I likely did something wrong.

 

Don't know where the emoticon, instead of point B). came from in my OP!

 

Since then I have played some more and have an update found with different dates.  It would appear that the original dates I was experimenting with all delivered the same name just by chance. In these cases I have stored SI32 into a DW, but going on memory of the previous attempts with the overwriting, I think the same result is likely using an MI.

I can get it all working fine with 3 separate files with the following:

 

Y_.UDT for 29/05/2015, (yeah...aussie date format!);

 __.UDT for 30/05 and

J.UDT for 1/06.

 

There is still something going on that I can't fathom in getting the seemingly simple task of changing SI32, which is the numbers I want in the order I want, into the new name for the next .UDT file.  Everything is working fine, just the names are wrong and it looks like there might be some overlaps of names which I first encountered which might lead to overwriting at some stage.  So I am there, but not quite.

 

Can someone enlighten me as to how the RTC values are developed and moved around within the system, as I think this is the fundamental info I am missing.

 

cheers,

 

Aus

Link to comment
Share on other sites

  • MVP 2023

I have got it to work ok.

 

In my first trials I tried using the RTC to ASCII conversion.  However, there was an unsuccessful write with the transfer status keeping on throwing up a no. 8 error (correct...no. 8!) for some reason, so I eventually gave up and tried another path.  After Joe's suggestion, I went back to the original idea using the parameters shown in the attached jpg...it is very wide to show the ladder, Sd write settings and also the results of 3 successful runs viewed via SD Card Explorer, all in the one screenshot.  Sorry for the high compression but it is readable enough.  MB11 is a combine of various things for the SD.

 

I don't know why it is working now, I haven't done anything differently except that I think that I was originally using the dd/mm format instead of DD_MM_YY.  Regardless...it works ok and is the result I want.  Thanks for the help and perhaps it might be of use to others.

 

cheers,

 

Aus

 

post-12856-0-97994600-1432984509_thumb.jpg

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...