#include "KMotionDef.h"
#include "SimpleHomeIndexFunction.c" 

main()
{
	
	
	int result;


	// HOME Z
	result = SimpleHomeIndexFunction(2,  // axis number to home
			   220000,  // speed to move toward home
			   1,      // direction to move toward home (+1 or -1)
			   1042, 	// limit bit number to watch for
			   1,		// limit polarity to wait for (1 or 0)
               5000,	// speed to move while searching for index
			   39,		// index bit number to watch for (use -1 for none)
			   1, 		// index polarity to wait for (1 or 0)
			   -1100000.0,	// amount to move inside limits
			   -330000.0);	// new home position
			   
	if (result==0)
	{
		printf("ZERO Osi Z wykonano\n");
	}
	else
	{
		printf("ZERO Osi Z niepowodzenie\n");
		return;
	}
	
	
	// HOME X

	result = SimpleHomeIndexFunction(0,  // axis number to home
			   220000,  // speed to move toward home
			   +1,      // direction to move toward home (+1 or -1)
			   1040, 	// limit bit number to watch for
			   1,		// limit polarity to wait for (1 or 0)
               5000.0,	// speed to move while searching for index
			   37,		// index bit number to watch for (use -1 for none)
			   1, 		// index polarity to wait for (1 or 0)
			   4000000.0,	// amount to move inside limits
			   7930000.0);	// new home position
			   
			  
	if (result==0)
	{
		printf("Wyzerowano Os X\n");
	}
	else
	{
		printf("Os X Niewyzerowana !\n");
		return;
	}
	
	// HOME Y
	
	result = SimpleHomeIndexFunction(1,  // axis number to home
			   220000.0,  // speed to move toward home
			   +1,      // direction to move toward home (+1 or -1)
			   1041, 	// limit bit number to watch for
			   1,		// limit polarity to wait for (1 or 0)
               5000.0,	// speed to move while searching for index
			   36,		// index bit number to watch for  (use -1 for none)
			   1, 		// index polarity to wait for (1 or 0)
			   2500000.0,	// amount to move inside limits
			   4750000.0);	// new home position
			   
	if (result==0)
	{
		printf("Wyzerowano Os Y\n");
		
	}
	else
	{
		printf("Os Y Niewyzerowana !\n");
		return;
		
		
	}
	
	
}

