NonCircularTurning - rmu75/linuxcnc-wiki GitHub Wiki
(This page is designed to give tantalising hints of how to do non-circular turning, but with just enough information left out to make it useless.)
If a lathe has a spindle encoder then it is possible to apply spindle-angle related offsets to the cross slide (or the Z slide, for example to make a face-cam).
Videos: http://www.youtube.com/watch?v=T4q8gCpeY1A
http://www.youtube.com/watch?v=FpP7iTKuWpw
The offsets are calculated with the simple HAL component listed below. Unfortunately it is necessary to re-compile to change the profile. That could be changed, but this was just a proof of concept.
component oval "Add a spindle-position related offset to an axis for oval turning";
pin in float encoder-pos "encoder position, should be scaled 0-1";
pin in bit disable "set high to disable, for example during homing";
pin in float pos-in "the input (axis position)";
pin in float offset "the required eccentricity";
pin out float pos-out "the modified position request";
pin in float fb-in "position feedback from joint";
pin out float fb-out "position feedback to motion";
function _ ;
license "GPL";
author "Andy Pugh";
;;
FUNCTION(_) {
static float profile[] =
{.0000, .0055, .0223, .0515, .0946, .1547, .0946, .0515, .0223,
.0055, .0000, .0055, .0223, .0515, .0946, .1547, .0946, .0515,
.0223, .0055, .0000, .0055, .0223, .0515, .0946, .1547, .0946,
.0515, .0223, .0055, .0000, .0055, .0223, .0515, .0946, .1547,
.0946, .0515, .0223, .0055, .0000, .0055, .0223, .0515, .0946,
.1547, .0946, .0515, .0223, .0055, .0000, .0055, .0223, .0515,
.0946, .1547, .0946, .0515, .0223, .0055, .0000,} ;
int i;
float f;
if (disable) {
pos_out = pos_in;
fb_out = fb_in;
return;
}
f = (encoder_pos - (int)(encoder_pos))*60.0;
i = f;
f = f-i;
pos_out = pos_in + offset*(profile[i] + f * (profile[i+1]-profile[i]));
fb_out = fb_in - (pos_out - pos_in);
}