RobotStudio event

Robtarget in record are reset to 0 when P-Start

Options
This is my problem.
I create a Tab of record with robtarget, but when I do a P-Start all my robtarget are reset to 0.
My Tab is a persistant variable, and I save my module in the savemanager.
I don't understand why it doesn't keep the value.
If you have any idea how to keep my data even with a P-start, I need your help :smile: 

I hope I made myself clear.

Thanks for the help.
Best regards,

Comments

  • lemster68
    Options
    Do you have your system parameters set to automatically load that module?
    Lee Justice
  • Paul_N
    Options
    Yes I did it... but it doen't work.
  • lemster68
    lemster68 ✭✭✭
    edited September 2018
    Options
    Do you get any kind of error upon startup like value of PERS not updated?  And, is that data shared between tasks?  I.e., same declarations in another task?  Finally, is it declared like so: PERS robtarget {10};  ?  With none of the places filled in.  If so, fill in all the elements of the array with robtarget values.
    Lee Justice
  • Paul_N
    Options
    No, I don't get any error, and the data is not shared between tasks.
    Yes, it's declared as PERS robtarget{10}. 
    I filled all the elements, and the data are not deleted when P-Start. It seems ok like this, but I don't understand why. Because PERS variable are supposed to be kept when restarting.

    Anyway, thank you for your help lemster68.
      :)
  • lemster68
    Options
    You are welcome, I agree.  I ran across this happening not too long ago.
    Lee Justice
  • Dmitry
    Options
    Paul_N said:
    Because PERS variable are supposed to be kept when restarting.
    Only if they have initial value :) Without initial value they behave like VAR.
    See RAPID kernel manual -> Intertask objects.

    A declaration can specify an initial value to a persistent object, but it will only set the initial value of the persistent when the module is installed or loaded for the first time.

    Example of usage (several initial values):

    Task 1: PERS tooldata tool1 := [...];

    Task 2: PERS tooldata tool1 := [...];

    Note that the current value of tool1 will not be updated with the initial value of tool1 in the second loaded module. This is a problem if the initial value differs in the two tasks. This is solved by specifying initial value in one declaration only.

    Example of usage (one initial value):

    Task 1: PERS tooldata tool1 := [...];

    task 2: PERS tooldata tool1;

    After load of the two tasks the current value of tool1 is guaranteed to be equal to the initial value of the declaration in task 1 regardless of the load order of the modules. It is recommended to use this technique for types such as tooldata, wobjdata, and loaddata. Specify initial value along with data declaration in the motiontask and omit initial value in other tasks. It is also possible to specify no initial value at all. Example of usage (no initial value):

    Task 1: PERS num state;

    Task 2: PERS num state;

    The current value of state will be initialized like a variable without initial value, in this case state will be equal to zero. This case is useful for intertask communication where the state of the communication should not be saved when the program is saved or at backup.