Hello Guest it is September 20, 2019, 12:14:03 AM

Author Topic: Help with button code  (Read 1626 times)

0 Members and 1 Guest are viewing this topic.

Offline MOTU

*
  •  15 15
    • View Profile
Help with button code
« 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"

Offline Hood

*
  •  25,849 25,849
  • Carnoustie, Scotland
    • View Profile
Re: Help with button code
« Reply #1 on: June 04, 2012, 10:33:22 AM »
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
 

Offline MOTU

*
  •  15 15
    • View Profile
Re: Help with button code
« Reply #2 on: June 04, 2012, 11:02:23 AM »
Thanks! This did the trick. Didn't think about using "Not GETUSERLED".

Offline Hood

*
  •  25,849 25,849
  • Carnoustie, Scotland
    • View Profile
Re: Help with button code
« Reply #3 on: June 04, 2012, 11:03:45 AM »
No probs, as said their is likely a neater way to do it but as long as it works.... :)
Hood