585,888 active members*
4,083 visitors online*
Register for free
Login
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2013
    Posts
    45

    Z tracking possible?

    I am to the next phase of the plasma table which is getting the Z axis to track the material. This is being done with a PLC. I am reading the analog output from the plasma cutter into the PLC, the desired tip offset is controlled with a pot that is connected to another analog input on the PLC. The direction the Z axis needs to move is controlled by digital outputs on the PLC that are connected to KFLOP inputs. If the analog signal from the plasma cutter is higher than the pot the PLC output comes on and the Z axis will (hopefully) go down and vice versa.

    The problem I have encountered is that I need the Z to move independently of the X and Y axis while following the G code path.

    Here is the code and some explanation of my intent.

    Code:
    G17 G20 G90 
    G00 X1. Y1.           'Position the torch above the material
    M100                    'Custom c program to send the Z axis down until a switch is hit to find the top of the material
    G91 G00 Z.1         ' Sets the pierce height for the plasma torch incrementally
    M3                       ' Turns on the plasma torch
    G4 P.75               'Wait to stabilize
    M7                       'Enable the PLC's outputs for Z axis tracking
    G90 G1 X? Y?       'Cut the material
    The digital outputs from the PLC are connected to inputs 20 & 21 to raise and lower the Z axis. I tried to use the Jog function in the loop at the end of my initialization file like this

    Code:
    #define Raise_Torch 20
    #define Lower_Torch 21
    
    for(;;)
    {	
         //Raise Torch
         if ((ReadBit(Raise_Torch)) && (JOB_ACTIVE == 1))
        {
          Jog(2,Torch_Speed);
        }
            
        //Lower Torch
        if ((ReadBit(Lower_Torch)) && (JOB_ACTIVE == 1))
        {
          Jog(2,-Torch_Speed);
        }
        
        //Stop Torch
        if ((!ReadBit(Raise_Torch)) && (!Readbit(Lower_Torch)) && (JOB_ACTIVE == 1))
        {
          Jog(2,0);
        }	
    }
    When I run the G code the Z axis will execute the M100 properly but once the M7 is active and the XY moves start it does not track at all move unless I press the pause button in KMCNC. I believe the problem is with the buffering of commands...Is there a way around this?

    Thanks.

  2. #2
    Join Date
    May 2006
    Posts
    4045

    Re: Z tracking possible?

    Hi Epiphany,

    Z Tracking is certainly possible. A better approach might have been to input the Analog Height signal into KFLOP so it could drive the Z Speed as a function of the error rather than just of/off up/down. But this approach should also work.

    When moving Z independently in Height Tracking mode Z should be removed from the Coordinated Motion System with the DefineCoordSystem() function.

    Another issue is that Jog commands should not be commanded continuously at a high rate. It is better to just command the Jog Speed once (and have the blended trajectory computed) until something changes.

    Below is simple loop that may work for you in a way that the Z Tracking mode can be turned on and off by activating a Virtual Bit. This loop can be added to your Initialization code (and merged with any other service activities) so no extra Threads in KFLOP are required. It is also attached as a .txt file.

    Code:
    #include "KMotionDef.h"
    
    // When Z Tracking Bit is set control Z Height based on two input bits
    
    main()
    {
        #define Raise_Torch 20
        #define Lower_Torch 21
    
        #define Torch_Speed 1000.0 // speed to move torch - counts/sec
    
        #define Z_TRACKING_MODE_BIT 1024 // set to begin Z height tracking  
    
        #define JoggingNone 0
        #define JoggingUp 1
        #define JoggingDown 2
    
        int JogState=JoggingNone;
    
        for(;;)
        {
            WaitNextTimeSlice();
    
            if (ReadBit(Z_TRACKING_MODE_BIT))
            {
                if (ReadBit(Raise_Torch)) //Raise Torch ??
                {
                    if (JogState!=JoggingUp)
                    {
                        JogState=JoggingUp;
                        Jog(2,Torch_Speed);
                    }
                }
                else if (ReadBit(Lower_Torch)) //Lower Torch ??
                {
                    if (JogState!=JoggingDown)
                    {
                        JogState=JoggingDown;
                        Jog(2,Torch_Speed);
                    }
                }
                else //Stop Torch
                {
                    if (JogState!=JoggingNone)
                    {
                        JogState=JoggingNone;
                        Jog(2,0);
                    }
                }	
            }
            else
            {
                JogState=JoggingNone;
            }
        }
    }
    Below is Code that may be assigned to an M Code to activate Z Tracking. It will remove Z from Coordinated Motion then set the virtual bit so Z Tracking will be serviced. Select Exec Prog/wait/sync

    Code:
    #include "KMotionDef.h"
    
    main()
    {
    	#define Z_TRACKING_MODE_BIT 1024 // set to begin Z height tracking  
    	// remove Z from coordinated motion
    	DefineCoordSystem(0,1,-1,-1);
    	SetBit(Z_TRACKING_MODE_BIT);
    }
    Below is Code that may be assigned to an M Code to deactivate Z Tracking. It will add Z back into the Coordinated Motion System then clear the virtual bit so Z Tracking will be serviced. Select Exec Prog/wait/sync so that Z is re-synchronized to its current position before continuing with G Code.

    Code:
    #include "KMotionDef.h"
    
    main()
    {
    	#define Z_TRACKING_MODE_BIT 1024 // set to begin Z height tracking  
    	// add Z to coordinated motion
    	DefineCoordSystem(0,1,2,-1);
    	ClearBit(Z_TRACKING_MODE_BIT);
    	Jog(2,0); // stop
    	while (!CheckDone(2)) ;
    }
    The code is untested so it may have bugs. Let us know if you have problems.

    HTH
    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Nov 2013
    Posts
    45

    Re: Z tracking possible?

    Tom,

    This is great.:banana: I have some questions.

    A better approach might have been to input the Analog Height signal into KFLOP so it could drive the Z Speed as a function of the error rather than just of/off up/down.
    Couple of issues here. I was not aware KFLOP could handle an analog signal without Kanalog. The PLC was used to provide isolation between the plasma and KFLOP, this is my first plasma table and that might not be necessary.


    When moving Z independently in Height Tracking mode Z should be removed from the Coordinated Motion System with the DefineCoordSystem() function.
    Is this why it would not move until I paused KMCNC?

    Another issue is that Jog commands should not be commanded continuously at a high rate. It is better to just command the Jog Speed once (and have the blended trajectory computed) until something changes.
    Wow that is an epiphany. Just issuing command over top of command does not allow for proper accel .

    I should be able to get this tested in a day or so (real work is getting in the way). Thanks again.

  4. #4
    Join Date
    May 2006
    Posts
    4045

    Re: Z tracking possible?

    Hi Epiphany

    I was not aware KFLOP could handle an analog signal without Kanalog.
    You are correct. KFLOP would need to have access to the error value somehow. ADC, parallel, Modbus, SPI, Serial, etc... You might connect a few bits from your PLC to KFLOP

    Is this why it would not move until I paused KMCNC?
    Yes. Any axis can only follow one trajectory at a time.

    Wow that is an epiphany. Just issuing command over top of command does not allow for proper accel .
    Yes. It is like pressing the recalculate button on your GPS a thousand times per second.

    Regards
    TK
    http://dynomotion.com

  5. #5
    Join Date
    Nov 2013
    Posts
    45

    Re: Z tracking possible?

    Just an update,

    The plasma table is fully functional. Thanks Tom the code worked fantastic. I had to tweak the math on my height adjustment in the PLC once I could see the usable range of the plasma feedback signal while cutting.

    One minor code change if anybody is thinking of using it.

    Code:
    #include "KMotionDef.h"
    
    // When Z Tracking Bit is set control Z Height based on two input bits
    
    main()
    {
        #define Raise_Torch 20
        #define Lower_Torch 21
    
        #define Torch_Speed 1000.0 // speed to move torch - counts/sec
    
        #define Z_TRACKING_MODE_BIT 1024 // set to begin Z height tracking  
    
        #define JoggingNone 0
        #define JoggingUp 1
        #define JoggingDown 2
    
        int JogState=JoggingNone;
    
        for(;;)
        {
            WaitNextTimeSlice();
    
            if (ReadBit(Z_TRACKING_MODE_BIT))
            {
                if (ReadBit(Raise_Torch)) //Raise Torch ??
                {
                    if (JogState!=JoggingUp)
                    {
                        JogState=JoggingUp;
                        Jog(2,Torch_Speed);
                    }
                }
                else if (ReadBit(Lower_Torch)) //Lower Torch ??
                {
                    if (JogState!=JoggingDown)
                    {
                        JogState=JoggingDown;
                        Jog(2,-Torch_Speed);            ! ! Add the - to the Torch_Speed so it will go down. That's all folks
                    }
                }
                else //Stop Torch
                {
                    if (JogState!=JoggingNone)
                    {
                        JogState=JoggingNone;
                        Jog(2,0);
                    }
                }	
            }
            else
            {
                JogState=JoggingNone;
            }
        }
    }
    And set your Z_TRACKING_MODE_BIT to what you are using.

    I put the logic in the PLC to stop Z tracking if the arc is not within limits so it doesn't dive if it comes off of the stock while cutting. Took a test cut on some 1/8" mild steel at 150 IPM. Very happy with the results.

    Thanks again Tom.:cheers:

Similar Threads

  1. tracking noise?
    By Fastest1 in forum CNC Machine Related Electronics
    Replies: 47
    Last Post: 08-29-2012, 12:27 PM
  2. knurling keep double tracking/cnc
    By MKMANU in forum MetalWork Discussion
    Replies: 5
    Last Post: 06-13-2011, 06:27 PM
  3. Need help with tool tracking
    By DerbyCountyFan in forum Haas Mills
    Replies: 1
    Last Post: 02-08-2011, 06:12 PM
  4. Tracking machine down time
    By noahwass in forum Haas Mills
    Replies: 3
    Last Post: 10-05-2010, 10:14 PM

Posting Permissions

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