'===================================== '''''''''' Unsuccessful attempts '''''''' '===================================== '**** M6Start == select Tools **** ' input signals poz = Index ' Port_2 Pin_6 active one in the right TOOL bit0 = Input1 ' 0000 Port_2 Pin_2 bit1 = Input2 ' 0000 Port_2 Pin_3 bit2 = Input3 ' 0000 Port_2 Pin_4 bit3 = Input4 ' 0000 Port_2 Pin_5 ' OEMTrig#1 ' SW-jos ATC Port_2 Pin_12 ' OEMTrig#2 ' SW-sus ATC Port_2 Pin_13 ' OEMTrig#3 ' SW-blocare Port_2 Pin_15 ' signal Run = Output2 ' Port_2 Pin_14 Rotate turret high speed Slo = Output3 ' Port_2 Pin_16 Rotate turret low speed Anti = Output4 ' Port_2 Pin_17 ANTI turret rotation time ' Variabile Dim Tur ' Variable tool shed Dim z_jos Dim z_sus Dim zero_z Dim dif_ Dim fan_1 Dim fan_2 ' Constante MaxTur = 10 ' maximum tools in shed Work_Z = GetOemDro ( 49 ) ' save the position where they did 0 Work Offset rpm = GetRPM () ' save motor rotation OldTool = GetOEMDro (1200) ' Located in machine tool Tool = GetSelectedTool() ' Tool of the program should work NewTool = Tool Message " old "& OldTool Message " new " & Tool If IsActive(ZHome) Then ' Milling head on ZHom Message "Get down tool Z - HOME and refa Z - HOME" Sleep (100) Exit Sub End If Call Turela(Tur) Message "Rise in pensions"& OldTool While NewTool = 0 NewTool = Question ("Please select Number. The tool different from 0" ) Wend While NewTool > MaxTur NewTool = Question ("MAXIMUM Tools turret ditch " & MaxTur) Wend If NewTool = OldTool Then ' If the machine tool is one of the program SetUserDRO( 1200,NewTool ) ' Subscribe new tool SetCurrentTool( NewTool ) ' Subscribe new tool Sleep ( 100 ) Exit Sub ' Do not change tools End If fan_1 = 0 fan_2 = 0 Call Urca_sw() ' Get the magazine If fan_1 = 1 Then ' Daca nu s-a BLOCAT Motorul sculei Call Coboara() ' HOME head descend to Z DoButton(3) ' stop moving Message "NU a fost BLOCAT Motorul sculei" Sleep (50) Exit Sub End If Call Selectie() ' Select the desired tool If fan_2 = 1 Then ' if not we got up at HOME Z Call Coboara() ' HOME head descend to Z DoButton(3) ' stop moving Message "Problem TURRET top" Sleep (50) Exit Sub End If Call Coboara() ' Coboara la Z_Home ' +++++++++++===== CLIMBING head to take TOOL =====+++++ ''' Be executed only if Santa SW_Sus '''' Sub Urca_sw() ' climbs to sw-OemTrig1 If IsActive(OEMTrig2) Then ' Daca santem sus putem selecta Exit Sub ' SCULELE End If Call AcasaZ() ' urca pana la sw-ZHome Sleep (100) z_casa = GetOEMDRO(85) ' citim poz- unde s-a atins ZHome z_jos = 73 + z_casa ' limita MAXIMA unde este SW z_sus = 205 + z_casa ' limita MAXIMA unde este SW Sleep (50) SetSpinSpeed( 200 ) ' 500 rotatii sens_ciasornic Sleep (50) DoSpinCW() Sleep (50) Call sw_jos ' acum e acum Message " S-a ajuns la SW_Jos " ' sugestiv ! NU ??? Sleep (50) ' ----------------------------------------------------- If sw_ax = 1 Then ' axul motorului nu e pe pozitie z_ze = GetOEMDRO(85) ' Aducem coordonata absoluta a masinii Message " Coboram urgent " Sleep ( 5000 ) SetDRO( 2 , z_ze ) ' inlocuim pozitia cutenta cu Machine Coordonate Sleep ( 50 ) code " G00 Z-1" ' Urcam Scula la 0 ( ZERO ) pe coord Z Sleep ( 500 ) While IsMoving() ' Asteptam executia Sleep ( 500 ) Wend DoButton(24) ' Aducem axa Z la pozitia Home Exit Sub ' si iesim din subprocedura End If ' ----------------------------------------------------- Call sw_sus ' aici dorim SCHIMBAREA Message " S-a ajuns la SW_Sus " ' sugestiv ! NU ??? Sleep (50) End Sub '''''''''''''''Subprogram din urcarea CAPului '''''''''''''' Sub AcasaZ() ' Dorim aducerea sculei la ZHome z_zero = GetOEMDRO(85) ' Aducem coordonata absoluta a masinii Message " Urcam la ZZ--Home "& z_zero ' Sleep (100 ) SetDRO( 2 , z_zero ) ' inlocuim pozitia cutenta cu Machine Coordonate Sleep (100 ) code " G00 Z-2" ' Urcam Scula la 0 ( ZERO ) pe coord Z Sleep (100) While IsMoving() ' Asteptam executia Sleep (500) Wend DoButton(24) ' Aducem axa Z la pozitia Home Sleep (50) End Sub '''''''''''''''Subprogram din urcarea CAPului '''''''''''''' Sub sw_jos() ' Dorim scula la sw_OemTrig 1 SetDRO( 2 , 0 ) ' inlocuim pozitia cutenta cu zero Message " Z_Jos = "&z_jos While Not IsActive(OEMTrig1)' pana la OemTrig1 Sleep(50) code " G00 F 300 Z"&z_jos 'cu viteza urcam spre VIITOR Wend Sleep(50) DoButton(3) ' Oprim ZZZborul Sleep(50) DoSpinStop ' oprim motorul FREZA Sleep(50) End Sub '''''''''''''''Subprogram din urcarea CAPului '''''''''''''' Sub sw_sus() ' Dorim scula la sw_OemTrig 2 If IsActive(OEMTrig3) Then ' daca axul motorului nu e pozitionat oprit de VENTIL Message " Nu este BLOCAT Motorul" ' Punem mesajul Sleep ( 50 ) ' Afisam si ateptam fan_1 = 1 ' setam un fanion in ( UNU ) Sleep ( 5000 ) ' Afisam si asteptam sa CITIM Exit Sub ' si iesim din subprocedura End If Message " Z_Sus = "&z_sus While Not IsActive(OEMTrig2)' pana la OemTrig 2 Sleep(50) code " G00 F 200 Z"&z_sus 'USUREL urcam spre VIITOR Wend Sleep(50) DoButton(3) ' Oprim ZZZborul Sleep(50) End Sub ' +++++++======+++++ SELECTAREA SCULELOR +++++++=========++++ Sub Selectie() If IsActive(OEMTrig2) = False Then ' Daca TOTUSI nu este turela sus Message " Nu este TURELA sus " ' Punem mesajul Sleep ( 50 ) ' Afisam si asteptam sa CITIM fan_2 = 1 ' Pozitionam fanionul 2 in ( UNU ) Sleep ( 5000 ) ' Afisam si asteptam sa CITIM Exit Sub ' incercam iesirea fortata End If Message " Selectam scula " Sleep ( 300 ) If NewTool < OldTool Then ' daca Nr.nou mai mic decat Nr. vechi dif_ = OldTool - NewTool ' diferenta de pozitie intre scule If dif_ <= 5 Then ' si diferenta e mai mica sau egal cu 5 ActivateSignal(Anti) ' Vom Invarti ANTI_Orar Sleep ( 80 ) Call Rotim() ' Rotim anti Orar Else dif_ = 10 - dif_ ' diferenta mare Call Rotim() ' Rotim Orar End If Else dif_ = NewTool - OldTool ' diferenta de pozitie intre scule If dif_ <= 5 Then ' ' Noula e mai mica rotim ORAR Call Rotim() ' Rotim ORAR Else dif_ = 10 - dif_ ' diferenta mare ActivateSignal(Anti) ' Vom Invarti ANTI_Orar Sleep ( 80 ) Call Rotim() ' Rotim anti Orar End If End If End Sub Sub Rotim() While dif_ <> 1 ' Daca diferenta dintre scule mai mare ActivateSignal(Run) ' decat 1 Atunci rotim RAPID pana la Sleep ( 200 ) ' apropierea de 1 While IsActive( poz ) = True ' Atata timp cat este Activ Message " asteptam eliberare POZ dif_"& dif_ ' astemtam trecerea Sleep (160 ) Wend While IsActive( poz ) = False ' Atata timp cat nu e Activ Message " asteptam POZ dif_"& dif_ ' asteptam trecerea pentru.. Sleep (160 ) Wend dif_ = dif_ - 1 ' a consemna faptul Wend '______________ ___________ While IsActive( poz ) = True ' Atata timp cat este Activ Message " asteptam eliberare POZ dif_"& dif_ ' astemtam trecerea Sleep (160 ) ActivateSignal(Run) ' cu Turatie ActivateSignal(Slo) ' Mica Wend '______________ ___________ While OldTool <> NewTool ' Acum asteptam aducerea Sculei Sleep ( 60 ) ' pe pozitie Message " Aducem Pensa "& NewTool Call Turela(Tur) Wend DeActivateSignal(Run) ' Oprim Rotirea DeActivateSignal(Slo) ' si la turatie mica DeActivateSignal(Anti) ' dezactivand totul Message " Asteptam 1 s " 'Iar dupa o Asteptare... Sleep ( 500 ) ' 1000 OldTool = 0 Call Turela(Tur) ' reverificam Pensa pt. SIGURANTA OldTool = Tur ' daca e pe pozitie Sleep (100) ' 3000 Message " Pensa -- Noua "& OldTool & NewTool If OldTool <> NewTool Then ' Daca a iesit de pe pozitie Message " PUNE Turela la POZITIE "& NewTool ' trebui pusa din mana Sleep ( 500 ) ' 2000 While OldTool <> NewTool ' Verificam din nou daca Call Turela(Tur) ' este pe pozitie Message " PUNE Turela la POZITIE "& NewTool ' Call Turela(Tur) ' Daca a iesit de pe pozitie Sleep ( 500 ) ' astepta 0.5 s If OldTool = NewTool Then ' Acum este bine si putem continua Message " Acum este Bine " ' deci Bai Bai Exit Sub End If Wend ' Verificam in ciclu pana pozitionam MECANIC End If End Sub ',,,,,,,,,,,,,,,,,,,,, Subrutina CITIRE SCULE de pe TURELA ,,,,,,,,,,,,,,,,,,,,,, Sub Turela(Tur) Tur = 0 If ((IsActive(bit0) = True) And (IsActive(bit1) = False) And (IsActive(bit2) = False ) And (IsActive(bit3) = False )) Then Tur = 1 ' 0001 End If If ((IsActive(bit0) = False) And (IsActive(bit1) = True) And (IsActive(bit2) = False ) And (IsActive(bit3) = False )) Then Tur = 2 ' 0010 End If If ((IsActive(bit0) = True) And (IsActive(bit1) = True) And (IsActive(bit2) = False ) And (IsActive(bit3) = False )) Then Tur = 3 ' 0011 End If If ((IsActive(bit0) = False) And (IsActive(bit1) = False) And (IsActive(bit2) = True ) And (IsActive(bit3) = False )) Then Tur = 4 ' 0100 End If If ((IsActive(bit0) = True) And (IsActive(bit1) = False) And (IsActive(bit2) = True ) And (IsActive(bit3) = False )) Then Tur = 5 ' 0101 End If If ((IsActive(bit0) = False) And (IsActive(bit1) = True) And (IsActive(bit2) = True ) And (IsActive(bit3) = False )) Then Tur = 6 ' 0110 End If If ((IsActive(bit0) = True) And (IsActive(bit1) = True) And (IsActive(bit2) = True ) And (IsActive(bit3) = False )) Then Tur = 7 ' 0111 End If If ((IsActive(bit0) = False) And (IsActive(bit1) = False) And (IsActive(bit2) = False ) And (IsActive(bit3) = True )) Then Tur = 8 ' 1000 End If If ((IsActive(bit0) = True) And (IsActive(bit1) = False) And (IsActive(bit2) = False ) And (IsActive(bit3) = True )) Then Tur = 9 ' 1001 End If If ((IsActive(bit0) = False) And (IsActive(bit1) = True) And (IsActive(bit2) = False ) And (IsActive(bit3) = True )) Then Tur = 10 ' 1010 End If OldTool = Tur End Sub ' +++++++======+++++ Coboara SCULA din magazie +++++++=========++++ Sub Coboara() zero_z = GetOEMDRO(85) ' Aducem coordonata absoluta a masinii Message " Coboram SCULA - "&NewTool ' pozitia pe care o dorim Sleep 50 SetDRO( 2 , zero_z ) ' inlocuim pozitia cutenta cu Machine Coordonate Sleep 50 code " G00 Z-1" ' coboram Scula la 0 ( ZERO ) pe coord Z Sleep 500 While IsMoving() ' Sleep (500) Wend DoButton(24) ' SetSpinSpeed( rpm ) ' Restabilim turatia veche SetUserDRO( 1200,NewTool ) ' Inscriem noua scula SetCurrentTool( NewTool ) ' Inscriem noua scula Sleep ( 100 ) ' End Sub '__________________ Refacerea Pozitiei de Z _______________ 'Sub Refacere () ' Incercam refacerea datelor pe AXA Z Message " Work_Z = " &Work_Z Sleep ( 100 ) Lung = ToolLengthOffset Message " Lung " &Lung Sleep ( 100 ) Dep = Work_Z + Lung Message " Dep = " & Dep Sleep ( 100 ) Code " G0 Z"& Dep Sleep (100) While IsMoving() ' Sleep (500) Wend If IsActive(ZHome) Then ' pana nu se ajunge la ZHome Message " Lungime Scula in Z - HOME " Sleep (100) Exit Sub End If Sleep(50) DoButton ( 10 ) ' Refacem ZERO - 0 - pe axa Z Sleep (200) DoButton(0) ' START CYCLU sleep (500) End Sub