Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Some recipe values storing with extra characters

TPTSys
2021-04-22
2021-04-26
  • TPTSys

    TPTSys - 2021-04-22

    Certain values of real type variables show extra characters in the recipe. The extra characters are also present in the recipe text file. As far as I can see, despite the strange extra characters the values save and restore properly, but it is causing some concern.

    Has anyone had a similar problem? Is there a way to solve this?

    For example:
    The value 0.9 saves as 0.9F16#E666666H-6
    The value 0.99 does something similar.
    the value 1.9 does something similar
    the value 2.9 saves and displays properly.

    There are some other values that do this too, though most store properly.
    Using RecipeManCommands function block to load and save recipes.
    The arrays which hold the recipe values are defined like this:

    //in global variable "rec"
        Cmd: RecipeManCommands;
        ActiveRecipeDef:STRING:='RecipeDef01';  //The current active recipe
        ActiveRecipeIndex:INT:=0;   //The index of the current active recipe
        sRecipeNames:ARRAY[0..max_recipes] OF STRING;    //Array of the recipe names
        sRecipeVariableNames:ARRAY[0..max_Variables] OF STRING;   //Array of the recipe variable names
        sRecipeValues:ARRAY[0..max_variables] OF STRING;  //Array that stores the recipe values
    

    Code to save the current PLC values to the recipe:

    rec.resultSaveRecipe:=rec.Cmd.ReadAndSaveRecipe(RecipeDefinitionName:=rec.ActiveRecipeDef,RecipeName:=rec.sRecipeNames[rec.ActiveRecipeIndex]);
    

    Code that loads the recipe values from the recipe storage to the display arrays

            rec.resultGetRecipeValues:=rec.Cmd.GetRecipeValues(RecipeDefinitionName:=rec.ActiveRecipeDef,RecipeName:=rec.sRecipeNames[rec.ActiveRecipeIndex],pStrings:=ADR(rec.sRecipeValues),iStartIndex:=0, iSize:=rec.max_Variables, iStringLength:=80);
            rec.resultGetRecipeVariableNames:=rec.Cmd.GetRecipeVariableNames(RecipeDefinitionName:=rec.ActiveRecipeDef,RecipeName:=rec.sRecipeNames[rec.ActiveRecipeIndex],pStrings:=ADR(rec.sRecipeVariableNames),iStartIndex:=0,iSize:=rec.max_Variables);
    

    Project Info:
    Codesys Version 3.5.16.40 64bit
    RecipeManagement 3.5.16.40
    Recipe Storage Textual
    Using Comma separator
    Recipe Management in the PLC

     
  • m.prestel

    m.prestel - 2021-04-22

    Hey,
    The values appended are the exact binary value.

    With Recipes 4.1.0.0 this value can be skipped from being created with the compiler define RECIPE_GENERATE_SIMPLE_STRINGREAL.

    Best regards,
    Marcel

     
  • TPTSys

    TPTSys - 2021-04-23

    Marcel,

    Thank you, i see how the value is the exact binary value now.

    I am not familiar with Recipes 4.1.0.0, is this a library?
    Is there a way i can implement this option in my project?

     
  • m.prestel

    m.prestel - 2021-04-26

    Hey,
    4.1.0.0 is the lib version
    You can always simply split the string apart at the # and use the first index.

    Best regards,
    Marcel

     

Log in to post a comment.