Gentlemen,
This is my gear shifting component. It probably is not the best
and may not be completely functional. I will test it on my machine
this week. It is somewhat functional on a sim machine.
I have included it here as it is not too loooong. It comps
successfully and the pins show up in EMC. This is a huge success for
me so far. Having some fun now.
component gear4 "Select gear range from requested spindle speed";
/* This component if for a 4 speed gearbox with a separate tram shifter.
* This has 5 solenoids to shift the gears and 5 limit switches to
indicate the gearbox state.
* It will sense the spindle speed near zero from the encoder
feedback and inhibit the
* tram shifting until the spindle is slow enough.
* It will drive the spindle very slow to allow gear mesh.
*/
pin in float spincmd "spindle command from EMC";
pin in float spinspeed "spindle speed from encoder";
pin out float spinon "spindle speed command to VFD";
pin in float spinslow "gear mesh speed";
pin out bit sol1;
pin out bit sol2;
pin out bit sol3;
pin out bit sol4;
pin out bit sol5;
pin in float min0;
pin in float max0;
pin in float max1;
pin in float max2;
pin in float max3;
pin in float zeromax "max spindle speed to be considered zero for tram";
pin in bit ls1;
pin in bit ls2;
pin in bit ls3;
pin in bit ls4;
pin in bit tram;
variable int skippy;
variable int range;
variable int shifting;
function _;
license "GPL";
;;
FUNCTION(_) {
double spin = spincmd;
double zero = spinspeed;
/* initialize the solenoids to the startup state of the gearbox */
if (!skippy) {
sol1 = ls1;
sol2 = ls2;
sol3 = ls3;
sol4 = ls4;
sol5 = tram;
skippy = 1;
}
/* do we shift and if so which gear */
if((min0 < spin) && (spin < max3) && (!tram))
if ((spin < max0) && (spin < max0) && (range != 1)) {
sol1 = true;
sol2 = false;
sol3 = true;
sol4 = false;
sol5 = false;
range = 1;
spin = spinslow;
shifting = 1;
}
else if ((spin < max1) && (range != 2)) {
sol1 = true;
sol2 = false;
sol3 = false;
sol4 = true;
sol5 = false;
range = 2;
spin = spinslow;
shifting = 1;
}
else if ((spin < max2) && (range != 3)) {
sol1 = false;
sol2 = true;
sol3 = true;
sol4 = false;
sol5 = false;
range = 3;
spin = spinslow;
shifting = 1;
}
else if ((spin < max3) && (range != 4)) {
sol1 = false;
sol2 = true;
sol3 = false;
sol4 = true;
sol5 = false;
range = 4;
spin = spinslow;
shifting = 1;
}
else {
sol1 = false;
sol2 = false;
sol3 = false;
sol4 = false;
sol5 = true;
}
else
if ((tram) && (zero < zeromax)) {
sol5 = true;
}
/* if we are shifting - wait until shifting is complete */
if (shifting) {
if ((range =1) && (sol1) && (!sol2) && (sol3) && (!sol4) && (!sol5)) {
shifting = 0;
spin = spincmd;
}
else if ((range =2) && (sol1) && (!sol2) && (!sol3) && (sol4)
&& (!sol5)) {
shifting = 0;
spin = spincmd;
}
else if ((range =3) && (!sol1) && (sol2) && (sol3) && (!sol4)
&& (!sol5)) {
shifting = 0;
spin = spincmd;
}
else if ((range =4) && (!sol1) && (sol2) && (!sol3) && (sol4)
&& (!sol5)) {
shifting = 0;
spin = spincmd;
}
}
}
all questions critiques comments welcome
be kind :)
how do I view the documentation created from this?
thanks
Stuart
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users