Tool height Setting Macro

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

Tool height Setting Macro

Postby ThreeDJ16 » Mon Sep 02, 2019 8:21 pm

Ok, I've been playing with the latest beta releases and had heard previously mentioned that tool table setup would be available at some point. I'm hoping but currently don't see a way to accomplish the work flow I am looking for. Maybe someone has already done it and I've missed it? Guess my question is how are those of you using fixed tools running through your table and setting up all your tools initially and then if you break a tool?

So obviously no programmer here (but basic understanding, which isn't obvious in the mess below as I just chunked the larger files together today), and this obviously doesn't work. Did manage to get it parts working separately thanks to Gerri and whomever wrote the fixed tool probe macro. But I wanted something that flows automatically instead of 1) Changing the tool number 2) Moving to a probe measurement area (which is set to tool change position) 3) Setting zero at the fixed probe location with reference tool 4) changing to next tool 5) using tool measure macro to measure tool and write to tool table 6) Rinse and repeat the last two steps

What I have been bastardizing all weekend...yeah, I'm slow. Is a compilation of Gerri's macros and the tool height set to table macro. I managed to get the first part working where it asks to start the macro y/ n , then requests a tool number with 0 exiting the routine and anything above 1 sends you on (and loops back to the tool number). Next I added in if tool 1 was selected, it takes you to set zero at the probe location, moves there and probes. Any tool above 1 just runs the tool height measure portion. So after I added in the last two sections, it all went to crap. Ok, honestly it's all crap as I'm not programmer, just hacking up someone else's work. But I'm learning slowly how things work C#. I also know that Jerri's code uses some of his custom fields, which will have to be changed.

Also don't want this macro to mess with G54-G59 in case you break a tool in the middle of an operation. Haven't gotten far enough along to figure out if I need to use the temp offset or just reset the DRO to its original offset. Still pondering how that portion works as I've always just worked in G54 space.

So if anyone has something in place that is similar, I'd love to see it it you don't mind sharing. Otherwise, here is my mess of a start to this semi-automated tool height measuring routine. Previously it was just one small file which fired off other macros, but wasn't sure how to loop things to continue asking for new tools. Thought making one file would be easier and of course I'm wrong...LOL. Anyway, I'm just really getting started learning C#, so don't judge too harshly on this mess. I think it does at least outline what I'm trying to accomplish.

M20599.txt
(645 Bytes) Downloaded 273 times


Also, I'm using notepad++ with the UCCNC style and other files added. But the compiler error file always gives me the wrong line numbers for the errors. Is there a work around or fix for that? It would help a lot if I knew which line to find all my errors...LOL.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Mon Sep 02, 2019 9:16 pm

Should have titled this semi-automatic tool height measuring macro. Also, eventually a second completely automatic tool height measuring for the tools in an ATC....one day.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Tue Sep 03, 2019 8:01 pm

D'oh.....Crap....sorry. I uploaded the wrong file. I was saving my work in progress file into a profile and not to the original starting file on my desktop.

My apologies to anyone who downloaded it. Any guidance would also be appreciated. I will start back working on it this weekend.

M20599.txt
(12.62 KiB) Downloaded 258 times
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Fri Sep 06, 2019 7:49 pm

Well, down to one error now I can't seem to work out. So of course I haven't been able to test whether it will work or not yet. But one step closer, yet still a long way to go. :roll:

Still curious how others with fixed tool heights handle this operation? Manually?

M20599.txt
(11.04 KiB) Downloaded 259 times
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sat Sep 07, 2019 12:29 am

Yah, no compiler errors.....LOL. Small victory, but at least it's progress. And I'm seeing and understanding more of what my errors are now. Also started reading a lot of great information from that UCCNC Macro PDF someone was kind enough to write. Not sure how I've missed seeing that before, but glad I found it.

Unfortunately now it's time to get the details of the macro actually working..LOL. Little by little, getting there. But most of the macro is actually working now.

M20599.txt
(11.18 KiB) Downloaded 263 times
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sat Sep 07, 2019 3:13 am

You'll rarely ever hear me state anything good about the other guys (Acorn), but when I was programming PLC code for my lathe turret, they have a damn nice debugger program. Lets you step through the program, see any variable state, set conditions up and really made programming nice. But on the flip side, it was a really funky PLC type code they used and hard to understand. At least C# is readable where their crap wasn't since it used mem locations mostly.

But the last tool height measure macro I posted is finally to the point where it's time to see what's going on within the program and getting the inner workings correct. I'm thinking the only way to see what's happening inside the macro is to post values into messages? Curious what other folks were using for debugging? I have MS Visual Studios, but didn't see a way to get any further debugging with it. So sorta banging my head trying to figure out a good way to see variables values at different stages so I can solve a few issues.

Anyone have any suggestions on debugging? Really want to learn more as I have a lot more macros I want to write.

Oh yeah, for anyone who did DL the macro, I know my while loop was done stupid, but after I locked up the computer twice decided no more of that. I'll go back and clean that up once I'm finished and find out how I was locking things up. It was odd, as there was a return at each step off, so couldn't see where it got stuck. Anyway, a proper example of how I should have it setup would be appreciated. Never really done anything where I needed a continuous loop and enter 0 to exit it before. But thought for tool setup, it might workout nicely rather then keep hitting buttons.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby cncdrive » Sat Sep 07, 2019 5:44 am

There is a console plugin in the plugins. You can enable that and then the Console.Write and Console.Writeline will be all redirected to that console plugin window. So you can write e.g. variable values in the console from your macro and see them in the console plugin window.
This feature is available in the newer dev.releases only though.

And there is no way to debug macros, because the macro compiler uses the .NET compiler (Codedom) and it gives no debugging options.
There would be another way for us to compile macros called Rosylin, which would give the option to debug everything, but it does not support older .NET frameworks than the version 4.5 and so then the UCCNC would not work then on Windows XP, so we did not make the move yet, because many people still using XP.
cncdrive
Site Admin
 
Posts: 3499
Joined: Tue Aug 12, 2014 11:17 pm

Re: Tool height Setting Macro

Postby ger21 » Sat Sep 07, 2019 11:17 am

I use Message Boxes to display values when things aren't working right. I do the same thing when writing plugins or programming in Visual Studio.
Haven't had a chance to look at your macro, been very busy lately.
Gerry
UCCNC 2017 Screenset - http://www.thecncwoodworker.com/2017.html
ger21
 
Posts: 1873
Joined: Sat Sep 03, 2016 2:17 am

Re: Tool height Setting Macro

Postby GaryLa » Sat Sep 07, 2019 12:23 pm

Per the documentation from MS, I don't understand why you're using Dispose in this manner: topform.Dispose();

"Disposes of the resources (other than memory) used by the Form." The MessageBox takes care of itself, why call Dispose for your "topform" after some MessageBox calls (but not all of them)?

Also, without placing some of this code after an "#Events" statement, my understanding is your "loop" variable will always be 1. Setting it to 0 and then returning will have no effect -- it gets reloaded again to 1.

Code: Select all
int loop = 1;

while(loop > 0) ....
loop = 0;  //unless this is global, this statement has no actual effect
return;
GaryLa
 
Posts: 67
Joined: Thu May 30, 2019 11:30 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sat Sep 07, 2019 5:38 pm

cncdrive wrote:There is a console plugin in the plugins. You can enable that and then the Console.Write and Console.Writeline will be all redirected to that console plugin window. So you can write e.g. variable values in the console from your macro and see them in the console plugin window.
This feature is available in the newer dev.releases only though.

And there is no way to debug macros, because the macro compiler uses the .NET compiler (Codedom) and it gives no debugging options.
There would be another way for us to compile macros called Rosylin, which would give the option to debug everything, but it does not support older .NET frameworks than the version 4.5 and so then the UCCNC would not work then on Windows XP, so we did not make the move yet, because many people still using XP.

I'm using the latest test releases, so I'll look into this. Thank you.

I wonder how many people still do use XP? Funny how every other version of Windows was total crap. Like Vista, 8 and so on where XP, 7 and now 10 were all great. Hopefully now that Windows has quit with using naming for it's newer version and will just be releasing "Updates" maybe one day we'll all be on the same page. I prefer to keep my older computers on the latest Windows versions simply due to driver support being discontinued for older version.

FYI, there was still a door for people to upgrade for free to Win10. I upgraded my mill laptop long after the official upgrade window closed using the media creation tool door, but it only works for Win 7 and 8 with an official licensed copy. Just to be clear, this is nothing illegal or a hack, crack or anything else. It's provided through official windows servers if anyone is interested.
Last edited by ThreeDJ16 on Sat Sep 07, 2019 6:08 pm, edited 1 time in total.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 4 guests