Jump to content
Skout

"Store DTI to File" fail due to multiple calls

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.

Share this post


Link to post
Share on other sites

Hey ! 

Its so fast, the increment, how can i manage it ? i have tried all the timers we got in unilogic it doesn't work, even thought sometimes it works if i isolate the timer using his output's contact 

image.thumb.png.4b212b7d751a239761e14fcb6e61f1eb.png

image.png.3ef5b89e23c6196619a3244c1b4b1108.png

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

 

Share this post


Link to post
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?

Share this post


Link to post
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 ?

Share this post


Link to post
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.

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×