Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: Ronny81 on December 19, 2007, 07:29:54 AM
-
Hi I my Ronny,
and i have a big problem.
First, sorry for me english, it is very well.
I want right a VB-Script vor me Mach3.
I have thinking me something and then
i right this:
If Hotkey (F5) incoming Then
SetOEMDRO (3,100)
X=GetOEMDRO (3)
MsgBox X
Else
End
If Hotkey (F6) incoming Then
SetOEMDRO (3,20)
X=GetOEMDRO (3)
MsgBox X
Else
End
If Hotkey (F7) incoming Then
SetOEMDRO (3,2)
X=GetOEMDRO (3)
MsgBox X
Else
End
Me Problem is, i dont know that i must right for "Hotkey (F7) incoming".
I whant do this
SetOEMDRO (3,2)
X=GetOEMDRO (3)
MsgBox X
if Hotkey (F7) is presst.
Can somebody help me ?
And pleas right very short and understandle.
Thanks a lot.
Ronny
-
hi Ronny
There are sure to be other ways to do what you want but here's one...
you need screen designer http://www.machsupport.com/Downloads/Mach3Screen.zip
1) load c:\mach3\1024.set
2) add a button (see one.jpg)
3) double click the new button
4) edit the button script (see two.jpg)
-
Ronny,
Here is the way to do it, the way your wanting to:
Goto Config>ports and pins>input tab:
Enable Input1, Input2 and Input3 leave the port/pin at 0/0, put a check in emulate, then set your hot key for Input 1, 2, and 3 to f5, f6, f7
leave an X in active low. Hit apply, then ok.
goto operator>VB scripter, open it and paste in the following, then goto File>save as and put the file name as: "Macropump.m1s", close the window (make sure that the macropump is saved in the macro folder for your profile).
'Macropump.m1s
a=GetUserDRO(2000)
b=GetUserDRO(2001)
c=GetUserDRO(2002)
If IsActive(INPUT1) And a=0 Then
SetOEMDRO(3,100)
x=GetOEMDRO(3)
SetUserDRO(2000,1)
Message("Slow Jog Rate set to 3")
Else
SetUserDRO(2000,0)
End If
If IsActive(INPUT2) Then
SetOEMDRO (3,20)
y=GetOEMDRO(3)
SetUserDRO(2001,1)
Message("Slow Jog Rate set to 20")
Else
SetUserDRO(2001,0)
End If
If IsActive(INPUT3) Then
SetOEMDRO (3,2)
z=GetOEMDRO (3)
SetUserDRO(2002,1)
Message("Slow Jog Rate set to 2")
Else
SetUserDRO(2003,0)
End If
Then: goto config>general and check the enable macropump, hit ok then close and re-open Mach.
now when you hit the f5, f6, or f7 keys you will see a message scroll across the bottom that shows what your slow jog % rate is.
You can also watch the dro itself by hitting the tab key and looking at the slow jog rate % DRO.
scott
-
Hi scott - interesting way of doing it and I'll forgive your little poke... ;D
the way your wanting to:
It's taught me what the macropump macro can be used for so thanks for that - however a couple of questions...
what's the userdro stuff for in your code? - I've studied it and can't see that it does anything at all. Also the x variable seems redundant.
here's mine based on yours which seems to do the same thing but maybe I'm missing something
'Macropump.m1s
If IsActive(INPUT1) Then
SetOEMDRO(3,100)
Message("Slow Jog Rate set to 100")
End If
If IsActive(INPUT2) Then
SetOEMDRO (3,20)
Message("Slow Jog Rate set to 20")
End If
If IsActive(INPUT3) Then
SetOEMDRO (3,2)
Message("Slow Jog Rate set to 2")
End If
Cheers
Ian
-
Ian,
sorry my reply wasnt meant to poke at you, I read it myself and it does come across that way, I am sorry. I should have read before I posted.
ON to the Macropump:
I forgot to remove the X=dros stuff, I tried the msgbox in the macro pump and it was a bad, bad, bad idea.........
so I changed it to message.
The DROs act as Interlocks so that the code only executes Once while the button is held down, (no human finger can release faster than the macropump can come around and scan it a few times). Since the macro pump runs in a continous loop this stops it from "Pushing a button" or executing some command every scan if you only want the command to execute once per scan..........
scott
-
corrected macropump code (without the extra garbage)
'Macropump.m1s
a=GetUserDRO(2000)
b=GetUserDRO(2001)
c=GetUserDRO(2002)
If IsActive(INPUT1) And a=0 Then
SetOEMDRO(3,100)
SetUserDRO(2000,1)
Message("Slow Jog Rate set to 3")
Else
SetUserDRO(2000,0)
End If
If IsActive(INPUT2) Then
SetOEMDRO (3,20)
SetUserDRO(2001,1)
Message("Slow Jog Rate set to 20")
Else
SetUserDRO(2001,0)
End If
If IsActive(INPUT3) Then
SetOEMDRO (3,2)
SetUserDRO(2002,1)
Message("Slow Jog Rate set to 2")
Else
SetUserDRO(2003,0)
End If
-
Hey scott - no problem - I was feigning offence - twas just a bit of fun. ;D
Thanks for the explanation - got it now.
Cheers
Ian
-
Hi,
thanks a lot for your Help. This is a great Forum whis very nice people !
Me Mach is running ;D This is gread!
Thank
Ronny
-
opps spotted another typo error....
'Macropump.m1s
a=GetUserDRO(2000)
b=GetUserDRO(2001)
c=GetUserDRO(2002)
If IsActive(INPUT1) And a=0 Then
SetOEMDRO(3,100)
SetUserDRO(2000,1)
Message("Slow Jog Rate set to 3")
Else
SetUserDRO(2000,0)
End If
If IsActive(INPUT2) Then
SetOEMDRO (3,20)
SetUserDRO(2001,1)
Message("Slow Jog Rate set to 20")
Else
SetUserDRO(2001,0)
End If
If IsActive(INPUT3) Then
SetOEMDRO (3,2)
SetUserDRO(2002,1)
Message("Slow Jog Rate set to 2")
Else
SetUserDRO(2002,0)
End If
-
Hi Scott - sorry, me again :)
shouldn't it be...
'Macropump.m1s
a=GetUserDRO(2000)
b=GetUserDRO(2001)
c=GetUserDRO(2002)
If IsActive(INPUT1) And a=0 Then
SetOEMDRO(3,100)
SetUserDRO(2000,1)
Message("Slow Jog Rate set to 100")
Else
SetUserDRO(2000,0)
End If
If IsActive(INPUT2) And b=0 Then
SetOEMDRO (3,20)
SetUserDRO(2001,1)
Message("Slow Jog Rate set to 20")
Else
SetUserDRO(2001,0)
End If
If IsActive(INPUT3) And c=0 Then
SetOEMDRO (3,2)
SetUserDRO(2002,1)
Message("Slow Jog Rate set to 2")
Else
SetUserDRO(2002,0)
End If
-
yep,
to much cuttin and pastin without paying attention
scott
-
If IsActive(INPUT1) And a=0 Then
SetOEMDRO(3,100)
SetUserDRO(2000,1)
Message("Slow Jog Rate set to 3")
Else
SetUserDRO(2000,0)
End If
Is this logic correct?
I don't think this only sets the OEMDRO once per button press, but every other running of the Macropump, which could be 200 times a second. It is not crictical in this case and would not even be noticable, but if the latch is put in......
Regards
Dave Hookings