is there a code that would enter something like "G00x0.0Y0.0" into the MDi bar?
maybe?
Code: Select all
#include "KMotionDef.h"
main()
{
Move0=0.0;
Move1=0.0;
}
Moderators: TomKerekes, dynomotion
Code: Select all
#include "KMotionDef.h"
main()
{
Move0=0.0;
Move1=0.0;
}
Code: Select all
#include "KMotionDef.h"
main()
{
Move(0, 0.0);
Move(1, 0.0);
}
Code: Select all
#include "KMotionDef.h"
main()
{
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=DAC_SERVO_MODE;
ch0->Vel=130000;
ch0->Accel=1.5e+006;
ch0->Jerk=3e+007;
ch0->P=4;
ch0->I=0.0;
ch0->D=550;
ch0->FFAccel=0;
ch0->FFVel=0;
ch0->MaxI=100;
ch0->MaxErr=2000;
ch0->MaxOutput=2000;
ch0->DeadBandGain=1;
ch0->DeadBandRange=0;
ch0->InputChan0=0;
ch0->InputChan1=0;
ch0->OutputChan0=7;
ch0->OutputChan1=0;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x0;
ch0->SoftLimitPos=1e+009;
ch0->SoftLimitNeg=-1e+009;
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=8000;
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=0.000769;
ch0->iir[2].B1=0.001538;
ch0->iir[2].B2=0.000769;
ch0->iir[2].A1=1.92081;
ch0->iir[2].A2=-0.923885;
EnableAxis(0);
ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=DAC_SERVO_MODE;
ch1->Vel=120000;
ch1->Accel=2e+006;
ch1->Jerk=3e+007;
ch1->P=7;
ch1->I=0.0;
ch1->D=1000;
ch1->FFAccel=0;
ch1->FFVel=0;
ch1->MaxI=100;
ch1->MaxErr=2000;
ch1->MaxOutput=2000;
ch1->DeadBandGain=1;
ch1->DeadBandRange=0;
ch1->InputChan0=1;
ch1->InputChan1=0;
ch1->OutputChan0=6;
ch1->OutputChan1=0;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x0;
ch1->SoftLimitPos=1e+009;
ch1->SoftLimitNeg=-1e+009;
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=8000;
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=0.000769;
ch1->iir[2].B1=0.001538;
ch1->iir[2].B2=0.000769;
ch1->iir[2].A1=1.92081;
ch1->iir[2].A2=-0.923885;
EnableAxis(1);
ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=DAC_SERVO_MODE;
ch2->Vel=120000;
ch2->Accel=1.8e+006;
ch2->Jerk=3e+007;
ch2->P=3;
ch2->I=0.001;
ch2->D=120;
ch2->FFAccel=0;
ch2->FFVel=0;
ch2->MaxI=100;
ch2->MaxErr=2000;
ch2->MaxOutput=2000;
ch2->DeadBandGain=1;
ch2->DeadBandRange=0;
ch2->InputChan0=2;
ch2->InputChan1=0;
ch2->OutputChan0=5;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x0;
ch2->SoftLimitPos=1e+009;
ch2->SoftLimitNeg=-1e+009;
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=8000;
ch2->StepperAmplitude=20;
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.000769;
ch2->iir[2].B1=0.001538;
ch2->iir[2].B2=0.000769;
ch2->iir[2].A1=1.92081;
ch2->iir[2].A2=-0.923885;
EnableAxis(2);
DefineCoordSystem(0,1,2,-1);
}
Code: Select all
// This is the header file for Matt specific Programs
// Matt.h Rev A JEY July 31, 2013
//MattRevB.h Rev B JEY October 10, 2013
#define HALTBIT 27
#define RESTARTBIT 28
#define ZEROALLBIT 29
#define KFLOP_LED46 46
#define ESTOP 136
#define CYCLESTARTBIT 137
#define FLOOD_CTL_BIT 138
#define FEEDHOLD_BIT 140
#define CW_BIT 144
#define CCW_BIT 145
#define FLOOD_BIT 153
// These are user.data bytes to identify which button pushed (and which routine to xeq)
// "LOC" identifies the LOCation in persist.User.Data
#define M5STOP_LOC 80
#define INIT_LOC 81
#define ENABLE_LOC 82
#define ZERO_LOC 83
#define SPEED500_LOC 84
#define FLOOD_LOC 85
#define FEEDHOLD_LOC 86
#define WATCHDOG 89
// SPINDLE_FACTOR converts RPM to voltage, SPINDLE_DAC is which DAC is in use
#define SPINDLE_FACTOR (-0.5386)
#define SPINDLE_DAC 0
Code: Select all
// Program to handle all the one shot KMotion functions
// oneshot.c Rev A JEY July 31, 2013
// Rev B JEY October 10, 2013
#include "KMotionDef.h"
#include "C:\Users\SHIZ\Desktop\mattheader.c"
int main()
{
//debug();
//test for each button or Mcode...call routine for found condition
if ( persist.UserData[M5STOP_LOC] ) M5stop();
if ( persist.UserData[FEEDHOLD_LOC] ) Feedhold();
if ( persist.UserData[FLOOD_LOC] ) Flood();
if ( persist.UserData[SPEED500_LOC] ) Speed500();
if ( persist.UserData[ZERO_LOC] ) ZeroMatt();
return 0;
}
/*----------------------------------------------------------------------------*/
// debug - prints UserData to console
debug()
{
int x;
for (x=80;x<=90;x++) {
printf("n%i=%i\n",x,persist.UserData[x]);
}
return 0;
}
/*----------------------------------------------------------------------------*/
// M5 command -> clear spindle direction and set speed to Zero
M5stop()
{
persist.UserData[M5STOP_LOC]=0; // Clear Switch
ClearBit(CCW_BIT);
ClearBit(CW_BIT);
DAC(SPINDLE_DAC,0);
}
/*----------------------------------------------------------------------------*/
// Handle FeedHold/Resume
Feedhold()
{
persist.UserData[FEEDHOLD_LOC]=0; // Clear Switch
if (CS0_StoppingState == 0){
StopCoordinatedMotion();}
else {
ResumeCoordinatedMotion();}
}
/*----------------------------------------------------------------------------*/
// Program to toggle bit that controls flood relay
Flood()
{
int x;
persist.UserData[FLOOD_LOC]=0; // Clear Switch
if (ReadBit(FLOOD_BIT)) // Check setting of flood bit
ClearBit(FLOOD_BIT); // Turn off if it was on
else
SetBit(FLOOD_BIT); // Turn on if it was off
printf("Flood toggled in oneshot\n");
for (x=1;x<2500;x++) { // Debounce by 500 breaks
WaitNextTimeSlice(); // Wait
persist.UserData[FLOOD_LOC]=0; // Clear Switch
}
}
/*----------------------------------------------------------------------------*/
// Program to set CW direction and spindle speed to 500 RPM
Speed500()
{
int x;
persist.UserData[SPEED500_LOC]=0; // Clear Switch
SetBit(CW_BIT); // Clockwise bit set
x=500*SPINDLE_FACTOR; // Compute DAC setting
DAC(SPINDLE_DAC,x); // Set spindel speed
}
/*----------------------------------------------------------------------------*/
// Zero the three axes by using a G-Code command
int DoPC(int cmd);
int DoPCInt(int cmd, int i);
#define GATH_OFF 0 // define the offset into the Gather buffer where strings are passed
ZeroMatt()
{
persist.UserData[ZERO_LOC]=0; // Clear Switch
MDI("G00 X0 Y0"); // move to x=zero, y=zero
}
/*----------------------------------------------------------------------------*/
// put the MDI string (Manual Data Input - GCode) in the
// gather buffer and tell the App where it is
int MDI(char *s)
{
char *p=(char *)gather_buffer+GATH_OFF*sizeof(int);
int i;
do // copy to gather buffer w offset 0
{
*p++ = *s++;
}while (s[-1]);
// issue the command an wait till it is complete
// (or an error - such as busy)
return DoPCInt(PC_COMM_MDI,GATH_OFF);
}
/*----------------------------------------------------------------------------*/
// Put an integer as a parameter and pass the command to the App
int DoPCInt(int cmd, int i)
{
int result;
persist.UserData[PC_COMM_PERSIST+1] = i;
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);
return result;
}
Code: Select all
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
main()
{
MDI("G0 X0 Y0"); // move to zero
}