.
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.
.
Forgot to add Overwriting M200.TXT will assign this macro to park button 1.
Cheers
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
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.
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
Last edited by Jon.N.CNC; 08-18-2015 at 06:59 PM.
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
Anytime I can help you work something out just give a shout.
(;-) TP
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!"); }
I copied and pasted directly from your wordpad doc. I opened it in text wrangler.
wow okay.. you were right notepad doesnt like it either.
Hi,
any update on the macro since that time?