How does Keep PV option in Download Affects MpRecipe

Hi Community,

I am having some trouble with the Keep PV option in program download working with my MpRecipeCsv command.

If I don’t select it and let the PLC run through the Exit and Init routine after download, everything works fine (I do need to disable MpRecipeReg and MpRecipeCsv in Exit and re-enable them to avoid other trouble).

If I select Keep PV, no matter if I let the PLC execute the Exit and Init routine or not, the MpRecipeCsv command will give an error 32772: INVALID_FILE_NAME if I trigger a recipe load or save.

I want to highlight that I created constants to give device name and file names to MpRecipeCsv. For example:

VAR CONSTANT
fileName : STRING[20] := ‘Recipe’;
deviceName : STRING[20] := ‘F:/recipefiles’
END_VAR

MpRecipeCsv.DeviceName := ADR(deviceName);
MpRecipeCsv.FileName := ADR(fileName);

I suspect the issue is by keeping PV, somehow the pointer to the strings is affected. Though I have tried to run the ADR() command in cyclic and assumed it will update the pointer, it didn’t help.

I believe there are some awesome engineers who can guide me through this.

Thanks👍

I guess I’ll answer this myself.

My specific issue is caused by my function block didn’t update the pointer value during PLC download.

In general, if the program download causes any type of memory restructure like change of UDT or tag size, the pointer used in the program will be affected. Hence, when using pointer, we need to make sure that the pointer is always updated.

Case closed.

1 Like