Hi there,
I would like to create my own kinematics module in order to compensate misalignment of my three axis CNC.
@jsskangas mentioned in another thread about this topic to create a dedicated kinematics module.
My approach was to use the userkins.comp file located in /home/christian/linuxcnc/src/hal/components/ and modify it to my needs.
Afterwards build and install the component using halcompile:
$ cd linuxcnc/src/hal/components
$ [sudo] halcompile --install userkins.comp
Last but not least modifying the INI to use the new kinematics module by KINEMATICS = userkins.
Now I have the following issues and questions:
1.) I use absolute encoder servo drives which means I don't need to 'home' the axes and NO_FORCE_HOMING = 1 and HOME_ABSOLUTE_ENCODER = 2
When I now jog my axes (without prior homing) the modifications of userkins work e.g. the X axis moves by 0.1 when Y axis moves by 10mm. However if I enter 'MDI' mode the X axis jumps immediately as it performs the command of the userkins function. As I have not homed the value of j[1] is not 0 and thus the commanded X-Axis position is changed by 0.01*y-axis position. So lets say my Y-Axis value equals 200 when switching to MDI mode or press home-all-axes then the X-axis jumps by 2mm.
When I switch to NO_FORCE_HOMING = 0 it is basically the same as when 'home all axes' is pressed it also jumps.
pos->tran.x = j[0] + j[1]*0.01; // X coordinate
j[0] = pos->tran.x + pos->tran.y*0.01; // joint 0
2,) I was expecting that the modifications/math performed in the userkins is not shown in the G54 coordinates displayed in linuxCNC. E.g. when I move the Y axis by 100mm the machine also moves the X axis by 1mm to compensate the machine misalignment but I have expected that the G54 coordinate value for the X-Axis shown in the GUI remains unchanged. Of course the absolute value has to change due to the absolute encoders.
- To answer my own question (and thus maybe be helpful for others that are new to this topic). In the DRO the actual position is given. However when moving the axis by G-Code in MDI it does exactly what it should. In the above example: If commanding G1 Y0 X0 F2000 and afterwards G1 Y100 X0 F2000 the machine will actually go to Y100 and X1.
3.) When compiling userkins.comp in the first place I received an error message:
userkins.comp:114:1: warning: data definition has no type or storage class userkins.comp:114:1: warning: type defaults to ‘int’ in declaration of ‘KINS_NOT_SWITCHABLE’ [-Wimplicit-int] In file included from userkins.c:2: After commenting the line ‘KINS_NOT_SWITCHABLE’ it works fine. Can anyone tell me what this line is good for and why I receive this error message?
4.) I have not fully understood the two different functions of userkins "kinematicsForward" and "kinematicsInverse". I have understood that kinematicsInverse is only called after the axes have been homed.
5.) Just in order to double check: I assume (hope) that for calculating the new position the absolute values are taken? My desired compensation for the axis is not of a first order type but third order e.g. ax³+bx²+cx+d and directly derived from the measured deviation/misalignment of the axis.
- After making some trials, I can confirm that absolute values are used