Button for macroloop? And logging files loaded

If you have a question about the software please ask it here.

Button for macroloop? And logging files loaded

Postby MRob » Fri Sep 18, 2020 1:45 am

Hi!
Two quick questions, first I am wondering if it is possible to create a button in my screenset to toggle on and off a macroloop? I have the macro set into #1 slot for the macroloops, just be nice to have a main button for it. I can handle the creation of the button, just not sure what to assign to it.
Second, when I load a gcode file into uccnc, it doesnt seem that there is a display which shows the name of the file? And thinking about it, it would be really useful if every time I loaded a file, the name was displayed in the status log on screen (using exec.AddStatusmessage). Any advice on how to do this, would be great!
Thanks for your time,
Rob
MRob
 
Posts: 49
Joined: Wed Dec 04, 2019 10:10 pm

Re: Button for macroloop? And logging files loaded

Postby dezsoe » Fri Sep 18, 2020 8:59 am

Hello Rob,

You can get the file name in field 895 (AS3.Getfield(895)), but it is shortened if the path is too long. You can get the full path with exec.mainform.filenametoload.

Code: Select all
string shortname = AS3.Getfield(895);
string fullname = exec.mainform.filenametoload;

To enable/disable a macroloop you can use bi-state buttons. Let's say, your button number is 20000. In your macroloop:

Code: Select all
if (AS3.Getbuttonstate(20000))
{
  // Your code here
}

// If you have something after #Events then leave it as is:
#Events

// Your code here

You can toggle the button's state with a macro (M20000):

Code: Select all
AS3.Switchbutton(!AS3.Getbuttonstate(20000), 20000);

You can toggle the state only if no code is runnning. If you need to toggle the button while a code is running, then use this plugin with a button number 4000..4899 instead of 20000. (Of course, then you have to change the macroloop to check this button instead of the 20000.)
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Button for macroloop? And logging files loaded

Postby MRob » Fri Sep 18, 2020 10:40 am

Awesome, thanks for the quick response!

I created a super simple macroloop, copied below in case anyone else needs it, that just toggles once each time cycle start is pressed, and prints out the file name in the status box. It also prints out complete file path, which is OK for me as I have already expanded that box out, but might be a problem if anyone else wants to copy it.

Code: Select all
double firstRun=0;

while(loop)
{

if (AS3.GetLED(54)) {

   if (firstRun==0) {
      //exec.AddStatusmessage(AS3.Getfield(895));
      exec.AddStatusmessage(exec.mainform.filenametoload);   
      firstRun = 1 ;
   }
}
else{
   firstRun=0;
}

}


With the toggling of a macroloop using a button, that will work great, I'll get onto it later today. Which I guess also means that I can add the mcode value into the gcode, add the plugin you linked, and toggle whether the macroloop is active that way - which solves another problem for me. Although I am curious, is there any easier way to control a macroloop from gcode?
MRob
 
Posts: 49
Joined: Wed Dec 04, 2019 10:10 pm

Re: Button for macroloop? And logging files loaded

Postby MRob » Fri Sep 18, 2020 12:23 pm

Oh wait, answered my own question about toggling whether a macro is active from gcode, use exec.Setvar to set a value in a macro, and the macroloop then watches this value with Getvar. Easy! Nice.
MRob
 
Posts: 49
Joined: Wed Dec 04, 2019 10:10 pm

Re: Button for macroloop? And logging files loaded

Postby MRob » Sun Sep 20, 2020 3:34 pm

Another quick question - guess the answer is no, since UCCNC doesnt support lathes but asking anyway - is there any way to create a macroloop that produces continuous A axis rotation?? At present I have an external pulse generator that handles this for me, but pre-programming it to take commands from UCCNC would be a pain, a macroloop would be much easier. Although max A axis speed in UCCNC is a little low, at 1140RPM (using 360deg for units), but it could be useful anyway.
MRob
 
Posts: 49
Joined: Wed Dec 04, 2019 10:10 pm

Re: Button for macroloop? And logging files loaded

Postby MRob » Tue Sep 22, 2020 1:29 pm

Love to get an answer? Just a straight "no" would be fine!
MRob
 
Posts: 49
Joined: Wed Dec 04, 2019 10:10 pm

Re: Button for macroloop? And logging files loaded

Postby cncdrive » Tue Sep 22, 2020 2:51 pm

No, it is not possible to create an asyncronous A axis rotation.
What about using step/dir spindle mode and then you could use the step signal as frequency signal for the control.
It will be not A axis, but spindle though.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Button for macroloop? And logging files loaded

Postby MRob » Wed Sep 23, 2020 9:37 am

Thanks for the reply, and nice idea, but the issue is I want mill turn - so the ability to switch between continuous rotation, and then normal A axis rotation for carving. Never mind, was always going to be a long shot! I'll figure a way to do it myself with an external signal generator.
MRob
 
Posts: 49
Joined: Wed Dec 04, 2019 10:10 pm


Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 36 guests