Tom,
I am trying to offset the Z axis on a plasma table to find the material. I am doing something wrong and need some assistance. I am using KMCNC version 4.33cc. My test G code looks like this.
Code:
G17 G20 G90
G00 X1.0 Y1.0
M100
G91 G00 Z.1
(Start Torch)
(Move X & Y)
(Stop Torch)
M101
This is the c program for the M100 and I am using Exec/Wait in the Tool Setup. The torch is spring loaded and hits a switch when it runs into the material.
Code:
#include "KMotionDef.h"
#define TS 19 //Tool Sensor Input
//Program to send Z axis down and find top of material
main()
{
Jog(2,-50000); //Down speed and direction
while(!ReadBit(TS));
Jog(2,0); //Stop at material
while(!CheckDone(2));
Jog(2,30000); //Reverse off of switch
while(ReadBit(TS));
Jog(2,0); //Stop off switch
while(!CheckDone(2));
MoveRelAtVel(2,900,5000); //Retract length to top of material
while(!CheckDone(2));
}
The problem is when the M100 completes the Z axis DRO goes to Zero on the machine coords. This is a problem when returning the Z to the "home" position. I wrote a c program to reference the Z (M101) but it holds the last value from when the M101 was executed. So if I end the cut at Z.1 the Z DRO shows a .1 when the M101 completes.
Here is the M101 c program.
Code:
#include "KMotionDef.h"
#include "Init_Burn Table.c"
main()
{
int SaveZLimits,ZSWN,ZSWP,LZ; //place to save limit switch settings
// disable the limits (first save how they were set)
SaveZLimits = ch2->LimitSwitchOptions;
ZSWN = ch2->SoftLimitNeg;
ZSWP = ch2->SoftLimitPos;
ch2->LimitSwitchOptions = 0;
ch2->SoftLimitNeg = -1000000;
ch2->SoftLimitPos = 1000000;
// Home Z
Jog(2,60000);
while(ReadBit(Limit_Z));
Jog(2,0);
while(!CheckDone(2)) ;
Jog(2,-15000);
while (!ReadBit(Limit_Z));
Jog(2,0);
while (!CheckDone(2)) ;
MoveRelAtVel(2,-3000,30000);
while (!CheckDone(2)) ;
Zero(2);
ch2->LimitSwitchOptions = SaveZLimits; // restore limit settings
ch2->SoftLimitNeg = ZSWN;
ch2->SoftLimitPos = ZSWP;
}
Thanks
Similar Threads: