This is the Enshu's two speed gear change component.

component gear2 "Select gear range from requested spindle speed";

// from EMC
pin in float SpindleCommand "spindle speed command";
pin in float minspeed "lowest spindle speed";
pin in float gear1max "low gear max speed";
pin in float gear2max "high gear max speed";
pin in float gain1 "low gear voltage ratio";
pin in float gain2 "high gear voltage ratio";
pin in float spinovride "spindle over ride percentage";
pin in bit reqSpindleOn "request Spindle Start";

// from enshutoolchange
pin in bit reqSpindleOrient "request Spindle Orient";

// I/Os
pin in bit SpindleAtZero "spindle at zero rpm";
pin in bit SpindleAlarmed "spindle alarm";
pin in bit SpindleInHigh "in high gear";
pin in bit SpindleInLow "in low gear";
pin in bit ToolClamped "tool clamped";

// to EMC
pin out float SpindleScale "spindle gear scale";
pin out float SpindleGear "spindle gear range";

// to PPMC
pin out float SpindleSpeed "spindle speed command to VFD";         //
ppmc.0.DAC.03.value
pin out bit HighGear "high gear";                                  //
ppmc.0.dout.18.out
pin out bit LowGear "low gear";                                    //
ppmc.0.dout.17.out
pin out bit SpindleOrient "orient spindle";                        //
ppmc.0.dout.15.out
pin out bit SpindleOn "start spindle";                             //
ppmc.0.dout.13.out
function _;
license "GPL";
;;

FUNCTION(_) {
   int Gear, InGear;
   float SpindleGain, SpindleDir;

        if ( abs((SpindleCommand/spinovride)) >= minspeed &&
abs((SpindleCommand/spinovride)) <= gear2max && ! reqSpindleOrient ) {

                // determine gear range
                if        ( abs((SpindleCommand/spinovride)) <= gear1max ) {
                    Gear = 1;
                } else {
                    Gear = 2;
                }

                // set outputs per gear range needed
                if ( Gear != SpindleGear ) {
                    SpindleSpeed = 0;
                    SpindleOn = true;  // this causes the spindle to creep
during the gear change
                    InGear = 0;
                        if (SpindleAtZero) {
                                switch (Gear) {
                                    case 0:
                                          break;
                                    case 1:
                                          LowGear  = 1;
                                          HighGear = 0;
                                          break;
                                    case 2:
                                          LowGear  = 0;
                                          HighGear = 1;
                                          break;
                                }
                            SpindleGear = Gear;
                        }
                } else {

                        // set gain per gear range and verify gear range
                        if ( SpindleInLow && LowGear ) {
                           SpindleGain = gain1;
                           InGear = 1;
                        } else if ( SpindleInHigh && HighGear ) {
                            SpindleGain = gain2;
                            InGear = 1;
                        } else {
                           SpindleGain = 0;
                           InGear = 0;
                        }

                        // start spindle
                        if ( ToolClamped && InGear && reqSpindleOn ) {
                            SpindleSpeed = SpindleCommand * SpindleGain;
                            SpindleOrient = false;
                            SpindleOn = true;
                        }
                }
        } else if ( reqSpindleOrient ) {
            SpindleSpeed = 0;
            SpindleOrient = true;
            SpindleOn = false;
        } else {
            Gear = 0;
            SpindleSpeed = 0;
            SpindleOrient = false;
            SpindleOn = false;
        }
}

have fun
Stuart


On Fri, Jun 5, 2015 at 12:36 PM, Stuart Stevenson <stus...@gmail.com> wrote:

> This is the tool change component I wrote for the Enshu at MPM in Wichita.
> The Enshu's tool changer is a side mounted chain matrix that moves the
> tool pot into position by counting the pots, overrunning the correct pot to
> allow a stop dog to fall into place, the chain rotates backward until the
> stop dog stops the chain, the hyraulics drops pressure to just maintain the
> chain in position, the pot rotates from horizontal to vertical. the Z axis
> retracts to tool change position, the arm rotates to engage the tool in the
> tool changer pot and the spindle at the same time, the tool changer pot and
> the spindle both release the tools at the same time, the arm drops and
> rotates and rises to exchange the tools, the pot and spindle clamp the
> tools, the arm returns to ready position and the pot rotates up to
> horizontal position. The tool changer is random so the tool numbers and pot
> numbers are always changing. LinuxCNC keeps track of which tool is in which
> pot.
> Restarting the control will recover from any tool changer error except
> when the tool arm is in its bottom position and the arm is partially
> rotated.
> I am not an official programmer so if this looks clunky or cludgy so be it
> - it works for me. :)
> I know it is not the official manner to include a long response in the
> reply but this is not very long.
>
> component enshutoolchange "tool change";
> // This is for a random automatic tool changer that requires all
> components to be individually controlled
>
> // from EMC
> pin in bit reqToolChange "EMC2 tool change request";            //
> iocontrol.0.tool-change
> pin in s32 CurrentToolNumber "current tool number";             //
> iocontrol.0.tool-number
> pin in s32 NextPocketNumber "next pocket number";               //
> iocontrol.0.tool-prep-pocket
> pin in bit reqPocketPrepare "do tool select";                   //
> iocontrol.0.tool-prepare
> pin in bit ToolChangePosition "tool change position";           //
> wcomp.0.out
> pin in float MaxPocketNumber "highest pocket number allowed";   // setp
> enshutoolchange.0.MaxPocketNumber 30
> pin in bit reqTLCHome "tool changer home signal";               //
> axis.2.homed
>
> // I/Os
> pin in bit ManualMagazineRotate "rotate magazine";              //
> ppmc.0.din.28.in-not
> pin in bit ToolUnClampButton "tool change button";              //
> ppmc.0.din.29.in-not
> pin in bit SpindleAtZero "spindle at zero rpm";                 //
> ppmc.0.din.42.in-not
> pin in bit SpindleOriented "spindle oriented";                  //
> ppmc.0.din.44.in-not
> pin in bit ToolClamped "tool clamped";                          //
> ppmc.0.din.50.in-not
> pin in bit ToolUnClamped "tool unclamped";                      //
> ppmc.0.din.51.in-not
> pin in bit Arm60Set "tool change arm 60 at 60";                 //
> ppmc.0.din.52.in-not
> pin in bit Arm60Reset "tool change arm 60 at 0";                //
> ppmc.0.din.53.in-not
> pin in bit Arm180Set "tool change arm 180 at 180";              //
> ppmc.0.din.54.in-not
> pin in bit Arm180Reset "tool change arm 180 at 0";              //
> ppmc.0.din.55.in-not
> pin in bit PotDown "tool change pot down";                      //
> ppmc.0.din.56.in-not
> pin in bit PotUp "tool change pot up";                          //
> ppmc.0.din.57.in-not
> pin in bit PotUnClamped "tool change pot unclamped";            //
> ppmc.0.din.58.in-not
> pin in bit ArmUp "tool change arm up";                          //
> ppmc.0.din.59.in-not
> pin in bit ArmDown "tool change arm down";                      //
> ppmc.0.din.60.in-not
> pin in bit PotCount "tool pot count";                           //
> ppmc.0.din.61.in-not
> pin in bit PotZero "tool pot zero";                             //
> ppmc.0.din.62.in-not
> pin in bit MagazineReverse "tool magazine reverse";             //
> ppmc.0.din.63.in-not
>
> //  OUTPUTS
> //    to emc
> pin out bit ToolChanged "tool change done";                     //
> iocontrol.0.tool-changed
> pin out bit ToolPrepared "tool selected";                       //
> iocontrol.0.tool-prepared
>
> // to gear2
> pin out bit reqSpindleOrient "request Spindle Orient";          //
> gear2.0.reqSpindleOrient
>
> // to ppmc I/O
> pin out bit TLCArmUp "tool change arm up";                      //
> ppmc.0.dout.19.out
> pin out bit TLCArmDown "tool change arm down";                  //
> ppmc.0.dout.20.out
> pin out bit TLCArm60Set "tool change arm 60 to 60";             //
> ppmc.0.dout.21.out
> pin out bit TLCArm60Reset "tool change arm 60 to 0";            //
> ppmc.0.dout.22.out
> pin out bit TLCArm180Set "tool change arm 180 to 180";          //
> ppmc.0.dout.23.out
> pin out bit TLCArm180Reset "tool change arm 180 to 0";          //
> ppmc.0.dout.24.out
> pin out bit TLCPotDown "tool change pot down";                  //
> ppmc.0.dout.25.out
> pin out bit TLCPotUp "tool change pot up";                      //
> ppmc.0.dout.26.out
> pin out bit TLCPotUnClamp "pot unclamp";                        //
> ppmc.0.dout.27.out
> pin out bit TLCChainForward "tool change magazine forward";     //
> ppmc.0.dout.28.out
> pin out bit AirBlast "tool change air blast";                   //
> ppmc.0.dout.29.out
> pin out bit ToolUnClamp "unclamp spindle tool";                 //
> ppmc.0.dout.30.out
> pin out bit TLCChainReverse "tool change magazine reverse";     //
> ppmc.0.dout.31.out
> pin out bit TLCChainDecel "tool change magazine slow";          //
> ppmc.0.dout.32.out
>
> // internal for debug
> pin out float dbOUTPUT;
> pin out bit dbmask1;
> pin out bit dbmask2;
> pin out bit dbmask3;
> pin out bit dbmask4;
> pin out bit dbmask5;
> pin out bit dbmask6;
> pin out bit dbmask7;
> pin out bit dbmask8;
> pin out bit dbmask9;
> pin out bit dbmask10;
>
> function _;
> license "GPL";
> ;;
>
> FUNCTION(_) {
>    static int toolpotcount = 0, currentpotcount, oldPotCount = 0,
> oldPotZero = 0, toolchangehomed = 0, dotoolchange, nexttool, initialstate =
> 0, mask1, mask2, mask3, mask4, mask5, mask6, mask7, mask8, mask9, mask10;
>
> // set tool change initial state
> if ( ! initialstate ) {
>     TLCArm60Set = false;
>     TLCArm60Reset = true;
>     TLCPotDown = false;
>     TLCPotUp = true;
>     TLCArmDown = false;
>     TLCArmUp = true;
>     TLCArm180Set = false;
>     TLCArm180Reset = true;
>     TLCPotUnClamp = false;
>     reqSpindleOrient = false;
>     initialstate = true;
> }
>
> // detect falling edge of count
> if ( ! PotCount && oldPotCount && ! TLCChainReverse && toolchangehomed ) {
>    toolpotcount = toolpotcount + 1;
> }
> //detect rising edge of zero
> if ( PotZero && ! oldPotZero ) {
>    toolpotcount = 1;
> }
> // remember current state of inputs for next time
> oldPotCount = PotCount;
> oldPotZero = PotZero;
>
> // magazine rotation and tool prep
> if ( reqPocketPrepare ) {
>         if ( currentpotcount == NextPocketNumber ) {
>             ToolPrepared = true;
>             ToolChanged = false;
>             mask1 = false;
>         } else {
>             TLCChainReverse = false;
>             TLCChainDecel = false;
>             TLCChainForward = true;
>             ToolPrepared = false;
>                 if ( ! toolchangehomed ) {
>                         if ( ! PotZero ) {
>                             toolchangehomed = true;
>                             toolpotcount = 1;
>                         }
>                 }
>                 if ( toolpotcount == NextPocketNumber ) {
>                     TLCChainDecel = true;
>                         if ( MagazineReverse ) {
>                             TLCChainForward = false;
>                             TLCChainReverse = true;
>                                 if ( PotCount ) {
>                                     ToolPrepared = true;
>                                     ToolChanged = false;
>                                     currentpotcount = NextPocketNumber;
>                                     mask1 = false;
>                                 }
>                         }
>                 }
>         }
> }
>
> // manual tool change
> if ( ToolUnClampButton && ! reqToolChange ) {
>     AirBlast = true;
>     ToolUnClamp = true;
> } else if ( ! reqToolChange ) {
>     AirBlast = false;
>     ToolUnClamp = false;
> }
>
> // cycle through the tool change procedure
> if ( reqToolChange ) {
>         if ( ToolChangePosition && ! mask1 ) {
>                 if ( ToolChangePosition ) {
>                     ToolChanged = false;
>                     TLCPotUp = false;
>                     TLCPotDown = true;
>                     reqSpindleOrient = true;
>                     mask1 = true;
>                     mask2 = false;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask2 ) {
>                 if ( SpindleOriented && PotDown ) {
>                     TLCArm60Reset = false;
>                     TLCArm60Set = true;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = false;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask3 ) {
>                 if ( SpindleOriented && PotDown && Arm60Set ) {
>                     TLCPotUnClamp = true;
>                     ToolUnClamp = true;
>                     AirBlast = true;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = false;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask4 ) {
>                 if ( SpindleOriented && PotDown && Arm60Set &&
> PotUnClamped && ToolUnClamped ) {
>                     TLCArmUp = false;
>                     TLCArmDown = true;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = false;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask5 ) {
>                 if ( SpindleOriented && PotDown && Arm60Set &&
> PotUnClamped && ToolUnClamped && ArmDown ) {
>                     TLCArm180Reset = false;
>                     TLCArm180Set = true;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = false;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask6 ) {
>                 if ( SpindleOriented && PotDown && Arm60Set &&
> PotUnClamped && ToolUnClamped && ArmDown && Arm180Set ) {
>                     TLCArmDown = false;
>                     TLCArmUp = true;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = false;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask7 ) {
>                 if ( SpindleOriented && PotDown && Arm60Set &&
> PotUnClamped && ToolUnClamped && Arm180Set && ArmUp ) {
>                     ToolUnClamp = false;
>                     TLCPotUnClamp = false;
>                     AirBlast = false;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = false;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask8 ) {
>                 if ( SpindleOriented && PotDown && Arm60Set && Arm180Set
> && ArmUp && ! PotUnClamped && ToolClamped ) {
>                     TLCArm60Set = false;
>                     TLCArm60Reset = true;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = false;
>                     mask10 = true;
>                 }
>         }
>         if ( ToolChangePosition && ! mask9 ) {
>                 if ( SpindleOriented && PotDown && Arm180Set && ArmUp && !
> PotUnClamped && ToolClamped && Arm60Reset ) {
>                     TLCArm180Set = false;
>                     TLCArm180Reset = true;
>                     TLCPotDown = false;
>                     TLCPotUp = true;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = false;
>                 }
>         }
>         if ( ToolChangePosition && ! mask10 ) {
>                 if ( SpindleOriented && ArmUp && ! PotUnClamped &&
> ToolClamped && Arm60Reset && Arm180Reset && PotUp ) {
>                     ToolChanged = true;
>                     dotoolchange = false;
>                     ToolPrepared = false;
>                     reqSpindleOrient = false;
>                     mask1 = true;
>                     mask2 = true;
>                     mask3 = true;
>                     mask4 = true;
>                     mask5 = true;
>                     mask6 = true;
>                     mask7 = true;
>                     mask8 = true;
>                     mask9 = true;
>                     mask10 = true;
>                 }
>         }
>         dbmask1 = mask1;
>         dbmask2 = mask2;
>         dbmask3 = mask3;
>         dbmask4 = mask4;
>         dbmask5 = mask5;
>         dbmask6 = mask6;
>         dbmask7 = mask7;
>         dbmask8 = mask8;
>         dbmask9 = mask9;
>         dbmask10 = mask10;
> } else {
> // Z axis is not in tool change position message
> }
>         dbOUTPUT = toolpotcount;
>
> }
>
> have fun
> Stuart
>
> On Fri, Jun 5, 2015 at 12:01 PM, Sebastian Kuzminsky <s...@highlab.com>
> wrote:
>
>> On 6/5/15 10:59 AM, Rick Lair wrote:
>> > I do build from source,
>> >
>> > So should I have the VMC folder be in my
>> > "home/testpc/linuxcnc-dev/configs directory,
>> >
>> > Then from the command line be in the
>> > "testpc@testpc:~/linuxcnc-dev/configs$" directory,
>> >
>> > Then do " sudo halcompile --install --install-doc carousel.comp"
>> >
>> > Does that sound right?
>>
>> That sounds right.
>>
>> Do you have 2.7 or later checked out in ~/linuxcnc-dev?
>>
>> You must have compiled the source tree in ~/linuxcnc-dev, and in the
>> shell that you run halcompile you must first have run "source
>> ~/linuxcnc-dev/scripts/rip-environment".
>>
>>
>> --
>> Sebastian Kuzminsky
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Emc-users mailing list
>> Emc-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/emc-users
>>
>
>
>
> --
> Addressee is the intended audience.
> If you are not the addressee then my consent is not given for you to read
> this email furthermore it is my wish you would close this without saving or
> reading, and cease and desist from saving or opening my private
> correspondence.
> Thank you for honoring my wish.
>
>


-- 
Addressee is the intended audience.
If you are not the addressee then my consent is not given for you to read
this email furthermore it is my wish you would close this without saving or
reading, and cease and desist from saving or opening my private
correspondence.
Thank you for honoring my wish.
------------------------------------------------------------------------------
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to