Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: amnon on January 29, 2015, 01:57:37 PM

Title: new button and led
Post by: amnon on January 29, 2015, 01:57:37 PM
Hello,

How can I add a led to my new button?

Best Regards
Amnon
Title: Re: new button and led
Post by: Hood on January 30, 2015, 09:04:48 AM
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
Title: Re: new button and led
Post by: amnon on January 31, 2015, 07:40:04 AM
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
Title: Re: new button and led
Post by: Hood on February 01, 2015, 04:52:00 AM
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
Title: Re: new button and led
Post by: amnon on February 01, 2015, 03:25:16 PM
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
Title: Re: new button and led
Post by: Hood on February 02, 2015, 03:43:03 PM
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
Title: Re: new button and led
Post by: amnon on February 05, 2015, 06:33:07 AM
When I push a button my led does not turn on. Wrong OEM LED number?  What number should I used.

Respect
Amnon
Title: Re: new button and led
Post by: Hood on February 05, 2015, 06:40:20 AM
Unless you say what your VB is actually doing then afraid there is no way that anyone can tell you what is wrong.
Hood
Title: Re: new button and led
Post by: amnon on February 07, 2015, 03:44:08 AM

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
Title: Re: new button and led
Post by: Hood on February 07, 2015, 04:13:33 AM
Can you attach/paste the VB please.
Hood
Title: Re: new button and led
Post by: amnon on February 07, 2015, 02:24:41 PM
Code: [Select]
SetOEMDRO(818, 10000)
If GetOemLed (14)=0 Then 
'Code "(I am turning on Joge)"
DoOEMButton(103)
Else
End If
Title: Re: new button and led
Post by: Hood on February 07, 2015, 03:06:50 PM
Try this

SetOEMDRO(818, 10000)
If GetOemLed (14)= 0 Then
DoOEMButton(204)   
End If   


Hood
Title: Re: new button and led
Post by: amnon on February 08, 2015, 09:02:29 AM
Thank's Hood,
But, what code should I add to this one, to turn on my LEDS

Amnon
Title: Re: new button and led
Post by: Hood on February 08, 2015, 09:04:51 AM
What is the LED to signify and when do you want it on and when off?
Hood
Title: Re: new button and led
Post by: amnon on February 08, 2015, 09:14:06 AM
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
Title: Re: new button and led
Post by: Hood on February 08, 2015, 01:59:36 PM
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
Title: Re: new button and led
Post by: Hood on February 08, 2015, 02:21:58 PM
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

Title: Re: new button and led
Post by: amnon on March 08, 2015, 12:46:23 PM
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
Code: [Select]
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
Title: Re: new button and led
Post by: Hood on March 08, 2015, 06:11:41 PM
Where do you get the code

If button34

from?

Hood
Title: Re: new button and led
Post by: amnon on March 09, 2015, 02:05:25 AM

I found this part of code in some macro.

Amnon
Title: Re: new button and led
Post by: Hood on March 09, 2015, 03:40:14 AM
I think there must be other parts to the code telling the macro what button34 actually is.

Hood
Title: Re: new button and led
Post by: TPS on March 09, 2015, 04:17:48 AM
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

Title: Re: new button and led
Post by: Hood on March 09, 2015, 05:05:59 AM
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
Title: Re: new button and led
Post by: amnon on March 09, 2015, 03:38:13 PM

So if the led needs to be turned on in this button script, how can I do this.

Amnon
Title: Re: new button and led
Post by: TPS on March 09, 2015, 03:54:33 PM
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