Mach3/Kflop - Homing


Results 1 to 6 of 6

Thread: Mach3/Kflop - Homing

  1. #1
    Registered
    Join Date
    Oct 2003
    Location
    USA
    Posts
    71
    Downloads
    0
    Uploads
    0

    Default Mach3/Kflop - Homing

    I have done a bit of search here, Google and the Yahoo group and I seem to be missing some thing.

    Here are my system specs,

    I have separate limit/home switches at both ends of travel all all 3 axis. These are wired in the OPTI-IN of a Kanalog board.

    This is on a mill. My drives are controlled by step/dir signals and the loop is closed at the drives (not sure this really matters).

    I'm using Mach3 for my control software. As of right now I can jog and run g-code with no problems.

    I'm having trouble seeing how to get Mach3/kflop to home my machine.

    Lets start with getting Mach3 to pass the homing call to Kflop. In my searching I found reference to this page Mach3 Plugin Enoder Setup which states that I need to modify the ref x/y/z buttons in Mach3. Only differences that I see between my button configs and the pics in the above link is the OEM code#. Mine are set on 22, 23, 24. The above link has them set for 1022, 1023, 1024, I assume this is what I need to change. It's not clear on that page what actually needs to be changed.

    I didn't find any information on what may need to be done with the 'Ref all' button in Mach. My best guess is I leave this one alone since it looks like it just "pushes" the ref x/y/z buttons for me.


    Now on to the c program.

    I have been studying SimpleHome3Axis.c and HomeMach3.c, it has been a while since I have done any type of programming but its starting to come back. Below is how I think my c program should look.

    Note I'm only working on the the z-axis. Figure I get that one working and the others are going to be really easy to set up.

    Couple of questions on some of the code.

    Jog(2,100); // So this reads jog axis number 2 (Z-axis) at 100 counts/second? If this jogs the wrong way do I just change the 100 to a negative number?

    while (!ReadBit(10)) // I think the '10' in this statements needs to be changed to the input number that I have the home switch connected too.

    Move(2,-1000.0); // Is the -1000.0 the number of encoder counts the motor is suppose to move? I would like 0.1" back off from the home switch, I have 10,000 counts/inch so it looks like the -1000.0 would be the correct number.


    Thanks
    -Wes


    Code:
    #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)
    	{
    		// Z-axis Homing
    
    	int SaveZLimits;  	//place to save limit switch settings
    	
    	DisableAxis(2);  	// Disable Z axis
    	
    		
    		// I don't have access to my axis parameters right now.
    		// My machine is at my dads house, I know what needs to go here.
    
    			// Set the axis parameters here
    			// after everything is configured in the KMotion Screens
    			// use copy C Code to clipboard on the configuration screen
    			// then paste here.  Repeat for each axis
    
    
    
    						 
    	SaveZLimits = ch2->LimitSwitchOptions;	// save how the limit is set
    	
    	ch2->LimitSwitchOptions = 0;		// disable the limit
    			
    	EnableAxis(2);				// enable Z axes and begin servoing where we are 
    
     
    	// jog z-axis until it sees the limit
    
        Jog(2,100);					// jog slowly positive
        while (!ReadBit(10)) ; 		 	// loop until IO bit goes high
        Jog(2,0);					// stop
        while (!CheckDone(2)) ; 			// loop until motion completes 
        DisableAxis(2);				// disable the axis
        Zero(2);					// Zero the position 
        EnableAxis(2);				// re-enable the ServoTick
        Move(2,-1000.0);			// move some amount inside the limits
        while (!CheckDone(2)) ; 			// loop until motion completes 
        ch2->LimitSwitchOptions = SaveZLimits;  // restore limit settings
    
    	}
    
    	
    	printf("Done\n"); 
    }


    Similar Threads:


  2. #2
    Registered
    Join Date
    May 2010
    Location
    USA
    Posts
    290
    Downloads
    0
    Uploads
    0

    Default

    It's been a little while since I went through this same stuff.....so I'm slightly fuzzy on the Mach part, but I believe you are on the right track.

    It depends what screen set you are using.

    I was using a lathe screen and had to change a bunch of things....just can't remember. Sorry.....it was for someone else's machine, or I would look to refresh my memory for you.

    I'm sure Tom will see this and answer.

    The answer to your C questions are yes , correct ( bit number of switch you are monitoring), and yes.

    Mike



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

    Default

    Hi Wes,

    Did you get this working?

    For your situation (no encoders) you shouldn't need to change the Mach3 Screen Buttons. In Mach3 terminology "Homing" is referred to as "Ref". Pushing a "Ref" button or the "Ref ALL Home" button will send messages to our Plugin which will then run the HomeMach3.c program (or whatever you have specified in our plugin configuration) with the flag variable passed to inform the program which axis should be homed.

    Your other questions are all correct.

    Regards

    Regards
    TK http://dynomotion.com


  4. #4
    Registered
    Join Date
    Oct 2003
    Location
    USA
    Posts
    71
    Downloads
    0
    Uploads
    0

    Default

    Tom,

    For the most part it is working. Only problem that I have run into is some times Mach zeros the axis DRO and turns the red referenced light the green with out moving the axis. Only way I get it to work when this happens is a complete reboot of my PC. That doesn't work all the time, I have had to do a couple reboots.

    When it is working I can home it all day long with no problems.

    Thanks
    -Wes



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

    Default

    Hi Wes,

    Not sure what would cause that. The only thing I can think of is the Home program is "stuck" and won't finish for some reason. For example the axis doesn't move (ie axis or amplifier disabled?) In this case the home program will wait forever looking to detect the switch input. You could check if this is the case by running KMotion.exe and looking on the C Program screen to see if the Thread you assigned to Home is still running (green bar over Thread indicates a program running). If so, look to see why the axis is not moving (disabled?). Also check if halting the thread allows recovery. Once we figure out what is going on we can work on a solution.

    Regards
    TK

    Regards
    TK http://dynomotion.com


  6. #6
    Registered
    Join Date
    Oct 2003
    Location
    USA
    Posts
    71
    Downloads
    0
    Uploads
    0

    Default

    Tom,

    You called that one. When I was testing out the homing program I had an incorrect limit switch input pin number in the code. What would happen is it was looking to the neg switch when I was traveling in a positive direction. I would hit the hard stop which would cause my drive to fault. After resetting the drive the kflop light was green for thread 3. The quick fix is to just activate the limit switch so that the home program will complete.

    That is all working now.

    Thanks
    -Wes



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

Mach3/Kflop - Homing

Mach3/Kflop - Homing