Page 1 of 4

make the machine semi-auto.

Posted: Wed Jul 14, 2021 7:34 am
by irmad
For a while now my press brake machine has been running on auto, but there are drawbacks, when using G CODE.

when the ram moves down, and we want to return to the previous position, we can't make the ram go up or back to the previous position. have to continue to finish the sequence on the G CODE sheet.. what should I do. and how to make the c program.

Re: make the machine semi-auto.

Posted: Wed Jul 14, 2021 8:09 am
by irmad
this is the c program file that has been created.

Re: make the machine semi-auto.

Posted: Wed Jul 14, 2021 8:10 am
by irmad

Code: Select all

#include "KMotionDef.h"	

#define CYCLESTARTBIT 138
#define ESTOP 138

// function prototypes for compiler
int DoPC(int cmd);
int DoPCFloat(int cmd, float f);

void main()
{

	ch0->InputMode=ENCODER_MODE;
	ch0->OutputMode=DAC_SERVO_MODE;
	ch0->Vel=50000;
	ch0->Accel=500000;
	ch0->Jerk=5000000;
	ch0->P=5;
	ch0->I=0.1;
	ch0->D=0.1;
	ch0->FFAccel=0;
	ch0->FFVel=0;
	ch0->MaxI=0;
	ch0->MaxErr=1000000;
	ch0->MaxOutput=1024;
	ch0->DeadBandGain=1;
	ch0->DeadBandRange=0;
	ch0->InputChan0=0;
	ch0->InputChan1=0;
	ch0->OutputChan0=0;
	ch0->OutputChan1=0;
	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=100000;
	ch0->StepperAmplitude=0;

	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=1;
	ch0->iir[2].B1=0;
	ch0->iir[2].B2=0;
	ch0->iir[2].A1=0;
	ch0->iir[2].A2=0;



	ch1->InputMode=ENCODER_MODE;
	ch1->OutputMode=DAC_SERVO_MODE;
	ch1->Vel=50000;
	ch1->Accel=500000;
	ch1->Jerk=5000000;
	ch1->P=10;
	ch1->I=0.1;
	ch1->D=0.1;
	ch1->FFAccel=0;
	ch1->FFVel=0;
	ch1->MaxI=0;
	ch1->MaxErr=1000000;
	ch1->MaxOutput=1024;
	ch1->DeadBandGain=1;
	ch1->DeadBandRange=0;
	ch1->InputChan0=1;
	ch1->InputChan1=0;
	ch1->OutputChan0=1;
	ch1->OutputChan1=0;
	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=100000;
	ch1->StepperAmplitude=0;

	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=1;
	ch1->iir[2].B1=0;
	ch1->iir[2].B2=0;
	ch1->iir[2].A1=0;
	ch1->iir[2].A2=0;
	

	
	EnableAxis(0);
	EnableAxis(1);
	
	DefineCoordSystem(-1,-1,1,-1);
	
	DAC(3,-1600);
	
	
	
	int result;

	for (;;) // loop forever
	{
		WaitNextTimeSlice();

		// Handle Cycle Start 138-1
		result = ReadBit(CYCLESTARTBIT);
		if  (result == 1)
		{
			DoPC(PC_COMM_EXECUTE);
		}
		

		// Handle ESTOP
		result = !ReadBit(ESTOP);
		if  (result == 1)
		{
			DoPC(PC_COMM_ESTOP);
		}
		
		while(!CheckDone(1));
	}

	
}

// Put a Float as a parameter and pass the command to the App
int DoPCFloat(int cmd, float f)
{
	int result;
	persist.UserData[PC_COMM_PERSIST+1] = *(int*)&f;
	return DoPC(cmd);
}


// Pass a command to the PC and wait for it to handshake
// that it was received by either clearing the command
// or changing it to a negative error code
int DoPC(int cmd)
{
	int result;
	
	persist.UserData[PC_COMM_PERSIST]=cmd;
	
	do
	{
		WaitNextTimeSlice();	
	}while (result=persist.UserData[PC_COMM_PERSIST]>0);
	
	printf("Result = %d\n",result);

	return result;
}





Re: make the machine semi-auto.

Posted: Wed Jul 14, 2021 8:25 am
by irmad
ini file g code urutan

Re: make the machine semi-auto.

Posted: Wed Jul 14, 2021 8:38 am
by irmad
M6 = 3 volt
M102 = activate relay down
M103 = activate relay slow
M110 = deactivate relay up
M107 = activate relay crown
M7 = 7 volt
M116 = deactivate relay crown
M111 = deactivate relay down
M112 = deactivate relay slow
M101 = activate relay up

Re: make the machine semi-auto.

Posted: Wed Jul 14, 2021 3:35 pm
by TomKerekes
Hi irmad,

I don't fully understand the issue, But if you are part way through a GCode program you may push Halt to stop it.

You might then configure a User Button to raise the press. To move the Z axis to a fixed position from a C Program you could code

Move(1, XXXX);

where XXXX is the position to move to in encoder counts.

HTH

Re: make the machine semi-auto.

Posted: Thu Jul 15, 2021 5:02 am
by irmad
how to make the jog panel in kmotion CNC work?
please help to provide an example script?

Re: make the machine semi-auto.

Posted: Sat Jul 17, 2021 12:56 am
by TomKerekes
The Z Jog button should work. But you will probably need to set your relays properly for how you are Jogging.

Re: make the machine semi-auto.

Posted: Tue Jul 27, 2021 3:25 am
by irmad
the relay settings are correct, sir.

so,

how to display encoder position for x and y in KmotionCNC panel? and how to edit it or add it in the Kmotion CNC panel?

because, currently only the Z coordinates are displayed.

Re: make the machine semi-auto.

Posted: Tue Jul 27, 2021 3:20 pm
by TomKerekes
Hi irmad,
how to display encoder position for x and y in KmotionCNC panel? and how to edit it or add it in the Kmotion CNC panel?

because, currently only the Z coordinates are displayed.
The photo you posted has the XY axes on the screen. But they are yellow. I don't see any configuration for any XY axes in your Initialization C Program. You will need to Configure the XY Axes, enable the axes, and add them to the Coordinate Motion System with the DefineCoordSystem() function.