Hello Guest it is April 25, 2024, 03:20:56 PM

Author Topic: How to attach VB script to button  (Read 20208 times)

0 Members and 1 Guest are viewing this topic.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: How to attach VB script to button
« Reply #10 on: September 13, 2007, 09:27:37 PM »
This will also work:

If GetOEMLed (846) Then
  DeActivateSignal(ENABLE1)
Else
   ActivateSignal(ENABLE1)
End If

Further: Open sceen designer (like screen 3 or 4), open the screen in it, goto page 5 the diag page, double click the Enable 1 Led, when the window opens, look up top, and click the button that says "blink" the led. hit OK, and save the screen set. and reopen in mach, but the above VB in your button.

scott
fun times
Re: How to attach VB script to button
« Reply #11 on: September 13, 2007, 09:43:30 PM »
I didn't realize you could do that with the LED.  I like the blinking LED better than solid, and if I implement Enable 1 through 6 in another way, I'll have them blink.  However, whether I made "Enable 1" output active high or low, Mach3 makes the output active when Mach3 starts up.  I need the output to start deactivated, so I will continue to use Output 6, which starts deactivated.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: How to attach VB script to button
« Reply #12 on: September 13, 2007, 09:56:15 PM »
Your Enable Outputs are special outputs, they turn on with mach comming up to enable things once mach is up. Like spindle enables etc.
there are OUTPUTS 1-20
fun times
Re: How to attach VB script to button
« Reply #13 on: September 13, 2007, 10:10:09 PM »
That gives me an idea.  I struggled with my microchip programming and the charge pump 12.5kHz signal output to my breakout board.  The charge pump, for me anyway, is not a clean signal, and my microchip could not count the frequency properly.  Now, however, I can just use "Enable 1" to activate when Mach3 starts up.  The active signal on "Enable 1" will be a clear low signal for my microchip to read and thereby enable my stepper drivers.  Cool.

Now I can forget the charge pump and it's "watchdog timer" function.  Whatever purpose that serves.  The Mach3 manual states that the charge pump is the signal to show when Mach3 is up and running, but if the Enable outputs are active when Mach3 starts up, they can serve the same purpose.
Re: How to attach VB script to button
« Reply #14 on: September 22, 2007, 02:21:54 PM »
Well I must be doing something simple wrong. Everthing worls as described to attach code to a button, except that the button still contains "None" after the save. Did I save to the wrong location? I am using Mach Turn, where should the .m1s file be saved to?

Getting close but no cigars yet

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: How to attach VB script to button
« Reply #15 on: September 22, 2007, 02:54:53 PM »
Download and open up screen3, then open up your button, there is a window that has your vb in it, to the left of that window are 3 radio buttons, make sure you have the Run VB button checked.
fun times
Re: How to attach VB script to button
« Reply #16 on: September 22, 2007, 05:15:59 PM »
okay, not sure why I cant do that in screen4, but it worked in screen3 and the code shows up in Mach3.

Dim Len, SD, FD, SR, FR, TD, ClearZ, I

SD = GetOEMDRO(1111)
SR = SD / 2
FD = GetOEMDRO(1112)
FR = FD / 2
TD = GetOEMDRO(1113)
Len = GetOEMDRO(1110)
ClearZ = SR + .1
Code "G18 G40 G49 G90 G94 G50 M48 G80"
Code "G0 Z" & ClearZ
Code "G0 X0"
Code "M3"
 for I = SR To FR Step -0.01
   Code "G1 Z" & I
   Code "G1 X" & Len - TD & "F6"
   Code "G0 Z" & ClearZ
   Code "G0 X0"
Next I

Code "G1 Z" & FR
Code "G1 X" & Len - TD
Code "G0 Z" & ClearZ
Code "G0 X0"
Code "M30"

however nothing goes into the code window on the screen, now what am I doing wrong?

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: How to attach VB script to button
« Reply #17 on: September 22, 2007, 08:12:25 PM »
copy and paste all that script into the "Window" once you open up the dialog window in screen 3, tick the button execute vb script,
hit ok,  Then goto the file menu and hit Save.......... Then load your screen and test.

scott
fun times
Re: How to attach VB script to button
« Reply #18 on: October 13, 2007, 10:25:26 PM »
Been following this thread and want to do something similar. Would like to activate output 4 whenever the enable 1 led is active or whenever Mach is online and not in reset.
Enabled Output 4 in Config/Ports & Pins/Outputs and tried both active high and active low.
Saved the following code as test.m1s under macros\mach3 mill, restarted Mach3 mill with no compile errors but Output 4 does not change when the Reset button is toggled.
Any one have any ideas as to what I am missing?
Thanks,
Claude


If GetOEMLed (846 = true) Then
  ActivateSignal(OUTPUT4)
Else
   DeActivateSignal(OUTPUT4)
End If

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: How to attach VB script to button
« Reply #19 on: October 13, 2007, 11:59:28 PM »
Try this,

If GetOEMLed (846,1) Then
  ActivateSignal (OUTPUT4)
Else
   DeActivateSignal (OUTPUT4)
End If
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!