UCCNC Camera/Laser Edge finder offset macro

Results 1 to 15 of 15

Thread: UCCNC Camera/Laser Edge finder offset macro

  1. #1
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default UCCNC Camera/Laser Edge finder offset macro

    Hi there,
    Here is a macro i have written for a camera edge finder macro, it is the first macro i have written and i have no programming experience but it seems to work well.

    When the macro is called from mdi, it simply checks x + y + z axis are homed,and responds with message box and halt if false. if true then the macro zeros the machines current positiont and add the offset of the camera/laser and moves to new zero and reports when complete, so before calling the macro script, you home the machine and place your camera/laser crosshair over the corner edges of your stock.

    I have called the macro m33 within the code, simply as m33 is not used as default. this can be changed to whatever you like.

    AS3.SETFIELD(**.**,226) is the script that sets the offset for x, change the **.** for your offset value.
    AS3.SETFIELD(**.**,227) is the script that sets the offset for y, change the **.** for your offset value.

    Save in notepad as m33.txt or chosen macro filename into folder : uccnc/profiles/*currentprofile*/macro_*currentprofile*

    if you decide to alter the macro filename you simply need to change the m33 in the message field within the macro to match. Camera can also be changed to laser respectively.

    m33.txt:


    if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLE D(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here...
    {
    MessageBox.Show("The machine was not yet homed, do homeing before executing camera offset M33!");
    exec.Stop();
    return;
    }


    AS3.Setfield(12.34, 226);
    AS3.Validatefield(226);


    AS3.Setfield(12.34, 227);
    AS3.Validatefield(227);

    exec.Wait(1000);


    while(exec.IsMoving()){}


    exec.Code("G90 G0 X0 Y0");


    while(exec.IsMoving()){}


    if(!exec.Ismacrostopped())
    {
    MessageBox.Show("Camera offset done.");
    }
    else
    {
    exec.StopWithDeccel();
    MessageBox.Show("Camera Offset was interrupted by user!");


    Enjoy

    Jon.
    CNC Routing - Southwest CNC Limited - CNC Routing UK | Cad Specialists Devon| CNC Parts Devon | CNC Cutting Devon | Plywood Cutting Devon| MDF Cutting Devon | Acrylic Cutting Devon

    Similar Threads:
    Last edited by Jon.N.CNC; 08-16-2015 at 12:44 PM.


  2. #2
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    .



  3. #3
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro



  4. #4
    Member
    Join Date
    Jun 2015
    Location
    Sweden
    Posts
    943
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Thanks Jon.N.CNC. I'm just installing a 2Watt laser module to the machine. Will try your macro.



  5. #5
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by OlfCNC View Post
    Thanks Jon.N.CNC. I'm just installing a 2Watt laser module to the machine. Will try your macro.
    Excellent, good to hear its of possible of use to someone. Hope it works okay for you.

    The one thing that is missing I think would be nice is if it was to check that after it checks that the axis have been homed is that the position has changed and not still at the home position, and warn and halt if false.

    My experience in programming is vague at best but my best guess is that it needs to write 3 variables of the x y and z position, and execute a code that totals the variables and if they equal zero, shows a message along with a halt return.

    I can't seem to find a documented script for this type of calculation. Would be very appreciative if anyone knows of a way to do this.

    But as it stands, it does the job.



  6. #6
    Member vmax549's Avatar
    Join Date
    Oct 2005
    Location
    Lady Lake
    Posts
    1145
    Downloads
    3
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Try this. It looks at the XYZ Machine coords Dros and IF they are at 0 then it errors with a message and exits. Else it displays a message in the status bar and proceeds.

    if ((exec.GetXmachpos() == 0) || (exec.GetYmachpos() == 0) || (exec.GetZmachpos() == 0))
    {
    MessageBox.Show("The Machine is still at HOME position");
    exec.Stop();
    return;
    }
    else

    AS3.Setfieldtext("The machine is ready to do Function",900);

    //End of Code


    (;-) TP



  7. #7
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Quote Originally Posted by vmax549 View Post
    Try this. It looks at the XYZ Machine coords Dros and IF they are at 0 then it errors with a message and exits. Else it displays a message in the status bar and proceeds.


    if ((exec.GetXmachpos() == 0) || (exec.GetYmachpos() == 0) || (exec.GetZmachpos() == 0))
    {
    MessageBox.Show("The Machine is still at HOME position");
    exec.Stop();
    return;
    }
    else


    AS3.Setfieldtext("The machine is ready to do Function",900);


    //End of Code




    (;-) TP

    Thank you! Only it doesn't seem to work correctly for me.

    Seems to show message regardless of position , looks close to what im looking for though.

    Just tested the original version and it didnt want to work so must have been a error somewhere.

    Fixed Version attached.

    Attached Files Attached Files
    Last edited by Jon.N.CNC; 08-18-2015 at 06:59 PM.


  8. #8
    Member vmax549's Avatar
    Join Date
    Oct 2005
    Location
    Lady Lake
    Posts
    1145
    Downloads
    3
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Try it this way, I can't even copy my own code correctly(;-)


    AS3.Setfieldtext("",900);
    if ( (exec.GetXmachpos() == 0.000) & (exec.GetYmachpos() == 0.000) & (exec.GetZmachpos() == 0.000) )
    {
    MessageBox.Show("The Machine is still at HOME position");
    exec.Stop();
    return;
    }
    else
    AS3.Setfieldtext("The Machine is ready to do Function",900);
    //End of Code



  9. #9
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Quote Originally Posted by vmax549 View Post
    Try it this way, I can't even copy my own code correctly(;-)


    AS3.Setfieldtext("",900);
    if ( (exec.GetXmachpos() == 0.000) & (exec.GetYmachpos() == 0.000) & (exec.GetZmachpos() == 0.000) )
    {
    MessageBox.Show("The Machine is still at HOME position");
    exec.Stop();
    return;
    }
    else
    AS3.Setfieldtext("The Machine is ready to do Function",900);
    //End of Code
    Worked perfectly, Thank you!!

    I dont think you are the only one,, I dont think this forum likes people posting code.
    Was just watching the code as page refreshed and it changed the split second the page had fully refreshed losing bits of code.Tried this on my other machine and the same thing happened :s g90 g0 x0 y0 turned into g900 y0 lol

    If you notice any spelling errors in the code message box fields.. Your having the same issue.

    Very odd.

    ** safest bet: download the file attactched **

    Thanks again for your help vmax

    Attached Files Attached Files


  10. #10
    Member vmax549's Avatar
    Join Date
    Oct 2005
    Location
    Lady Lake
    Posts
    1145
    Downloads
    3
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Anytime I can help you work something out just give a shout.

    (;-) TP



  11. #11
    Member
    Join Date
    Aug 2006
    Location
    usa
    Posts
    143
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    If you go to the advanced editor there is a # symbol. This allows you to post code without extra crap.
    I also tried to edit a macro terry sent me with word pad and it did something strange to it as well. I downloaded notepad ++ and that seems to work much better with macros for UCCNC.

    I use text wrangler on my Mac.


    Code:
    if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here...
    {
    MessageBox.Show("Theine was not yet homed, HOME before executing camera offset M33!");
    exec.Stop();
    return;
    }
    
    AS3.Setfieldtext("",900);
    if ( (exec.GetXmachpos() == 0.000) & (exec.GetYmachpos() == 0.000) & (exec.GetZmachpos() == 0.000) )
    {
    MessageBox.Show("The machine is still at HOME position! Position camera on edge(s) and restart macro");
    exec.Stop();
    return;
    }
    else
    AS3.Setfieldtext("The Machine is ready to do Function",900);
    
    
    AS3.Setfield(12.34, 226); // x offset value (12.34)
    AS3.Validatefield(226);
    
    
    AS3.Setfield(12.34, 227); // y offset value (12.34)
    AS3.Validatefield(227);
    
    
    exec.Wait(1000);
    
    
    while(exec.IsMoving()){}
    
    
    exec.Code("G90 G0 X0 Y0");
    
    
    exec.Wait(1000);
    
    
    while(exec.IsMoving()){}
    
    
    if(!exec.Ismacrostopped()) 
    
    
    
    
    {
    MessageBox.Show("Camera offset finished!");
    }
    else
    {
    exec.StopWithDeccel();
    MessageBox.Show("Cameraet was interrupted by user!");
    }




  12. #12
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Quote Originally Posted by derek View Post
    If you go to the advanced editor there is a # symbol. This allows you to post code without extra crap.
    I also tried to edit a macro terry sent me with word pad and it did something strange to it as well. I downloaded notepad ++ and that seems to work much better with macros for UCCNC.

    I use text wrangler on my Mac.


    Code:
    if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here...
    {
    MessageBox.Show("Theine was not yet homed, HOME before executing camera offset M33!");
    exec.Stop();
    return;
    }
    
    AS3.Setfieldtext("",900);
    if ( (exec.GetXmachpos() == 0.000) & (exec.GetYmachpos() == 0.000) & (exec.GetZmachpos() == 0.000) )
    {
    MessageBox.Show("The machine is still at HOME position! Position camera on edge(s) and restart macro");
    exec.Stop();
    return;
    }
    else
    AS3.Setfieldtext("The Machine is ready to do Function",900);
    
    
    AS3.Setfield(12.34, 226); // x offset value (12.34)
    AS3.Validatefield(226);
    
    
    AS3.Setfield(12.34, 227); // y offset value (12.34)
    AS3.Validatefield(227);
    
    
    exec.Wait(1000);
    
    
    while(exec.IsMoving()){}
    
    
    exec.Code("G90 G0 X0 Y0");
    
    
    exec.Wait(1000);
    
    
    while(exec.IsMoving()){}
    
    
    if(!exec.Ismacrostopped()) 
    
    
    
    
    {
    MessageBox.Show("Camera offset finished!");
    }
    else
    {
    exec.StopWithDeccel();
    MessageBox.Show("Cameraet was interrupted by user!");
    }
    Ahh i c.. will try that in future. Cheers.

    see your getting it too - "Theine was not yet homed" looks as tho its the MessageBox.Show command that screws it up.



  13. #13
    Member
    Join Date
    Aug 2006
    Location
    usa
    Posts
    143
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    I copied and pasted directly from your wordpad doc. I opened it in text wrangler.



  14. #14
    Registered
    Join Date
    Jun 2014
    Posts
    777
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    wow okay.. you were right notepad doesnt like it either.



  15. #15
    Member
    Join Date
    May 2017
    Location
    Germany
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Re: UCCNC Camera/Laser Edge finder offset macro

    Hi,

    any update on the macro since that time?



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

UCCNC Camera/Laser Edge finder offset macro

UCCNC Camera/Laser Edge finder offset macro