Newbie struggling with probe macro

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Newbie struggling with probe macro

Postby chap1 » Tue Feb 08, 2022 10:09 am

Hi. I'm relatively new to cnc and completely new to writing macros and C#. Hope someone can help.

I wanted to write a custom probing macro to find the centre of a round bar. The probing screen in UCCNC appears to have the
capability but I couldn't get my head round it and my machine doesn't do homing. I don't understand why the following code doesn't
work. The G1 code starts OK and the probe LED lights up - the probe is working. What I expected it to do was to sit in the while loop until the
probe LED came on. I need to add some timeout code but there's no point if it doesn't stop when I know it's made contact. Running it manually in macro
M1000 not replacing M31, the machine moves.

exec.Code("G1F" + FastRate + " X" + MaxTravel);

//Wait til probe is touched
while (!AS3.GetLED(37)){};
exec.Stop();

TIA Gordon
chap1
 
Posts: 4
Joined: Tue Feb 08, 2022 8:50 am

Re: Newbie struggling with probe macro

Postby ger21 » Tue Feb 08, 2022 11:44 am

Just use a G31 probing move. That's all you need.

exec.Code("G31 F" + FastRate + " X" + MaxTravel);

Then get the touch point.

Xhit = exec.Getvar(5061); // Read the touch point
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Newbie struggling with probe macro

Postby chap1 » Tue Feb 08, 2022 11:53 am

Thank you.
chap1
 
Posts: 4
Joined: Tue Feb 08, 2022 8:50 am

Re: Newbie struggling with probe macro

Postby chap1 » Fri Feb 11, 2022 11:22 am

Great, got that working thanks to ger21. I can get the centre accurately enough. What I don't appear to be able to do is set the axes to zero.
According to the doc's changing the axes DRO's (to zero) doesn't do anything as the axes values are from internal variables. I can do it
manually of course but it would be nice to have it all done automatically.

What I did find by searching around is function ChangeAxisDROvalue(axis number, value (string)) but can't see where you get the axis number from.
The example I found had the axis number as 2, the Z axis in that particular case.

TIA Gordon
chap1
 
Posts: 4
Joined: Tue Feb 08, 2022 8:50 am

Re: Newbie struggling with probe macro

Postby ger21 » Fri Feb 11, 2022 11:47 am

For X axis,

AS3.Setfield(Value, 226);
AS3.Validatefield(226);
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Newbie struggling with probe macro

Postby chap1 » Fri Feb 11, 2022 11:58 am

OK, thanks. The doc's gave the impression that wouldn't work. I'll give it a try.

Cheers, Gordon
chap1
 
Posts: 4
Joined: Tue Feb 08, 2022 8:50 am

Re: Newbie struggling with probe macro

Postby fixebr » Fri Feb 11, 2022 1:25 pm

In the examples I used as a basis, there was code
Code: Select all
exec.mainform.sumoffsetcontrol1.G54.newCzinput(0);

It works. It is possible to change the offset separately for different coordinate systems, the axis is selected in the word "zinput". (xinput, yinput and so on)
My English is bad, so you're reading machine translation results. Alas.
User avatar
fixebr
 
Posts: 40
Joined: Thu Dec 30, 2021 8:30 pm
Location: Russia, Moscow


Return to Macros

Who is online

Users browsing this forum: No registered users and 6 guests