On 29 May 2013 13:24, Les Newell <[email protected]> wrote:
> My HAL component used a simple lookup table that mapped spindle angle to
> X position.

After much messing about I found the maths to be fairly simple.
Here is the comp, it goes in between the axis.0.motor-pos-cmd and the
PID/stepgen.
It needs connections to the spindle position and the current radius
and tool offset (halui holds this).
It knows how to lie about position feedback to prevent f-errors.
If the facets pin is > 2 it tries to make a polygon. Handy for those
home-made pentagonal allen keys and matching bolts :-)


component polygon "Add a spindle-position related offset to an axis
for polygon turning";
pin in float encoder-pos "encoder position, should be scaled 0-1";
pin in float pos-in "the input (motor position)";
pin in float pos-relative "The commanded position, used for calcs.
halui.axis.N.pos-relative";
pin in float tool-offset;
pin in float facets = 0 "the number of facets required";
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";

;;
#include <rtapi_math.h>
FUNCTION(_) {
    float f, d;
    if (facets < 3) {
        pos_out = pos_in;
        fb_out = fb_in;
        return;
    }
    f = encoder_pos - floor(encoder_pos * facets)/facets - (1 / (2 * facets));
    d = (pos_relative - tool_offset) * (1 / cos(6.28318530717959 * f) - 1);
    pos_out = pos_in + d;
    fb_out = fb_in - d;
}



-- 
atp
If you can't fix it, you don't own it.
http://www.ifixit.com/Manifesto

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to