Welcome to the Schneider Electric corporate Website

ENGLISH | FRENCH

You can choose another country to view available products or go to our Global website for company information.

Choose your country or region

    Technical FAQs

    Ask a Question

    How to extend the life of a File System SD Card used for Logging Data

    Goals and Symptoms
    How to extend the life of a File System SD Card used for Logging Data

    Facts and Change
    Unity, 

    Causes and Fixes
    The MODICON M340 and M580 SD Card Interface Buffer is 512 Bytes.
    The optional SD File Storage Cards have 512 Byte Sectors.
    The SD Card Interface includes Wear Leveling Algorithms.

    SD Cards have a limited number of Write Operations per Sector before the Sector is marked bad (approximately 100,000).
    Delete Operations also count against the number of Write Operations.
    There is no 'Gas Gauge' to know when a Sector is approaching its end of life.

    Because of these technology restrictions it is critical to optimize the use of the MODICON M340 and M580 SD File Storage Card.
    This is accomplished by only writing 512 Bytes per Write Operation.

    There are two exceptions to this:
    > The total number of Bytes required in a file is less than 512 Bytes.
    > The last Write to a file before closing it will be less than 512 Bytes.


    M340/M580 SD File Storage Card Best Practices
    1) Instances of the File Management EFBs in Unity Pro should be executed every scan.
    This insures that the Done, Status and Error output data from them EFBs is always updated.
    2) File names on the SD File Storage Card must be unique.
    3) Files should be opened and remain open for as long as there will be data written.
    Avoid Opening and Closing Files each time Writing is required.
    4) Avoid FTP Client interaction with the Log Files that are currently Open.
    5) The use of Periodic Scan Configuration of the MAST Task will reduce (improve) SD File Storage Card FTP file transfer time.


    Below is Example Code. This code is only provided as a reference and is incomplete to actually
    function as there is no File Create/Open nor Close.

    The purpose of the Example Code is to demonstrate a method of limiting the Writing of data to the
    SD File Storage Card with 512 Bytes when the overall amount of data needing to be written is
    greater than 512 Bytes.

    If you require a Functional Example or Application Assistance with MODICON M340 and M580 SD
    File Storage Card Writing then contact your local Schneider Electric Representative or Schneider
    Electric Technical Support.

    Here are the Variables defined and used in the Example Code.

     
     

    EXAMPLE CODE

        IF %S13 THEN (* First Scan Initialization *)
        MyDINT := 0;
        My1025byteVariable := '';
        END_IF;
        IF WR_DATA_TO_FILE_EFB.DONE THEN
        RESET(MyWriteToFile);
        My512byteVariable := '';
        JMP Skip_1_Scan;
        END_IF;
        IF NOT %S13 OR (WR_DATA_TO_FILE_EFB.DONE AND NOT MyWriteToFile_TargetReached) THEN
            WHILE LEN_INT(IN := My1025byteVariable) <= 512 DO
            MyDINTasSTRING := DINT_TO_STRING(IN := MyDINT); (* MyDINTasSTRING length = 11 characters *)
            My1025byteVariable := CONCAT_STR(IN1 := My1025byteVariable,
                                                IN2 := MyDINTasSTRING);
            MyDINT := MyDINT + 1;
            END_WHILE(* here: the length of My1025byteVariable will always be 512..522 *)
            My512byteVariable := My1025byteVariable(* truncation will not set %S15 *)
            MyTempINT := LEN_INT(My1025byteVariable);
            My1025byteVariable := MID_INT(My1025byteVariable, MyTempINT - 512, 513);
        END_IF;
    Skip_1_Scan:
        IF NOT MyWriteToFile_TargetReached THEN
        SET(MyWriteToFile);
        END_IF;
        WR_DATA_TO_FILE_EFB(REQ := MyWriteToFile,
                            FILEDESC := MyFileDesc,
                            VARIABLE := My512byteVariable,
                            DONE => MyWriteToFile_DONE,
                            ERROR => MyWriteToFile_ERROR,
                            STATUS => MyWriteToFile_STATUS);
        MyWriteTest_CTU(CU := MyWriteToFile,
                        R := %S13,
                        PV := MyWriteToFile_Target,
                        Q => MyWriteToFile_TargetReached,
                        CV => MyWriteToFile_Count);
     
     
    Was this helpful?
    What can we do to improve the information ?