saving the kmotion cnc jogged value to a permanent common variables
Moderators: TomKerekes, dynomotion
Re: saving the kmotion cnc jogged value to a permanent common variables
Respected Sir,
using the "SetFixturez.c" program i can the read the value in the offset variable. but the jogged value gets added in the same variable unless i change the fixture offset in the gcode screen. is there a way to store the jogged value one by one in each variable in the variable file .and also i need to combine "SetFixtureX.c", "SetFixtureY.c", "SetFixtureZ.c" into a single program so that when I press a user button I need to move all three axis value to variable file in corresponding each variable. now im trying to combine these three program but i cant understand the functions used in these program.where can i find the description of the function used in the "SetFixturez.c" program.
regards,
M.Ajith Arawinth,
using the "SetFixturez.c" program i can the read the value in the offset variable. but the jogged value gets added in the same variable unless i change the fixture offset in the gcode screen. is there a way to store the jogged value one by one in each variable in the variable file .and also i need to combine "SetFixtureX.c", "SetFixtureY.c", "SetFixtureZ.c" into a single program so that when I press a user button I need to move all three axis value to variable file in corresponding each variable. now im trying to combine these three program but i cant understand the functions used in these program.where can i find the description of the function used in the "SetFixturez.c" program.
regards,
M.Ajith Arawinth,
- TomKerekes
- Posts: 2529
- Joined: Mon Dec 04, 2017 1:49 am
Re: saving the kmotion cnc jogged value to a permanent common variables
Hi Ajith,
Well the functions should be fairly self-explanatory.
You don't understand what GetDROs does?
Please put some effort into studying the Program and explain what parts you understand and don't understand.
The basic function this program does (which is somewhat different from what you may want) is:
New Fixture Offset = Previous Origin Offset + DRO
Well the functions should be fairly self-explanatory.
You don't understand what GetDROs does?
Please put some effort into studying the Program and explain what parts you understand and don't understand.
The basic function this program does (which is somewhat different from what you may want) is:
New Fixture Offset = Previous Origin Offset + DRO
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: saving the kmotion cnc jogged value to a permanent common variables
Respected Sir,
After gone through the "SetFixtureZ.c" I had doubts in the following program lines,
can you explain what is
After gone through the "SetFixtureZ.c" I had doubts in the following program lines,
can you explain what is
and[PC_COMM_PERSIST+2]
what is the purpose of variable n(no of elements)? can you explain this command lineDoPCInt(PC_COMM_GET_VARS,varoff);
what is this line mean((int*)(&d))[1] = persist.UserData[i*2+1];
if (DoPCInt(PC_COMM_GET_DROS,TMP)) return 1;
- TomKerekes
- Posts: 2529
- Joined: Mon Dec 04, 2017 1:49 am
Re: saving the kmotion cnc jogged value to a permanent common variables
Hi Ajith,
I think you would be better focusing on what the functions do rather than how they do it. You only need to know what they do to use them. But sometimes it helps to know how they do things.
This line of code gets the 2nd persist variable - persist.UserData[i*2+1].
Then takes the memory address of the double "&d".
Then tells the Compiler to treat it as an address that points to an integer "((int*)(&d))".
Then advances to the next integer memory location " ((int*)(&d))[1]"
And puts the persist variable there.
Minor thing: I assume you mean "questions". In English the word "doubt" is used more when you distrust or don't have confidence in something. What is the word for question in your language?After gone through the "SetFixtureZ.c" I had doubts in the following program lines,
I think you would be better focusing on what the functions do rather than how they do it. You only need to know what they do to use them. But sometimes it helps to know how they do things.
There is an array of 200 persist variables in KFLOP that both the PC and KFLOP can read and write called persist.UserData. These are 32-bit integer variables. A few of these are used to send commands and parameters to KMotionCNC. PC_COMM_PERSIST is the first one used. PC_COMM_PERSIST+1 is the 2nd. PC_COMM_PERSIST+2 is the 3rd.can you explain what is
[PC_COMM_PERSIST+2]
This puts the varoff (where KMotionCNC should put the results) into [PC_COMM_PERSIST+1] and places the Command Code PC_COMM_GET_VARS into [PC_COMM_PERSIST] which issues the command that tells KMotionCNC that it should put some GCode variables into KFLOP.DoPCInt(PC_COMM_GET_VARS,varoff);
This tells KMotionCNC how many GCode Variables KFLOP wantswhat is the purpose of variable n(no of elements)?
This is a bit complicated because the persist variables that are shared between KFLOP and KMotioCNC are 32-bit integers and the GCode Variables are 64-bit floating point numbers (doubles). So 2 32-bit persist variable need to be packed into one 64-bit double.can you explain this command line
((int*)(&d))[1] = persist.UserData[i*2+1];
This line of code gets the 2nd persist variable - persist.UserData[i*2+1].
Then takes the memory address of the double "&d".
Then tells the Compiler to treat it as an address that points to an integer "((int*)(&d))".
Then advances to the next integer memory location " ((int*)(&d))[1]"
And puts the persist variable there.
This tells KMotionCNC to get the 6 DRO values and place them as pairs into 12 KFLOP persist variables starting at persist variable pair TMP.what is this line mean
if (DoPCInt(PC_COMM_GET_DROS,TMP)) return 1;
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: saving the kmotion cnc jogged value to a permanent common variables
Dear sir,
Is
The doubt i mentioned is just a question that popup in my mind.This kmotion controller is purely new concept for me. whatever your reply and solution for my questions i always try it and once again come to search answers for my question while trying the solution you suggested. so i dont distrust you, maybe my grammer is somewhat bad to understand.Minor thing: I assume you mean "questions". In English the word "doubt" is used more when you distrust or don't have confidence in something. What is the word for question in your language?
Is
means TMP carries a value 10 which is constant.or else TMP and 10 symbolises temporary addresses.#define TMP 10
return DoPCInt(PC_COMM_GET_VARS,varoff);
In this lines, does cmd=PC_COMM_GET_VARS,varoff. because in the calling function the parameter cmd is defined as an integer but some command is passed in calling side.int DoPCInt(int cmd, int i)
{
int result;
persist.UserData[PC_COMM_PERSIST+1] = i;
return DoPC(cmd);
}
- TomKerekes
- Posts: 2529
- Joined: Mon Dec 04, 2017 1:49 am
Re: saving the kmotion cnc jogged value to a permanent common variables
Yes. You can basically think of a define as text replacement. Replace TMP everywhere with 10. In this case TMP defines which Persist variables are to be temporarily used in the communication between KMotionCNC and KFLOP.means TMP carries a value 10 which is constant.or else TMP and 10 symbolises temporary addresses.
Its not clear what you mean. But yes cmd is set to PC_COMM_GET_VARS and i is set to varoff by the function call.In this lines, does cmd=PC_COMM_GET_VARS,varoff. because in the calling function the parameter cmd is defined as an integer but some command is passed in calling side.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: saving the kmotion cnc jogged value to a permanent common variables
respected sir,
My question is that where i can spectate the printed line in my flop amd kmotion cnc software.
In this program, after the input for keyboard there is a if else clause inside the if and else block there is print commandAnswer = InputBox("Enter Distance",&value);
,printf("Operator Canceled\n");
.printf("Operator Entered Value of %.3f\n",value);
My question is that where i can spectate the printed line in my flop amd kmotion cnc software.
- TomKerekes
- Posts: 2529
- Joined: Mon Dec 04, 2017 1:49 am
Re: saving the kmotion cnc jogged value to a permanent common variables
I don't understand the question. The number the operator entered will be in 'value'
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: saving the kmotion cnc jogged value to a permanent common variables
Respected sir,
My question is if i execute the program via both kmotion nd kmotion cnc where will the printed statement will be displayed?
Because when I executed the "setfixtureZ" program the variable 5223 value changed. That is the the DRO value of Z Axis after executing the "SetFixtureIndexZ"value get added with the present value in the variable 5223 and the DRO of Z axis is zeroed.
next the below line gets executed
then what about
atlast may I know the algorithm of "SetFixtureIndexZ".
Is it possible to arrange an online meeting with you atleast an audio call?
regards,
Ajith Arawinth,
In the above command the operator enters a value which is stored in the value and is assigned to the variable "Answer".Answer = InputBox("Enter Distance",&value);
Next If any value is assigned to the variable "Answer"if (Answer)
then the if block is executed which contains a print statement.printf("Operator Canceled\n");
My question is if i execute the program via both kmotion nd kmotion cnc where will the printed statement will be displayed?
In the above program what is purpose of these lines#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#define Zaxis 2
main()
{
int FixtureIndex;
double NewOriginOffset,OriginOffsetZ;
double DROx, DROy, DROz, DROa, DROb, DROc;
GetFixtureIndex(&FixtureIndex);
GetOriginOffset(&OriginOffsetZ, FixtureIndex, Zaxis);
GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
// Adjust Origin Offset to make DRO zero
NewOriginOffset = OriginOffsetZ + DROz;
SetUserDataDouble(TMP,NewOriginOffset);
SetVars(5201+FixtureIndex*20+Zaxis, 1, TMP);
DoPC(PC_COMM_UPDATE_FIXTURE);
}
GetFixtureIndex(&FixtureIndex);
GetOriginOffset(&OriginOffsetZ, FixtureIndex, Zaxis);
GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
Because when I executed the "setfixtureZ" program the variable 5223 value changed. That is the the DRO value of Z Axis after executing the "SetFixtureIndexZ"value get added with the present value in the variable 5223 and the DRO of Z axis is zeroed.
This command is a calling function which calls the following function blockGetFixtureIndex(&FixtureIndex);
where the address of fixture index is send as a parameter.int GetFixtureIndex(int *FixtureIndex)
{
if (GetVars(5220,1,TMP)) return 1; // Download to persist TMP
*FixtureIndex=GetUserDataDouble(TMP);
return 0;
}
When this line gets executed which calls the below function blockif (GetVars(5220,1,TMP)) return 1;
where varoff=5220 and n=1 poff=TMP. in this block we are sending the parameter to kmotion cnc that is no of variable (n) and the value from kmotion cnc to be stored in TMP. Then the below line gets executed,int GetVars(int varoff, int n, int poff)
{
persist.UserData[PC_COMM_PERSIST+2] = n; // number of elements
persist.UserData[PC_COMM_PERSIST+3] = poff; // persist offset (doubles)
return DoPCInt(PC_COMM_GET_VARS,varoff); // Var index and Cmd
}
return DoPCInt(PC_COMM_GET_VARS,varoff);
This is the clarification you have given earlier and with that I Came to an conclusion that we are storing the value of the variable 5220 in the TMP.. This is what i understand and if the If block gets executed then it returns 1 and where will be this 1 is used? . but my question is why we need the value of the variable 5220?This puts the varoff (where KMotionCNC should put the results) into [PC_COMM_PERSIST+1] and places the Command Code PC_COMM_GET_VARS into [PC_COMM_PERSIST] which issues the command that tells KMotionCNC that it should put some GCode variables into KFLOP.
next the below line gets executed
which calls the below function block*FixtureIndex=GetUserDataDouble(TMP);
In this if i=TMP(which carries the value of variable 5220). then whether i also carries the value of variable 5220?double GetUserDataDouble(int i)
{
double d;
((int*)(&d))[0] =persist.UserData[i*2];
((int*)(&d))[1] = persist.UserData[i*2+1];
return d;
}
then what about
In the above line what will be the value i*2? but already you told that kmotion cnc value is 64bit so it was stored in two 32 bit persist.userdata.persist.UserData[i*2];
atlast may I know the algorithm of "SetFixtureIndexZ".
Is it possible to arrange an online meeting with you atleast an audio call?
regards,
Ajith Arawinth,
- TomKerekes
- Posts: 2529
- Joined: Mon Dec 04, 2017 1:49 am
Re: saving the kmotion cnc jogged value to a permanent common variables
No Answer isn't assigned the value. Answer is set based on whether the operator clicked OK or Cancel.Answer = InputBox("Enter Distance",&value);
In the above command the operator enters a value which is stored in the value and is assigned to the variable "Answer".
then the if block is executed which contains a print statement.
My question is if i execute the program via both kmotion nd kmotion cnc where will the printed statement will be displayed?In both cases the program executes in KFLOP and KMotion.exe Console Screen shows KFLOP printfs. Note printfs are normally only used for debugging. Any final code shouldn't have any printf statements.
The 1st gets the Fixture index to determine which Fixture offset is in effect. G54, G55, G56, etcIn the above program what is purpose of these lines
GetFixtureIndex(&FixtureIndex);
GetOriginOffset(&OriginOffsetZ, FixtureIndex, Zaxis);
GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
The second gets the current Z Offset for the fixture in use
The 3rd gets the DROs
The Offset is adjusted to make the DRO zero. Don't think of it as zeroing the DRO. The DROs display where the machine actually is in the current coordinate system. So if we want the current position to be zero then we shift the coordinate system to make this so.Because when I executed the "setfixtureZ" program the variable 5223 value changed. That is the the DRO value of Z Axis after executing the "SetFixtureIndexZ"value get added with the present value in the variable 5223 and the DRO of Z axis is zeroed.
correctwhere the address of fixture index is send as a parameter.
We are asking KMotionCNC to put GCode Variable #5220 into the KFLOP persist variables at location TMPThis is the clarification you have given earlier and with that I Came to an conclusion that we are storing the value of the variable 5220 in the TMP
i and TMP are 10 which specifies where the value is located, not the value of variable 5220In this if i=TMP(which carries the value of variable 5220). then whether i also carries the value of variable 5220?
then what about
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 21In the above line what will be the value i*2? but already you told that kmotion cnc value is 64bit so it was stored in two 32 bit persist.userdata.
That's what we've been discussing.atlast may I know the algorithm of "SetFixtureIndexZ".
For personal training we charge a fee. We charge $250/hr with a 2hr minimum. Contact our support if you would like to arrange this.Is it possible to arrange an online meeting with you atleast an audio call?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.