587,462 active members*
3,374 visitors online*
Register for free
Login
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    71

    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"); 
    }

  2. #2
    Join Date
    May 2010
    Posts
    290
    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
    Join Date
    May 2006
    Posts
    4048
    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
    TK
    http://dynomotion.com

  4. #4
    Join Date
    Oct 2003
    Posts
    71
    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
    Join Date
    May 2006
    Posts
    4048
    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
    TK
    http://dynomotion.com

  6. #6
    Join Date
    Oct 2003
    Posts
    71
    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

Similar Threads

  1. KFLOP replacing LPT/Mach3 How To
    By Fish4Fun in forum Dynomotion/Kflop/Kanalog
    Replies: 48
    Last Post: 05-20-2014, 11:22 PM
  2. Homing Mach3
    By omboli in forum Mach Software (ArtSoft software)
    Replies: 3
    Last Post: 08-10-2012, 12:30 PM
  3. Mach3 vs Kflop
    By MarunovV in forum Dynomotion/Kflop/Kanalog
    Replies: 13
    Last Post: 07-25-2012, 08:54 PM
  4. KFlop+Mach3 on Windows 7
    By nova24 in forum Dynomotion/Kflop/Kanalog
    Replies: 2
    Last Post: 03-08-2012, 05:40 AM
  5. Mach3 - Homing Problems
    By rc123456 in forum Mach Software (ArtSoft software)
    Replies: 3
    Last Post: 02-19-2010, 02:58 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
  •