Electronic spindle gearbox

More
11 years 7 months ago #56573 by andypugh
Replied by andypugh on topic Electronic spindle gearbox

microsprintbuilder wrote: is the timeout = 10 ten seconds? or ten of something else?


"fperiod" is (floating point) seconds. "period" is nanoseconds.

www.linuxcnc.org/docs/html/hal/comp.html#_implicit_parameters

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56709 by microsprintbuilder
does this look right?

component ebox "electronic gearbox component";
licence "GPL";

pin in bit spindle-slow
pin in bit spindle-on-in;
pin out bit spindle-on-out;
pin in float spindle-speed;
pin out bit relay1;
pin out bit relay2;
pin out bit relay3;
pin out s32 spindle-gearbox-output-scale
pin out s32 spindle-gearbox-out-min-limit
pin out s32 spindle-gearbox-out-max-limit
pin in s33 spindle-gearbox-low-output-scale
pin in s32 spindle-gearbox-low-min-limit
pin in s32 spindle-gearbox-low-max-limit
pin in s32 spindle-gearbox-mid-output-scale
pin in s32 spindle-gearbox-mid-min-limit
pin in s32 spindle-gearbox-mid-max-limit
pin in s32 spindle-gearbox-hi-output-scale
pin in s32 spindle-gearbox-hi-min-limit
pin in s32 spindle-gearbox-hi-max-limit
int gear-called
int gear-set

function _;

;;

FUNCTION(_){
static int timer;

if (timer > 0){
timer -= 1;
spindle_on_out = 0;
} else {
spindle_on_out = spindle_on_in;
}


// determine gear required

if (spindle_speed >= 2500){
gear-called = 3
} else if (spindle-speed <= 1200)
{
gear-called = 1
} else
{
gear-called = 2
}

// determine if gear change required

while (gear-called <> gear-set)
{
spindle_on_out=0
if (spindle-slow=0){
wait
} else {
if (spindle_speed >= 2500)
{
relay 1 = 0;
relay 2 = 0;
relay 3 = 1;
spindle-gearbox-output-scale = spindle-gearbox-hi-output-scale
spindle-gearbox-out-min-limit = spindle-gearbox-hi-min-limit
spindle-gearbox-out-max-limit = spindle-gearbox-hi-max-limit
gear-set = 3
timer = 2000
} else if (spindle-speed <= 1200)
{
relay 1 = 1;
relay 2 = 0;
relay 3 = 0;
spindle-gearbox-output-scale = spindle-gearbox-low-output-scale
spindle-gearbox-out-min-limit = spindle-gearbox-low-min-limit
spindle-gearbox-out-max-limit = spindle-gearbox-low-max-limit
gear-set = 1
timer = 2000
} else {
relay 1 = 0;
relay 2 = 1;
relay 3 = 0;
spindle-gearbox-output-scale = spindle-gearbox-mid-output-scale
spindle-gearbox-out-min-limit = spindle-gearbox-mid-min-limit
spindle-gearbox-out-max-limit = spindle-gearbox-mid-max-limit
gear-set = 2
timer = 2000
}}}}

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56715 by andypugh
Replied by andypugh on topic Electronic spindle gearbox
Rather than ask if it looks right, does it compile, and does it work?

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56716 by microsprintbuilder
Haven't done that yet. I thought I'd ask to see if it's plausible. Instead I get my question answered with a question. Thanks for you help.

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56717 by andypugh
Replied by andypugh on topic Electronic spindle gearbox
It looks like it ought to work, except that you have relay 1 instead of relay1 (etc) in a few places. The pin names and variable names need to match exactly, and can't have spaces.

Please Log in or Create an account to join the conversation.

More
3 years 3 weeks ago #282515 by Trav328
Replied by Trav328 on topic Electronic spindle gearbox
Resurrected with mod approvalĀ 

Microsprintbuilder , did you ever get this working right ? , I am doing a retrofit on a milltronics partner lathe with the identical spindle winding "gear" setup , probably even the same parts , im going to try compiling the last bit you posted and see what can be done with that , this board has no pm's so this is the only way to reach out.

Please Log in or Create an account to join the conversation.

Time to create page: 0.061 seconds
Powered by Kunena Forum