starting my C program, any guidance would be appreciated. - Page 10


Page 10 of 11 FirstFirst ... 7891011 LastLast
Results 181 to 200 of 215

Thread: starting my C program, any guidance would be appreciated.

  1. #181
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Quote Originally Posted by TomKerekes View Post
    After hitting a limit switch? If so how are they wired/configured?
    I have them wired through JP15, (168, 169, 170 i believe thats the #) both hot wires are run to a 24v power supply and the neg. switch wire is run to jp15 with the neg. power supply wire is run to JP6 GND. And I just configured them to prevent a move into stop. I was attempting to correct this yesterday but if I manually move awat from the limit switch the machine still refuses to move, I have to do a move in the step response screen.



  2. #182
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    I have them wired through JP15, (168, 169, 170 i believe thats the #) both hot wires are run to a 24v power supply and the neg. switch wire is run to jp15 with the neg. power supply wire is run to JP6 GND.
    I can't follow that


    And I just configured them to prevent a move into stop.
    This doesn't tell me how it is actually configured.


    I was attempting to correct this yesterday but if I manually move awat from the limit switch the machine still refuses to move, I have to do a move in the step response screen.
    Manually Jogging? Is feed hold active?

    Regards
    TK http://dynomotion.com


  3. #183
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Quote Originally Posted by TomKerekes View Post
    I can't follow that
    I was attempting to describe limit wiring from memory, but got some things wrong.
    I have them wired through JP15, (168, 169, 170 i believe thats the #)
    Each limit switch has a red and black wire, the red is run to JP15 + side.
    the Black wire of the limit SW. is on the 24v power supply + side.
    Neg.(-) switch wire is run from the power supply to jp15 neg.(-) side.


    This doesn't tell me how it is actually configured.
    I don't know what you mean by configured, (maybe this screen print)?


    Manually Jogging? Is feed hold active?
    No, I had to disable the axis and move it away from the limit switch by hand spinning the servo. I have tried what the reading stated, which is to press the feed hold switch when its blinking and move the axis away from the limit sw. but it refuses to move.

    Attached Thumbnails Attached Thumbnails starting my C program, any guidance would be appreciated.-untitled-png  


  4. #184
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    I don't know what you mean by configured, (maybe this screen print)?
    Yes. It is configured to "Disable Drive into Limit". In this case when the limit is hit the axis is disabled. You can't move an axis when it is disabled. You could have checked to see that it was disabled on the Axis Screen. Or noticed yellow DROs in KMotionCNC indicating the disabled axis. The Step Response Screen disables the axis, sets all parameters, enables the axis, then moves. That's why that worked. In this mode you should be able to re-initialize (which should enable your axes), then Jog or Move out of the limit.

    Regards
    TK http://dynomotion.com


  5. #185
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Quote Originally Posted by TomKerekes View Post
    In this mode you should be able to re-initialize (which should enable your axes), then Jog or Move out of the limit.
    This is what it's not doing, I am able to re-enable the axis but not able to jog out of the limit. Also could you give me link to setting the soft limits, I am unable to find it again?



  6. #186
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    This is what it's not doing, I am able to re-enable the axis but not able to jog out of the limit.
    Well what happens? Does axis disable? Any messages? What are the Commanded Destination and Positions before and after the Jog?


    Also could you give me link to setting the soft limits, I am unable to find it again?
    To get help on any parameter on a screen click "Help" then click on the parameter.

    Regards
    TK http://dynomotion.com


  7. #187
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Quote Originally Posted by TomKerekes View Post
    Well what happens? Does axis disable? Any messages? What are the Commanded Destination and Positions before and after the Jog?
    I get no messages and the axis just disables again after I activate it and press the move direction arrow. The commanded destination varies, it usually happens when I run a program and the machine tries to make a move more than I have travel for. Dont have my machine zero set yet, which may help but doesn't fix it if I do run into a limit.



  8. #188
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Are you sure there are no messages on the Console Screen?

    What Version are you running?

    Regards
    TK http://dynomotion.com


  9. #189
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Quote Originally Posted by TomKerekes View Post
    Are you sure there are no messages on the Console Screen?

    What Version are you running?
    Yes, V4.35f



  10. #190
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    I see now both positive and negative limits are set to the same Input Bit 136. KFLOP will only allow you to Jog the direction out of the limit without disabling. If both limits are set both directions will not be permitted. Please use different inputs for opposite limits.

    Regards
    TK http://dynomotion.com


  11. #191
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Ok, the original way each limit was wired was as one limit switch on each axis, if either limit was tripped it would shut down the machine. SO i need t I rewire them separately. Thank you.....



  12. #192
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    I'm still waiting on limit switch to get in but the ones I have are working the way they should now.

    I am now a bit confused how to get the MPG I purchased up and working. The code (MPGServiceSmoothHardwareEnc) has #defines ENABLE_MPG and #define HANDWHEEL_EN which I dont know what way to configure. I understand that this code should be copied and place at the end of the Init. program? Here is what I have as far as code and how my MPG is wired, is there something I'm missing or should I use a different code file? MPG is Wired to JP4.
    Code:
    #include "KMotionDef.h"
    
    // Example Init program that includes "smooth" MPG motion example
    // which makes use of the exponential motion command.
    
    #define MPG_INPUT_AXIS 7
    
    #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
    
    #define ENABLE_MPG ?
    
    #define SELECTX 23
    #define SELECTY 24
    #define SELECTZ 25
    #define SELECTA 22
    
    #define FACTOR1 16
    #define FACTOR10 17
    #define FACTOR100 18
    
    #define HANDWHEEL_EN ?	
    #define A 19		// define to which IO bits the AB signals are connected 
    #define B 20		// define to which IO bits the AB signals are connected 
    #define TAU 0.35 		// Max smoothing factor
    #define MINTAU 0.12 	// min smoothing factor
    #define RATE 1.1 		// Smoothing factor rate of change per second after no mpg movement
    #define FINAL_TIME 1.0 	// Set final dest after this amount of time with no change
    
    void ServiceMPG(void)
    {
    	static int Pos, FirstTime=TRUE;
    	static int InMotion=FALSE,Axis,LastAxis=-1;
    	static double LastChangeTime=0,Target,Factor=0;
    	int Change1, NewPos;
    	
    	if (FirstTime)
    	{
    		Pos = chan[MPG_INPUT_AXIS].Position;
    		FirstTime=FALSE;
    	}
    
    	NewPos = chan[MPG_INPUT_AXIS].Position;
    	Change1 = NewPos - Pos;
    	Pos = NewPos;
    
            
    	if (!ReadBit(HANDWHEEL_EN) || JOB_ACTIVE) // if not button pressed or Job Active ignore the encoder.
    		Change1 = 0;
    	else 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;
    	else if (ReadBit(SELECTA))  // is A selected?
    		Axis=3;
    
    	// 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;
    	}
    
    	if (InMotion) 							// If still moving
    	{		
    		NEWTAU = TAU - (RATE * (Time_sec() - LastChangeTime));	 		// Adjust NEWTAU
    		if (NEWTAU < MINTAU) NEWTAU = MINTAU; 				// Limit NEWTAU Mininum
    		MoveExp(Axis,Target,NEWTAU);  					// Move with updated smoothing factor
    	}
    	else
    	{
    		WaitNextTimeSlice();
    	}		
    }


    Attached Thumbnails Attached Thumbnails starting my C program, any guidance would be appreciated.-mpg-wiring-png  
    Last edited by Gunmachinist; 04-10-2021 at 11:18 PM.


  13. #193
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    I understand that this code should be copied and place at the end of the Init. program?
    Sort of, but you don't need to copy the code into the Init program. Instead you can just include the file towards the beginning, then add a call to ServiceMPG() from a loop at the end.

    I'm not sure how well that MPG program works. It was contributed by a User. I do know that MPGServiceSmoothHardwareEncFilteredRev3.c works well so I would suggest using it instead.

    Otherwise your changes to the defines seem reasonable.

    Regards
    TK http://dynomotion.com


  14. #194
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default re: starting my C program, any guidance would be appreciated.

    Quote Originally Posted by TomKerekes View Post
    Sort of, but you don't need to copy the code into the Init program. Instead you can just include the file towards the beginning, then add a call to ServiceMPG() from a loop at the end..
    How do I "call to ServiceMPG() from a loop"?



  15. #195
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: starting my C program, any guidance would be appreciated.

    One way to form a loop in C is with a "for" statement. The for statement is very powerful where 3 things can be specified: what should be performed before the loop, when to exit the loop, and something to be performed at the end of each loop. for example

    Code:
    for (i=0; i<10; i++)
    {
    }
    will set I to zero before the loop, keep looping while i is less than 10, and increment i at the end of each loop. Everything within the curly brackets will be executed each loop.

    The simplest for loop where nothing is done before, the loop never exits (forever loop), and nothing is performed at the end of the loop, is:

    Code:
    for (;;)
    {
    }


    To make a "call" to a function specify the name of the function to be called followed by empty parenthesis '()' if the function doesn't have any parameters to be specified. See here.


    C is probably the most common programming language in the world. So you can easily look these things up on the Internet.

    HTH

    Regards
    TK http://dynomotion.com


  16. #196
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by TomKerekes View Post
    One way to form a loop in C is with a "for" statement. The for statement is very powerful where 3 things can be specified: what should be performed before the loop, when to exit the loop, and something to be performed at the end of each loop. for example

    Code:
    for (i=0; i<10; i++)
    {
    }
    will set I to zero before the loop, keep looping while i is less than 10, and increment i at the end of each loop. Everything within the curly brackets will be executed each loop.

    The simplest for loop where nothing is done before, the loop never exits (forever loop), and nothing is performed at the end of the loop, is:

    Code:
    for (;;)
    {
    }


    To make a "call" to a function specify the name of the function to be called followed by empty parenthesis '()' if the function doesn't have any parameters to be specified. See here.


    C is probably the most common programming language in the world. So you can easily look these things up on the Internet.

    HTH
    Ok, I understood looping just didn't understand what was meant by, to call a function, but I got it now thanks.



  17. #197
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default Re: starting my C program, any guidance would be appreciated.

    I did my changes to MPGServiceSmoothHardwareEncFilteredRev3 and I am getting an error (; expected) when there is already a ; WTF
    Code:
    #include "KMotionDef.h"
    // Example Function as "smooth" MPG motion example
    // which makes use of the exponential motion command.
    // Additionally double Filtered to be very smoot with limited Jerk
    
    #define MPG_INPUT_AXIS 2  // Axis used to read hardware encoder (not necessarily the encoder channel)
    #define QA 19	// define to which IO bits the AB signals are connected 
    #define QB 20	
    
    #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)
    #define FINAL_TIME 1.0		// Set final dest after this amount of time with no change
    
    #define FACTOR1 16
    #define FACTOR10 17
    #define FACTOR100 18
    
    #define SELECTX 21
    #define SELECTY 22
    #define SELECTZ 23
    #define SELECTA 24
     
    
    void ServiceMPG(void)
    {
    	static int Pos, FirstTime= 1;
    	static int InMotion = 0,Axis,LastAxis = -1;
    	static double LastChangeTime = 0,Target,Factor = 0;
    	static double Target1, Target2, K1, K2, K1M, K2M;
    
    	int Change1, NewPos;
    	
    main()
    	if (FirstTime);
    	{
    		K1 = exp(-2 * TIMEBASE / TAU1);	// filter coefficients
    		K2 = exp(-2 * TIMEBASE / TAU2);
    		K1M = 1.0 - K1;
    		K2M = 1.0 - K2;
    		FirstTime = FALSE;
    	}
    
    	Change1 = NewPos - Pos;
    	Pos = NewPos;
    
    	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;
    	else if (ReadBit(SELECTA))	// is A selected?
    		Axis = 3;
    
    
    	// Feedhold fully stopped ??
    	if (CS0_StoppingState == 4 && InMotion)
    	{
    		Change1 = 0;			// ignore any MPG change
    		Jog(LastAxis, 0);
    		InMotion = FALSE;
    	}
    
    	// 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, Target1);	//finalize any motion
    
    		LastAxis = Axis;
    		InMotion = FALSE;
    	}
    
    	if (Change1)				// did we move?
    	{
    		if (!InMotion)
    			Target = Target1 = Target2 = chan[Axis].Dest;
    		Target1 += Change1 * Factor;
    		LastChangeTime = Time_sec();
    		InMotion = TRUE;
    	}
    
    	if (InMotion)				// If moving
    	{
    		if (Target1 > chan[LastAxis].SoftLimitPos)
    			Target1 = chan[LastAxis].SoftLimitPos;
    		if (Target1 < chan[LastAxis].SoftLimitNeg)
    			Target1 = chan[LastAxis].SoftLimitNeg;
    		Target2 = Target2 * K1 + Target1 * K1M;
    		Target = Target * K2 + Target2 * K2M;
    		MoveExp(Axis, Target, TAU);
    	}
    }




  18. #198
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: starting my C program, any guidance would be appreciated.

    You have a function call to main() in the middle of the ServiceMPG function which make no sense and is also is missing a ;

    Note you can not compile a function as a program. This just defines a function it is not a complete program. Instead include it into some Program such as your Init Program and compile that program.

    Remove the #include "KMotionDef.h". The Program this is being included into should already include that. No reason to include it again here.

    It would have been nice to tell us which line the error was.

    Regards
    TK http://dynomotion.com


  19. #199
    Member Gunmachinist's Avatar
    Join Date
    May 2020
    Posts
    252
    Downloads
    0
    Uploads
    0

    Default Re: starting my C program, any guidance would be appreciated.

    I am a little confused about setting my home positions. I am using SimpleHome3axis.c in the c code folder. I have copied my axis information into the program like it states to do, and changed the information to equal my axis numbers. I have attempted to run the c code by placing it in tool setup under user buttons and labeling it Home, is this correct or should I put it in as one of the M codes? Here is what I have:
    Code:
    #include "KMotionDef.h"
    
    // Configuration and Homing program for a 3 axis System
    // Limit switches are disabled and used as a home switch
    // then they are re-enabled
    
    
    main()
    {
    	int SaveXLimits,SaveYLimits,SaveZLimits;  //place to save limit switch settings
    	
    	DisableAxis(0);  // Disable all axes
    	DisableAxis(1);
    	DisableAxis(2);
    
    	// Set the axis parameters here
    	// after everything is configured in the KMotion Screens
    	// use copy C Code to clipboard on the configuration screen
    	// then paste here.  Repeat for each axis
    	ch0->InputMode=ENCODER_MODE;
    	ch0->OutputMode=DAC_SERVO_MODE;
    	ch0->Vel=25000;
    	ch0->Accel=250000;
    	ch0->Jerk=80000;
    	ch0->P=2;
    	ch0->I=0.0001;
    	ch0->D=2;
    	ch0->FFAccel=0.0005;
    	ch0->FFVel=0.006;
    	ch0->MaxI=80000;
    	ch0->MaxErr=100000;
    	ch0->MaxOutput=2000;
    	ch0->DeadBandGain=0;
    	ch0->DeadBandRange=1;
    	ch0->InputChan0=0;
    	ch0->InputChan1=1;
    	ch0->OutputChan0=0;
    	ch0->OutputChan1=1;
    	ch0->MasterAxis=0;
    	ch0->LimitSwitchOptions=0x11f;
    	ch0->LimitSwitchNegBit=136;
    	ch0->LimitSwitchPosBit=137;
    	ch0->SoftLimitPos=1e+09;
    	ch0->SoftLimitNeg=-1e+08;
    	ch0->InputGain0=1;
    	ch0->InputGain1=1;
    	ch0->InputOffset0=0;
    	ch0->InputOffset1=0;
    	ch0->OutputGain=1;
    	ch0->OutputOffset=0;
    	ch0->SlaveGain=0;
    	ch0->BacklashMode=BACKLASH_OFF;
    	ch0->BacklashAmount=1;
    	ch0->BacklashRate=4;
    	ch0->invDistPerCycle=0;
    	ch0->Lead=10;
    	ch0->MaxFollowingError=100000;
    	ch0->StepperAmplitude=250;
    
    	ch0->iir[0].B0=3.44761;
    	ch0->iir[0].B1=-6.74051;
    	ch0->iir[0].B2=3.29464;
    	ch0->iir[0].A1=1.91668;
    	ch0->iir[0].A2=-0.918416;
    
    	ch0->iir[1].B0=0.123861;
    	ch0->iir[1].B1=0.123861;
    	ch0->iir[1].B2=0;
    	ch0->iir[1].A1=0.752278;
    	ch0->iir[1].A2=0;
    
    	ch0->iir[2].B0=0.0166075;
    	ch0->iir[2].B1=0.033215;
    	ch0->iir[2].B2=0.0166075;
    	ch0->iir[2].A1=1.6066;
    	ch0->iir[2].A2=-0.673034;
    
    		ch1->InputMode=ENCODER_MODE;
    	ch1->OutputMode=DAC_SERVO_MODE;
    	ch1->Vel=80000;
    	ch1->Accel=100000;
    	ch1->Jerk=80000;
    	ch1->P=12;
    	ch1->I=0.0001;
    	ch1->D=3;
    	ch1->FFAccel=0.0008;
    	ch1->FFVel=0.001;
    	ch1->MaxI=8000;
    	ch1->MaxErr=1e+06;
    	ch1->MaxOutput=2047;
    	ch1->DeadBandGain=2;
    	ch1->DeadBandRange=1;
    	ch1->InputChan0=1;
    	ch1->InputChan1=1;
    	ch1->OutputChan0=1;
    	ch1->OutputChan1=1;
    	ch1->MasterAxis=-1;
    	ch1->LimitSwitchOptions=0x110;
    	ch1->LimitSwitchNegBit=140;
    	ch1->LimitSwitchPosBit=141;
    	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=0;
    	ch1->BacklashMode=BACKLASH_LINEAR;
    	ch1->BacklashAmount=0;
    	ch1->BacklashRate=0;
    	ch1->invDistPerCycle=0;
    	ch1->Lead=0;
    	ch1->MaxFollowingError=100000;
    	ch1->StepperAmplitude=250;
    
    	ch1->iir[0].B0=3.44761;
    	ch1->iir[0].B1=-6.74051;
    	ch1->iir[0].B2=3.29464;
    	ch1->iir[0].A1=1.91668;
    	ch1->iir[0].A2=-0.918416;
    
    	ch1->iir[1].B0=0.123861;
    	ch1->iir[1].B1=0.123861;
    	ch1->iir[1].B2=0;
    	ch1->iir[1].A1=0.752278;
    	ch1->iir[1].A2=0;
    
    	ch1->iir[2].B0=0.0166094;
    	ch1->iir[2].B1=0.0332189;
    	ch1->iir[2].B2=0.0166094;
    	ch1->iir[2].A1=1.60679;
    	ch1->iir[2].A2=-0.673229;
    
    		ch2->InputMode=ENCODER_MODE;
    	ch2->OutputMode=DAC_SERVO_MODE;
    	ch2->Vel=50000;
    	ch2->Accel=400000;
    	ch2->Jerk=100000;
    	ch2->P=2;
    	ch2->I=0.0001;
    	ch2->D=2;
    	ch2->FFAccel=0.0008;
    	ch2->FFVel=0.001;
    	ch2->MaxI=3000;
    	ch2->MaxErr=100000;
    	ch2->MaxOutput=2047;
    	ch2->DeadBandGain=0;
    	ch2->DeadBandRange=1;
    	ch2->InputChan0=2;
    	ch2->InputChan1=1;
    	ch2->OutputChan0=2;
    	ch2->OutputChan1=1;
    	ch2->MasterAxis=-1;
    	ch2->LimitSwitchOptions=0x11f;
    	ch2->LimitSwitchNegBit=138;
    	ch2->LimitSwitchPosBit=139;
    	ch2->SoftLimitPos=1e+30;
    	ch2->SoftLimitNeg=-1e+30;
    	ch2->InputGain0=1;
    	ch2->InputGain1=1;
    	ch2->InputOffset0=0;
    	ch2->InputOffset1=0;
    	ch2->OutputGain=-1;
    	ch2->OutputOffset=0;
    	ch2->SlaveGain=1;
    	ch2->BacklashMode=BACKLASH_LINEAR;
    	ch2->BacklashAmount=0;
    	ch2->BacklashRate=0;
    	ch2->invDistPerCycle=0;
    	ch2->Lead=12;
    	ch2->MaxFollowingError=100000;
    	ch2->StepperAmplitude=250;
    
    	ch2->iir[0].B0=0.123861;
    	ch2->iir[0].B1=0.123861;
    	ch2->iir[0].B2=0;
    	ch2->iir[0].A1=0.752278;
    	ch2->iir[0].A2=0;
    
    	ch2->iir[1].B0=3.44761;
    	ch2->iir[1].B1=-6.74051;
    	ch2->iir[1].B2=3.29464;
    	ch2->iir[1].A1=1.91668;
    	ch2->iir[1].A2=-0.918416;
    
    	ch2->iir[2].B0=0.0166094;
    	ch2->iir[2].B1=0.0332189;
    	ch2->iir[2].B2=0.0166094;
    	ch2->iir[2].A1=1.60679;
    	ch2->iir[2].A2=-0.673229;
    
    	
    	
    	
    	
    		// disable the limits (first save how they were set) 
    	SaveXLimits = ch0->LimitSwitchOptions;
    	SaveYLimits = ch1->LimitSwitchOptions;
    	SaveZLimits = ch2->LimitSwitchOptions;
    	ch0->LimitSwitchOptions = 0;
    	ch1->LimitSwitchOptions = 0;
    	ch2->LimitSwitchOptions = 0;
    	
    	// enable all 3 axes and begin servoing where we are 
    	
    	EnableAxis(0);
    	EnableAxis(1);
    	EnableAxis(2);
    
     
    	// Home Z up first - jog until it sees the limit
    
        Jog(0,100);             // jog slowly positive
        while (!ReadBit(137)) ;  // loop until IO bit goes high
        Jog(0,0);				// stop
        while (!CheckDone(0)) ; // loop until motion completes 
    	DisableAxis(0);			// disable the axis
        Zero(0);				// Zero the position
    	EnableAxis(0);			// re-enable the ServoTick
    	Move(0,-1000.0);		// move some amount inside the limits
        while (!CheckDone(0)) ; // loop until motion completes 
    	ch2->LimitSwitchOptions = SaveZLimits;  // restore limit settings
    
    
    	// Home X next - jog until it sees the limit
    
        Jog(2,-100);  			// jog slowly negative
        while (!ReadBit(139)) ;  // loop until IO bit goes high
        Jog(2,0);				// stop
        while (!CheckDone(2)) ; // loop until motion completes 
    	DisableAxis(2);			// disable the axis
        Zero(2);				// Zero the position
    	EnableAxis(2);			// re-enable the ServoTick
    	Move(0,1000.0);			// move some amount inside the limits
        while (!CheckDone(2)) ; // loop until motion completes 
    	ch0->LimitSwitchOptions = SaveXLimits;  // restore limit settings
    
    
    	// Home Y next - jog until it sees the limit
    
        Jog(1,-100);  			// jog slowly negative
        while (!ReadBit(141)) ;  	// loop until IO bit goes high
        Jog(1,0);				// stop
        while (!CheckDone(1)) ; // loop until motion completes 
    	DisableAxis(1);			// disable the axis
        Zero(1);				// Zero the position
    	EnableAxis(1);			// re-enable the ServoTick
    	Move(1,1000.0);			// move some amount inside the limits
        while (!CheckDone(1)) ; // loop until motion completes 
    	ch1->LimitSwitchOptions = SaveYLimits;  // restore limit settings
    
    	DefineCoordSystem(2,1,0,-1);  //Define XYZ coordinated motion axes
    }




  20. #200
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: starting my C program, any guidance would be appreciated.

    Hi,

    If you want the system to home when you push a button then assign the program to a button.

    Regards
    TK http://dynomotion.com


Page 10 of 11 FirstFirst ... 7891011 LastLast

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
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

starting my C program, any guidance would be appreciated.

starting my C program, any guidance would be appreciated.