Can't zero axis Kflop+Kanalog
Posted: Mon Feb 26, 2018 10:59 am
Hello everyone! Can't zero axes on Kflop+Kanalog board. I use virtual bits 36 and 37 of Kanalog Board JP2 terminals to zero axes by encoders' zero marks, but it doesn't work. SetDirectionBit(36,0) and SetDirectionBit(37,0) are announced. I've tried to use virtual bits 6 and 7 of JP1 terminal to zero axis and it worked, but I need them for another device. Kmotion version is 4.34j. Please help
#include "KMotionDef.h"
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
main()
{
SetBitDirection(36,0); // Х
SetBitDirection(37,0); // Y
//for X
Jog(0,-2500);
while (ReadBit(140)) ;
Zero(0);
Jog(0,0);
Jog(0,1000);
while (!ReadBit(36)) ;
Zero(0);
Jog(0,0);
//for Y
Jog(1,15000);
while (!ReadBit(141)) ;
Zero(1);
Jog(1,0);
Jog(1,-1000);
while (!ReadBit(37)) ;
Zero(1);
Jog(1,0);
MDI("G92.1"); // clean offsets
}
// 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;
}
#include "KMotionDef.h"
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
main()
{
SetBitDirection(36,0); // Х
SetBitDirection(37,0); // Y
//for X
Jog(0,-2500);
while (ReadBit(140)) ;
Zero(0);
Jog(0,0);
Jog(0,1000);
while (!ReadBit(36)) ;
Zero(0);
Jog(0,0);
//for Y
Jog(1,15000);
while (!ReadBit(141)) ;
Zero(1);
Jog(1,0);
Jog(1,-1000);
while (!ReadBit(37)) ;
Zero(1);
Jog(1,0);
MDI("G92.1"); // clean offsets
}
// 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;
}