Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 03:22:05 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  General Mach Discussion
| | |-+  Pausing a Macro to wait for a signal from an input
Pages: 1   Go Down
Print
Author Topic: Pausing a Macro to wait for a signal from an input  (Read 367 times)
0 Members and 2 Guests are viewing this topic.
Aeroshade
Active Member

Offline Offline

Posts: 138


View Profile
« on: February 11, 2011, 02:40:47 PM »

I'm writing my tool changer macro and I need a little help. I need to make my tool magazine move and stop when it triggers a position switch. This is what I have so far (Note this is to make the mag go CCW):


If IsActive(OUTPUT5) = True Then
    DeactivateSignal(OUTPUT5) 'Mag CW
End If
   
ActivateSignal(OUTPUT6) ' Mag CCW

While IsActive(OEMTRIG12) = False Then
    Sleep 10
Wend

DeactivateSignal(OUTPUT6)


Note:
OUTPUT5 = Mag CW
OUTPUT6 = Mag CCW
OEMTRIG12 = Pocket position switch

When I run this the mag just keeps spinning.

Any help would be great!!

Thanks,

Aero
Logged
Hood
Active Member

Offline Offline

Posts: 17,362


Carnoustie, Scotland


View Profile
« Reply #1 on: February 11, 2011, 04:27:08 PM »

I do my toolchange with Do Loops but I am crap at VB so there is likely better ways to do it although they do work great for me so I will stick to them Smiley
Hood
Logged
djc
Active Member

Offline Offline

Posts: 47


View Profile
« Reply #2 on: February 11, 2011, 05:52:53 PM »

If IsActive(OUTPUT5) = True Then

Try IsOutputActive instead of IsActive.

Don't ask me how long it's just taken me to realise the difference.

Also, you don't need = True. The function returns a value of 1 if it's true and 0 if it's false. Hence asking if 1 = true is unnecessary.
Logged
Aeroshade
Active Member

Offline Offline

Posts: 138


View Profile
« Reply #3 on: February 11, 2011, 09:14:26 PM »

OK I got it working!!!! I attached it below if anyone needs a Tool changer that uses cam driven magazine with position switches. The do loop worked great Smiley

I will list the inputs and outputs later... I'm beeeeet!!!


Thanks for all the help guys!!!

Aero

* M6 Macro-Aero.txt (4.37 KB - downloaded 36 times.)
Logged
djc
Active Member

Offline Offline

Posts: 47


View Profile
« Reply #4 on: February 12, 2011, 04:29:16 AM »

OK I got it working!

Have you tested it? Big difference between 'working' and 'working and tested'. My bike engine works really well right up to the point where I realise the kill switch isn't wired up and I drive through the wall at the end of the street.

There are lots of places in your macro where you test IsActive against an OUTPUT signal. This will not work correctly.

See:

http://www.machsupport.com/MachCustomizeWiki/index.php?title=Mach_specific_Subroutines/Functions_grouped_by_purpose#Signals

Try this and you will see the difference.

Code:
ActivateSignal(OUTPUT5)
 Message "OUTPUT5 is active. The value of IsActive(OUTPUT5) is " & IsActive(OUTPUT5)
 If IsActive(OUTPUT5) Then
  Message "I can only print this if IsActive(OUTPUT5) is true"
 End If
 Sleep 5000
 Message ""
 Sleep 5000
 If IsOutputActive(OUTPUT5) Then
  Message "I can only print this if IsOutputActive(OUTPUT5) is true"
 End If


Logged
Aeroshade
Active Member

Offline Offline

Posts: 138


View Profile
« Reply #5 on: February 12, 2011, 09:57:39 AM »

Hmmm.. I tested it a few times and it seemed to work. BUT I'm not sure if when I test if an OUTPUT is on truly works. From what I read I should change the IsActive for outputs to IsOutputActive.

Thanks for the INFO, that would have sucked if I really needed to test against an OUTPUT and it didn't work Tongue


Thanks again,

Aero
Logged
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!