Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: zealous on June 06, 2006, 06:24:37 AM

Title: E-stop VB script
Post by: zealous on June 06, 2006, 06:24:37 AM
How do you trigger an event from the message ticker or the "active" on/off state of the emergency function(Estop).

I'd like to call on some type of event to trigger a "wave file script getter" for the active on/off state of the E-Stop.

If some one could help with the code then we can incorporate a wave file function to the estop. ;D


Here is the basic function code to call on a wave sound placed on a button:

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long


    sndPlaySound "C:\WINDOWS\MEDIA\ding.wav", &H1


Here is the code to place on the "Display" button(This is a two state button with two diffrent state sounds!)

value = GetParam("Boundry")
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

If  value = 1 Then
'SetButtonText " Job "
SetParam "Boundry" , 0
 sndPlaySound "C:\WINDOWS\MEDIA\ding.wav", &H1
 Else
SetParam "Boundry" , 1
'SetButtonText "Machine"
sndPlaySound "C:\WINDOWS\MEDIA\tada.wav", &H1
End If

  Currently I haven't found the code to trigger a wave sound for the E-Stop, need some help

Title: Re: E-stop VB script
Post by: Brian Barker on June 06, 2006, 08:22:11 AM
You are going to have to put that in the macropump... You can check the state of the Estop LED and if you see an estop run the script that you posted :)

That should get it working
Title: Re: E-stop VB script
Post by: zealous on June 06, 2006, 12:43:19 PM
How do I create a macropump? Is it the (.M1s) ???

I feel that I must have missed a lot of valuable information about scripting in Mach. I've been looking around but can't find too much.

Where is the code for the Emergency function so I can check the state with a macropump?

Can I use something like this?
(b1) Inspect the input with a IsActive(ss) call in a Macropump


Mr.Barker,
Do you think there might be a better way to call on wave files?
Title: Re: E-stop VB script
Post by: zealous on June 06, 2006, 01:47:18 PM
Okay, I'm alittle slow :P
Found tons of info on customizing.
http://www.machsupport.com/documentation/Customizing.pdf
Title: Re: E-stop VB script
Post by: Brian Barker on June 06, 2006, 01:51:27 PM
This is a good way to play the wave files, The length on the macropump is not going to hurt the computer at all :)

To check the LED look in the Wiki at the LED codesHere: http://www.machsupport.com/MachCustomizeWiki/index.php?title=Standard_LEDs. once you have the code you can do this:

If(GetLED(0))Then
'Put your code here
end if
Title: Re: E-stop VB script
Post by: zealous on June 06, 2006, 02:56:00 PM
Does Mach load all macro's on start up? or how do I load a macro?

Would the Macro listen for the getLed(0) and play a wave file? so all the code would be place in the .M1s?
 or can I place VB code on LED's/Dro's?

Thanks for the help Mr.Barker
Title: Re: E-stop VB script
Post by: Brian Barker on June 06, 2006, 03:07:49 PM
You need to save the macropump.m1s macro in the macros/mach3mill directory (if that is the profile that you are using) this is where the macro that you are going to put all your code into :) There is a video on the Macropump that I made some time ago...  The maco pump gets run a few time's a sec all the time! so take care in writing your macro!

There are many things to learn but you are getting there (you have good questions)

Thanks
Brian
Title: Re: E-stop VB script
Post by: zealous on June 06, 2006, 04:17:32 PM
Okay now I'm getting some where,
I can use the Macropump.m1s
with:

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
sndPlaySound "C:\WINDOWS\MEDIA\ding.wav", &H1

but I'm getting a compiler error when I add:

If(GetLED(0))Then

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
sndPlaySound "C:\WINDOWS\MEDIA\ding.wav", &H1
end if


Is the (getLED(0)) declared by Mach3 or do I need to declare it?

I haven't seen the video, I'd like to ;D
Title: Re: E-stop VB script
Post by: Graham Waterworth on June 06, 2006, 04:24:34 PM
I would have thought it should look more like this

But I may be wrong as I use VB 2005

Graham

If(GetLED(0))Then
  sndPlaySound ()
end if

Public Declare Sub sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
sndPlaySound "C:\WINDOWS\MEDIA\ding.wav", &H1
End Sub
Title: Re: E-stop VB script
Post by: zealous on June 06, 2006, 07:49:14 PM
Getting closer,

This code will work with the "physical Estop" but is not working with the Mach3 E-stop.
So when I engage my physical E-stop I get a sound responce, when I unengaged the sound stops like it should behave, but if the Mach 3 E-stop is still blinking or if I hit the softwear e-stop it will not give a sound responce.

What I think is I'm reaching the OEM code for the physical E-stop but not the virtual one. ???

Here is the code:

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long


'Public Declare Function GetOEMLED (ledOEMCode As Integer) As Boolean
 
If GetOEMLed (19) Then

sndPlaySound "C:\WINDOWS\MEDIA\tada.wav"
End If

'Else GetOEMLed (67) = 0
'sndPlaySound "C:\WINDOWS\MEDIA\tada.wav", &H1
'End If       
 

Title: Re: E-stop VB script
Post by: Brian Barker on June 06, 2006, 08:10:09 PM
Try getLED(0) this is the reset LED :)
Title: Re: E-stop VB script
Post by: zealous on June 06, 2006, 09:19:30 PM
Thank you to Brian Baker,Graham Waterworth and Liquidseek.com for your your help and codes. ;D

I think I got it now.

I would have been done a few hours ago but I found that my Mach 3 install is a little bit off. I'm getting a "Run loop Macro the.." with a "OK" or "Cancel" prompt that was effecting the way Mach 3 is handling the code.

Since this was giving me problems the "getLED(0) and some other codes where not working properly.

Tried the code on my machine computer and works flawlessly. Let me know if you have any problems.

Any suggestion on the Mach 3 problem I'm having, I've reinstalled but the same screen keeps popping up before Mach starts?

One more quick question can we have a wave file play when Mach starts and ends?

Thanks for your Patience and talents ;D


Here is the final code:
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

 
If GetLED (0) Then

sndPlaySound "C:\WINDOWS\MEDIA\tada.wav"
End If

If GetLed (19) Then

sndPlaySound "C:\WINDOWS\MEDIA\tada.wav"
End If
   
   
or download the .M1s: