Page 1 of 1

running cnc without g code

Posted: Sun Nov 01, 2020 1:16 pm
by irmad

Code: Select all

#include "KMotionDef.h"

void main()
{
	ch0->InputMode=ENCODER_MODE;
	ch0->OutputMode=NO_OUTPUT_MODE;
	ch0->Vel=5000;
	ch0->Accel=50000;
	ch0->Jerk=500000;
	ch0->P=12;
	ch0->I=0;
	ch0->D=0;
	ch0->FFAccel=0;
	ch0->FFVel=0;
	ch0->MaxI=200;
	ch0->MaxErr=1e+06;
	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=75000;
	ch0->StepperAmplitude=20;

	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=5000;
	ch1->Accel=50000;
	ch1->Jerk=500000;
	ch1->P=12;
	ch1->I=0;
	ch1->D=0;
	ch1->FFAccel=0;
	ch1->FFVel=0;
	ch1->MaxI=200;
	ch1->MaxErr=1e+06;
	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=75000;
	ch1->StepperAmplitude=20;

	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);
	Move(0,1000);
	DAC(0,1024); // voltage for Axis Y1 amplifier
	DAC(2,1000); // voltage for pressure amplifier
	while (!CheckDone(0));
	while (!CheckDone(1));
	
	if ( CheckDone(0))
	{
		DAC(2,0); // after reaching the destination, i want the DAC to be 0 volts.
	}
	
 
	
	
}

please advise if something is missing or wrong.
please correct the c program that I made, whether the above code can move together.

will the voltage of DAC 1 follow or equal to the voltage of DAC 0 ?

Re: running cnc without g code

Posted: Sun Nov 01, 2020 3:44 pm
by TomKerekes
Hi irmad,

You have axis 0 set to No Output

Code: Select all

ch0->OutputMode=NO_OUTPUT_MODE;
should be:

Code: Select all

	ch0->OutputMode=DAC_SERVO_MODE;


You have axis 1 slaved to itself

Code: Select all

	ch1->MasterAxis=1;
should be:

Code: Select all

	ch1->MasterAxis=0;


Don't write to a DAC which an axis is already continuously writing to.

Code: Select all

	DAC(0,1024); // voltage for Axis Y1 amplifier

The Servo will command whatever output (DAC) is necessary to try to follow axis 0. If the axes are identical, have the same friction, same load, same valves, etc then the DACs to each axis will be the same.




'if' statement is uneccesary. You already waited for the axis to be done.

Code: Select all

	if ( CheckDone(0))

Re: running cnc without g code

Posted: Sun Nov 01, 2020 4:29 pm
by irmad
how to move axes without having to write down positions or goals. like moving up or down.
because if I write MOVE it must include a goal. because manual mode does not require the target position.
TomKerekes wrote:
Sun Nov 01, 2020 3:44 pm


You have axis 1 slaved to itself

Code: Select all

	ch1->MasterAxis=1;
should be:

Code: Select all

	ch1->MasterAxis=0;
sorry, i mean ch1->MasterAxis=0;

Re: running cnc without g code

Posted: Sun Nov 01, 2020 6:31 pm
by TomKerekes
To move forever use

Code: Select all

Jog(axis, speed);