Need help with a macro

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

Need help with a macro

Postby 1JUMPER10 » Wed Nov 08, 2017 4:32 am

Hi all. I'm trying to use a button and a Macro to activate a relay on Port 1, Pin 1. I used a macro that Ger21 had written and posted on this forum for another member and modified it for my purposes and made a button to call it. It worked as expected. The problem was my expectations were incorrect. The function of the relay is to be an override for a safety circuit so I can recover from a Reset condition. Like I said, in normal operation it works as expected, closing the relay on the first push, releasing it on the second. The problem is that it needs to work when the software is in Reset. UCCNC wont allow me to push the button when its in Reset. Here is the text of the macro:

bool buttonstate = AS3.Getbuttonstate(20001);
int Port=1;
int Pin=1;

if (buttonstate)
{
exec.Setoutpin(Port,Pin);
exec.AddStatusmessage(" OSSD NORMAL");
AS3.Switchbutton(false,20001);
}
else
{
exec.Clroutpin(Port,Pin);
exec.AddStatusmessage(" OSSD OVERRIDDEN");
AS3.Switchbutton(true,20001);
}
while (exec.IsMoving()){} // Wait for exec.Code to finish

Is it possible to make this work while in Reset?
1JUMPER10
 
Posts: 48
Joined: Tue Oct 04, 2016 1:54 am

Re: Need help with a macro

Postby Robertspark » Wed Nov 08, 2017 7:27 am

I don't think it is possible via a macro or onscreenset button.

It may however be possible via plugin....

The reason is because the problem is the screenset (AS3) object you are pressing and trying to toggle, where as the Reset condition is set to ignore the screenset interface inputs in everything but the reset change of state {this at least is my understanding of the reset button}

Whereas if you had a floating button on a plugin all you are doing is toggling pins on a port and have no screenset interaction, you have effectivly bypassed the reset safety feature.
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: 988
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Need help with a macro

Postby 1JUMPER10 » Wed Nov 08, 2017 8:40 am

Ok Thanks Robert. I don't think calling a Plugin is a path I want to go down. It seems complicated, probably because I'm not that familiar with using plugins. Maybe its more simple than I'm thinking.
Another way I thought might be possible to accomplish the same thing was creating an LED and linking port 1, pin 1 output to it. I'm just not sure what condition I could monitor with an LED that would work. I tried it with LED 25, the Reset LED and it oscillated on and off. If I cant do this with a software/macro/LED solution I'll wire up a physical switch directly to the board's override input.
1JUMPER10
 
Posts: 48
Joined: Tue Oct 04, 2016 1:54 am

Re: Need help with a macro

Postby ger21 » Wed Nov 08, 2017 11:45 am

Why not just use a momentary pushbutton, and bypass UCCNC altogether?
Gerry
UCCNC 2017 Screenset - http://www.thecncwoodworker.com/2017.html
ger21
 
Posts: 1143
Joined: Sat Sep 03, 2016 2:17 am

Re: Need help with a macro

Postby cncdrive » Wed Nov 08, 2017 11:46 am

Dezsoe will help you with the macro soon.
cncdrive
Site Admin
 
Posts: 2260
Joined: Tue Aug 12, 2014 11:17 pm

Re: Need help with a macro

Postby Robertspark » Wed Nov 08, 2017 12:11 pm

I'd be interested to see how Dezsoe does it?
__________________________-
1Jumper10

What exactly are you trying to accomplish with the pin + button {what do you want it for / what does it do, other than the obvious of the macro}

What does OSSD stand for?

______________________________
Normally if I am working directly with pins and ports, instead of checking the state of the button {a created screenset button state} I would recommend checking the physical state of the port + pin and then running your macro to toggle the state + set the screenset button.
The reason why I do it this way was if for instance you had something else that could toggle that same port + pin then the buttonstate may not be correct.
Just something to consider when using buttonstate to check a physical output state that may be able to be toggled via something else
Last edited by Robertspark on Wed Nov 08, 2017 12:29 pm, edited 1 time in total.
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: 988
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Need help with a macro

Postby 1JUMPER10 » Wed Nov 08, 2017 12:28 pm

Gerry - The momentary switch is an option. Its just that the K1 relay is already there on the board and not being used. If it can be made to work then it represents a nice, neat solution. That and I'm learning a little about screen editing, buttons and macro's.

Robert, OSSD stands for "output signal switching device". I'm using a UB1 board and the OSSD circuit is a latching safety circuit. I have it monitoring my "ok" signals from all my servo's, and my VFD and my E-stop switch. All the inputs have to be "OK" or the OSSD sends the E-stop input to UCCNC and the machine goes in to re-set. The OSSD when it is faulted such as when the machine is in Reset, or a servo malfunctioned, requires an override input to unlatch and return to normal. Much like the "override limits" soft button lets you clear a Reset and jog off a limit switch. I am trying to use an onboard relay on the UB1 as this override input. The onboard relay is linked to port 1, pin 1 output.

Thank you Dezsoe.
1JUMPER10
 
Posts: 48
Joined: Tue Oct 04, 2016 1:54 am

Re: Need help with a macro

Postby Dan911 » Wed Nov 08, 2017 12:48 pm

I put your macro in a the button event in plugin and should run.

The button# needs to be 22222 for button used in UCCNC.

You will get a false Statusmessag that macro can't be read, just create a Blank macro 22222 if this bothers you.


Pin1.zip
(2.49 KiB) Downloaded 53 times
Dan911
 
Posts: 423
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Need help with a macro

Postby Dan911 » Wed Nov 08, 2017 1:21 pm

I did this quickly and just seen I had the Switchbutton bools reversed, if you think you will find this of use let LMK and I fix.
Dan911
 
Posts: 423
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Need help with a macro

Postby Dan911 » Wed Nov 08, 2017 1:42 pm

I see 3 downloads so I just fixed to match macro you posted.

Pin1.zip
(2.49 KiB) Downloaded 46 times
Dan911
 
Posts: 423
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 2 guests