584,865 active members*
4,959 visitors online*
Register for free
Login
Page 15 of 18 51314151617
Results 281 to 300 of 344
  1. #281
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post
    Hi PeterTheWolf,

    Maybe you have something in your Init C Program continuously moving the Y axis? Please post your Init C Program.

    Here is the Init C-Program I am currently using: "Init3Analog_Pete's_Final.c"

    Here is a link to the Tool Setup Screens images of my current KMotuonCNC.


    Init3Analog_Pete's_Final.c -- Code below.

    Code:
    #include "KMotionDef.h"
    
    main()
    {
    	SetBit(152);  // enable AMPS
    	SetBit(157);
    	SetBit(158);
    	
    	// Start of Pete's Setting for X-axis RAPID
    	
       	ch0->InputMode=ENCODER_MODE;
    	ch0->OutputMode=DAC_SERVO_MODE;
    	ch0->Vel=40000;
    	ch0->Accel=300000;
    	ch0->Jerk=3e+06;
    	ch0->P=1.54;
    	ch0->I=1.8e-05;
    	ch0->D=90;
    	ch0->FFAccel=0.0002;
    	ch0->FFVel=0.0376;
    	ch0->MaxI=2500;
    	ch0->MaxErr=100000;
    	ch0->MaxOutput=2047;
    	ch0->DeadBandGain=1;
    	ch0->DeadBandRange=0;
    	ch0->InputChan0=0;
    	ch0->InputChan1=1;
    	ch0->OutputChan0=0;
    	ch0->OutputChan1=1;
    	ch0->MasterAxis=-1;
    	ch0->LimitSwitchOptions=0x100;
    	ch0->LimitSwitchNegBit=0;
    	ch0->LimitSwitchPosBit=0;
    	ch0->SoftLimitPos=1e+09;
    	ch0->SoftLimitNeg=-1e+09;
    	ch0->InputGain0=-1;
    	ch0->InputGain1=1;
    	ch0->InputOffset0=0;
    	ch0->InputOffset1=0;
    	ch0->OutputGain=-1;
    	ch0->OutputOffset=0;
    	ch0->SlaveGain=1;
    	ch0->BacklashMode=BACKLASH_OFF;
    	ch0->BacklashAmount=0;
    	ch0->BacklashRate=0;
    	ch0->invDistPerCycle=1;
    	ch0->Lead=0;
    	ch0->MaxFollowingError=40;
    	ch0->StepperAmplitude=250;
    
    	ch0->iir[0].B0=1;
    	ch0->iir[0].B1=0;
    	ch0->iir[0].B2=0;
    	ch0->iir[0].A1=0;
    	ch0->iir[0].A2=0;
    
    	ch0->iir[1].B0=1;
    	ch0->iir[1].B1=0;
    	ch0->iir[1].B2=0;
    	ch0->iir[1].A1=0;
    	ch0->iir[1].A2=0;
    
    	ch0->iir[2].B0=0.016609;
    	ch0->iir[2].B1=0.033219;
    	ch0->iir[2].B2=0.016609;
    	ch0->iir[2].A1=1.60679;
    	ch0->iir[2].A2=-0.673229;
    // End of Pete's Settings for X-axis RAPID
    
    // Start of Pete's Setting for Y-axis RAPID
    	ch1->InputMode=ENCODER_MODE;
    	ch1->OutputMode=DAC_SERVO_MODE;
    	ch1->Vel=60000;
    	ch1->Accel=500000;
    	ch1->Jerk=800000;
    	ch1->P=8.4;
    	ch1->I=1e-06;
    	ch1->D=20;
    	ch1->FFAccel=0.0002;
    	ch1->FFVel=0.0325;
    	ch1->MaxI=2500;
    	ch1->MaxErr=100000;
    	ch1->MaxOutput=2047;
    	ch1->DeadBandGain=1;
    	ch1->DeadBandRange=0;
    	ch1->InputChan0=1;
    	ch1->InputChan1=1;
    	ch1->OutputChan0=1;
    	ch1->OutputChan1=1;
    	ch1->MasterAxis=-1;
    	ch1->LimitSwitchOptions=0x100;
    	ch1->LimitSwitchNegBit=0;
    	ch1->LimitSwitchPosBit=0;
    	ch1->SoftLimitPos=1e+09;
    	ch1->SoftLimitNeg=-1e+09;
    	ch1->InputGain0=-1;
    	ch1->InputGain1=1;
    	ch1->InputOffset0=0;
    	ch1->InputOffset1=0;
    	ch1->OutputGain=-1;
    	ch1->OutputOffset=0;
    	ch1->SlaveGain=1;
    	ch1->BacklashMode=BACKLASH_OFF;
    	ch1->BacklashAmount=0;
    	ch1->BacklashRate=0;
    	ch1->invDistPerCycle=1;
    	ch1->Lead=0;
    	ch1->MaxFollowingError=30;
    	ch1->StepperAmplitude=250;
    
    	ch1->iir[0].B0=1;
    	ch1->iir[0].B1=0;
    	ch1->iir[0].B2=0;
    	ch1->iir[0].A1=0;
    	ch1->iir[0].A2=0;
    
    	ch1->iir[1].B0=1;
    	ch1->iir[1].B1=0;
    	ch1->iir[1].B2=0;
    	ch1->iir[1].A1=0;
    	ch1->iir[1].A2=0;
    
    	ch1->iir[2].B0=0.016609;
    	ch1->iir[2].B1=0.033219;
    	ch1->iir[2].B2=0.016609;
    	ch1->iir[2].A1=1.60679;
    	ch1->iir[2].A2=-0.673229;
    	
    // End of Pete's Settings for Y-axis RAPID
    
    
    // Start of Pete's Setting for Z-axis RAPID
    
    	ch2->InputMode=ENCODER_MODE;
    	ch2->OutputMode=DAC_SERVO_MODE;
    	ch2->Vel=40000;
    	ch2->Accel=600000;
    	ch2->Jerk=280000;
    	ch2->P=2.8;
    	ch2->I=6e-06;
    	ch2->D=30;
    	ch2->FFAccel=8.7e-05;
    	ch2->FFVel=0.04;
    	ch2->MaxI=2500;
    	ch2->MaxErr=100000;
    	ch2->MaxOutput=2047;
    	ch2->DeadBandGain=1;
    	ch2->DeadBandRange=0;
    	ch2->InputChan0=2;
    	ch2->InputChan1=1;
    	ch2->OutputChan0=2;
    	ch2->OutputChan1=1;
    	ch2->MasterAxis=-1;
    	ch2->LimitSwitchOptions=0x100;
    	ch2->LimitSwitchNegBit=0;
    	ch2->LimitSwitchPosBit=0;
    	ch2->SoftLimitPos=1e+09;
    	ch2->SoftLimitNeg=-1e+09;
    	ch2->InputGain0=-1;
    	ch2->InputGain1=1;
    	ch2->InputOffset0=0;
    	ch2->InputOffset1=0;
    	ch2->OutputGain=-1;
    	ch2->OutputOffset=0;
    	ch2->SlaveGain=1;
    	ch2->BacklashMode=BACKLASH_OFF;
    	ch2->BacklashAmount=0;
    	ch2->BacklashRate=0;
    	ch2->invDistPerCycle=1;
    	ch2->Lead=0;
    	ch2->MaxFollowingError=20;
    	ch2->StepperAmplitude=250;
    
    	ch2->iir[0].B0=1;
    	ch2->iir[0].B1=0;
    	ch2->iir[0].B2=0;
    	ch2->iir[0].A1=0;
    	ch2->iir[0].A2=0;
    
    	ch2->iir[1].B0=1;
    	ch2->iir[1].B1=0;
    	ch2->iir[1].B2=0;
    	ch2->iir[1].A1=0;
    	ch2->iir[1].A2=0;
    
    	ch2->iir[2].B0=0.016609;
    	ch2->iir[2].B1=0.033219;
    	ch2->iir[2].B2=0.016609;
    	ch2->iir[2].A1=1.60679;
    	ch2->iir[2].A2=-0.673229;
    	
    // End of Pete's Settings for Z-axis RAPID
    
        EnableAxis(0);
    	EnableAxis(1);
    	EnableAxis(2);
    
        DefineCoordSystem(0,1,2,-1);
    }

    LINK to download the file of the CODE above.


    .....
    .....

    J325 Quick Links:

    Machine
    Existing Machine Schematics
    Electronic Cabinet-Right Side
    Electronic Cabinet-Back SIde
    Existing Drive Board SD1525-10
    J325 Servo Drive-SD1525 Manual
    3-Phase Rotary Convert Used
    RickB's J325 Retrofit Wiring
    KFLOP 5VDC/15Watt/3A Power Supply
    KANALOG Mounted & Connected
    Kmotion - Axis Encoder Manual Test of Position via Manual Movement
    Kanalog-Encoder Voltage High/Low Checks & 1KOhm Resister
    Kmotion Configuration Screens "RUN-AWAY"
    Tree Journeyman 325 Designed Specs.
    Tree Journeyman 325 Axis-Tension Frequency Settings
    Final Axis Tuned Error Parameters
    VFD Wiring to Existing Tree325 Old Controller
    DAC Values to RPM / Voltage Checks

    .....
    .....

  2. #282
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    Hmmm. No there is no forever loop at all in your Init C Program.

    I can't see any reason why your Y axis would start tripping following error by only wiring in the MPG and not doing anything with it. Furthermore why running an unconfigured MPG program would somehow fix it.

    Are you sure you didn't change something else or maybe were running something else in Thread #7?

    Otherwise it might be just that your system is marginal and sometimes faults for basically no reason. I see the Y Max Following Error is set quite small at 30 counts. The Trajectory Planner Acceleration is set quite high (5 times what X is). The Max following error doesn't need to be that tight. You might try increasing it and re-testing your infinite Jerk "Feed" Acceleration/Velocity settings in the Step Response Screen to see what the Following Errors currently are.

    Regards
    TK
    http://dynomotion.com

  3. #283
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post
    Hi PeterTheWolf,

    Hmmm. No there is no forever loop at all in your Init C Program.

    I can't see any reason why your Y axis would start tripping following error by only wiring in the MPG and not doing anything with it. Furthermore why running an unconfigured MPG program would somehow fix it.

    Are you sure you didn't change something else or maybe were running something else in Thread #7?

    Otherwise it might be just that your system is marginal and sometimes faults for basically no reason. I see the Y Max Following Error is set quite small at 30 counts. The Trajectory Planner Acceleration is set quite high (5 times what X is). The Max following error doesn't need to be that tight. You might try increasing it and re-testing your infinite Jerk "Feed" Acceleration/Velocity settings in the Step Response Screen to see what the Following Errors currently are.

    Ok ... I knew back when I set these parameters that the following errors were set quite tight. At the time I was going to run with them, once I got up and running, and then open them up if I needed too.

    Whats strange is, I did not get any of the Y-axis following errors before on all testing until I plugged in the JP6 connector from the the MPG pendant into KFLOP. Even now, if I pull the MPG connector from the JP6 on KFLOP, then I do not get any Y-axis following errors when I start testing again.

    As far as the Forever Loop added to the Init Main C-Program .... Did I added this correctly to the end?

    Code:
    #include "KMotionDef.h"
    
    
    //....................................................................
    // Below was added from the beginning of "MPGSmooth.c" code as Forever Loop
    //....................................................................
    #define QA 26	// define to which IO bits the AB signals are connected 
    #define QB 27	
    
    #define TAU 0.08 // smoothness factor (Low Pass Time constant seconds)
    #define FINAL_TIME 1.0 // Set final dest after this amount of time with no change
    
    
    // Start of Pete's Final "Init" code for Journeyman Tree 325 retrofit
    // 9/15/2018; added "MPGSmooth.c" code as Forever Loop at the end 
    // and the varibles defined above.
    
    main()
    {
    	SetBit(152);  // enable AMPS
    	SetBit(157);
    	SetBit(158);
    	
    	// Start of Pete's Setting for X-axis RAPID
    	
       	ch0->InputMode=ENCODER_MODE;
    	ch0->OutputMode=DAC_SERVO_MODE;
    	ch0->Vel=40000;
    	ch0->Accel=300000;
    	ch0->Jerk=3e+06;
    	ch0->P=1.54;
    	ch0->I=1.8e-05;
    	ch0->D=90;
    	ch0->FFAccel=0.0002;
    	ch0->FFVel=0.0376;
    	ch0->MaxI=2500;
    	ch0->MaxErr=100000;
    	ch0->MaxOutput=2047;
    	ch0->DeadBandGain=1;
    	ch0->DeadBandRange=0;
    	ch0->InputChan0=0;
    	ch0->InputChan1=1;
    	ch0->OutputChan0=0;
    	ch0->OutputChan1=1;
    	ch0->MasterAxis=-1;
    	ch0->LimitSwitchOptions=0x100;
    	ch0->LimitSwitchNegBit=0;
    	ch0->LimitSwitchPosBit=0;
    	ch0->SoftLimitPos=1e+09;
    	ch0->SoftLimitNeg=-1e+09;
    	ch0->InputGain0=-1;
    	ch0->InputGain1=1;
    	ch0->InputOffset0=0;
    	ch0->InputOffset1=0;
    	ch0->OutputGain=-1;
    	ch0->OutputOffset=0;
    	ch0->SlaveGain=1;
    	ch0->BacklashMode=BACKLASH_OFF;
    	ch0->BacklashAmount=0;
    	ch0->BacklashRate=0;
    	ch0->invDistPerCycle=1;
    	ch0->Lead=0;
    	ch0->MaxFollowingError=40;
    	ch0->StepperAmplitude=250;
    
    	ch0->iir[0].B0=1;
    	ch0->iir[0].B1=0;
    	ch0->iir[0].B2=0;
    	ch0->iir[0].A1=0;
    	ch0->iir[0].A2=0;
    
    	ch0->iir[1].B0=1;
    	ch0->iir[1].B1=0;
    	ch0->iir[1].B2=0;
    	ch0->iir[1].A1=0;
    	ch0->iir[1].A2=0;
    
    	ch0->iir[2].B0=0.016609;
    	ch0->iir[2].B1=0.033219;
    	ch0->iir[2].B2=0.016609;
    	ch0->iir[2].A1=1.60679;
    	ch0->iir[2].A2=-0.673229;
    // End of Pete's Settings for X-axis RAPID
    
    // Start of Pete's Setting for Y-axis RAPID
    	ch1->InputMode=ENCODER_MODE;
    	ch1->OutputMode=DAC_SERVO_MODE;
    	ch1->Vel=60000;
    	ch1->Accel=500000;
    	ch1->Jerk=800000;
    	ch1->P=8.4;
    	ch1->I=1e-06;
    	ch1->D=20;
    	ch1->FFAccel=0.0002;
    	ch1->FFVel=0.0325;
    	ch1->MaxI=2500;
    	ch1->MaxErr=100000;
    	ch1->MaxOutput=2047;
    	ch1->DeadBandGain=1;
    	ch1->DeadBandRange=0;
    	ch1->InputChan0=1;
    	ch1->InputChan1=1;
    	ch1->OutputChan0=1;
    	ch1->OutputChan1=1;
    	ch1->MasterAxis=-1;
    	ch1->LimitSwitchOptions=0x100;
    	ch1->LimitSwitchNegBit=0;
    	ch1->LimitSwitchPosBit=0;
    	ch1->SoftLimitPos=1e+09;
    	ch1->SoftLimitNeg=-1e+09;
    	ch1->InputGain0=-1;
    	ch1->InputGain1=1;
    	ch1->InputOffset0=0;
    	ch1->InputOffset1=0;
    	ch1->OutputGain=-1;
    	ch1->OutputOffset=0;
    	ch1->SlaveGain=1;
    	ch1->BacklashMode=BACKLASH_OFF;
    	ch1->BacklashAmount=0;
    	ch1->BacklashRate=0;
    	ch1->invDistPerCycle=1;
    	ch1->Lead=0;
    	ch1->MaxFollowingError=30;
    	ch1->StepperAmplitude=250;
    
    	ch1->iir[0].B0=1;
    	ch1->iir[0].B1=0;
    	ch1->iir[0].B2=0;
    	ch1->iir[0].A1=0;
    	ch1->iir[0].A2=0;
    
    	ch1->iir[1].B0=1;
    	ch1->iir[1].B1=0;
    	ch1->iir[1].B2=0;
    	ch1->iir[1].A1=0;
    	ch1->iir[1].A2=0;
    
    	ch1->iir[2].B0=0.016609;
    	ch1->iir[2].B1=0.033219;
    	ch1->iir[2].B2=0.016609;
    	ch1->iir[2].A1=1.60679;
    	ch1->iir[2].A2=-0.673229;
    	
    // End of Pete's Settings for Y-axis RAPID
    
    
    // Start of Pete's Setting for Z-axis RAPID
    
    	ch2->InputMode=ENCODER_MODE;
    	ch2->OutputMode=DAC_SERVO_MODE;
    	ch2->Vel=40000;
    	ch2->Accel=600000;
    	ch2->Jerk=280000;
    	ch2->P=2.8;
    	ch2->I=6e-06;
    	ch2->D=30;
    	ch2->FFAccel=8.7e-05;
    	ch2->FFVel=0.04;
    	ch2->MaxI=2500;
    	ch2->MaxErr=100000;
    	ch2->MaxOutput=2047;
    	ch2->DeadBandGain=1;
    	ch2->DeadBandRange=0;
    	ch2->InputChan0=2;
    	ch2->InputChan1=1;
    	ch2->OutputChan0=2;
    	ch2->OutputChan1=1;
    	ch2->MasterAxis=-1;
    	ch2->LimitSwitchOptions=0x100;
    	ch2->LimitSwitchNegBit=0;
    	ch2->LimitSwitchPosBit=0;
    	ch2->SoftLimitPos=1e+09;
    	ch2->SoftLimitNeg=-1e+09;
    	ch2->InputGain0=-1;
    	ch2->InputGain1=1;
    	ch2->InputOffset0=0;
    	ch2->InputOffset1=0;
    	ch2->OutputGain=-1;
    	ch2->OutputOffset=0;
    	ch2->SlaveGain=1;
    	ch2->BacklashMode=BACKLASH_OFF;
    	ch2->BacklashAmount=0;
    	ch2->BacklashRate=0;
    	ch2->invDistPerCycle=1;
    	ch2->Lead=0;
    	ch2->MaxFollowingError=20;
    	ch2->StepperAmplitude=250;
    
    	ch2->iir[0].B0=1;
    	ch2->iir[0].B1=0;
    	ch2->iir[0].B2=0;
    	ch2->iir[0].A1=0;
    	ch2->iir[0].A2=0;
    
    	ch2->iir[1].B0=1;
    	ch2->iir[1].B1=0;
    	ch2->iir[1].B2=0;
    	ch2->iir[1].A1=0;
    	ch2->iir[1].A2=0;
    
    	ch2->iir[2].B0=0.016609;
    	ch2->iir[2].B1=0.033219;
    	ch2->iir[2].B2=0.016609;
    	ch2->iir[2].A1=1.60679;
    	ch2->iir[2].A2=-0.673229;
    	
    // End of Pete's Settings for Z-axis RAPID
    
        EnableAxis(0);
    	EnableAxis(1);
    	EnableAxis(2);
    
        DefineCoordSystem(0,1,2,-1);
    
    //..............................................................................
    // Below was added from the end of "MPGSmooth.c" code as Forever Loop, 9/18/2018
    // for my MPG Pendant connection to work.
    //..............................................................................
    
    for (;;)
    	{
    		// convert quadrature to 2 bit binary
    		BitA = ReadBit(QA);   
    		PosNoWrap = (ReadBit(QB) ^ BitA) | (BitA<<1);
    
    		// Diff between expected position based on average of two prev deltas
    		// and position with no wraps.  (Keep as X2 to avoid division by 2)
    		
    		DiffX2 = 2*(Pos-PosNoWrap) + (Change2+Change1);
    		
    		// Calc quadrature wraparounds to bring Diff nearest zero
    		// offset by 128 wraps to avoid requiring floor()
    		wraps = ((DiffX2+1028)>>3)-128;
    		
    		// factor in the quadrature wraparounds
    		NewPos = PosNoWrap + (wraps<<2);
    
    		Change2 = Change1;
    		Change1 = NewPos - Pos;
    		Pos = NewPos;
    
    		if (ReadBit(33))  // is X0.01 selected?
    			Factor = 0.01;
    		else if (ReadBit(34))  // is X0.1 selected?
    			Factor = 0.1;
    		else if (ReadBit(31))  // is X1 selected?
    			Factor = 1.0;
    		else if (ReadBit(32))  // is X100 selected?
    			Factor = 75.0;
    		else                   // must be X10 then
    			Factor = 10.0;
    
    		if (ReadBit(28))  // is x selected?
    			Axis=0;
    		else if (ReadBit(29))  // is y selected?
    			Axis=1;
    		else if (ReadBit(30))  // is z selected?
    			Axis=2;
    
    		// check if the Axis just changed or we have been 
    		// converging to the target for a long time
    		if (Axis != LastAxis || 
    			(InMotion && Time_sec() > LastChangeTime+FINAL_TIME))
    		{
    			if (InMotion)
    				Move(LastAxis,Target);  //finalize any motion
    	
    			LastAxis = Axis;
    			InMotion = FALSE;
    		}
    		
    		if (Change1) // did we move?
    		{
    			if (!InMotion) Target = chan[Axis].Dest;
    			Target += Change1 * Factor;
    			MoveExp(Axis,Target,TAU);  // note: contains a WaitNextTimeSlice
    			LastChangeTime = Time_sec();
    			InMotion=TRUE;
    		}
    		else
    		{
    			WaitNextTimeSlice();
    		}		
    	}	
    
        return 0;
    
    
    }

  4. #284
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    Regarding the forever loop: Yes that looks correct except you forgot to declare the variables used by that code at the beginning of the main function. Add:

    Code:
    	int BitA, Change1 = 0, Change2 = 0, DiffX2;
    	int PosNoWrap, NewPos, Pos = 0, wraps;
    	int InMotion = FALSE, Axis, LastAxis = -1;
    	double LastChangeTime = 0, Target, Factor = 0;

    However I believe you have the MPG wired to a hardware encoder input (Encoder #7 KFLOP Inputs 42 and 43). That code was designed to monitor the encoder signals in software in order to not consume any encoder input and to be free to use any input pins. In your case since you have ample free encoder inputs and are already wired to one you might as well make use of the technique that uses a hardware encoder input instead. Furthermore there is a newer double filtered approach that is much smoother. Consider using the MPGServiceSmoothHardwareEncFiltered.c example instead.

    Regards
    TK
    http://dynomotion.com

  5. #285
    Join Date
    May 2012
    Posts
    537

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post
    Hi PeterTheWolf,

    Regarding the forever loop: Yes that looks correct except you forgot to declare the variables used by that code at the beginning of the main function. Add:

    Code:
    	int BitA, Change1 = 0, Change2 = 0, DiffX2;
    	int PosNoWrap, NewPos, Pos = 0, wraps;
    	int InMotion = FALSE, Axis, LastAxis = -1;
    	double LastChangeTime = 0, Target, Factor = 0;

    However I believe you have the MPG wired to a hardware encoder input (Encoder #7 KFLOP Inputs 42 and 43). That code was designed to monitor the encoder signals in software in order to not consume any encoder input and to be free to use any input pins. In your case since you have ample free encoder inputs and are already wired to one you might as well make use of the technique that uses a hardware encoder input instead. Furthermore there is a newer double filtered approach that is much smoother. Consider using the MPGServiceSmoothHardwareEncFiltered.c example instead.

    Regards
    Tom is right, this MPG program is by far the best to use.

    Also Tom, one minor revision you should include with this program in the next release. Change this:

    Code:
    // converging to the target for a long time
    	if (Axis != LastAxis || 
    		(InMotion && Time_sec() > LastChangeTime+FINAL_TIME))
    	{
    		if (InMotion)
    			Move(LastAxis,Target);  //finalize any motion
    
    		LastAxis = Axis;
    		InMotion = FALSE;
    	}
    To this:
    Code:
    // converging to the target for a long time
    	if (Axis != LastAxis || 
    		(InMotion && Time_sec() > LastChangeTime+FINAL_TIME))
    	{
    		if (InMotion)
    			Move(LastAxis,Target1);  //finalize any motion
    
    		LastAxis = Axis;
    		InMotion = FALSE;
    	}
    So final motion is sent to "Target1" instead of "Target". Without this change the final target drifts off sligtly due to the smoothing. So if your set on 0.010 increments and you move a full turn on the MPG you will now move exactly 1.000 instead of 0.99852 or something like that.

  6. #286
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi mmurray70,

    Thanks for pointing that out. Attached is a new Rev3 with that correction and some cleanup.

    Note the code is moved into a separate file so it can be easily included and called from the forever loop. The required variables are now in the function as static variables so they aren't spread out and are automatically included. There is also an example of how to include the file and call the function.

    Regards
    TK
    http://dynomotion.com

  7. #287
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post
    Hi mmurray70,

    Thanks for pointing that out. Attached is a new Rev3 with that correction and some cleanup.

    Note the code is moved into a separate file so it can be easily included and called from the forever loop. The required variables are now in the function as static variables so they aren't spread out and are automatically included. There is also an example of how to include the file and call the function.
    This C-Programming is still over my head a bit ... however, this is what I tried with these two new files Tom posted on #285 of this thread.

    I have edited my init file to …. “Init4Analog_Pete's_Final.c” and pointed it to the init button and I defined a button for the MPG pendant to be turned on based on line “#define ENABLE_MPG 29 // Switch/Button used to enable MPG Motion” in file “MPGServiceSmoothHardwareEncFilteredRev3_Petes.c ”.
    Is this correct?

    Attachment 402292 ....................LINK

    I then loaded the new “MPGServiceSmoothHardwareEncFilteredRev3_Petes.c ”, which I changed the FACTORxx and SELECTxx variables to what I throught they should be based on my wiring connection to KFLOP JP6, into the KMotion C-Program editor to complied it to see if I got any errors. And I got this error:

    Attachment 402294 ...........LINK


    I also tried running the new init file and then hitting the “MPG” button and I get this error in the console window (needless to say … no movement with the MPG):

    Attachment 402296 ..............LINK

    Some help would be great ...........

    Here are the files I am using ... at the bottom of this thread page:


    My MPG wiring diagram for reference:

    Attachment 398352 PDF file for zooming in on the details.

    .....
    .....

    J325 Quick Links:

    Machine
    Existing Machine Schematics
    Electronic Cabinet-Right Side
    Electronic Cabinet-Back SIde
    Existing Drive Board SD1525-10
    J325 Servo Drive-SD1525 Manual
    3-Phase Rotary Convert Used
    RickB's J325 Retrofit Wiring
    KFLOP 5VDC/15Watt/3A Power Supply
    KANALOG Mounted & Connected
    Kmotion - Axis Encoder Manual Test of Position via Manual Movement
    Kanalog-Encoder Voltage High/Low Checks & 1KOhm Resister
    Kmotion Configuration Screens "RUN-AWAY"
    Tree Journeyman 325 Designed Specs.
    Tree Journeyman 325 Axis-Tension Frequency Settings
    Final Axis Tuned Error Parameters
    VFD Wiring to Existing Tree325 Old Controller
    DAC Values to RPM / Voltage Checks

    .....
    .....

  8. #288
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    I have edited my init file to …. “Init4Analog_Pete's_Final.c” and pointed it to the init button and I defined a button for the MPG pendant to be turned on based on line “#define ENABLE_MPG 29 // Switch/Button used to enable MPG Motion” in file “MPGServiceSmoothHardwareEncFilteredRev3_Petes.c ”.
    Is this correct?
    Well no you need to decide how you want the MPG to be enabled.

    Sometimes the MPG has a physical button you need to hold down for it to be active otherwise any MPG motion is ignored as somewhat of a safety feature.

    Or you might want the MPG to always be active (in that case remove the check for that Bit in the program, or configure a bit you know will always be on like a KFLOP LED bit 46).

    There is a feature in this program to disable the MPG while a Job is active. That is the test for JOB_ACTIVE.

    It probably doesn't make sense to have a screen button to enable it. If you do want a screen button to enable it, you should probably have another button to disable it otherwise what is the point? In that case you would want to have a button to set bit 29 to 1 and another to set bit 29 to 0(not set bit 29 to 29 as you have). You will also need to configure Bit29 as an output so the screen buttons can set it. So you would need to add SetBitDirection(29,1); in your Init Program.

    I then loaded the new “MPGServiceSmoothHardwareEncFilteredRev3_Petes.c ”, which I changed the FACTORxx and SELECTxx variables to what I throught they should be based on my wiring connection to KFLOP JP6, into the KMotion C-Program editor to complied it to see if I got any errors. And I got this error:
    I think that looks reasonable except that file is included as part of your Init4Analog_Pete's_Final.c program. You can't compile it as a program by itself. Instead go back to the program that includes it and compile that.

    I also tried running the new init file and then hitting the “MPG” button and I get this error in the console window (needless to say … no movement with the MPG):
    As stated above you can only set a bit to 1 or 0 (not 29).

    HTH
    Regards
    TK
    http://dynomotion.com

  9. #289
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post
    Well no you need to decide how you want the MPG to be enabled.

    Sometimes the MPG has a physical button you need to hold down for it to be active otherwise any MPG motion is ignored as somewhat of a safety feature.
    I was thinking that would be accomplished with the "OFF" position of the axis selection knob since this MPG pendant does not have the a safety switch to be held-In while using it.
    However, getting there is not clear to me. Obviously the button concept was not what I intended ... I just did understand the C-Program enough to know what the line “#define ENABLE_MPG 29 // Switch/Button used to enable MPG Motion” in file “MPGServiceSmoothHardwareEncFilteredRev3_Petes.c ” was doing.
    Honestly ... I still do not know what this line is doing since I do not have a switch/button on this MPG.

    Isn't there a way to check if the axis selection knob is in the off position? Sorry, this may be obvious to most on this forum; however, it is not to me.
    Correct me if I am wrong here ... but doesn't the axis selection knob pins have 3.3V on which ever one is selected?
    And if that is the case, wouldn't the OFF position of the axis selection knob then mean that all the axis would have 0V?
    Wouldn't I then be able to test for the 3.3V on the X,Y,Z axis and then use this to enable the MPG?

    Attachment 402324 ....LINK to Image



    Quote Originally Posted by TomKerekes View Post

    There is a feature in this program to disable the MPG while a Job is active. That is the test for JOB_ACTIVE.
    This "JOB_ACTIVE" variable, this is either a 0 or 1 ... where does this get set? Is this set when an NC Program is running?



    ....
    ....

  10. #290
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    I was thinking that would be accomplished with the "OFF" position of the axis selection knob since this MPG pendant does not have the a safety switch to be held-In while using it.
    Yes of course you can do this. What confused me was on the schematic the 4 positions were labeled X Y Z A. Let's treat the A selection as "OFF". BTW its actually not necessary to have the OFF position wired in as we could assume if no X Y Z is selected, then assume OFF. But since it is wired in let's use it.

    Let's change these definitions:

    Code:
    #define ENABLE_MPG 29   // Switch/Button used to enable MPG Motion
    
    #define FACTOR1 31  //Petes JP6 pin #12 to MPG pin #18 Wire
    #define FACTOR10 32  //Petes JP6 pin #13 to MPG pin #6 Wire
    #define FACTOR100 33  //Petes JP6 pin #14 to MPG pin #19 Wire
    #define FACTOR200 23  //Not Used -- Petes MPG does not have a X200 setting
    
    #define SELECTX 28  //Petes JP6 pin #7 to MPG pin #16 Wire
    #define SELECTY 29  //Petes JP6 pin #10 to MPG pin #4 Wire
    #define SELECTZ 30  //Petes JP6 pin #11 to MPG pin #17 Wire
    #define SELECTA 27  //Petes JP6 pin #6 to MPG pin #5 Wire
    to

    Code:
    #define FACTOR1 31  //Petes JP6 pin #12 to MPG pin #18 Wire
    #define FACTOR10 32  //Petes JP6 pin #13 to MPG pin #6 Wire
    #define FACTOR100 33  //Petes JP6 pin #14 to MPG pin #19 Wire
    
    #define SELECTX 28  //Petes JP6 pin #7 to MPG pin #16 Wire
    #define SELECTY 29  //Petes JP6 pin #10 to MPG pin #4 Wire
    #define SELECTZ 30  //Petes JP6 pin #11 to MPG pin #17 Wire
    #define SELECTOFF 27  //Petes JP6 pin #6 to MPG pin #5 Wire

    Now change

    Code:
    if (!ReadBit(ENABLE_MPG) || JOB_ACTIVE)	// if not button pressed or Job Active ignore the encoder.
    		Change1 = 0;
    To (notice the '!' NOT operator is removed as when the OFF bit is active we want to prevent motion, rather than when an ENABLE bit is not active). Also change to the more appropriate symbol name.

    Code:
    if (ReadBit(SELECTOFF) || JOB_ACTIVE)	// if OFF or Job Active ignore the encoder.
    		Change1 = 0;
    change
    Code:
    if (ReadBit(FACTOR1))		// is X1 selected?
    	Factor = 4;
    else if (ReadBit(FACTOR10))	// is X10 selected?
    	Factor = 20;
    else if (ReadBit(FACTOR100))	// is X100 selected?
    	Factor = 40;
    else if (ReadBit(FACTOR200))	// is X200 selected?
    	Factor = 400;
    else
    	Factor = 0.0;
    
    if (ReadBit(SELECTX))		// is x selected?
    	Axis = 0;
    else if (ReadBit(SELECTY))	// is y selected?
    	Axis = 1;
    else if (ReadBit(SELECTZ))	// is z selected?
    	Axis = 2;
    else if (ReadBit(SELECTA))	// is A selected?
    	Axis = 3;
    to this because we don't have a FACTOR200 or an A axis

    Code:
    if (ReadBit(FACTOR1))		// is X1 selected?
    	Factor = 4;
    else if (ReadBit(FACTOR10))	// is X10 selected?
    	Factor = 20;
    else if (ReadBit(FACTOR100))	// is X100 selected?
    	Factor = 40;
    else
    	Factor = 0.0;
    
    if (ReadBit(SELECTX))		// is x selected?
    	Axis = 0;
    else if (ReadBit(SELECTY))	// is y selected?
    	Axis = 1;
    else if (ReadBit(SELECTZ))	// is z selected?
    	Axis = 2;
    Make sense?

    Regards
    TK
    http://dynomotion.com

  11. #291
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post

    Yes of course you can do this. What confused me was on the schematic the 4 positions were labeled X Y Z A. Let's treat the A selection as "OFF". BTW its actually not necessary to have the OFF position wired in as we could assume if no X Y Z is selected, then assume OFF. But since it is wired in let's use it.

    Let's change these definitions:
    ......
    ......

    Make sense?

    Tom ... this does make sense.

    I implemented the changes to my "MPGServiceSmoothHardwareEncFilteredRev3_Petes .c" file as you suggested and tried it. No errors in the console window of KMotion and I can see the I/O changing correctly as I select the axis/scale factor; however, I still get no movement on any of the axis.

    Can you suggest something I should be looking at to help me find why this MPG pendant may not be working correctly?



    Attachment 402480 .....LINK


    Thanks............



    .....
    .....

    J325 Quick Links:

    Machine
    Existing Machine Schematics
    Electronic Cabinet-Right Side
    Electronic Cabinet-Back SIde
    Existing Drive Board SD1525-10
    J325 Servo Drive-SD1525 Manual
    3-Phase Rotary Convert Used
    RickB's J325 Retrofit Wiring
    KFLOP 5VDC/15Watt/3A Power Supply
    KANALOG Mounted & Connected
    Kmotion - Axis Encoder Manual Test of Position via Manual Movement
    Kanalog-Encoder Voltage High/Low Checks & 1KOhm Resister
    Kmotion Configuration Screens "RUN-AWAY"
    Tree Journeyman 325 Designed Specs.
    Tree Journeyman 325 Axis-Tension Frequency Settings
    Final Axis Tuned Error Parameters
    VFD Wiring to Existing Tree325 Old Controller
    DAC Values to RPM / Voltage Checks

    .....
    .....

  12. #292
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    I think we forgot to configure the Encoder Input. I believe you have the encoder wired up to encoder input #7. You must pick a spare KFLOP Axis. (ie Axis 5 as your MPG Program has a define to use that axis) Configure it to have Encoder Input and set the InputChan0 to 7. All other axis parameters don't matter. Do not enable the axis. The axis Position will track the encoder regardless of whether the Axis is enabled or not. Once you do this verify on the KMotion Axis Screen that when the MPG encoder is moved the Axis 5 Position Changes. Then see if the MPG Program works.

    Regards
    TK
    http://dynomotion.com

  13. #293
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post

    I think we forgot to configure the Encoder Input. I believe you have the encoder wired up to encoder input #7. You must pick a spare KFLOP Axis. (ie Axis 5 as your MPG Program has a define to use that axis) Configure it to have Encoder Input and set the InputChan0 to 7. All other axis parameters don't matter. Do not enable the axis. The axis Position will track the encoder regardless of whether the Axis is enabled or not. Once you do this verify on the KMotion Axis Screen that when the MPG encoder is moved the Axis 5 Position Changes. Then see if the MPG Program works.

    Tom ... Thanks ......... after changing the "5" to the "7" in the following line

    #define MPG_INPUT_AXIS 7 // Axis used to read hardware encoder (not necessarily the encoder channel)

    in my "MPGServiceSmoothHardwareEncFilteredRev3_Petes .c" file the MPG pendant is now working.

    However, I am not getting the correct amount of move on the "X1 / X10 / X100" scale settings.

    One incremental move on the MPG dial with the scale set to "X1" is giving me:

    X-axis .... 0.0008"
    Y-Axis .....0.0008"
    Z-Axis .....0.0006"

    While, One incremental move on the MPG dial with the scale set to "X10" is giving me:

    X-axis .... 0.0040"
    Y-Axis .....0.0040"
    Z-Axis .....0.0032"

    And One incremental move on the MPG dial with the scale set to "X100" is giving me:

    X-axis .... 0.0080"
    Y-Axis .....0.0080"
    Z-Axis .....0.0064"

    What line(s) in the file "MPGServiceSmoothHardwareEncFilteredRev3_Petes .c" file do I need to be looking at to correct this?
    File attached.

    .....
    .....

    J325 Quick Links:

    Machine
    Existing Machine Schematics
    Electronic Cabinet-Right Side
    Electronic Cabinet-Back SIde
    Existing Drive Board SD1525-10
    J325 Servo Drive-SD1525 Manual
    3-Phase Rotary Convert Used
    RickB's J325 Retrofit Wiring
    KFLOP 5VDC/15Watt/3A Power Supply
    KANALOG Mounted & Connected
    Kmotion - Axis Encoder Manual Test of Position via Manual Movement
    Kanalog-Encoder Voltage High/Low Checks & 1KOhm Resister
    Kmotion Configuration Screens "RUN-AWAY"
    Tree Journeyman 325 Designed Specs.
    Tree Journeyman 325 Axis-Tension Frequency Settings
    Final Axis Tuned Error Parameters
    VFD Wiring to Existing Tree325 Old Controller
    DAC Values to RPM / Voltage Checks

    .....
    .....

  14. #294
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    "Factor" is the amount to move in counts per click. Because your resolution is different based on axis your factors will need to be modified based on the chosen axis. I'm not sure what your final axis resolutions are but you might change this:

    Code:
        if (ReadBit(FACTOR1))        // is X1 selected?
            Factor = 4;
        else if (ReadBit(FACTOR10))    // is X10 selected?
            Factor = 20;
        else if (ReadBit(FACTOR100))    // is X100 selected?
            Factor = 40;
        else
            Factor = 0.0;
    
        if (ReadBit(SELECTX))        // is x selected?
            Axis = 0;
        else if (ReadBit(SELECTY))    // is y selected?
            Axis = 1;
        else if (ReadBit(SELECTZ))    // is z selected?
            Axis = 2;
    to something like:

    Code:
        if (ReadBit(FACTOR1))        // is X1 selected?
            Factor = 0.001;
        else if (ReadBit(FACTOR10))  // is X10 selected?
            Factor = 0.01;
        else if (ReadBit(FACTOR100)) // is X100 selected?
            Factor = 0.1;
        else
            Factor = 0.0;
    
        if (ReadBit(SELECTX))        // is x selected?
        {
            Axis = 0;
            Factor *= 20225.0;        // Multiply by x Resolution
        }
        else if (ReadBit(SELECTY))    // is y selected?
        {
            Axis = 1;
            Factor *= 20225.0;      // Multiply by y Resolution
        }
        else if (ReadBit(SELECTZ))    // is z selected?
        {
            Axis = 2;
            Factor *= 25280.0;      // Multiply by z Resolution
        }
    HTH
    Regards
    TK
    http://dynomotion.com

  15. #295
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post

    "Factor" is the amount to move in counts per click. Because your resolution is different based on axis your factors will need to be modified based on the chosen axis. I'm not sure what your final axis resolutions are but you might change this:

    .... Code found in page #293 of thread.
    Thanks again Tom .... here is the code I ended up with that gave me correct scaled movements on my MPG pendant (X1 / X10 / X100)... at least on the KMotionCNC postion readouts :

    Code:
    if (ReadBit(FACTOR1))        // is X1 selected?
                Factor = 0.000025;
            else if (ReadBit(FACTOR10))  // is X10 selected?
                Factor = 0.00025;
            else if (ReadBit(FACTOR100)) // is X100 selected?
                Factor = 0.0025;
            else
                Factor = 0.0;
    
            if (ReadBit(SELECTX))        // is x selected?
            {
                Axis = 0;
                Factor *= 20010.0;        // Multiply by x Resolution
            }
            else if (ReadBit(SELECTY))    // is y selected?
            {
                Axis = 1;
                Factor *= 20005.0;      // Multiply by y Resolution
            }
            else if (ReadBit(SELECTZ))    // is z selected?
            {
                Axis = 2;
                Factor *= 25000.0;      // Multiply by z Resolution
            }
    Question: When using this MPG Pendant, what code is used to determine the actual speed the axis moves with each tick of the MPG dial?

    If I have the X100 scale selected on the X-axis and ... lets say .... start to turn this MPG dial maybe 10-20 ticks very quick.... the axis moves very fast. If I turn too fast I start getting following errors.
    Is there a way to slow the motion down some?
    Or does user of the MPG need to be more conservative in the speed of rotating the MPG dial?


    .....
    .....

    J325 Quick Links:

    Machine
    Existing Machine Schematics
    Electronic Cabinet-Right Side
    Electronic Cabinet-Back SIde
    Existing Drive Board SD1525-10
    J325 Servo Drive-SD1525 Manual
    3-Phase Rotary Convert Used
    RickB's J325 Retrofit Wiring
    KFLOP 5VDC/15Watt/3A Power Supply
    KANALOG Mounted & Connected
    Kmotion - Axis Encoder Manual Test of Position via Manual Movement
    Kanalog-Encoder Voltage High/Low Checks & 1KOhm Resister
    Kmotion Configuration Screens "RUN-AWAY"
    Tree Journeyman 325 Designed Specs.
    Tree Journeyman 325 Axis-Tension Frequency Settings
    Final Axis Tuned Error Parameters
    VFD Wiring to Existing Tree325 Old Controller
    DAC Values to RPM / Voltage Checks

    .....
    .....

  16. #296
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    Question: When using this MPG Pendant, what code is used to determine the actual speed the axis moves with each tick of the MPG dial?

    If I have the X100 scale selected on the X-axis and ... lets say .... start to turn this MPG dial maybe 10-20 ticks very quick.... the axis moves very fast. If I turn too fast I start getting following errors.
    Is there a way to slow the motion down some?
    Or does user of the MPG need to be more conservative in the speed of rotating the MPG dial?
    No the Operator should never be able to cause a following error regardless of how quickly they turn the MPG.

    The Motion should be limited to the Velocity and Acceleration in the Axis Parameters (Rapid Profile Settings). Although Jerk is not necessarily honored. Are you sure you can make big moves with your Rapid settings? What about with "infinite" Jerk (set to 1000X acceleration).

    Increasing these TAU values should make the motion smoother, accelerate slower, with more lag. You might try increasing these (all by some factor).

    #define TAU 0.01 // smoothness factor (Low Pass Time constant seconds for MoveExp)
    #define TAU1 0.015 // smoothness factor (Low Pass Time constant seconds for pre filter 1)
    #define TAU2 0.015 // smoothness factor (Low Pass Time constant seconds for pre filter 2)

    Regards
    TK
    http://dynomotion.com

  17. #297
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post

    No the Operator should never be able to cause a following error regardless of how quickly they turn the MPG.

    The Motion should be limited to the Velocity and Acceleration in the Axis Parameters (Rapid Profile Settings). Although Jerk is not necessarily honored. Are you sure you can make big moves with your Rapid settings? What about with "infinite" Jerk (set to 1000X acceleration).
    I can move larges move on all axis via the KmotionCNC rapid buttons without any following errors.


    Quote Originally Posted by TomKerekes View Post

    Increasing these TAU values should make the motion smoother, accelerate slower, with more lag. You might try increasing these (all by some factor).

    #define TAU 0.01 // smoothness factor (Low Pass Time constant seconds for MoveExp)
    #define TAU1 0.015 // smoothness factor (Low Pass Time constant seconds for pre filter 1)
    #define TAU2 0.015 // smoothness factor (Low Pass Time constant seconds for pre filter 2)

    I did find the following settings usable in my "MPGServiceSmoothHardwareEncFilteredRev3_Petes .c" file:


    #define TAU 0.015 // smoothness factor (Low Pass Time constant seconds for MoveExp) Second Try * 1.5
    #define TAU1 0.0225 // smoothness factor (Low Pass Time constant seconds for pre filter 1) Second Try * 1.5
    #define TAU2 0.030 // smoothness factor (Low Pass Time constant seconds for pre filter 2) Third Try * 2.0

    #define FINAL_TIME 1.0 // Set final dest after this amount of time with no change

    Now I can use the MPG Pendant as design without any following errors .............. Thanks Tom!


    On another subject .... Setting the Raw Machine Zero (Home Position) manually.

    I want to created a button that I can use each time I start-up my machine which will set the Raw Machine Zeros.
    And then I would like to set some soft-limits based on the counts.
    I know back on page #186 of this thread I was going to set-up some proximity sensor; however, I have yet to do that.

    So, I thought I would make a button I can use on machine start-up.

    Question: Is this C-Code correct for setting a button such that once I hit the button the Raw Machine Coordinate system will be zeroed out on all three axis?

    Code:
    #include "KMotionDef.h"
    
    // Manually setting Raw Machine Zeros on 3 axis System (via Button)
    // after manually moving each axis to a know user home position
    // then re-enabled all axis for KmotionCNC use.
    
    
    main()
    {
    	int SaveXLimits,SaveYLimits,SaveZLimits;  //place to save limit switch settings
    
    	// Set Machine Zero for X-Axis
    	DisableAxis(0);		// disable the axis
            Zero(0);		// Zero the position
    	EnableAxis(0);		// re-enable the ServoTick
    
            // Set Machine Zero for Y-Axis
    	DisableAxis(1);		// disable the axis
            Zero(1);		// Zero the position
    	EnableAxis(1);		// re-enable the ServoTick
    	
            // Set Machine Zero for Z-Axis
    	DisableAxis(2);		// disable the axis
            Zero(2);		// Zero the position
    	EnableAxis(2);		// re-enable the ServoTick
    
    	DefineCoordSystem(0,1,2,-1);  //Define XYZ coordinated motion axes
    }
    .....
    .....

    J325 Quick Links:

    Machine
    Existing Machine Schematics
    Electronic Cabinet-Right Side
    Electronic Cabinet-Back SIde
    Existing Drive Board SD1525-10
    J325 Servo Drive-SD1525 Manual
    3-Phase Rotary Convert Used
    RickB's J325 Retrofit Wiring
    KFLOP 5VDC/15Watt/3A Power Supply
    KANALOG Mounted & Connected
    Kmotion - Axis Encoder Manual Test of Position via Manual Movement
    Kanalog-Encoder Voltage High/Low Checks & 1KOhm Resister
    Kmotion Configuration Screens "RUN-AWAY"
    Tree Journeyman 325 Designed Specs.
    Tree Journeyman 325 Axis-Tension Frequency Settings
    Final Axis Tuned Error Parameters
    VFD Wiring to Existing Tree325 Old Controller
    DAC Values to RPM / Voltage Checks

    .....
    .....

  18. #298
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    Question: Is this C-Code correct for setting a button such that once I hit the button the Raw Machine Coordinate system will be zeroed out on all three axis?
    That should work. Although it has some unnecessary things:

    #1 it's not necessary to disable the axes to Zero them.
    #2 the Coordinate System is probably already defined by your Init Program
    #3 The Save variables are not used so no need to define them.

    You might want to add in setting the Soft Limits here. It doesn't usually make sense to set them in the Init Program until the system has been Homed.
    TK
    http://dynomotion.com

  19. #299
    Join Date
    Aug 2008
    Posts
    213

    Re: Tree325 Retrofit Started

    Quote Originally Posted by TomKerekes View Post

    That should work. Although it has some unnecessary things:

    #1 it's not necessary to disable the axes to Zero them.
    #2 the Coordinate System is probably already defined by your Init Program
    #3 The Save variables are not used so no need to define them.

    You might want to add in setting the Soft Limits here. It doesn't usually make sense to set them in the Init Program until the system has been Homed.
    ....

    Tom .... can you please confirm this C-Code below? I took what I defined as the "Set Home Zero" C-code with your suggested edits and added the code in from the "SoftLimits3AxesV2.c" that came from the KMotion "C:\KMotion434\C Programs\" install directory. I changed the +/- axis count line according to the soft-limit that should stop the machine from hitting the hard-limits.

    I guess I am unsure if any of this code needs to go into my "Init" main program.



    Code:
    #include "KMotionDef.h"
    
    // Soft Limit travel on Y-13.00X +/-13.00 inches from machine home set zero
    #define XMINUS -260130.0  // about -13.0in (in counts)
    #define XPLUS 260130.0  // about +13.0in (in counts)
    // Soft Limit travel on Y-13.00 inches from machine home set zero
    #define YMINUS -260065.0   // about -13.0in (in counts)
    #define YPLUS 250.0  // about +.012in (in counts)
    // Soft Limit travel on Z-5.0in inches from machine home set zero
    #define ZMINUS -125000.0    // about -5.0in (in counts)
    #define ZPLUS 313.0    // about +.012in (in counts)
    
    int InLimit();
    int CheckALimit(CHAN *ch, double Min, double Max);
    
    #define SIGMA 0.01
    
    
    // This File Name is--  SetMachineZeros.c
    // Manually setting Raw Machine Zeros on 3 axis System (via Button)
    // after manually moving each axis to a know user home position
    // then re-enabled all axis for KmotionCNC use.
    
    
    main()
    {
    
    	// Set Machine Zero for X-Axis
            Zero(0);		// Zero the position
    
            // Set Machine Zero for Y-Axis
            Zero(1);		// Zero the position
    	
            // Set Machine Zero for Z-Axis
            Zero(2);		// Zero the position
    
    	DefineCoordSystem(0,1,2,-1);  //Define XYZ coordinated motion axes
    
    	
    	
    	for (;;)  // loop forever
    	{
    		if (InLimit())  // check for any limit
    		{
    			DisableAxis(0);
    			DisableAxis(1);
    			DisableAxis(2);
    			
    			Delay_sec(2);
    			
    			EnableAxisDest(0,ch0->Dest); 
    			EnableAxisDest(1,ch1->Dest); 
    			EnableAxisDest(2,ch2->Dest); 
    		}
    	}	
    }
    
    int InLimit()
    {
    	WaitNextTimeSlice();
    	return CheckALimit(ch0,XMINUS,XPLUS) ||
    		   CheckALimit(ch1,YMINUS,YPLUS) ||
    		   CheckALimit(ch2,ZMINUS,ZPLUS);
    }
    
    // check if in limit while moving in the direction of the limit
    
    int CheckALimit(CHAN *ch, double Min, double Max)
    {
    	if (ch->Dest < Min && ch->last_vel < -SIGMA) return 1;
    	if (ch->Dest > Max && ch->last_vel >  SIGMA) return 1;
    	return 0;
    }
    .....
    .....

    J325 Quick Links:

    Machine
    Existing Machine Schematics
    Electronic Cabinet-Right Side
    Electronic Cabinet-Back SIde
    Existing Drive Board SD1525-10
    J325 Servo Drive-SD1525 Manual
    3-Phase Rotary Convert Used
    RickB's J325 Retrofit Wiring
    KFLOP 5VDC/15Watt/3A Power Supply
    KANALOG Mounted & Connected
    Kmotion - Axis Encoder Manual Test of Position via Manual Movement
    Kanalog-Encoder Voltage High/Low Checks & 1KOhm Resister
    Kmotion Configuration Screens "RUN-AWAY"
    Tree Journeyman 325 Designed Specs.
    Tree Journeyman 325 Axis-Tension Frequency Settings
    Final Axis Tuned Error Parameters
    VFD Wiring to Existing Tree325 Old Controller
    DAC Values to RPM / Voltage Checks

    .....
    .....

  20. #300
    Join Date
    May 2006
    Posts
    4043

    Re: Tree325 Retrofit Started

    Hi PeterTheWolf,

    #2 the Coordinate System is probably already defined by your Init Program

    That code assumes you will zero when the machine is at the center, back, up position. Is that what you plan to do?

    That soft limit code is somewhat old. It disables the axes when the software limits are entered. It then tries to automatically enable every 2 seconds to allow you to move back out of the limits. Is that the way you want it to work? Since you have encoders the EnableAxisDest should be changed to enable to the current position chx->Position rather than the last commanded destination.

    If you get something that works the way you like it can be added to your Init program.
    TK
    http://dynomotion.com

Page 15 of 18 51314151617

Similar Threads

  1. Emco VMC 100 Mach 3 Retrofit started
    By whiteriver in forum EMCO Mills
    Replies: 11
    Last Post: 02-10-2017, 11:30 PM
  2. RETROFIT CONTROL & RETROFIT PROJECTS WITH NCT CNC SYSTEM
    By NCT201 in forum Machinery Manuals / Brochures
    Replies: 0
    Last Post: 07-26-2016, 11:24 AM
  3. Replies: 31
    Last Post: 11-27-2008, 06:55 AM
  4. camsoft retrofit to a anilam crusader retrofit
    By bowlingmac in forum CamSoft Products
    Replies: 44
    Last Post: 07-25-2008, 03:00 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •