Page 1 of 1

Newbie struggling with probe macro

PostPosted: Tue Feb 08, 2022 10:09 am
by chap1
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

Re: Newbie struggling with probe macro

PostPosted: Tue Feb 08, 2022 11:44 am
by ger21
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

Re: Newbie struggling with probe macro

PostPosted: Tue Feb 08, 2022 11:53 am
by chap1
Thank you.

Re: Newbie struggling with probe macro

PostPosted: Fri Feb 11, 2022 11:22 am
by chap1
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

Re: Newbie struggling with probe macro

PostPosted: Fri Feb 11, 2022 11:47 am
by ger21
For X axis,

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

Re: Newbie struggling with probe macro

PostPosted: Fri Feb 11, 2022 11:58 am
by chap1
OK, thanks. The doc's gave the impression that wouldn't work. I'll give it a try.

Cheers, Gordon

Re: Newbie struggling with probe macro

PostPosted: Fri Feb 11, 2022 1:25 pm
by fixebr
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)