Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: Giuno85 on January 23, 2024, 06:02:52 AM
-
Hi Graham, the script you made works great I tried it.
I would like to ask you, since I control the start cycle from an external button via Modbus and Brains.
I tried to command the button by setting execute button script at the lobe termination, but it doesn't work.
can you help me?
-
Mach3 brains is not my strong point maybe one of the other members can help you on this one.
-
as far i know there is no direct way to run a VB Script via brain.
your screen button is excecuting your VB instructions and at the the end is call's
the DoButton for Start.
your brain will only excecute the DoButton Start and not the Butttonscript witch is "behind"
the button on your screen.
a possible way might be to set a OEMLed in your brain and the macropump script, witch
is running continious, will react to this OEMLed and excecute the VB commands + do
the start.
vou have to make sure that the code will be only done once if the OEMLed comes true.
and pls avoid double post's.
-
thank you very much for the reply, I also published the topic on the forum in the screen designer section.
So I have no way to call a new button created on machscreen with my brain?
Is it possible to call an assigned hotkey with the brain?
the problem is that I customized the start call by doing other things and that's why I modified the button
sorry, I created several posts because it is a topic that touched more than one topic in the forums :-[ :-[
-
you can copy your code from Start Button into macropump 1 to 1.
example for macropump.m1s:
If ((GetUserLed(1500) = True) And (GetUserLed(1501) = False)) Then
'insert your button code here
'.
'.
'Start machine
DoOEMButton(1000)
End If
'make sure we run the code only one
SetUserLED(1501,GetUserLed(1500))
then modify your brain that the modbus input set's UserLed(1500)
and make sure macropump is enabled in Config->General Config
-
Thanks for the reply, can I also recall the LED button from the button on the screen?
-
the LED (green frame arround start button) will come up automaticly when programm is running.
-
I was talking about calling the GetUser Led(1500) by programming the start cycle button with machscreen design as well as calling it with brain and external button.
If you assigned the button as per the attached image, is it correct?
-
in standard 1024 screenset this small led ring arround the button is assigned to OEMled(804)
witch is the program start LED.
so if you assign it to OEMLed(1500), witch is only a onoe to one copy of your modbus input,
it will only light green as long you press your extrenal start button and will not show that programm
is running.
-
I'm sorry, I explained myself poorly.
what I would like to do is run the program you wrote before
If ((GetUserLed(1500) = True) And (GetUserLed(1501) = False)) Then
'insert your button code here
'.
'.
'Start machine
DoOEMButton(1000)
End If
'make sure we run the code only one
SetUserLED(1501,GetUserLed(1500))
both from the external button and from the start cycle button to the panel what I would like to know is how to assign the button that you told me to call with brain to the panel button
-
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.
-
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
-
now i got you, you will have to use a seperate UserLed because brain will overwrite UserLed(1500).
-
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?
-
i would use oemcode(34) -> basic script
then in basic script window
SetUserLed(1503,1)
and then in macropump.m1s
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)
-
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?
-
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:
msgbox("i was here")
to macropump to chech that it's running.
-
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
-
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?
-
IS THIS WAY ONLY DONE ONCE?
-
so it looks like UserLed(1500) is false if you push the buttom
in this case If condition should look like this:
If ((GetUserLed(1500) = False) And (GetUserLed(1501) = True)) Then
-
I tried but if I put true
And (GetUserLed(1501) = True)) Then
the button doesn't work...
I have to put false
And (GetUserLed(1501) = False)) Then
otherwise it doesn't work, I don't know why...
If I leave it false, is it a problem could I have malfunctions?
-
I tried to implement the button from the panel by adding to the code in macropump as you wrote
Or (GetUserLed(1503) = True) Then
and I modified the button script as per the attached image (imm-f)
I tried but failed to invoke GetUserLed(1503)...
I press the button on the panel but nothing happens...
am I doing something wrong?
-
for test place three simple Led's on your screen (1500,1501,1503)
to see the status of those three led's.
then you can witch is true or false.
-
hi TPS I did the tests with the LEDs.
And they worked in the panel.
At this point, however, I was unable to recall UserLed1503..
I tried to replace the code in macropump using the codes 1 and 0 (Imm-g) instead of the booleans true and false.
It worked great.
The cycle start panel button works!!! calls the script contained in macropump.
And the external button with userled1500-1501 from external button from brain also works. At this point I changed the brain to pass signal (imm-b1).
Great job, thanks again for your help, you were very kind, I couldn't have done it without you.