Does anyone have a working C program for homeing


Results 1 to 8 of 8

Thread: Does anyone have a working C program for homeing

  1. #1
    Member
    Join Date
    Apr 2013
    Location
    usa
    Posts
    20
    Downloads
    0
    Uploads
    0

    Question Does anyone have a working C program for homeing

    I tried multiple ways to home but with no luck. One of the codes that did work was very very slow when homing.

    Please post a code where I can learn how to get it to work.

    I have limit switches on both ends of the axis which I would like to use as home switch.

    Also please help me point out how to adjust the speed.

    Similar Threads:


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Does anyone have a working C program for homeing

    Hi mack7988,

    See the example SimpleHomeIndexFunctionTest.c

    Code:
    #include "KMotionDef.h"
    #include "SimpleHomeIndexFunction.c" 
    
    main()
    {
        int result;
    
    
        // HOME Z
    
        result = SimpleHomeIndexFunction(2,  // axis number to home
            1000.0,  // speed to move toward home
            -1,      // direction to move toward home (+1 or -1)
            138,     // limit bit number to watch for
            0,	 // limit polarity to wait for (1 or 0)
            100.0,   // speed to move while searching for index
            -1,      // index bit number to watch for (use -1 for none)
            1, 	 // index polarity to wait for (1 or 0)
            5000);   // amount to move inside limits
    
        if (result==0)
        {
            printf("Home Z succeded\n");
        }
        else
        {
            printf("Home Z failed\n");
            return;
        }
    
        // HOME X
    
        result = SimpleHomeIndexFunction(0,  // axis number to home
            1000.0,  // speed to move toward home
            -1,      // direction to move toward home (+1 or -1)
            136,     // limit bit number to watch for
            0,	 // limit polarity to wait for (1 or 0)
            100.0,	 // speed to move while searching for index
            -1,	 // index bit number to watch for (use -1 for none)
            1, 	 // index polarity to wait for (1 or 0)
            5000);	 // amount to move inside limits
    
        if (result==0)
        {
            printf("Home X succeded\n");
        }
        else
        {
            printf("Home X failed\n");
            return;
        }
    
        // HOME Y
    
        result = SimpleHomeIndexFunction(1,  // axis number to home
            1000.0,  // speed to move toward home
            -1,      // direction to move toward home (+1 or -1)
            137, 	 // limit bit number to watch for
            0,	 // limit polarity to wait for (1 or 0)
            100.0,	 // speed to move while searching for index
            -1,	 // index bit number to watch for  (use -1 for none)
            1, 	 // index polarity to wait for (1 or 0)
            5000);	 // amount to move inside limits
    
        if (result==0)
        {
            printf("Home Y succeded\n");
        }
        else
        {
            printf("Home Y failed\n");
            return;
        }
    }
    Explain which parts you can understand.

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  3. #3
    Member
    Join Date
    Apr 2013
    Location
    usa
    Posts
    20
    Downloads
    0
    Uploads
    0

    Default Re: Does anyone have a working C program for homeing

    Hello Tom,

    Thank you for the reply.

    What I don't understand is where in homemach3.c


    #include "KMotionDef.h"

    //Plugin calls for Mach3 Home (actually Purge) Commands

    main()
    {
    int flags = persist.UserData[5]; // Mach3 flags bit0=X, bit1=Y, Bit2=Z, etc...

    printf("Mach3 Home Call, flags = %d\n",flags);

    if (flags==1)
    {
    // do x homing here
    }

    if (flags==2)
    {
    // do y homing here
    }

    if (flags==4)
    {
    // do z homing here
    }


    printf("Done\n");
    }
    ************************************************** **********************
    Also where in the code does it save limit switch settings
    and when finished homing it re enables limit switches.



  4. #4
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Does anyone have a working C program for homeing

    Hi mack7988,

    Did you see my previous response? Please respond to it.

    HomeMach3.c is an empty shell of a program that does nothing except print messages that show Mach3 is configured properly to request an axis to home.

    Did you configure it? Do you get the messages on the Console Screen?

    Regards

    Regards
    TK http://dynomotion.com


  5. #5
    Member
    Join Date
    Apr 2013
    Location
    usa
    Posts
    20
    Downloads
    0
    Uploads
    0

    Default Re: Does anyone have a working C program for homeing

    Quote Originally Posted by TomKerekes View Post
    Hi mack7988,

    Did you see my previous response? Please respond to it.

    HomeMach3.c is an empty shell of a program that does nothing except print messages that show Mach3 is configured properly to request an axis to home.

    Did you configure it? Do you get the messages on the Console Screen?

    Regards
    I know its a empty shell but what is the proper way to put the simpleindexfunction into the code. I don't understand it well. I'm sorry for the confusion.



  6. #6
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Does anyone have a working C program for homeing

    Hi mack7988,

    Please put more effort into your responses.

    Were you able to change the parameters in SimpleHomeIndexFunctionTest.c and get it to work for your system by running it from the C Programs Screen in KMotion.exe ?

    Regards

    Regards
    TK http://dynomotion.com


  7. #7
    Member
    Join Date
    Apr 2013
    Location
    usa
    Posts
    20
    Downloads
    0
    Uploads
    0

    Default Re: Does anyone have a working C program for homeing

    Hi Tom,

    I did change the parameters in SimpleHomeInderFunctionTest.c but I didn't test it in Kmotion.exe because I don't know how to use it. This is what I know

    As you press REFALL in Mach3
    There is a flagcall 4 2 1
    which is handled by kflop to move each axis to the homing position.
    The question I have is...How do I put simplehomeindex.c into the same c code as Homemach3.c?



  8. #8
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Does anyone have a working C program for homeing

    Hi mack7988,

    To test your modified SimpleHomeIndexFunction.c push Save/Compile/Download/Run (button with all the arrows on it).

    Does it home all 3 of your axes properly?

    Regards

    Regards
    TK http://dynomotion.com


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Does anyone have a working C program for homeing

Does anyone have a working C program for homeing