Gentlemen, For your perusal, comments, use, modification - whatever - here is my gear change component. I have two slightly different versions for two different machines. I hope someone can find this useful for their machine. A review and critique is more than welcome. This is a working version. There may (will) be some clean up done after this version. I would like to add some delay for a down shift as the transmission has a very slight gear tooth noise during a down shift. I will be working on that. Have fun.
component gear4_GL "Select gear range from requested spindle speed";
/* This component if for a 4 speed gearbox with a separate tram shifter.
This has 6 solenoids to shift the gears and 4 limit switches to
indicate the gearbox state. Tram state is not indicated by limit
switch
It will sense the spindle speed near zero from the encoder feedback
and inhibit the shifting until the spindle is slow enough.
* It will drive the spindle very slow to allow the gears to mesh.
*/
pin in float spincmd "spindle command from EMC";
pin in float spinspeed "spindle speed from encoder";
pin in float spndlinching "gear mesh speed";
pin in float minspeed "lowest spindle speed";
pin in float gear1max "first gear max speed";
pin in float gear2max "second gear max speed";
pin in float gear3max "third gear max speed";
pin in float gear4max "fourth gear max speed";
pin in float shiftspeed "spindle speed to be considered zero for tram
and gear shifting";
pin in float gain "numerator of voltage ratio";
pin in bit ls1 "solenoid 1 limit switch";
pin in bit ls2 "solenoid 2 limit switch";
pin in bit ls3 "solenoid 3 limit switch";
pin in bit ls4 "solenoid 4 limit switch";
pin in bit ls5 "solenoid 5 limit switch";
pin in bit ls6 "solenoid 6 limit switch";
pin in bit spinzero "spindle at zero";
pin in bit tram "tram select input";
pin in bit tramallow "allow tram - connect to motion.spindle-brake output";
pin out float spinon "spindle speed command to VFD";
pin out float feedadapt "adjust feed for spindle speed";
pin out bit sol1 "shifting solenoid";
pin out bit sol2 "shifting solenoid";
pin out bit sol3 "shifting solenoid";
pin out bit sol4 "shifting solenoid";
pin out bit sol5 "tram on";
pin out bit sol6 "tram off";
function _;
license "GPL";
;;
FUNCTION(_) {
int Gear, CurrentGear = 0, InGear = 0;
float Scale = 0.0;
if (tram && tramallow) {
Scale = 0.0;
spinon = 0.0;
if (spinzero) {
sol5 = 1;
sol6 = 0;
feedadapt = 1;
} else {
sol5 = 0;
sol6 = 1;
}
} else {
sol5 = 0;
sol6 = 1;
// set desired gear ////////////////////
if (abs(spincmd) >= minspeed && abs(spincmd) <= gear4max) {
if (abs(spincmd) <= gear1max) {
Gear = 1;
} else if (abs(spincmd) <= gear2max) {
Gear = 2;
} else if (abs(spincmd) <= gear3max) {
Gear = 3;
} else {
Gear = 4;
}
} else {
Gear = 0;
}
/// shift gears if necessary ///////////
if (CurrentGear != Gear) {
InGear = 0;
// shift gears
if (spinzero) {
switch (Gear) {
case 0:
break;
case 1:
sol1=0;
sol2=1;
sol3=0;
sol4=1;
sol5=0;
sol6=1;
break;
case 2:
sol1=1;
sol2=0;
sol3=0;
sol4=1;
sol5=0;
sol6=1;
break;
case 3:
sol1=0;
sol2=1;
sol3=1;
sol4=0;
sol5=0;
sol6=1;
break;
case 4:
sol1=1;
sol2=0;
sol3=1;
sol4=0;
sol5=0;
sol6=1;
break;
case 5:
Scale = 0.0;
break;
}
} else {
}
//////////////////////////////////////////
if (Gear == 1 && ls2 && ls4 && !sol5
&& sol6) {
Scale = 48.233695652;
InGear = 1;
} else if (Gear == 2 && ls1 && ls4 && !sol5
&& sol6) {
Scale = 19.293478261;
InGear = 1;
} else if (Gear == 3 && ls2 && ls3 && !sol5
&& sol6) {
Scale = 7.717391304;
InGear = 1;
} else if (Gear == 4 && ls1 && ls4 && !sol5
&& sol6) {
Scale = 3.086956522;
InGear = 1;
} else {
InGear = 0;
}
} else {
}
//////////////////////////////////////////
if (InGear && !tramallow) {
spinon = abs(spincmd) * Scale * gain / gear4max;
CurrentGear = Gear;
if (spincmd == 0 && !spinzero) {
feedadapt = 0;
} else if (spincmd == 0 &&
spinzero) {
feedadapt = 1;
} else {
feedadapt = spinspeed /
spincmd;
}
} else {
if (!InGear && !tramallow) {
Scale = 1;
spinon = spndlinching * gain /
gear4max;
} else {
Scale = 0.0;
spinon = 0.0;
}
}
}
}
thanks
Stuart
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users
