Hello Guest it is April 28, 2024, 05:22:27 PM

Author Topic: Execute Button Script with button configured screen designer  (Read 894 times)

0 Members and 2 Guests are viewing this topic.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Execute Button Script with button configured screen designer
« Reply #10 on: January 26, 2024, 09:25:23 AM »
ok, the example code i posted has to be in macropump.m1s witch is located in your
macro folder. normaly C:\Mach3\macros\'your profile name'

this macro is running automaticly cyclic if it is enabled in Config->General Config->Run Macro Pump

as soon as enabled and Mach3 is up it will "look" cyclic for UserLed(1500) and as it becomes
true the code witch is in the If Then EndIf will be excecuted.

your brain will only read modbus input (your external start button) and the set UserLed(1500) true
when the button is pressed. you have nothing to do in your screenset, except copying the code from
start button into the macropump macro.   
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Execute Button Script with button configured screen designer
« Reply #11 on: January 26, 2024, 09:47:19 AM »
you were clear from the beginning, I understood from your explanation that I should have copied the program into macropump etc.. etc...
I was wondering if there was a way to leave only one script in macropump by removing it from the start cycle button so as not to create a duplicate script.
in this case I need a call from the start cycle button in the panel to userled 1500 contained in the macropump script to be able to use both buttons, both the external one in modbus and the one on the panel

I truly thank you for your availability and your help

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Execute Button Script with button configured screen designer
« Reply #12 on: January 26, 2024, 09:49:27 AM »
now i got you, you will have to use a seperate UserLed because brain will overwrite UserLed(1500).
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Execute Button Script with button configured screen designer
« Reply #13 on: January 26, 2024, 10:11:09 AM »
OK understood.
but how do I assign it to user led from machscreen design?
with OEM code? as in the picture?

the right syntax is as I put in the image?
« Last Edit: January 26, 2024, 10:13:43 AM by Giuno85 »

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Execute Button Script with button configured screen designer
« Reply #14 on: January 26, 2024, 12:09:34 PM »
i would use oemcode(34) -> basic script
then in basic script window

Code: [Select]
SetUserLed(1503,1)

and then in macropump.m1s
Code: [Select]
If ((GetUserLed(1500) = True) And (GetUserLed(1501) = False)) Or (GetUserLed(1503) = True) Then
'insert your button code here
'.
'.

'Start machine
DoOEMButton(1000)
End If
'make sure we run the code only one
SetUserLED(1501,GetUserLed(1500))
SetUserLED(1503,0)
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Execute Button Script with button configured screen designer
« Reply #15 on: January 26, 2024, 06:03:35 PM »
I'm trying the script only the first part of the external button only but I'm struggling to make it work.
The image of the brain is when the external button is not pressed so when I don't press it it is at 1...
Is it correct to use the script you wrote to me with this situation?

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Execute Button Script with button configured screen designer
« Reply #16 on: January 27, 2024, 02:25:04 AM »
if you go to

Operator -> Brain Control -> select your Brain -> view Brain

can you see the branch getting green when you press the external start button?

have you restarted Mach3 after you added code to macropump?
you have to do this every time you change macropump script.

add for test this code:
Code: [Select]
msgbox("i was here")
to macropump to chech that it's running.



anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Execute Button Script with button configured screen designer
« Reply #17 on: January 27, 2024, 09:51:45 AM »
if you go to

Operator -> Brain Control -> select your Brain -> view Brain

can you see the branch getting green when you press the external start button?


yes I see it turn green, using Invert as action and I also tried using pass signal.
Both work. as attached image (imm-a)-(imm-b)


have you restarted Mach3 after you added code to macropump?
you have to do this every time you change macropump script.


yes I did and as an image (imm-c) it works

Re: Execute Button Script with button configured screen designer
« Reply #18 on: January 27, 2024, 10:00:23 AM »
can't fit into the "if"
It works if I use in Brain (invert) as an action see (imm-a) and modify the script with

If ((GetUserLed(1500) = False)

 as I attach the complete script image (imm-d)

can I leave it like this or is it a mistake?

it seems to work (imm-e) but I don't know if it can cause problems, is there something I did wrong in the script?
Re: Execute Button Script with button configured screen designer
« Reply #19 on: January 27, 2024, 10:48:20 AM »
IS THIS WAY ONLY DONE ONCE?