Lagun Knee Mill Retrofit - Page 3


Page 3 of 3 FirstFirst 123
Results 41 to 57 of 57

Thread: Lagun Knee Mill Retrofit

  1. #41
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    Hi Tom,
    Been adjusting V,A and J using your link to article, everything appears nice and smooth so far in Kmotion, havent setup KmotionCNC planner yet. Right now iam working on my INIT program.
    Currently trying to add external buttons control to the code. I copied some debounce code from another working INIT program from another mill i built. This is code you helped/did for me. I am getting a compile error..."c:229: initializer element is not constant" at the first line of my CycleStart button portion of code. Obviously dont understand what iam missing. Can you take a look at it? I still have a few more button and switches to add also.
    Attached is INIT file.
    Thanks in advance,
    Troy

    Attached Files Attached Files
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  2. #42
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    Not sure if this is correct but i dont get any errors when compiling .
    I changed directions of a bracket that is at begining of code for FeedHold button.....

    { //Changed bracket from this "}" to this "{"


    // Handle FeedHold/Resume
    result = Debounce(ReadBit(FEEDHOLDBIT),&fcount,&flast,&flas tsolid);
    if (result == 1)
    {
    if (CS0_StoppingState == 0)
    StopCoordinatedMotion();
    else
    ResumeCoordinatedMotion();
    }

    www.tsjobshop.com, www.homecncstuff.elementfx.com


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

    Default Re: Lagun Knee Mill Retrofit

    Hi Troy,

    Yes curly brackets are very critical in C Programming. The concept is very simple. They go in pairs much like parenthesis or begin-end statements. For example:

    Code:
    {
        {
        }
        {
        }
    }
    Good C Programmers indent the code with spaces or tabs so it is obvious that the brackets are paired up.

    Something like this is obviously wrong

    Code:
    {
        {
            {
    }
    Note that cnczone doesn't handle tabs or spaces well. In the Advanced Posting mode there is a button # to add tags that works better with C code indented with spaces.

    Now that you understand curly brackets and indentation format your file to make it more readable

    Find all the matching pairs. If necessary print out the program and draw a pencil line between them. (Trust me you only need to do that once to get the idea and make it unnecessary).

    Now find where the "main" function begins and ends.

    The Code you added to check and debounce the buttons needs to be placed in a forever loop at the end but yet inside the main function. The way your program was written the buttons would only be checked once. and then the program would terminate.

    A forever loop has this format: (the curly brackets define the beginning and end of the loop)

    Code:
    for (;;)
    {
        // stuff here is inside the loop and gets executed over and over forever
    }

    Let me know how much of this makes sense.

    Regards

    Regards
    TK http://dynomotion.com


  4. #44
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    You have told me this once before a few years back. Its starting to jog my memory now.
    External buttons...as you already know...are not working.
    Going to try and fix with info you just gave me and see if i can get it.
    Thanks again,
    Troy

    www.tsjobshop.com, www.homecncstuff.elementfx.com


  5. #45
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    Hay Tom,
    Got INIT code working so far. Next i need to add external switch control for spindle and coolant.

    Something else i was wondering concerning a C program that does a homing sequence for Y axis. This is what i have for Y axis.
    Code:
    #include "KMotionDef.h"
    
    #define Y 1
    
    
    main()
    {
    ch1->LimitSwitchOptions=0x00000000; // disable limits
    
    	DisableAxis(Y);
    	Zero(Y);
    	EnableAxisDest(Y,0.0);
    
    	Jog(Y,2000); // start moving
    	while (!ReadBit(139)) ; // wait for switch (input #139) to change
    	Jog(Y,0); // StopMotion
    		
    	while(!CheckDone(Y)) ;
    
    	Jog(Y,-500); // start moving off of switch
    	while (ReadBit(139)) ; // wait for switch (input #139) to change
    	Jog(Y,0); // StopMotion
    
    	while(!CheckDone(Y)) ;
    	Delay_sec(.5);
    		
    	DisableAxis(Y);
    	Zero(Y);
    	EnableAxisDest(Y,0.0);
    	//Jog(Y,-2000);
    	//Move(Y,-800);
    		
    	while(!CheckDone(Y)) ;
    	Delay_sec(.5);
    		
    	DisableAxis(Y);
    	Zero(Y);
    	EnableAxisDest(Y,0.0);
    	Delay_sec(.9);
    	ch1->LimitSwitchOptions=0x113;	
    }
    I copied this code from a working example for my Z axis and worked fine. But would not work for Y axis. When executed for Y, table would not move off of switch until i changed the first ReadBit line by adding a "!" and then removing the "!" from second ReadBit. Is this because my limit switches of Z axis is set as Active High and my Y axis switches is set to Active Low?

    The above code works fine for Y axis now,... but man.... was like finding a needle in a hay stack when you dont know what your looking for

    Thanks,
    Troy

    Attached Files Attached Files
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  6. #46
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    Also, am trying to get an external button to toggle Coolant Pump on and off. The code i have so far only works sporadically. I was trying to use what i have learned on an arduino/teensy project i did, but still no go . I have hit a wall with something so simple. What am i missing?

    Thanks,
    Troy

    Attached Files Attached Files
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  7. #47
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    Been customizing KMotionCNC face. Here is a screenshot so far. Hope to have a test video up of machine in a couple days. It has very nice rapids.
    Lagun Knee Mill Retrofit-kmotioncnc-7-18-2016-jpg

    Troy

    www.tsjobshop.com, www.homecncstuff.elementfx.com


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

    Default Re: Lagun Knee Mill Retrofit

    Hi Troy,

    Did get your coolant toggle to work?

    This code is checking whether the bit is an Input or Output instead of whether it is on or off and the close parenthesis for the function is misplaced:
    Code:
    		if
    			(GetBitDirection(154 == 1))
    			ClearBit(154);
    				
    		else
    			
    			//(GetBitDirection(18)==1);
    			//(GetBitDirection(154)==0);
    			SetBit(154);
    Should be:

    Code:
    if (ReadBit(154) == 1)  // read the bit is it on?
        ClearBit(154);  // yes, turn it off
    else
        SetBit(154);  // no, turn it off
    regards

    Regards
    TK http://dynomotion.com


  9. #49
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Coolant Pump Toggle Code

    Hi Tom,
    I got close. Here is what i ended up with...

    Code:
    if (ReadBit(154))
       ClearBit(154);
    else
       SetBit(154);
    But was not consistent with my external switch and having code in my main INIT program. Something i dont understand is if i made a separate C program just for coolant and set it to a user button, that user button would toggle coolant no problem.
    I made the changes as you stated and all works well
    Thanks,
    Troy

    www.tsjobshop.com, www.homecncstuff.elementfx.com


  10. #50
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Lube Pump Timer

    Now i have a new issue. Iam trying to control a lube pump with a relay and output from Kanalog. Here is code i placed in my main INIT program....
    Code:
    //Lube Pump On/Off timer
    	SetBit(155);
    	Delay_sec(300.);
    	ClearBit(155);
    	Delay_sec(3600.);
    Problem is that the rest of C program will not run when this delay is running. I used the millis() function once in the Arduino world that would handle this issue.Does KFLOP support this function? Or how do you get such a delay to run without delaying the rest of program? Or is there a better way to cycle lube pump on and off? I read this part "Performing multiple Operations continually in a forever Loop" on the Wiki page, but dont see any examples.
    Thanks,
    Troy

    Last edited by Need TECH Help!; 07-19-2016 at 08:54 AM.
    www.tsjobshop.com, www.homecncstuff.elementfx.com


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

    Default Re: Lagun Knee Mill Retrofit

    Hi Troy,

    I added an example to the wiki. See:
    KFLOP C Programs - Dynomotion

    Regards

    Regards
    TK http://dynomotion.com


  12. #52
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    Hi Tom,
    I tried running your example in a separate thread in Kmotion (not KMCNC) and Output bit never toggles off. What did i miss?
    Thanks again,
    Troy

    www.tsjobshop.com, www.homecncstuff.elementfx.com


  13. #53
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    Hi Tom,
    My bad, when i copied and paste the #include "KMotionDef.h" got missed. Now to see if i can get it into main INIT program.
    Thanks,
    Troy

    www.tsjobshop.com, www.homecncstuff.elementfx.com


  14. #54
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Lube Pump Timer

    Hi Tom,
    Believe i got lube pump timer in INIT ok. All is running fine, so far.
    Thanks
    Troy

    Attached Files Attached Files
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  15. #55
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Limit Switch Pop UP during Referance

    Hi Tom,
    I have PopUp windows when a limit switch is hit to notify user. But how can i disable these pop ups when iam doing a reference of axis? The axes use the same switch for Reference and limit.
    This is more of a annoyance than a problem....
    Attached is current main INIT c program.
    Troy

    Attached Files Attached Files
    Last edited by Need TECH Help!; 07-20-2016 at 08:41 AM.
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  16. #56
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Lagun Knee Mill Retrofit

    A more important issue i just found out is when i use the zero buttons in KMotionCNC to zero part, and then change my Jog Percentage, the part zeros in the axes DROs is replaced with the Machine Coord. Also noticed that the Work Offset is not being updated when using the a axis zero button. Did i miss something in my INIT c program or settings?
    Thanks,
    Troy

    Last edited by Need TECH Help!; 07-20-2016 at 11:02 AM.
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  17. #57
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: Limit Switch Pop UP during Referance

    Found it here....Tool Setup Trajectory Planner
    I had setting "Zero Using Fixture Offsets" turned off.

    Thanks,
    Troy

    www.tsjobshop.com, www.homecncstuff.elementfx.com


Page 3 of 3 FirstFirst 123

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

Lagun Knee Mill Retrofit

Lagun Knee Mill Retrofit