Probing stock macro help

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

Probing stock macro help

Postby gabi68 » Thu Dec 27, 2018 7:53 pm

Hi to all,

I want to write a macro which will help me to probe a rectangular or circular stock. How I wanted that to work:
1. set G43 Hx (my probe is measured and entered in the tool table);
2. jog the probe down near the stock;
3. probe the stock from the X+ plus side (double probe);
4. set X to zero on the touch point;
5. probe will go up 5 mm or so and then continue to go X+ another 5mm
6. probe for Z zero
7. Now the tricky part:
I need to have a window with 2 radio buttons (1 for rectangular shape and 2 for circular shape)
3 fields (for rectangular shape - X length Y length and/or one for circular shape - diameter).
8. based on the values entered on the window fields the probe will travel (at Z measured before + 3mm) to a X measures + 5 mm
9 probe X - and Z up + 3
10. split that distance and go center X (of the stock).
11. repeat procedures for Y (to find center).

I can manage the probe procedures, but I don't know how to create the window and use the entered values for further calculations.
If something like this is already there tell me since I don't want to reinvent the wheel.
I contacted cahit via PM because his divideby2 plugin is very close to what I need (with some addition's), but I did not received an answer.
Any help will be very appreciated.

Thank you
Gabi
gabi68
 
Posts: 57
Joined: Wed Dec 07, 2016 10:35 pm

Re: Probing stock macro help

Postby Dan911 » Fri Dec 28, 2018 8:28 am

On Xmas vacation and have some play time, I expended on the example form from the UCCNC manual.

Dress the form up as you like, I added keypress events on textbox's to only allow digits and 1 decimal are allowed. I commented in macro where to add rectangle and circle probe macro's.

Test Form.JPG
Test Form.JPG (20.43 KiB) Viewed 11670 times


M21222.txt
(4.93 KiB) Downloaded 670 times
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Probing stock macro help

Postby Dan911 » Fri Dec 28, 2018 6:47 pm

I realized you may need negative values for the X and Y textbox's so replace X and Y keypress events with code below. This will allow minus sign(negative) only on start.

Don't mean to insult if mentioning the obvious but.... these textbox strings will need to be converted to double to use in your probe macro's.

Have Fun,
Dan

Code: Select all
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
                   (e.KeyChar != '.') && (e.KeyChar != '-'))
            {
                e.Handled = true;
            }

            // only allow one decimal point
            if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
            {
                e.Handled = true;
            }

            //0nly allow minus on start
            if (e.KeyChar == '-' && (textBox1.SelectionStart != 0 || textBox1.Text.Contains("-")))
            {
                e.Handled = true;
            }
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Probing stock macro help

Postby Dan911 » Sat Dec 29, 2018 9:18 pm

Hi Gabi, I hope you don't mind but going to answer your PM here, it's threads like this that help others.

There are many probe macro's available that can easily be edited to what you want/posted. For starters take a look in your default macro folder(M31).

Check out A_Camera thread/macro's that can be found here.... viewtopic.php?f=9&t=538

Also, you can purchase the 2017 screenset..... http://www.thecncwoodworker.com/2017.html the macro's alone are well worth the 20 buc cost. There is also a Macro thread on the zone.

As far as the TextBox being strings...............

double Tbox1 = Convert.ToDouble(textBox1.Text)
double Tbox2 = Convert.ToDouble(textBox2.Text)
double Tbox3 = Convert.ToDouble(textBox3.Text)

Take a look at some of the probe macro/links I posted and any questions I will be happy to help.

Dan
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Probing stock macro help

Postby gabi68 » Sun Dec 30, 2018 2:07 pm

Hi Dan,

Thank you for your answer. I still struggle. Programing is not my forte. That being said I need help with:
- where should i put that 3 lines of code
double Tbox1 = Convert.ToDouble(textBox1.Text)
double Tbox2 = Convert.ToDouble(textBox2.Text)
double Tbox3 = Convert.ToDouble(textBox3.Text)
- where should I put the values (variables) introduced by the user (in the X,Y fields) in order to have the right movement?

exec.Code("G31 X" + Xmin + " F" + ProbeFeedrate);
while(exec.IsMoving()){}
exec.Wait(100);
Console.Beep();
exec.Code("G92 X0"); // Zero the X-axis
exec.Code("G00 X" + XYClearance); // Safe X retract
while(exec.IsMoving()){}
exec.Wait(100);
Thank you
Gabi
gabi68
 
Posts: 57
Joined: Wed Dec 07, 2016 10:35 pm

Re: Probing stock macro help

Postby Dan911 » Sun Dec 30, 2018 3:38 pm

Hi Gabi,

I didn't give any thought to this other than what you requested in post. My form example was taken from the UCCNC manual and I expanded with textboxes and checkbox's to show how to use the textbox info based on what was checked. With that being said......

Looking at first line of program>>>> exec.Code("G31 X" + Xmin + " F" + ProbeFeedrate);

Xmin is a variable for "X"
ProbeFeedrate is a variable for "F"( feedrate)

In the start of the macro you would declare these variables.

string Xmin = textbox4.text;
string ProbeFeedrate = textbox5.text;

or

double Xmin = Convert.ToDouble(textBox4.Text);
double ProbeFeedrate = Convert.ToDouble(textBox5.Text);

Since a probing macro can be complicated I suggest using a written 1, read manual first before making any attempt in editing it. In the Documentation folder in your UCCNC directory there's tons of info.

Dan
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Probing stock macro help

Postby dezsoe » Mon Dec 31, 2018 7:17 pm

Hi Gabi,

You could check the latest test version for a probing collection.
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Probing stock macro help

Postby Dan911 » Tue Jan 01, 2019 1:59 am

dezsoe wrote:Hi Gabi,

You could check the latest test version for a probing collection.


Wow....Looks great!!!!
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Probing stock macro help

Postby gabi68 » Tue Jan 01, 2019 11:30 am

Hi,

WOOOWW indeed. Looks great. A little "how to" video will be great (not to miss anything). Sadly does not work in demo mode :D . Garage time then. Thank you for this.

Gabi
gabi68
 
Posts: 57
Joined: Wed Dec 07, 2016 10:35 pm

Re: Probing stock macro help

Postby dezsoe » Tue Jan 01, 2019 11:52 am

Hi,

I didn't make any videos, I think the drawings, the status line and the detailed doc should be enough. Take care of the C clearance: it has to be negative to lower the Z when finding outers. The dot on the mode buttons always shows where the probe has to be when you start a probing sequence.
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Macros

Who is online

Users browsing this forum: No registered users and 5 guests