Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 09:14:11 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  Macro Controlling Multiple Outputs
Pages: 1   Go Down
Print
Author Topic: Macro Controlling Multiple Outputs  (Read 1458 times)
0 Members and 1 Guest are viewing this topic.
sunmix
Active Member

Offline Offline

Posts: 35


View Profile
« on: November 11, 2006, 04:16:10 AM »

Hi, I'm new to this forum, but I have been a Mach user for 2 years, just that I didn't really  play with macros. I'm setting up a oxy control, which control valves of oxy. and acet., to suit the traditional cutting style. As you can see, there are ignition delay, preheat delay and pierce delay, and 3 of them are controlled by 3 different outputs. The problem i'm facing is everytime i trigger this macro script, all the outputs triggers at the same time. I cant get it to delay before triggering another output. Can someone kindly help to neaten up the script? Thanks!

rem  M3 Macro
Dim IgnitionDelay, PreheatDelay, PierceDelay
IgnitionDelay = getUserDRO (1001)
PreheatDelay = getUserDRO (1002)
PierceDelay = getUserDRO (1003)

ActivateSignal(Output1)
code "G4 P" & (IgnitionDelay)

ActivateSignal(Output2)
code "G4 P" & (PreheatDelay)

ActivateSignal(Output3)
code "G4 P" & (PierceDelay)
End
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #1 on: November 11, 2006, 09:09:19 AM »

This is what I like to see Smiley you tried and all I have to do is a little work to the script! You get a star for the day Wink

Okay you are VERY close to haveing what you need... this should work for you:

Rem  M3 Macro
Dim IgnitionDelay, PreheatDelay, PierceDelay
IgnitionDelay = getUserDRO (1001)
PreheatDelay = getUserDRO (1002)
PierceDelay = getUserDRO (1003)

ActivateSignal(Output1)
code "G4 P" & (IgnitionDelay)
While IsMoving()
Wend

ActivateSignal(Output2)
code "G4 P" & (PreheatDelay)
While IsMoving()
Wend

ActivateSignal(Output3)
code "G4 P" & (PierceDelay)
While IsMoving()
Wend
End
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
sunmix
Active Member

Offline Offline

Posts: 35


View Profile
« Reply #2 on: November 11, 2006, 09:24:51 AM »

Whoa! Thanks!!!! I've been waiting for this moment for a long, long time! Thanks!!!

What's the difference between WEnd, Sub End, and End?
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #3 on: November 11, 2006, 01:11:42 PM »

Sub End is to end a Subroutine

Wend is the end of a While loop

End ... there is no end Smiley There is an End if and this tells the end of an if statement


Thanks
Brian
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
creep_pea
Active Member

Offline Offline

Posts: 90


View Profile
« Reply #4 on: November 14, 2006, 04:38:57 AM »

While your on about controlling outputs, how do you turn them off.

Thanks

Chris
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #5 on: November 14, 2006, 07:28:54 PM »

DeActivateSignal(Output3)  That will do it  Shocked
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
creep_pea
Active Member

Offline Offline

Posts: 90


View Profile
« Reply #6 on: November 14, 2006, 07:30:04 PM »

I've sorted it, I was been dumb, if anyone wishes to know it's simple really DeActivateSignal(output5)

This is what I'm trying to do.  Hopefully it will turn my spindle on on my bridgeport series 1 boss machine when I wire it in.

M3.m1s

If (GetOEMDRO (56) = 1) Then
DoSpinCW()
ActivateSignal(Output5)
Message "Spindle Start Requested"      
SystemWaitFor(Input2)            
While IsMoving ()              
Wend
DeActivateSignal(output5)                    
Message "Spindle Start Delay"        
Code "G4 P2"                  
While IsMoving                  
Wend                    
Message ""                  
Call SetUserLED(1010,1)
End If
If (GetOEMDRO (56) = 2) Then
DoSpinCCW()
ActivateSignal(Output6)
Message "Spindle Start Requested"      
SystemWaitFor(Input2)            
While IsMoving ()              
Wend          
DeActivateSignal(output6)
Message "Spindle Start Delay"        
Code "G4 P2"                  
While IsMoving                  
Wend                    
Message ""                  
Call SetUserLED(1010,1)
End If

It's a bit long but it seams to work when I simulate it, the M4 ones the same but the other way around.

Cheers

Chris
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #7 on: November 14, 2006, 07:40:06 PM »

No problem Smiley Looks like you are getting it!
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!