Machsupport Forum

Mach Discussion => Mach Screens => Screen designer tips and tutorials => Topic started by: Katoh on July 14, 2017, 09:26:01 PM

Title: Adding a couple of buttons
Post by: Katoh on July 14, 2017, 09:26:01 PM
Hi Friends

This may seem like a pretty simple question but I have forgotten how to do it.
I am using screen4 to edit the lathe screen I have added a C axis position  and zero button to the screens but need to add to anther 2 buttons, these buttons  control certain aspects of the servo motor I use as the spindle. One being "Alarm Off" the other is "Servo Disable". What I want is when the button is pressed it simply activates an output in ports in pins, that’s it! Just not certain how to do it.
Thanks
Title: Re: Adding a couple of buttons
Post by: RICH on July 15, 2017, 07:52:37 AM
ActivateSignal(Output#)  ' # is the output  as defined in configuration

RICH
Title: Re: Adding a couple of buttons
Post by: Katoh on July 15, 2017, 10:06:26 AM
Thanks Rich
Got it!
Just one thing can I switch it off again with the same button?
i.e hit button once it turns on then hit the same button it turns off?
Thanks
Title: Re: Adding a couple of buttons
Post by: ger21 on July 15, 2017, 10:14:08 AM
Add a User LED to the screen.
When you click the button, check the state of the LED.
If the LED is off, turn it on, and activate the output.
If the LED is on, turn it off, and de-activate the output.
Title: Re: Adding a couple of buttons
Post by: Katoh on July 15, 2017, 11:51:03 AM
Sorry now I’m a little confused.
What I have done from scratch might give you an idea where Im most likely going wrong.
In screen4 I have made a button that says Servo On / Servo Off, I have ticked in its properties use VB script. Now I go into mach and open VB button editor and open that button, In the editor, line one reads ActivateSignal(output1) line two reads deActivateSignal(output1). but it just doesn’t work.
Made two buttons one for off and one for on, that works but its painful, screen4 is the worst program I think I have ever used, You set it up then open mach and things are not where they should be takes hours going back and forth to get things in the correct position.
Thanks for the replies
Title: Re: Adding a couple of buttons
Post by: ger21 on July 15, 2017, 12:10:51 PM
Screen 4 works perfectly, and is my preferred editor. But it works best in XP, and if the entire screen fits in the window without scroll bars. You may find MachScreen more to your liking.

Add an LED with OEM code 1500, and you're code should look like this:

If GetOEMLED(1500) Then
SetUserLED(1500,0)
deActivateSignal(output1)

else

SetUserLED(1500,1)
ActivateSignal(output1)

end if

Title: Re: Adding a couple of buttons
Post by: Katoh on July 15, 2017, 08:56:43 PM
Quote
Screen 4 works perfectly, and is my preferred editor. But it works best in XP, and if the entire screen fits in the window without scroll bars.

Now that explains it all, I’m using windows 7 and yes there are scroll bars both left to right and top to bottom. I do have an old system running XP I might try it on thay one as the win7 machine is simple painful.

Thanks for that code I definitely will try that.