Page 1 of 2

M61 T# macro fquestion

PostPosted: Wed Jul 24, 2024 11:15 pm
by bhdavis
On my new Rapidchange ATC tool changer I type M61 T# to change the number of a tool in the spindle if needed. It's not needed often but does come in handy occasionally.

I'd like to create a screen button for the command. However I'm not sure how to code the macro so it asks me for the tool number to use. I think I can create a pop-up box but it's been a while since I did that. Then further though I don't have a clue on how to make a tool number I insert in the pop-up box get assigned to the tool in the spindle.

Could someone point me in the right direction?

Thanks,
BH

Re: M61 T# macro fquestion

PostPosted: Fri Jul 26, 2024 11:11 am
by bhdavis
I created a test macro M20099 with the following:

// test input box

string val = exec.TextQuestion("Enter loaded tool number.");

exec.Code("M61 T()");


I get the popup box and can enter a tool number but it does not record it on the T# data cell on screen. If I replace the () with a tool number, i.e. M61 T5, that works.

So the macro concept works but not the part where what I enter for a tool number in () gets recorded on screen.

I imagine I'm way off here on the concept of how to do this but thought I'd try a few things.

BH

Re: M61 T# macro fquestion

PostPosted: Fri Jul 26, 2024 11:40 am
by ger21
Try this:

Code: Select all
string val = exec.TextQuestion("Enter loaded tool number.");
string toolch = "M6 T" + val;

exec.Code(toolch);

Re: M61 T# macro fquestion

PostPosted: Fri Jul 26, 2024 12:25 pm
by bhdavis
Thank you Gerry. Worked perfectly.

BH

Re: M61 T# macro fquestion

PostPosted: Fri Jul 26, 2024 6:36 pm
by bhdavis
Drats.....forget that "works perfect" comment above. I posted that after trying it in Demo mode and before putting it on the CNC.

What you gave me was basically calling for a tool change from one bit to another. I already have that covered with my individual buttons as you'll see in the attached screen shot.

What I need is to rename a tool that is already in the spindle.

Say for example I'm doing some alignment testing on the tool rack. I might have T3 in the spindle but my open holder is T1 and I want the tool in the spindle to be renamed T1.

What I would type in the MDI is: M61 T1

That would change the tool recorded in UCCNC from T3 to T1.

Or if I had no tool in the spindle but T1 etc was recorded in UCCNC, then typing: M61 T0 would change the recorded tool to T0.

So instead of having to type M61 T# I could just push the screen button and it would ask me for the number.

Thanks Gerry,
BH

Re: M61 T# macro fquestion

PostPosted: Fri Jul 26, 2024 8:48 pm
by bhdavis
Okay. Here is your suggested code:

string val = exec.TextQuestion("Enter loaded tool number.");
string toolch = "M6 T" + val;

exec.Code(toolch);

which executes a tool change.

******************************************************************************************************************

Here is my working M61 T# code that changes the existing recorded tool to a new T# when I type M61 T# in the MDI box:

int newTool = exec.Getnewtool();

if (newTool < 0)
{
return;
}
else
{
exec.Setcurrenttool(newTool);
}

**************************************************************************************************

I've combined the two as follows (plus numerous other ways):

string val = exec.TextQuestion("Enter loaded tool number.");

string Setcurrenttool(newTool); = "M61 T" + val;

exec.Setcurrenttool(newTool);


but am getting a code error message when entering this macro into the MDI. Obviously I'm only guessing as I don't have much background in doing this.

*****************************************************************************************************


Thoughts?

Thanks for you time,
BH

Re: M61 T# macro fquestion

PostPosted: Sat Jul 27, 2024 7:19 pm
by ger21
If I understand correctly, you just need this:
Code: Select all
string val = exec.TextQuestion("Enter loaded tool number.");

exec.Setcurrenttool(val);

Re: M61 T# macro fquestion

PostPosted: Sat Jul 27, 2024 8:27 pm
by bhdavis
Thanks Gerry. I'll give it a try shortly. I just hauled home a used Minimax S45 18" bandsaw and need to unload it before playing with the CNC.

BH

Re: M61 T# macro fquestion

PostPosted: Sat Jul 27, 2024 10:31 pm
by bhdavis
Gerry,

I get "script errors" when I run that last suggestion. But, yes, I think you understand what I'm trying to do.

BH

Re: M61 T# macro fquestion

PostPosted: Sun Jul 28, 2024 5:24 am
by dezsoe
Here it is fixed:

Code: Select all
double val = exec.Question("Enter loaded tool number.");
exec.Setcurrenttool(Convert.ToInt32(val));