Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: amnon on January 29, 2015, 01:57:37 PM
-
Hello,
How can I add a led to my new button?
Best Regards
Amnon
-
What exactly are you meaning, is it to have a LED within a button such as the pic below or is it to have a LED associated with something that the button does?
If the latter you will have to explain what your button is for and whether it is a standard button or a VB one.
Hood
-
Hej Hood,
I'd like to add button and LED, but made in mach Screen (not a standard). LED will give me information, if a VB code was executed.
Respect
Amnon
-
If your button is a VB button then you just need to include code to turn on/off the LED when appropriate. The LED will most likely have to be a User LED unless of course what the VB is turning on/off is a standard output.
Hood
-
Thank's Hood,
Is it a VB button, if I create It in Mach Screen? hmmm... How can I create such a button in VB, VB studio?
Amnon
-
In the screen designer you make a VB button then once back in Mach you go to Operator menu then Edit Button Scripts. The VB button will be flashing, click it then enter your VB in the editor that appears then save and close the editor.
Hood
-
When I push a button my led does not turn on. Wrong OEM LED number? What number should I used.
Respect
Amnon
-
Unless you say what your VB is actually doing then afraid there is no way that anyone can tell you what is wrong.
Hood
-
My button is changing Feed Rate and turning on JOG, if it is not active. When I push it, macro is changing Feed Rate and turn on 1 LED, then check if JOG is active or not and then turning on LED.
Amnon
-
Can you attach/paste the VB please.
Hood
-
SetOEMDRO(818, 10000)
If GetOemLed (14)=0 Then
'Code "(I am turning on Joge)"
DoOEMButton(103)
Else
End If
-
Try this
SetOEMDRO(818, 10000)
If GetOemLed (14)= 0 Then
DoOEMButton(204)
End If
Hood
-
Thank's Hood,
But, what code should I add to this one, to turn on my LEDS
Amnon
-
What is the LED to signify and when do you want it on and when off?
Hood
-
Signification of my LED is to show me that my button was pressed. So I want it on, when feed rate is changening by pushing my button.
Amnon
-
It would be a very simple matter to turn the LED on but the problem would be turning it off again when the circumstances had changed, ie the DRO does not have that value in it or the Jog mode is other than continuous.
What you would need to do is use the macropump or a Brain for that rather than trying to do it from within the button itself.
You would just look at the value in the DRO and the state of the Jog LED and if both were right you would turn the User LED on, if they were not both in the right state then turn it off.
Hood
-
Just tested this in the macropump and it works fine.
If GetOemDRO(818)=10000 And GetOemLED(14) Then
SetUserLED(2000,1)
Else
SetUserLED(2000,0)
End If
What you will need to do if you do not already have the macropump is firstly go to General Config page and enable the macropump.
Then Operator menu and VB Script editor. In the window that opens paste the code above then save the file as macropump.m1s making sure you save it to the macro folder of the profile you are using.
You will then need to add a User LED to your screenset and give it the OEM code of 2000.
When you next open Mach it should light the LED if the DRO is 10000 and the Jog mode is Continuous, as soon as either of these change the LED should go out.
Hood
-
Hej Hood,
Your code works fine, now I try to add next UserLED to probe button. My intension is to set my LED when a probe button was pressed, and turn them off when probing is finished. I add to macropump
If button34 = 1 Then
SetUserLED(1406,1)
Else
SetUserLED(1406,0)
End if
but It doesn't work.
It is a little strange for me, that all buttons with my different macros have the same number 34. Can I change a button number?
Amnon
-
Where do you get the code
If button34
from?
Hood
-
I found this part of code in some macro.
Amnon
-
I think there must be other parts to the code telling the macro what button34 actually is.
Hood
-
Hi,
I think there must be other parts to the code telling the macro what button34 actually is.
Hood
it's not button34.
code 34 in the screendesigner means to do a basic script, with is
in (dont know how to say) this button.
so the led needs to be turned on in ths button script.
Thomas
-
Ok if it is a way for Machscreen to define a VB Script button then will need to know what is in the button or what he is wanting to actually do.
Hood
-
So if the led needs to be turned on in this button script, how can I do this.
Amnon
-
ok,
hard road,
open your screen in screedesigner (witch ever your use).
go to bottom of this vb macro,(by double click on the vb code,)
and enter setoemled(whateveryouwhanttosetoemled).
LIVE IS DIFFICULT.
Thomas