Need Help! G43 G49 status Led and Toggle


Results 1 to 8 of 8

Thread: G43 G49 status Led and Toggle

  1. #1
    Member
    Join Date
    Mar 2013
    Location
    us
    Posts
    31
    Downloads
    0
    Uploads
    0

    Default G43 G49 status Led and Toggle

    Hello everyone I am trying to implement a button to turn tool length compensation on and off or at the least a Led to see the status.

    Only thing I can think of is to monitor the variables for tool length offset and current fixture offset

    Is there an easier solution
    I don't have the ability to recompile from visual studio.

    Similar Threads:


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

    Default Re: G43 G49 status Led and Toggle

    Hi dirtdigger257,

    I can't think of an easy way to do this without adding some new functionality.

    The Tool Length Index is -1 when Length Compensation is turned off.

    Here is a C Program that maintains a Virtual Bit (actually a KFLOP LED Bit 46) based on periodically requesting the Index

    Code:
    #include "KMotionDef.h"
    
    #define TMP 10                    // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    void ServiceToolOffsetMode(void);
    
    main()
    {
        for (;;)                    // forever loop
        {
            ServiceToolOffsetMode();
        }
    }
    
    #define STATUSBIT 46
    
    // periodically set Virtual Bit based on Tool Table Index
    void ServiceToolOffsetMode(void)
    {
        static double LastTime = 0;
        int Units, TWORD, HWORD, DWORD;
    
        if (Time_sec() < LastTime + 0.3)
            return;
    
        LastTime = Time_sec();
        GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);
        SetStateBit(STATUSBIT, HWORD != -1);
    }



    Attached Program and Screen Script

    Attached Files Attached Files
    Regards
    TK http://dynomotion.com


  3. #3
    Member
    Join Date
    Mar 2013
    Location
    us
    Posts
    31
    Downloads
    0
    Uploads
    0

    Default

    Thanks works great

    Is it ok to have two for loops running in separate threads
    one in my init the for the MPG
    the other for servicing KmotioCNC jog rate and tool offset?

    If not it take to long to run threw the init for loop and cause problems jogging.



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

    Default Re: G43 G49 status Led and Toggle

    Hi dirtdigger257,

    You could use 2 Threads but each extra Thread increases the time between Time Slices so it is better to use less Threads where possible.

    Please try the code below (and attached) that is written in a non-blocking manner so your MPG should always be serviced using a single loop.


    Code:
    #include "KMotionDef.h"
    
    #define TMP 10                    // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    void ServiceToolOffsetMode(void);
    
    main()
    {
        for (;;)                    // forever loop
        {
            ServiceToolOffsetMode();
        }
    }
    
    #define STATUSBIT 46
    
    // periodically set Virtual Bit based on Tool Table Index
    // keeps track of state of sequence to always return immediately
    void ServiceToolOffsetMode(void)
    {
        static BOOL WaitingForResponse = FALSE;
        static double LastTime = 0;
        int HWORD;
    
        if (WaitingForResponse)        // Waiting for a response from the PC?
        {
            if (persist.UserData[PC_COMM_PERSIST] <= 0)    // Has PC Responded??
            {
                HWORD = persist.UserData[TMP + 2];    // Get Tool H Word
    
                SetStateBit(STATUSBIT, HWORD != -1);    // -1 indicates no active offset 
                LastTime = Time_sec();
                WaitingForResponse = FALSE;
            }
        }
        else
        {
            if (Time_sec() > LastTime + 0.3)    // only request periodically
            {
                DoPCIntNoWait(PC_COMM_GET_MISC_SETTINGS, TMP);    // Request settings from PC
                WaitingForResponse = TRUE;    // Remember we are waiting for a response
            }
        }
    }


    Attached Files Attached Files
    Regards
    TK http://dynomotion.com


  5. #5
    Member amitkumar171's Avatar
    Join Date
    Aug 2017
    Location
    India
    Posts
    109
    Downloads
    0
    Uploads
    0

    Default Re: G43 G49 status Led and Toggle

    Quote Originally Posted by TomKerekes View Post
    Hi dirtdigger257,

    You could use 2 Threads but each extra Thread increases the time between Time Slices so it is better to use less Threads where possible.

    Please try the code below (and attached) that is written in a non-blocking manner so your MPG should always be serviced using a single loop.


    Code:
    #include "KMotionDef.h"
    
    #define TMP 10                    // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    void ServiceToolOffsetMode(void);
    
    main()
    {
        for (;;)                    // forever loop
        {
            ServiceToolOffsetMode();
        }
    }
    
    #define STATUSBIT 46
    
    // periodically set Virtual Bit based on Tool Table Index
    // keeps track of state of sequence to always return immediately
    void ServiceToolOffsetMode(void)
    {
        static BOOL WaitingForResponse = FALSE;
        static double LastTime = 0;
        int HWORD;
    
        if (WaitingForResponse)        // Waiting for a response from the PC?
        {
            if (persist.UserData[PC_COMM_PERSIST] <= 0)    // Has PC Responded??
            {
                HWORD = persist.UserData[TMP + 2];    // Get Tool H Word
    
                SetStateBit(STATUSBIT, HWORD != -1);    // -1 indicates no active offset 
                LastTime = Time_sec();
                WaitingForResponse = FALSE;
            }
        }
        else
        {
            if (Time_sec() > LastTime + 0.3)    // only request periodically
            {
                DoPCIntNoWait(PC_COMM_GET_MISC_SETTINGS, TMP);    // Request settings from PC
                WaitingForResponse = TRUE;    // Remember we are waiting for a response
            }
        }
    }
    Hi tom,

    Thanks for your reply, i am having some problem while running the above c program,

    The issue is When i am starting KmotionCNC.exe first time then it runs fine.

    But when i am giving G49 and closing KmotionCNC.exe

    After running the KmotionCNC.exe again i am getting LED On state but , i turned it off while closing KmotionCNC.exe

    I want this whole state off or on untill unless i give G43 H1001 or G43.4 H1001 or G49.

    Closing KmotionCNC should not reset it.

    Regards

    Amit Kumar


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

    Default Re: G43 G49 status Led and Toggle

    Hi Amit,

    The LED is displaying the true state of the Interpreter.

    If the Tool Setup Options: Tool Length/Offset Immediately and M6 on Tool Table Changes

    G43 G49 status Led and Toggle-toollengthimmediately-png

    are selected, then when KMotionCNC starts up the Tool Compensation is enabled and set to match the selected tool displayed on the screen:

    G43 G49 status Led and Toggle-selectedtool-png




    If those options are not selected then the Settings File parameter slot_for_length_offset

    G43 G49 status Led and Toggle-setupfile-png

    can be used to initialize which Tool is in use or -1 for not applied.




    If no setting is included the Interpreter length offset is initialized to -1 for none.




    I want this whole state off or on untill unless i give G43 H1001 or G43.4 H1001 or G49.
    Disable the Options and set the Settings file parameter slot_for_length_offset to -1 to initialize the Interpreter with no Length Compensation in effect.

    Regards
    TK http://dynomotion.com


  7. #7
    Member amitkumar171's Avatar
    Join Date
    Aug 2017
    Location
    India
    Posts
    109
    Downloads
    0
    Uploads
    0

    Default Re: G43 G49 status Led and Toggle

    Quote Originally Posted by TomKerekes View Post
    Hi Amit,

    The LED is displaying the true state of the Interpreter.

    If the Tool Setup Options: Tool Length/Offset Immediately and M6 on Tool Table Changes

    G43 G49 status Led and Toggle-toollengthimmediately-png

    are selected, then when KMotionCNC starts up the Tool Compensation is enabled and set to match the selected tool displayed on the screen:

    G43 G49 status Led and Toggle-selectedtool-png




    If those options are not selected then the Settings File parameter slot_for_length_offset

    G43 G49 status Led and Toggle-setupfile-png

    can be used to initialize which Tool is in use or -1 for not applied.




    If no setting is included the Interpreter length offset is initialized to -1 for none.




    Disable the Options and set the Settings file parameter slot_for_length_offset to -1 to initialize the Interpreter with no Length Compensation in effect.
    Hi tom,

    Thanks for your reply,

    I tried the above method for the tool offset led toggle, i am facing one problem that,

    When i am turning power on the kflop board its remembering its last state wheather it was turned on or off last time.

    But i don't want to remember that, i just want after every power recycle G43 G49, LED should be initially off.and i have to manually turn it ON on every power off and on Sequence.

    Waiting for your kind reply.

    Regards

    Amit Kumar


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

    Default Re: G43 G49 status Led and Toggle

    Hi Amit,

    Please be more specific what you are doing.

    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

G43 G49 status Led and Toggle

G43 G49 status Led and Toggle

G43 G49 status Led and Toggle