584,879 active members*
5,240 visitors online*
Register for free
Login
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2004
    Posts
    244

    Limit switches in series

    Sorry for the 1000 questions, but I have yet an other question. Can I get the kflop to work with my limit switches wired in series with Mach such that when one switch is hit the kflop will stop all motion and allow the moment off from the switch? I also would like to use the switches for homing as well. Was thinking the c routine would home one axis at a time by disabling the limit switches and watching the bit the limits are wired to to go low, slowly back away until the bit goes high, set the position, set a flag axis complete, then do the next till all are done and re-enable limits. Dose this sound about right?
    Everything in moderation, including moderation.

  2. #2
    Join Date
    May 2006
    Posts
    4043
    Hi eman5oh,

    You can do pretty much anything as long as you consider all the various scenarios. But it gets complicated.

    Were you planning on separate inputs for positive and negative limits? That makes it simpler for KFLOP to know which direction all the axes can be allowed to go if only one limit is active.

    Or you could add a button in Mach3 to enable/disable limits. I'm not sure how to hook into the existing one.

    You can code your Homing to disable limits while homing and then re-enable limits. The SimpleHomeFunction.c example does this.

    Regards
    TK
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Aug 2004
    Posts
    244
    Tom thanks, I had not tough to use one plus input and one minus input for all the limits, this will make it a lot easier without chewing up a lot of i/o.
    Everything in moderation, including moderation.

  4. #4
    Join Date
    Aug 2004
    Posts
    244
    Tom,

    So I go the homing and soft limits to work with one exception, when I home the machine it run thought the routine twice, I modified one of the sample as below. Can you tell why it runs twice?


    #include "KMotionDef.h"

    // Configuration and Homing program for a 3 axis System
    // Limit switches are disabled and used as a home switch
    // then they are re-enabled


    main()
    {
    int SaveXLimits,SaveYLimits; //place to save limit switch settings

    DisableAxis(0); // Disable all axes
    DisableAxis(1);
    //DisableAxis(2);

    // 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







    // disable the limits (first save how they were set)
    SaveXLimits = ch0->LimitSwitchOptions;
    SaveYLimits = ch1->LimitSwitchOptions;
    //SaveZLimits = ch2->LimitSwitchOptions;
    ch0->LimitSwitchOptions = 0;
    ch1->LimitSwitchOptions = 0;
    //ch2->LimitSwitchOptions = 0;

    // enable all 3 axes and begin servoing where we are

    EnableAxis(0);
    EnableAxis(1);
    //EnableAxis(2);


    // Home Z up first - jog 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


    // Home X next - jog until it sees the limit
    ch0->SoftLimitPos=100000;
    ch0->SoftLimitNeg=-100000;
    Jog(0,-1000); // jog slowly negative
    while (ReadBit(6)) ; // loop until IO bit goes low
    Jog(0,0); // stop
    while (!CheckDone(0)) ; // loop until motion completes
    DisableAxis(0); // disable the axis
    Zero(0); // Zero the position
    EnableAxis(0); // re-enable the ServoTick
    Move(0,1000.0); // move some amount inside the limits
    while (!CheckDone(0)) ; // loop until motion completes
    ch0->LimitSwitchOptions = SaveXLimits; // restore limit settings
    ch0->SoftLimitPos=100000;
    ch0->SoftLimitNeg=0;


    // Home Y next - jog until it sees the limit
    ch1->SoftLimitPos=55000;
    ch1->SoftLimitNeg=-55000;
    Jog(1,-1000); // jog slowly negative
    while (ReadBit(4)) ; // loop until IO bit goes low
    Jog(1,0); // stop
    while (!CheckDone(1)) ; // loop until motion completes
    DisableAxis(1); // disable the axis
    Zero(1); // Zero the position
    EnableAxis(1); // re-enable the ServoTick
    Move(1,1000.0); // move some amount inside the limits
    while (!CheckDone(1)) ; // loop until motion completes
    ch1->LimitSwitchOptions = SaveYLimits; // restore limit settings
    ch1->SoftLimitPos=55000;
    ch1->SoftLimitNeg=0;

    DefineCoordSystem(0,1,-1,-1); //Define XYZ coordinated motion axes
    }
    Everything in moderation, including moderation.

  5. #5
    Join Date
    May 2006
    Posts
    4043
    Hi eman5oh,

    Mach3 calls the Home program one time for each axis with a "flags" variable indicating which axes should be homed. See HomeMach3.c for an example to receive and check the "flags" variable to allow your program to home only the requested axis.

    Also see this description.

    Regards
    TK
    http://dynomotion.com

  6. #6
    Join Date
    Aug 2004
    Posts
    244
    Great, I hacked together something that now works. For now I have one final piece to get working, I have a push button wired to input 5 on the kflop. I have it mapped to Input one in Mach. Both Mach and Kmotion show it toggle when I push the button but I can not get to work as the cycle start. I have added the hot key config to mach with the OEM code of 1000 for cycle start and have it set up in ports and pins for input one port 1 pin 5.
    Everything in moderation, including moderation.

  7. #7
    Join Date
    May 2006
    Posts
    4043
    Hi eman5oh,

    Did you configure mach3 OEM Trig #1 for that IO?

    Otherwise there is a special Config | Plugins | Dynomotion | Cycle Start | Input Bit for that.

    Regards
    TK
    http://dynomotion.com

  8. #8
    Join Date
    Aug 2004
    Posts
    244
    Thanks the only thing I had missing was the config on the plug in screen.
    Everything in moderation, including moderation.

  9. #9
    Join Date
    Aug 2004
    Posts
    244
    So I have had my machine running for a couple weeks as I work on things, finally switched from a manual Z to cnc. Any how I have a question on how the soft limits work. I t seems that when I am jogging the machine it will over travel them slightly and then Mach will require a reset and it allows my to drive away from the soft limit. Do the soft limits inherit the action from the hard limits or is it just hard coded? I can't seem to get the mach slow zones to work with the soft limits, this is not too big a deal but would be nice to have working while jogging.
    Everything in moderation, including moderation.

  10. #10
    Join Date
    May 2006
    Posts
    4043
    Hi eman5oh,

    The Soft Limits in KFLOP trigger a Hardware FeedHold Stopping any motion regardless of how the Hard Limits are configured. Mach3 RESET or Stop will clear the FeedHold. Or you could add a screen or external button to clear the FeedHold as well. As long as there is no motion in the direction into the Soft Limit the FeedHold should remain clear allowing you to move away. Because the axes are decelerated to a controlled stop they will come to a rest somewhat beyond the Soft Limit Position.
    HTH
    Regards
    TK
    http://dynomotion.com

Similar Threads

  1. Replies: 3
    Last Post: 11-05-2013, 02:54 AM
  2. Series 1 limit switches
    By boss4 in forum Bridgeport / Hardinge Mills
    Replies: 4
    Last Post: 09-04-2013, 01:13 AM
  3. Series Limit Switches with Shielded Wire
    By Wolfspaw in forum DIY CNC Router Table Machines
    Replies: 2
    Last Post: 12-27-2011, 09:54 PM
  4. Bridgeport Series II Interact 2 EMC retrofit -- limit switches
    By ichudov in forum Bridgeport / Hardinge Mills
    Replies: 2
    Last Post: 06-28-2010, 01:15 AM
  5. Help with Bridgeport Interact Series 1 MK2 Stuck on the Limit Switches
    By mwibbels in forum Bridgeport / Hardinge Mills
    Replies: 12
    Last Post: 02-05-2009, 09:33 PM

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
  •