Toggle Type User Button linked to Macro

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

Toggle Type User Button linked to Macro

Postby Robertspark » Wed Oct 03, 2018 11:30 am

Anyone got a way of using a toggle type user button to trigger a macro which will check the state of the button and trigger the macro if the button state is True and another part of the macro if the state is false?

I thought about getting the macro to check a var# for a specific value, and if it was not correct to run part A of the macro, and set the var# to say value "9876", and if the var# was = to value "9876" to run part B of the macro and clear the var# for next toggle use.

Is there another way?

Terry got me thinking about an alternative to the default feedhold button, and getting it to run a custom macro which
checks a var# flag, if FALSE {
checks and saves if active to vars# M3,M4, M7, M8, M10+Q{not sure if possible}, M205, M207, M209, M211 (customise as applicable to machine)
run cycle stop (stops the machine with deceleration + runs M5 & M9 & M11)
saves the 6 axis co-ordinates to vars#
saves set feedrate to vars#
saves set spindle speed to vars#
retracts Z to safeZ
sets a var# flag
/return from macro
}
checks a var# flag, if TRUE {
moves machine to safe Z
moves machine to saved vars# X,Y,A,B,C
move machine to saved var#Z
set feedrate to saved var#
set spindle speed to saved var#
enable if saved vars# set M3,M4, M7, M8, M10+Q{not sure if possible}, M205, M207, M209, M211 (customise as applicable to machine)
(presume all set delays are correct to allow sufficient spindle spinup + coolant etc, if plasma, move M3+M10 to suit cyclestart)
clear all vars# (flag, X,Y,Z,A,B,C,feedrate, spindle speed, M3, M4, M7, M8)
run cycle start
/return from macro
}
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 1008
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Toggle Type User Button linked to Macro

Postby ger21 » Wed Oct 03, 2018 12:10 pm

Something like this?

Code: Select all
bool buttonstate = AS3.Getbuttonstate(20328);

if (buttonstate)
{
   AS3.Setcheckboxstate(false, 228);
   AS3.Switchbutton(false,20328);
}
else
{
   AS3.Setcheckboxstate(true, 228);
   AS3.Switchbutton(true,20328);

}
Gerry
UCCNC 2017 Screenset - http://www.thecncwoodworker.com/2017.html
ger21
 
Posts: 1155
Joined: Sat Sep 03, 2016 2:17 am

Re: Toggle Type User Button linked to Macro

Postby Vmax549 » Wed Oct 03, 2018 1:21 pm

Hi Robert, I tried that ;) . There were several problems.

1 You cannot run a macro with a Gcode program running. SO the gathering of STOP data has to be done internally in UCCNC. THink macro loop OR plugin and monitor teh Cycle stop button number 8-) to run teh data gathering .

2 OR UCCNC has to let us have a couple of macro numbers that WILL let you interupt a Gcode program.

3 OR UCCNC has to allow a alias macro that is triggered by teh FeedHold Button so w can build our OWN data gathering macro

3B when you press STOP it shuts OFF teh spindle and M8 so when the function ends you do not know at that point what the state of teh spindle or coolant was ( M3,M4 ? M7,M8 ? )

4 There is a chance your button will get out of sync with itself. You would need heavy error trapping and a scheme to create a default condition. BUT see rule 1 .

5 There is more data you need. You need ALL teh modal data that was in PLAY at teh time you Feedhold to be able to restart safely (G0 G1 G2 G3?, G90 G91?, etc) as you NEVER know what may be done while you are in feedhold :o . You are free to do ANY function you please before you resume ;) So you need ALL teh data to be able to resume.

6 Plasma and mill restarts are 2 totally different CATS :)

ALSO for safety's sake I do not like single button functions that restart motion IF they can get out of 100% sync. MURPHY will get you every time sooner or later. Been there done that one. ALSO I prefer the OP to restart teh Spindle as one last safety check. I had planned a Window event similar to the RFH window for teh resume side.
That way it can be a safety check before resuming.

I am still working on it myself. I will let you know if I run into anything else.

Just a thought, (;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Toggle Type User Button linked to Macro

Postby Robertspark » Wed Oct 03, 2018 2:03 pm

Thanks Terry,

1) yes, not thought about in my haste.....

2) don't think that will happen

3) see 2, but it would be helpful to allow more options

3B) thats why I proposed gathering the active M-codes before the cycle stop

4) probably

5) .... the thought was for simple jog away tasks, change plasma tip, tool change (replacement) clear swaff whatever..... just jog in feedhold.

6) yes.... but that is why I was highlighting the thought process / consideration.

I see your point with single toggle button operation..... maybe best resort to two buttons

Oh, thanks Gerry, I'll have a think over it tonight
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 1008
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Toggle Type User Button linked to Macro

Postby Vmax549 » Wed Oct 03, 2018 5:34 pm

I have been working with " AS3.Getbuttonstate(130) " from a Macroloop to get around teh problem of NOT being able to run a macro while teh Gcode is running and cannot get it to respond. Matter of fact I have not been able to get ANY button press to respond from a macroLoop

if(AS3.Getbuttonstate(130)==true)
{
MessageBox.Show("Test STOP");
}

HERE it does not respond at all. I can invert teh logic and it works BUT will not respond when the button is pressed or held down.

Probably something I do not understand about it yet.

(;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Toggle Type User Button linked to Macro

Postby dezsoe » Wed Oct 03, 2018 5:58 pm

The Getbuttonstate function is for bi-state buttons (like M3 etc.), you cannot get the "pressed" state with it. Try the Getbutton function.

(From the docs: "Example: while(!AS3.Getbutton(128)); //Waits for the cycle start button press on the main screen.")
dezsoe
 
Posts: 573
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Toggle Type User Button linked to Macro

Postby Robertspark » Wed Oct 03, 2018 6:22 pm

If you were saving the current position, with a view to restoring that position later, would you save the current machine coordinates AND the current work offset, AND the current work offset coordinates.

That way when you returned to the previous position you would ensure it is the ACTUAL previous position.... And if something had happened to the work offsets (for whatever reason) you have a means to restore the ACTUAL previous position.

As I'm just typing and thinking.. :roll: .. If these values were saved to text file.... In theory.... It would be possible to shut everything down and reboot and re-home the machine and pick up from where you left off?
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 1008
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Toggle Type User Button linked to Macro

Postby Vmax549 » Wed Oct 03, 2018 8:20 pm

HIYA Robert I have the basics working now. It senses when the Stop button is pressed and records teh XYZ positions to #vars. Then the Resume button returns it back to the return positions ready for a restart. Press {CycleStart} to resume teh program run.

I am not crazy about using a MacroLoop for that though. I prefer a dedicated macro that is triggered directly from teh Cycle Stop function.
Attachments
Resume.jpg
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Toggle Type User Button linked to Macro

Postby Vmax549 » Wed Oct 03, 2018 8:35 pm

I don't think a COLD restart would work because there would be NOTHING in teh buffer to tell UCCNC to start exactly at the restart point. It could ONLY restart from teh beginning of a Line RFH works well for that.

Now for plasma teh restart should work well. The CycleStop records teh POS and teh return would move back to position and then do a Top of material routine to set teh torch height for pierce then fires the torch and resume.

Even with a flameout it should recover nicely

You could even restart from the middle of an arc.

I did a LOT of feature routines for Plasma 8-)

(;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Toggle Type User Button linked to Macro

Postby Robertspark » Wed Oct 03, 2018 8:38 pm

I don't think I'd be keen about using the cycle stop and cycle start buttons....I'd prefer two separate buttons to avoid confusion.... Stop should be stop.... Start should be start.

Not the same as cycle pause and resume or some other term
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 1008
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 4 guests