Hi,
I'm really confused right now. I've been trying for hours to have a variable saved across power ups but to no avail... I set the following :
int *Last_Tool = &persist.UserData[50];
The value starts at 0
Then later after manipulating the variables , it is set this way:
*Last_Tool = Index;
So now the value is set to my last position of my tool holder.
When I power up again , the variable is set to 0 again. How do I make it so that when it powers up , it will retain the last value that was stored in?
I'm really confused. Thanks for you help.
Saving a variable between power ups
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Saving a variable between power ups
Hi Roamin,
You can save the Current Tool to a PC Disk File to be recovered after a power loss.
See the GetCurrentTool() and SaveCurrentTool() in the Linear4ToolHolders Rev 2.c example
You can save the Current Tool to a PC Disk File to be recovered after a power loss.
See the GetCurrentTool() and SaveCurrentTool() in the Linear4ToolHolders Rev 2.c example
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Saving a variable between power ups
Thanks for your input, Tom
Is there no way to directly save it to the flash memory of the Kflop ? Since everything program can be flashed to the Kflop, surely it's possible to save a single variable?
I will start looking into saving to disk, but it seems overkill to save a single byte?
Thanks
Is there no way to directly save it to the flash memory of the Kflop ? Since everything program can be flashed to the Kflop, surely it's possible to save a single variable?
I will start looking into saving to disk, but it seems overkill to save a single byte?
Thanks
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Saving a variable between power ups
In general if the system has a PC we recommend using the resources of the PC and leave KFLOP in its virgin state. Otherwise it can be confusing if KFLOPs are swapped or replaced. If you prefer to Flash data to KFLOP see the examples in the FlashNonVolatile folder.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Saving a variable between power ups
Thanks for that information. I have used the 2 functions you told me about and now my tool changer keeps track of its tool position after power off.