M code to "unwind" 4th axis


Results 1 to 4 of 4

Thread: M code to "unwind" 4th axis

  1. #1
    Member
    Join Date
    May 2012
    Location
    canada
    Posts
    388
    Downloads
    0
    Uploads
    0

    Default M code to "unwind" 4th axis

    Hi Tom,

    I need to make an M code to "unwind" my 4th axis. Im running a 4 axis surface here today and ending up at like 80,000 degrees when its done. Need something to take current A machine position, divide it by 360 degrees and reset position at closest multiple of turns to zero. Same as this:

    Im really busy with work at the moment and a little out of practice with c programming, wondering if you might be able to help me with this. Should be fairly simple.Thanks.

    Mark

    Similar Threads:


  2. #2
    Member machinehop5's Avatar
    Join Date
    Aug 2009
    Location
    United States
    Posts
    162
    Downloads
    0
    Uploads
    0

    Default Re: M code to "unwind" 4th axis

    G28A0 maybe



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

    Default Re: M code to "unwind" 4th axis

    Hi Mark,

    See the Modulo360.c example:

    If your system has encoders the encoder would need to be adjusted also:

    Code:
    #include "KMotionDef.h"
    
    #define CNTS_PER_DEG 1000.0
    #define AXISA 4
    
    double modf(double, double *);    // returns integer part with more than 32-bit precision
    
    double floor(double x)            // truncate down toward -infinity
    {
        double y;
        return (modf(x, &y) < 0 ? y - 1 : y);
    }
    
    main()
    {
        double dest = chan[AXISA].Dest;
        double cnts = CNTS_PER_DEG * 360.0;
        double delta = (floor(dest / cnts)) * cnts;
        WaitNextTimeSlice();        // Avoid interrupts
        DisableAxis(AXISA);
        chan[AXISA].Position -= delta;
        EnableAxisDest(AXISA, dest - delta);
    }


    Regards
    TK http://dynomotion.com


  4. #4
    Member
    Join Date
    May 2012
    Location
    canada
    Posts
    388
    Downloads
    0
    Uploads
    0

    Default Re: M code to "unwind" 4th axis

    Awesome, that looks easy enough. Ill give it a try on the next 4th axis job. Thanks again.



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

M code to &quot;unwind&quot; 4th axis

M code to &quot;unwind&quot; 4th axis