Jump to content

"Store DTI to File" fail due to multiple calls


Skout

Recommended Posts

Hi,
My application Ladder code writing to an "Indexed Data Table" (DTI). I'm getting in the writing "Store DTI to File" Ladder function the status (-6) which means "Write file error".
I think that issue is coming from the speed of "Store DTI to File" calls. I use a timer to put a delay between every row, maybe i don't know how to use them, but it doesn't work for me when i put a timer and try it online, it doesn't work.

Link to comment
Share on other sites

Under System.SD Files you have a bit called "Date DT Busy". If I understand correctly, then you need to use it.

If you have 2 writes happening at the same time, then you will cause problems. In every file system, a file can have multiple readers, but only one writer.

 

You can also use the status of the Store DTI. 0 means success (or no errors), 1 means in progress, and any negative number means error.

As soon as you call the Store DTI to file, the status changes from 0 to 1, so you can check the value before trying to execute another write.

 

When loading a DTI from file, you should also check the status (so no read is in progress, because either the file might be in use, or the table is currently being loaded from file.

 

  • Like 1
Link to comment
Share on other sites

Dear Skout,

for each second the PLC do a lot of complete cycles; if you let active the BIT for a request, like "store DTI to file" this will return the error "-35" that means too many request.

I don't know your complete sketch but you have to arise only one time this command and check for the "answer"...usually you can add a simple reset (R) of the BIT command immediately after the UDFB "store DTI to file" and enable another BIT to check the result with "equal" that will do other stuff.

same thing for the instructions INC and DEC etc...if you let active the BIT these will increase/decrease by one every PLC cycle...than wil be very fast. 

EDIT: as SARAGANI wrote to avoid that two instruction are done very close you can check the BIT "SD BUSY" or you can use your own BIT...depends on how you want manage these situation.

Link to comment
Share on other sites

Hi ! 

Yeah i found  Save DT Busy, but i don't know how to deal with it :p  

But the second thing you were talking about seems interesting, so I will be comparing the status of the Store DTi to 0 just before starting the storage, if it's ok we can continue storing if it's not 0 it will wait ?

And I want to get only some analogs inputs ( current - voltage ) get them in the DTI then store them in files on SD, i don't need to read or view them through Ladder ( it's available  in UniApps ) 

image.png

 

EDIT: Tried out the second suggestion, nothing.. I'm pretty sure doing something wrong, I really need some help 

image.thumb.png.5d946d7b6203e351d3939af49be36bcb.png

Edited by Skout
Link to comment
Share on other sites

"I will be comparing the status of the Store DTi to 0 just before starting the storage, if it's ok we can continue storing if it's not 0 it will wait ?"

 

No. This will only work if the last request succeeded. 

If it ended with an error, then you will not be able to do any requests. You should check that the status is not 1 (in progress), and / or also the SD Busy bit.

 

Link to comment
Share on other sites

17 hours ago, Saragani said:

No. This will only work if the last request succeeded. 

If it ended with an error, then you will not be able to do any requests. You should check that the status is not 1 (in progress), and / or also the SD Busy bit.

 

Got the first thing but the SD Busy bit, what does it mean?, what should i do using this output tag?

Link to comment
Share on other sites

UP 

I think the main reason is the missing of the sd card, i got one today and i tried out the Ladder 

image.png.3bc5e04dde52f1cb2af3c00c20b50bb9.png

Actually its working, it writes date correctly, but the Storing Status doesn't set to 0 even if it ended writing ( verified  ) is it a problem ?

I would like to have everyday separated file named with the day when they were created like this one "20180522"   , I'm using "nom fichier table" as a tag, How can i do it ?

Link to comment
Share on other sites

I'm not sure why the status doesn't change to 0. Does it stay as 1 (in progress) or change to negative number (error)?

For converting the current date into a string, I would use a UDFB someone wrote (You can find it in the examples).

Download the example projects from our website. You should find a project called: UniStream_070_RTC_To_ASCII.ulpr

Open that project, and export the function called RTC to ASCII.

The re-open your project and import that function.

Use that imported function (UDFB) in your ladder. The function accepts a format as input, and outputs the result as string.

If you pass a format = 13, then you will get the date as MM-DD-YY, for example,  05-30-18. and if you pass format = 11, then the date will be as DD-MM-YY, for example 30-05-18

 

After you have that string, you can use "Inset String" element for adding the enreg suffix to the result string.

If you need 4 year digits, no separator, and year appearing first, then you can edit the UDFB code, and add another format (like 14), that will do what's needed.

 

Link to comment
Share on other sites

Thanks for answering me, understood what you suggested and tried it out without exporting it in my program  maybe I got an issue with the program because of this 

image.thumb.png.91eb33a289645cee8da8e7f1019d2be5.png

am I supposed to get that in the output ? It's the same with almost the other formats

EDIT : Used an outdated version ( maybe ), tried another one in the same folder it's working, i will try to do the job,  and get back for some feedbacks

Link to comment
Share on other sites

Before closing this topic I would like to know if is it possible to create a folder named YYYY ( Year) where i will stock the both of the files created from "Store DTI to File", How can i use it with this function ? Or how can i choose the folder's path from this function

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