# Knee mill table height; external offset or something else?

02 Nov 2023 07:17 #284302 by m0602232
Hi everybody!

I have an old Bridgeport Interact CNC retrofitted to Linuxcnc. Since quill traverse is only 127mm I would want to include linear encoder measuring table height. Table height is adjusted manually.

I did set it up using external offset and it seems to be working but what concerns me is the manual:
"When teleop jogging with external offsets enabled and non-zero values applied, encountering a soft
limit will stop motion in the offending axis without a deacceleration interval. Similarly, during
coordinated motion with external offsets enabled, reaching a soft limit will stop motion with no deac-
celeration phase. For this case, it does not matter if the offsets are zero."

Is there any other way to include table height encoder? It's basically only needed after tool changes when using long drillbits etc.

Any ideas will be appreciated, thanks!

02 Nov 2023 11:39 #284315 by andypugh
You could just add the two encoders together before passing the result to the position feedback, but that would lead to problems with homing and joint limits.

The best answer is probably to use a custom kinematics module where Z is the sum of the two joint positions, but then the joints can home independently and have separate travel limits.

I am guessing that this is a manually-opearted knee?

Take a look at the very old trivkins before it learned about tandem axes, a kinematics module can be pretty simple:
github.com/LinuxCNC/linuxcnc/blob/2.7/sr...inematics/trivkins.c
Basically two functions, one to convert joint to axis, and one to convert axis to joint.

02 Nov 2023 11:40 #284316 by andypugh
You could just add the two encoders together before passing the result to the position feedback, but that would lead to problems with homing and joint limits.

The best answer is probably to use a custom kinematics module where Z is the sum of the two joint positions, but then the joints can home independently and have separate travel limits.

I am guessing that this is a manually-opearted knee?

Take a look at the very old trivkins before it learned about tandem axes, a kinematics module can be pretty simple:
github.com/LinuxCNC/linuxcnc/blob/2.7/sr...inematics/trivkins.c
Basically two functions, one to convert joint to axis, and one to convert axis to joint.

02 Nov 2023 11:53 #284318 by m0602232
I thought about adding the encoders together but as far as I see it would be impossible to use because of joint limits being incorrect as you also stated.

Manually operated knee yes, originally there is no encoder but it is really inconvenient to use as is.

I will take a look at the link and will be back with even more questions i'm afraid , thank you!

04 Nov 2023 13:26 #284526 by m0602232
So I managed to link both encoders to Z-axis with custom kinematics module or at least the dro value changes correspondingly. The axis does not move when the table encoder is moved, it can be linked in HAL (sum2 joint.8.motor-pos-fb => joint.2.motor-pos-cmd) but then following error calculations go wrong.

Is there something else I can try? I dont completely understand how the kinematics module should be affecting joint outputs so there might be something wrong also.

#### File Attachment:

File Name: customkins.c
File Size:2 KB
##### Attachments:

22 Nov 2023 07:25 #286212 by m0602232
Progress, I think.

Kinematics module now connects two joints to an axis but there is some sort of issue. Forgot to take screenshot of halscope but when the knee is moved, velocity command of joint2 is full of extremely sharp spikes which causes pid to oscillate. In other words acceleration and max.speed limits are ignored. How should trajectory planner be involved in this kind of case? Could there be a way to smoothen the table encoder input before kinematics module? Any other ideas?

22 Nov 2023 20:12 - 22 Nov 2023 20:42 #286268 by Aciera
Are you still using the same kinematic you posted above?

Last edit: 22 Nov 2023 20:42 by Aciera.

23 Nov 2023 15:26 #286330 by m0602232
Not the same, something like:

static double pos3 = 0;
int kinematicsForward(const double joints,
EmcPose pos,
const KINEMATICS_FORWARD_FLAGS * fflags,
KINEMATICS_INVERSE_FLAGS * iflags)

{

pos->tran.x = joints[0];
pos->tran.y = joints[1];
pos->tran.z = joints[2] + joints[3];
pos3 = joints[3];
pos->a = joints[3];
pos->b = 0;
pos->c = 0;
pos->u = 0;
pos->v = 0;
pos->w = 0;

return 0;
}

int kinematicsInverse(const EmcPose * pos,
double joints,
const KINEMATICS_INVERSE_FLAGS iflags,
KINEMATICS_FORWARD_FLAGS * fflags)

{

joints[0] = pos->tran.x;
joints[1] = pos->tran.y;
joints[2] = pos->tran.z - pos3;
joints[3] = pos->a;
joints[4] = pos->b;
joints[5] = pos->c;
joints[6] = pos->u;
joints[7] = pos->v;
joints[8] = pos->w;

return 0;

}

23 Nov 2023 15:44 #286334 by Aciera
Not sure but what is the purpose of the variable 'pos3'?

I would have tried something like this:

```int kinematicsForward(const double joints,
EmcPose pos,
const KINEMATICS_FORWARD_FLAGS * fflags,
KINEMATICS_INVERSE_FLAGS * iflags)

{

pos->tran.x = joints[0];
pos->tran.y = joints[1];
pos->tran.z = joints[2] + joints[3];
pos->a = joints[3];
pos->b = 0;
pos->c = 0;
pos->u = 0;
pos->v = 0;
pos->w = 0;

return 0;
}

int kinematicsInverse(const EmcPose * pos,
double joints,
const KINEMATICS_INVERSE_FLAGS iflags,
KINEMATICS_FORWARD_FLAGS * fflags)

{

joints[0] = pos->tran.x;
joints[1] = pos->tran.y;
joints[2] = pos->tran.z - pos->a;
joints[3] = pos->a;
joints[4] = pos->b;
joints[5] = pos->c;
joints[6] = pos->u;
joints[7] = pos->v;
joints[8] = pos->w;

return 0;

}```