Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: lostincnc on May 30, 2012, 01:01:44 AM
-
Please Help Iam stuck I don't know enough vb. I have TU150e this is fitted with a 8 station turret each position there is an output not bcd strange I know. There is a lock/unlock switch . The motor is driven by an inverter the turret indexes in one direction only and then reverses to lock. I am using a Deva 004 servo card everything is working well but stuck on the dam turret. Please help its driving me nuts
-
post what you got and maybe someone without psychic powers will be along to help.
-
PM'ed you regarding the toolchanger issue.
-
Thougnt I had stirling . a barafauldi 8 station turret fitted to a denford tu150e Each position there is an output not bcd like other turrets
-
The ONLY thing approaching a question so far in TWO posts is "please help".
WTF is the problem? Oh wait a minute... your "stuck on the dam turret". Oh well that's clear then isn't it?
Post your VB and tell us what's working and what isn't.
-
Thamks for your helpful messages and your warm welcome to the forum sterling I feel most welcome here thanks to you. As dont post on forums much Iam feeling my way round I sent an open post as far as I saw it. The code is as follows I think I have set up the inputs correctly I coppied and pasted some code from other files but Iam stuck were the argument else. If anyone could help I would grateful
Sub Main()
OldTool = GetOEMDRO (1200) 'Tool In spindle DRO You must add this to your settings screen
x = GetToolChangeStart( 0 )
z = GetToolChangeStart( 2 )
'Inputs are as follows:
'
'
'OEMTRIG1 = Encoder Bit 1
'OEMTRIG2 = Encoder Bit 2
'OEMTRIG3 = Encoder Bit 3
'OEMTRIG4 = Encoder Bit 4
'OEMTRIG5 = Encoder Bit 5
'OEMTRIG6 = Encoder Bit 6
'OEMTRIG7 = Encoder Bit 7
'OEMTRIG8 = Encoder Bit 8
'OEMTRIG9 = Lock Proximity Switch
'OEMTRIG10 = Door Switch
'
'
'Outputs are as follows:
'
'
'OUTPUT10 = Lock Solenoid
'
'
'If IsActive(OEMTRIG10) Then 'check Door state
'MsgBox("Close the Door")
'End If
'Read the Encoder Bits
If IsActive(OEMTRIG1) Then
Bit1 = 1
Else
Bit1 = 0
End If
If IsActive(OEMTRIG2) Then
Bit2 = 1
Else
Bit2 = 0
End If
If IsActive(OEMTRIG3) Then
Bit3 = 1
Else
Bit3 = 0
End If
If IsActive(OEMTRIG4) Then
Bit4 = 1
Else
Bit4 = 0
End If
If IsActive(OEMTRIG5) Then
Bit5 = 1
Else
Bit5 = 0
End If
If IsActive(OEMTRIG6) Then
Bit6 = 1
Else
Bit6 = 0
End If
If IsActive(OEMTRIG7) Then
Bit7 = 1
Else
Bit7 = 0
End If
If IsActive(OEMTRIG8) Then
Bit8 = 1
Else
Bit8 = 0
End If
'Where the hell is the turret now?
If Bit1=1 Then Position = 1
If Bit2=1 Then Position = 2
If Bit3=1 Then Position = 3
If Bit4=1 Then Position = 4
If Bit5=1 Then Position = 5
If Bit6=1 Then Position = 6
If Bit7=1 Then Position = 7
If Bit8=1 Then Position = 8
Else
MsgBox("Turret out of position")
End
End If
OldTool = Position
NewTool = GetSelectedTool()
NumberOfStations = 0
LockProx = 0
IndexProx = 0
Rotation = 0
If NewTool < 1 Then
MsgBox("Tool Number Too Low")
End
End If
If NewTool > 8 Then
MsgBox("Tool Number Too High")
End
End If
If NewTool = OldTool Then
MsgBox("Selected Current Tool")
End
End If
'Determine which way to turn and how many stations
If NewTool > OldTool Then
NumberOfStations = (NewTool-OldTool)
Else
NumberOfStations = (OldTool-NewTool)
End If
If NewTool = (OldTool+NumberOfStations) Then
Rotation = 1
ElseIf NewTool = (OldTool-NumberOfStations) Then
Rotation = -1
ElseIf (OldTool+NumberOfStations) > 8 Then
Rotation = 1
ElseIf (OldTool-NumberOfStations) < 1 Then
Rotation = -1
Else
Rotation = 1
End If
DoOemButton(138) 'Go home
While IsMoving() 'wait for movement
sleep(100)
Wend 'to end
For I = 1 To 18 'Slow jog is needed
DoOemButton(112) 'for extra torque
Next I '
If Rotation = 1 Then
DoOemButton(310) 'Rotate Turret CCW (axis Y-)
Else
DoOemButton(309) 'Rotate Turret CW (axis Y+)
End If
sleep (500) 'Turn for .5 sec
DoOemButton(1003) 'Stop Motor
For I = 1 To 18 'Back to Fast jog
DoOemButton(111)
Next I
If Rotation = 1 Then
DoOemButton(310) 'Rotate Turret CCW (axis Y-)
Else
DoOemButton(309) 'Rotate Turret CW (axis Y+)
End If
For I = 1 To NumberOfStations 'Count number of stations
While Strobe1 = 0 'Wait for Strobe1 to go high
If IsActive(OEMTRIG6) Then
Strobe1 = 1
Else
Strobe1 = 0
End If
Wend
While IsActive(OEMTRIG6) 'Look for Strobe1 to go low
Wend 'Number of Srobe1 falls =
'Number of stations
Strobe1 = 0
Next I
ActivateSignal(OUTPUT10) 'Energize lock solenoid
While LockProx = 0 'Look for Lock Proximity Switch
If IsActive(OEMTRIG9) Then 'to go high
LockProx = 1
Else
LockProx = 0
End If
Wend
DoOemButton(1003) 'stop motor
Sleep(100) 'wait for damping
For I = 1 To 18 'slow jog
DoOemButton(112) 'for increased torque
Next I
If Rotation = 1 Then 'Reverse Motor
DoOemButton(309) 'Rotate Turret CW (axis Y+)
Else
DoOemButton(310) 'Rotate Turret CCW (axis Y-)
End If
sleep (200) 'Turn for .2 sec
DoOemButton(1003) 'Stop Motor
For I = 1 To 18 'Fast Jog
DoOemButton(111)
Next I
If Rotation = 1 Then 'Continue to Reverse Motor
DoOemButton(309) 'Rotate Turret CW (axis Y+)
Else
DoOemButton(310) 'Rotate Turret CCW (axis Y-)
End If
While IndexProx = 0 'Look for IndexProx to go high
If IsActive(OEMTRIG8) Then 'IndexProx must complete
IndexProx = 1 'OFF-ON-OFF
Else
IndexProx = 0
End If
Wend
While IsActive(OEMTRIG8) 'Look for IndexProx to go low
Wend
DoOemButton(1003) 'Stop motor
sleep(200)
DeActivateSignal(OUTPUT10) 'De-Energize Lock Solenoid
'Now in position
SetCurrentTool( NewTool )
Main
EDIT: code tags added by mod.
-
Yep - I'm a regular blue meanie arn't I - but hey you get what you pay for... All I was trying to do was avoid the usual 20+ questions before we get to the actual issue.
That said, I've taken a look at your code and you don't need to say any more. I'm afraid it's just a complete non-sensical mess and IMHO not worth spending any time on (yours or mine).
My advice FWIW would be start afresh by writing a SHORT piece of code for each thing you need to happen. So for example write a piece of code that just rotates the carousel. Then when you're happy write the code to rotate it to a particular slot. Then write the code to (say) open/close the solenoid etc. etc. ALL as separate macros so you can go back to them if needs be. Then you'll have all the aspects of your toolchanger under your hat. Then put them together ONE AT A TIME checking each new step behaves as you want. Then you'll not only have your toolchanger but YOU'LL undertand it. Follow someone elses code ONLY for simple techniques (if you need to) like how to close/open a solenoid and even then check a few peoples code to convince yourself you're not following someone else's rubbish.
PLEASE DO NOT FOLLOW any of the code you've posted - there's just about NOTHING in there as it stands that is either correct OR good technique.
Come back whenever you need help - I'll try to be Mr. Nice if you try to not make me guess what your problem is if that's fair enough.
Ian