Hi Lars,
Writing data to FLASH is a possibility but there are a limited number of write cycles (10000+).
Writing data to disk in the form of a C #include file is another possibility. Here is a simple example that helped a User keep track of the Last Tool Loaded:
A Program to Write the File:
Code:
#include "KMotionDef.h"
#define LAST_TOOL_VAR 7 // Tool changer Last tool position is saved globally in this Var
int *LastTool = &persist.UserData[LAST_TOOL_VAR];
main()
{
*LastTool=1234; // as an example
FILE *f=fopen("C:\\temp\\LastTool.h","wt");
fprintf(f,"#define SAVED_LAST_TOOL %d\n",*LastTool);
fclose(f);
}
The file Written:
#define SAVED_LAST_TOOL 1234
Program to access the data:
Code:
#include "KMotionDef.h"
#include "C:\temp\LastTool.h"
#define LAST_TOOL_VAR 7 // Tool changer Last tool position is saved globally in this Var
int *LastTool = &persist.UserData[LAST_TOOL_VAR];
main()
{
*LastTool = SAVED_LAST_TOOL;
printf("LastTool was = %d\n",*LastTool);
}
M6 now passes both the Slot and the Tool ID. The Slot is passed into the specified Variable and the Tool ID is passed in the next Variable.
HTH
Regards