Home
Downloads
Mach3
Plugins
CAM Post Processors
Screensets
Purchase
Support
Forum
Tutorial Videos
Documentation
Yahoo Group
Mach Wiki
Resources
Contact Us
Links
CNCZone
German Forum
Italian Forum
Korean Forum
Portugese (Brazil) Forum
Russian Forum (RSK CNCROUTER)
Thai Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 28, 2012, 01:24:05 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Select from and to languages
Chinese-simp to English
Chinese-trad to English
English to Chinese-simp
English to Chinese-trad
English to Dutch
English to French
English to German
English to Greek
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Russian
English to Spanish
Dutch to English
Dutch to French
French to English
French to German
French to Greek
French to Italian
French to Portuguese
French to Dutch
French to Spanish
German to English
German to French
Greek to English
Greek to French
Italian to English
Italian to French
Japanese to English
Korean to English
Portuguese to English
Portuguese to French
Russian to English
Spanish to English
Spanish to French
Machsupport Forum
Mach Discussion
VB and the development of wizards
Button with two functions
Pages:
1
2
»
Go Down
« previous
next »
Author
Topic: Button with two functions (Read 703 times)
0 Members and 1 Guest are viewing this topic.
peter81
Active Member
Offline
Posts: 60
Button with two functions
«
on:
August 25, 2011, 03:28:13 PM »
Hello all,
on my pendant I have momentary switch connected to OEMTRIGGER5. How can I make this switch to activate output5 (output must stay active) and then with the same button deactivate output5? I've been trying this all day with no luck. Can somebody please help?
Peter
Logged
BR549
Active Member
Offline
Posts: 2,557
Re: Button with two functions
«
Reply #1 on:
August 25, 2011, 07:21:02 PM »
SOmething along these lines may work, I have seen a better example on here somewhere.
Sub Main()
If OemTrigger1 And GetVar(1000)< 1 Then GoTo N2
If OemTrigger1 And GetVar(1000)> 0 Then GoTo N3
GoTo N4
N2:
ActivateSignal(output5)
SetVar(1000,1)
GoTo N4
N3:
DeactivateSignal(output5)
SetVar(1000,0)
GoTo N4
N4:
End Sub
End
OR maybe something like this
If OemTrigger1 And GetVar(1000)<1 Then
ActivateSignal(output5)
SetVar(1000,1) '
End If
If OemTrigger1 And GetVar(1000)>0 Then '
ActivateSignal(output5)
SetVar(1000,0)
End If
End
Hope it helps, (;-) TP
«
Last Edit: August 25, 2011, 07:33:15 PM by BR549
»
Logged
peter81
Active Member
Offline
Posts: 60
Re: Button with two functions
«
Reply #2 on:
August 26, 2011, 02:48:05 PM »
Hi BR549,
thanks for reply. I've tried your second code you posted. I put it in the macropump and it didn't worked. Then I've tried with IsActive(OEMTRIG1) instead OemTrigger1 and it worked. The output 5 becomes active. The only problem is that I can't turn it off with the same button. What do I need to change in the code?
If IsActive(OEMTRIG1) And GetVar(1000)<1 Then
ActivateSignal(output5)
SetVar(1000,1) '
End If
IsActive(OEMTRIG1) And GetVar(1000)>0 Then '
ActivateSignal(output5)
SetVar(1000,0)
End If
End
Peter
Logged
BR549
Active Member
Offline
Posts: 2,557
Re: Button with two functions
«
Reply #3 on:
August 26, 2011, 02:59:35 PM »
Look at the second part of your example it is using ActivateSignal(output5) It needs to be DeactivateSignal(output5).
If that does not do it then try using a lower var number such as 600.
(;-) TP
Logged
stirling
Global Moderator
Offline
Posts: 1,190
UK
Re: Button with two functions
«
Reply #4 on:
August 27, 2011, 03:27:21 AM »
Or...
Code:
If isActive(OEMTRIG5) then
if isOutputActive(OUTPUT5) then
deActivateSignal(OUTPUT5)
else
ActivateSignal(OUTPUT5) '
end if
however, using the macropump to respond to triggers is kinda missing the point of triggers...
Ian
«
Last Edit: August 27, 2011, 03:29:38 AM by stirling
»
Logged
peter81
Active Member
Offline
Posts: 60
Re: Button with two functions
«
Reply #5 on:
August 27, 2011, 06:14:14 AM »
Hi stirling,
I've tried your code but I get syntax error. Must be something wrong in the code.
Logged
peter81
Active Member
Offline
Posts: 60
Re: Button with two functions
«
Reply #6 on:
August 27, 2011, 06:36:38 AM »
Ok I put another End If at the end of the code
If IsActive(OEMTRIG5) Then
If IsOutputActive(OUTPUT5) Then
DeActivateSignal(OUTPUT5)
Else
ActivateSignal(OUTPUT5)
End If
End If
Now the problem is that when I press the button the output does not come on. The LED of the output comes on and then turns off. If I hold button for longer time, output LED blinks tree or more times and then stay active. If I deactivate output I also must hold button for longer time, then LED blinks tree times and then turns off.
Peter
Logged
peter81
Active Member
Offline
Posts: 60
Re: Button with two functions
«
Reply #7 on:
August 27, 2011, 06:46:54 AM »
I've find this topic of self made pendant
http://www.machsupport.com/forum/index.php/topic,2823.0.html
this guy is using stop button with two funtions. Hold button less than one second pause the program, hold button more than one second stops the program. I was looking at his macropump file and I can't figure out how he made it.
Peter
Logged
stirling
Global Moderator
Offline
Posts: 1,190
UK
Re: Button with two functions
«
Reply #8 on:
August 27, 2011, 08:05:13 AM »
Peter - yes - I mislaid an "end if" but you found it - fingers not keeping up with head again.
The problem you're encountering is ONE reason why I said earlier that this is not the best way to do it. The macropump is running at 10Hz so it's not unreasonable that when you press the button the macropump reads it several times - what you end up with is a rather nice game of roulette. The macropump POLLS the state of the input. A TRIGGER acts like an interrupt and executes it's macro on the active state change of the input. This does away with this problem.
see
http://www.machsupport.com/forum/index.php/topic,15120.msg101160.html#msg101160
Ian
«
Last Edit: August 27, 2011, 08:51:37 AM by stirling
»
Logged
peter81
Active Member
Offline
Posts: 60
Re: Button with two functions
«
Reply #9 on:
August 27, 2011, 02:00:05 PM »
Quote from: stirling on August 27, 2011, 08:05:13 AM
Peter - yes - I mislaid an "end if" but you found it - fingers not keeping up with head again.
The problem you're encountering is ONE reason why I said earlier that this is not the best way to do it. The macropump is running at 10Hz so it's not unreasonable that when you press the button the macropump reads it several times - what you end up with is a rather nice game of roulette. The macropump POLLS the state of the input. A TRIGGER acts like an interrupt and executes it's macro on the active state change of the input. This does away with this problem.
see
http://www.machsupport.com/forum/index.php/topic,15120.msg101160.html#msg101160
Ian
Thanks Ian now it's working.
Peter
«
Last Edit: August 27, 2011, 02:07:07 PM by peter81
»
Logged
Pages:
1
2
»
Go Up
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Mach Discussion
-----------------------------
=> General Mach Discussion
=> Mach3 under Vista
=> Quantum
=> Mach SDK plugin questions and answers.
===> Finished Plugins for Download
=> VB and the development of wizards
=> Brains Development
=> Video P*r*o*b*i*n*g
=> Mach Screens
===> Screen designer tips and tutorials
===> Works in progress
===> Finished Screens
===> Flash Screens
===> JetCam screen designer
===> Machscreen Screen Designer
===> CVI MachStdMill (MSM)
=> Feature Requests
=> Non English Forums
===> Italian
===> French
===> Spanish
===> Chinese
===> German
===> Russian
===> Romanian
===> Japanese
===> Vietnamese
=> FAQs
-----------------------------
*****VIDEOS*****
-----------------------------
=> *****VIDEOS*****
-----------------------------
General CNC Chat
-----------------------------
=> Share Your GCode
=> Show"N"Tell ( What you have made with your CNC machine.)
=> Building or Buying a Wood routing table.. Beginnners guide..
=> Show"N"Tell ( Your Machines)
-----------------------------
G-Code, CAD, and CAM
-----------------------------
=> G-Code, CAD, and CAM discussions
=> LazyCam (Beta)
-----------------------------
Third party software and hardware support forums.
-----------------------------
=> LazyTurn
=> GearoticMotion Preliminary testing
=> Tempest Trajectory Planner
=> Contec
=> dspMC/IP Motion Controller
=> HiCON Motion Controller
=> Third party software and hardware support forums.
=> Galil
=> Newfangled Solutions Wizards
=> Mach3 and G-Rex
=> Mesa
=> Modbus
=> NC Pod
=> PoKeys
=> SmoothStepper USB
=> Sieg Machines
=> Promote and discuss your product
-----------------------------
Tangent Corner
-----------------------------
=> Tangent Corner
=> Competitions
=> Polls
=> Bargain Basement
-----------------------------
Support
-----------------------------
=> Downloads
===> XML files
===> Post Processors
===> Macros
===> Tutorials
===> Others
===> Beta Brains
===> Screen Sets
===> Documents
===> MACH TOOL BOX
=> One on one phone support.
=> Forum suggestions and report forum problems.
-----------------------------
Mach4
-----------------------------
=> Mach4 pre-Alpha Testing
Loading...