saving the kmotion cnc jogged value to a permanent common variables

Moderators: TomKerekes, dynomotion

ajith
Posts: 65
Joined: Sat May 21, 2022 3:57 am
Location: TamilNadu

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by ajith » Wed Jul 06, 2022 11:48 am

Respected sir,
double GetUserDataDouble(int i)
{
double d;

((int*)(&d))[0] = persist.UserData[i*2];
((int*)(&d))[1] = persist.UserData[i*2+1];
return d;
}
i and TMP are 10 which specifies where the value is located, not the value of variable 5220
i*2 = 10*2 = 20, I*2+1 = 10*2+1 = 21. So variable 5220 can be extracted from the pair of persist variables 20 and 21
In the above function block the variable 5220 value is stored in the TMP .my question is how the TMP value get accessed with persist.userdata{0] and [21].
#include "KMotionDef.h"


#define TMP 10 // which spare persist to use to transfer data

#include "KflopToKMotionCNCFunctions.c"

#define Xaxis 0
#define Yaxis 1
#define Zaxis 2
main()
{
double DROx, DROy, DROz, DROa, DROb, DROc;
GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
SetUserDataDouble(TMP,DROx);
SetVars(100+Xaxis+1, 1, TMP);
SetUserDataDouble(TMP,DROy);
SetVars(100+Yaxis+1, 1, TMP);
SetUserDataDouble(TMP,DROz);
SetVars(100+Zaxis+1, 1, TMP);
DoPC(PC_COMM_UPDATE_FIXTURE);
}
using above program format but with the variable 5220 in the place of 100 is used which records the all dro value .
but is there away to change the variable 100 instead of 5220. i tied but i cant do it

User avatar
TomKerekes
Posts: 2527
Joined: Mon Dec 04, 2017 1:49 am

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by TomKerekes » Wed Jul 06, 2022 4:27 pm

In the above function block the variable 5220 value is stored in the TMP .my question is how the TMP value get accessed with persist.userdata{0] and [21].
Did you mean 20 and 21? I'ts not clear what you are asking. But the value is not stored into TMP. Rather TMP indicates where it is placed into the persist.UserData array.
using above program format but with the variable 5220 in the place of 100 is used which records the all dro value .
but is there away to change the variable 100 instead of 5220. i tied but i cant do it
That code would store the XYZ DROs into GCode Vars 101, 102, and 103. Is that what you want to do? The GCode Variables int the 5220 range are special for the GCode Offsets. That range is fixed and can't be changed. The Variable 0 - 4999 are for any use you want.
Regards,

Tom Kerekes
Dynomotion, Inc.

ajith
Posts: 65
Joined: Sat May 21, 2022 3:57 am
Location: TamilNadu

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by ajith » Thu Jul 07, 2022 6:21 am

Respected sir,
Did you mean 20 and 21? I'ts not clear what you are asking. But the value is not stored into TMP. Rather TMP indicates where it is placed into the persist.UserData array.
you told that the vaue is not stored in TMP and it indicates where it placed.
double GetUserDataDouble(int i)
{
double d;

((int*)(&d))[0] = persist.UserData[i*2];
((int*)(&d))[1] = persist.UserData[i*2+1];
return d;
}
i and TMP are 10 which specifies where the value is located, not the value of variable 5220
i*2 = 10*2 = 20, I*2+1 = 10*2+1 = 21. So variable 5220 can be extracted from the pair of persist variables 20 and 21
In the above "getuserdatadouble" function block whether the temporary persist variable is 20 and 21.if it is, then how TMP=i=10 represent it.
That code would store the XYZ DROs into GCode Vars 101, 102, and 103. Is that what you want to do? The GCode Variables int the 5220 range are special for the GCode Offsets. That range is fixed and can't be changed. The Variable 0 - 4999 are for any use you want.
My requirement is that whether there is a way to add extra variables like 100 into the varsfile if do so then can we use the below program to save my dro value into the variable 100.
#include "KMotionDef.h"


#define TMP 10 // which spare persist to use to transfer data

#include "KflopToKMotionCNCFunctions.c"

#define Xaxis 0
#define Yaxis 1
#define Zaxis 2
main()
{
double DROx, DROy, DROz, DROa, DROb, DROc;
GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
SetUserDataDouble(TMP,DROx);
SetVars(100+Xaxis+1, 1, TMP);
SetUserDataDouble(TMP,DROy);
SetVars(100+Yaxis+1, 1, TMP);
SetUserDataDouble(TMP,DROz);
SetVars(100+Zaxis+1, 1, TMP);
DoPC(PC_COMM_UPDATE_FIXTURE);
}

User avatar
TomKerekes
Posts: 2527
Joined: Mon Dec 04, 2017 1:49 am

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by TomKerekes » Thu Jul 07, 2022 4:13 pm

In the above "getuserdatadouble" function block whether the temporary persist variable is 20 and 21.if it is, then how TMP=i=10 represent it.
it is the index of the pair of two variables.

My requirement is that whether there is a way to add extra variables like 100 into the varsfile if do so then can we use the below program to save my dro value into the variable 100.
Yes. But for some reason you are adding 1 so it would start with 101. This saves it to the GCode Interpreter variables in memory. Not to a file. You can change the emc.var file to save it on program exit and restore it on program start.
Regards,

Tom Kerekes
Dynomotion, Inc.

ajith
Posts: 65
Joined: Sat May 21, 2022 3:57 am
Location: TamilNadu

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by ajith » Fri Jul 08, 2022 12:34 pm

respected sir,
i had altered my program and modified my emc vars file so that i can store my dro value in #100, #101, #102 etc...
my doubt is that will this changes reflect in my fixture offset variable that is stored default in the emc vars file.
emc100.PNG

whether is it possible to add password for this function because i had already tried to create a password program that is incorporate with my user button .but thats still in progress.

User avatar
TomKerekes
Posts: 2527
Joined: Mon Dec 04, 2017 1:49 am

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by TomKerekes » Fri Jul 08, 2022 4:59 pm

Variables #100 - #104 will have no effect on fixture offsets.

If you have code to ask for a password you might add that to this code.
Regards,

Tom Kerekes
Dynomotion, Inc.

ajith
Posts: 65
Joined: Sat May 21, 2022 3:57 am
Location: TamilNadu

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by ajith » Sat Jul 09, 2022 11:51 am

Respected sir,
#include "KMotionDef.h"

#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"

void main()
{
int Answer;
float value;
Answer = InputBox("Enter the four digit password",&value);
float a=value;
int i=0;
if (Answer==0)
{
printf("The password is entered\n");
if(a==1234)
{
printf("The entered password is correct\n");
ScreenScript("SScript:UNLOCK DEFAULT.SCR");
printf("Screen unlocked\n");
}
else
{
printf("The entered password is incorrect\n");
ScreenScript("SScript:LOCK DEFAULT.SCR");
printf("The screen is not unlocked\n");
value=0;
}
}
else
{
printf("The entered password is not entered\n");
ScreenScript("SScript:LOCK DEFAULT.SCR");
printf("The screen is not unlocked\n");
value=0;
}
}
This is the program I have been used to change the gcode screen to read and writ mode along with the code to ask for a password.but there is a bug I wants to clear that is the password i have been using is stored and displayed as dropdown box whenever i entered the password.Is there a way to clear it
WhatsApp Image 2022-07-09 at 5.05.12 PM.jpeg
char *p = (char *)gather_buffer + GATH_OFF * sizeof(int);
what is the purpose of this line ?
what is gather_buffer?
WaitNextTimeSlice();
what is the purpose of this command line?

Variables #100 - #104 will have no effect on fixture offsets.
what happens if i use variables other than fixture offset variable?
Is there a limit that only a particular amount of variable can be stored and accessed in VARS FILE?

User avatar
TomKerekes
Posts: 2527
Joined: Mon Dec 04, 2017 1:49 am

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by TomKerekes » Sat Jul 09, 2022 5:22 pm

This is the program I have been used to change the gcode screen to read and writ mode along with the code to ask for a password.but there is a bug I wants to clear that is the password i have been using is stored and displayed as dropdown box whenever i entered the password.Is there a way to clear it
I wouldn't call that a bug. We already discussed this.

char *p = (char *)gather_buffer + GATH_OFF * sizeof(int);

what is the purpose of this line ?
what is gather_buffer?
The gather_buffer is an general purpose 8MByte buffer often used for gathering data for plots and so forth.

The line creates a character pointer 'p' into it at some offset.
what happens if i use variables other than fixture offset variable?
Is there a limit that only a particular amount of variable can be stored and accessed in VARS FILE?
Like I said before variables 0-4999 are available for you to use however you wish. Nothing will happen unless you use them for some purpose.
Regards,

Tom Kerekes
Dynomotion, Inc.

ajith
Posts: 65
Joined: Sat May 21, 2022 3:57 am
Location: TamilNadu

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by ajith » Mon Jul 11, 2022 4:25 am

Respected sir,
WhatsApp Image 2022-07-09 at 5.05.12 PM.jpeg
my program to ask for password works fine but the password i have been typing in the inputbox get listed as dropdown box as shown in the above image. Is it possible to create to clear the drop down box.

User avatar
TomKerekes
Posts: 2527
Joined: Mon Dec 04, 2017 1:49 am

Re: saving the kmotion cnc jogged value to a permanent common variables

Post by TomKerekes » Mon Jul 11, 2022 4:23 pm

My mistake I thought it was you asking the same question. See here.

But no there is no option to clear recent entries without changing KMotionCNC's source code.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply