Would some kind person write me a simple macro?

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

Re: Would some kind person write me a simple macro?

Postby dezsoe » Fri Sep 15, 2017 4:24 am

And if you use that range for DROs, UCCNC will save their values to your profile on exiting. If you need them later, you can load back their last values. Sample from my profile:

Code: Select all
[UserTextfields]
20601=No tool
20602=6
20603=
20604=600
20605=1.6
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Would some kind person write me a simple macro?

Postby A_Camera » Fri Sep 15, 2017 6:34 am

Greolt wrote:On my Milling Machine I occasionally use spindle reverse but this is for a router and I never use reverse.

The only reason why I implemented the reverse rotation is compatibility with UCCNC function and for fun/test purposes to see how fast my VFD can reverse the motor without overcurrent some other alarms. I never bothered to remove that part but of course, removing would simplify the macro if you don't need it and not interested in playing with it.
A_Camera
 
Posts: 638
Joined: Tue Sep 20, 2016 11:37 am

Re: Would some kind person write me a simple macro?

Postby Greolt » Fri Sep 15, 2017 8:03 am

When I first got a VFD controlled via Mach3, I did the same. Just to see what could be done.

It meant getting the VFD and Mach3 settings all correct. Yes it would go from full speed CW to full speed CCW. Fun to watch.

However after that I simplified it all down to only what I need.

Haven't even bothered with the settings for reverse in this VFD.
Greolt
 
Posts: 230
Joined: Sun Sep 04, 2016 6:22 am

Re: Would some kind person write me a simple macro?

Postby Greolt » Sun Sep 17, 2017 11:19 pm

This simple little macro that is used as a macroloop only has a few lines and is not time critical.

So I am wondering if I should add a delay just to lighten the load.

Thread.Sleep(20);

Is this good practice? Is it correct syntax?
Greolt
 
Posts: 230
Joined: Sun Sep 04, 2016 6:22 am

Re: Would some kind person write me a simple macro?

Postby cncdrive » Sun Sep 17, 2017 11:48 pm

There is a built in Thread.Sleep at the end of the macro loops as explained in the UCCNC manual.
When the code execution reaches the end of the macro then the Sleep is executed and only after runs the macro again.

You only have to place your own Sleep code if you not allowing the macro code to reach to the end, for example if you embed your own loop inside the macro loop, for example:

Code: Select all
while(true)
{
  // Do something...
}


In this case there will be no built in sleep, because the macro will never reach the end of the code. The code execution will circulate inside your own loop, so you then have to add your own Sleep code to avoid overloading the computer, like:

Code: Select all
while(true)
{
  // Do something...
  Thread.Sleep(10);
}
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Re: Would some kind person write me a simple macro?

Postby Greolt » Sun Sep 17, 2017 11:55 pm

Thanks for that.

I see now the section in the manual.

Should have seen that first. :oops:
Greolt
 
Posts: 230
Joined: Sun Sep 04, 2016 6:22 am

Previous

Return to Macros

Who is online

Users browsing this forum: No registered users and 3 guests