585,931 active members*
3,627 visitors online*
Register for free
Login
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    537

    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: https://www.youtube.com/watch?v=vupmJflbAIE

    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

  2. #2
    Join Date
    Aug 2009
    Posts
    1573

    Re: M code to "unwind" 4th axis

    G28A0 maybe

  3. #3
    Join Date
    May 2006
    Posts
    4045

    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);
    }
    TK
    http://dynomotion.com

  4. #4
    Join Date
    May 2012
    Posts
    537

    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.

Similar Threads

  1. Need help working out feed rate for "C" Axis and "Z" axis simultaneously.
    By Jonaldhinio in forum Australia, New Zealand Club House
    Replies: 0
    Last Post: 08-12-2014, 09:27 AM
  2. Replies: 1
    Last Post: 07-16-2014, 04:13 PM
  3. Replies: 17
    Last Post: 02-22-2014, 06:58 PM
  4. X Axis "Goes Off Pattern", "Awry", "Skewed", "Travels"
    By DaDaDaddio in forum Laser Engraving / Cutting Machine General Topics
    Replies: 1
    Last Post: 05-06-2013, 09:59 AM

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
  •