Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: MOTU on June 04, 2012, 09:16:39 AM
-
The task is to get either or a combination of the vertical axis servo motors (X,Z,B) to run, based on the condition of the LED associated with each axis.
If the X axis LED is on then the X axis runs; if both X axis and Z axis LED's are on then both will run, etc.
I would like all motors to run simultaneously - vs sequentially, if the LED status indicates more than one motor is to run.
BTW, the Y axis indexes a belt between the vertical axis cycles.
Right now, the current button has the motors running sequentially.
Thanks in advance for any help.
This is the code I currently have on the button.
MoveBelt = GetUserDRO (1060) 'Belt Index Increment
code "G91"
code "F5"
If GETUSERLED (1031) Then 'checks X axis LED
code "G1X-1"
code "G1X1"
End If
If GETUSERLED (1032) Then 'checks Z axis LED
code "G1Z-1"
code "G1Z1"
End If
If GETUSERLED (1033) Then 'checks B axis LED
code "G1B-1"
code "G1B1"
End If
code "F200"
code "G1A" & MoveBelt
While IsMoving
SETUSERLED (1036,1) 'turn on A axis LED
Wend
SETUSERLED (1036,0) 'turn off A axis LED
code "G90"
-
First thing to say is I muddle through when it comes to VB and often there are much neater ways to do the same thing ;)
Think you would have to do each sequence individually for example for single axis X Z B moves you would basically have what you have above but added to each line that looks for the LED you would also need to look to see the others are not active. You could then have similar for your your combined moves.
Eg the single ones would be something like this
If GETUSERLED (1031) And Not GETUSERLED (1032) And Not GETUSERLED (1033) Then
code "G1X-1"
code "G1X1"
End If
The combination ones something like this
If GETUSERLED (1031) and GETUSERLED (1032) and GETUSERLED (1033) Then
code "G1X-1Z-1B-1"
code "G1X1Z1B1"
End If
Hood
-
Thanks! This did the trick. Didn't think about using "Not GETUSERLED".
-
No probs, as said their is likely a neater way to do it but as long as it works.... :)
Hood