diff --git a/Common-PF1250.TPA.mlpe b/Common-PF1250.TPA.mlpe index d8b6e25..184532e 100644 --- a/Common-PF1250.TPA.mlpe +++ b/Common-PF1250.TPA.mlpe @@ -407,10 +407,18 @@ function OnMachiningStart() -- se lama su aggregato testa sotto, aggiusto subito angolo scelto per asse virtuale A elseif EMT.HEAD == 'H22' then -- valore dell'asse virtuale + local dPrevA = dPosA dPosA = GetCurrSawingVirtualAxis() -- imposto home dell'asse C2 (A=0 -> T201, A=90 -> T204) local MyParkCSawC2 = GetSawCHomeFromVirtualAxis( dPosA) EmtModifyAxisHome( 'C2', MyParkCSawC2) + -- se lavorazione attuale e precedente con sega a catena con angolo A diverso, devo scaricare e ricaricare + if EMT.HEAD == EMT.PREVHEAD_H2 then + if abs( dPosA - dPrevA) > 1 then + EMT.TO_ZMAX = true + EMT.R3_CHANGED = true + end + end end -- gestione eventuale lavorazione in doppio @@ -805,12 +813,16 @@ function OnRapid() -- se bisogna scrivere tutti gli assi if WriteAllCoordsOnFirstM101 then if EMT.HEAD == 'H22' then - EmitMoveDataHead( 2, { X=MinX2, Z=ParkZ2, B=ParkB2, C=ParkC2, S=Speed}) + EmitMoveDataHead( 2, { X=ParkSawX2, Z=ParkZ2, B=0, C=ParkC2, S=Speed}) else EmitMoveDataHead( 2, { X=ParkX2, Z=ParkZ2, B=ParkB2, C=ParkC2, S=Speed}) end else - EmitMoveDataHead( 2, { X=ParkX2, S=Speed}) + if EMT.HEAD == 'H22' then + EmitMoveDataHead( 2, { X=ParkSawX2, S=Speed}) + else + EmitMoveDataHead( 2, { X=ParkX2, S=Speed}) + end end EmitMoveStartHead( 2) EmitMoveWaitHead( 2) @@ -821,8 +833,8 @@ function OnRapid() local dPosT = EMT.TPOS or EMT.L1op EmitParkRoller( dPosT, bSplitCut) end - EmitMoveDataHead( 2, { X=EMT.L2, Z=EMT.L3, S=Speed}) EmitMoveDataHead( 2, { B=EMT.R2, C=EMT.R1, S=Speed}) + EmitMoveDataHead( 2, { X=EMT.L2, Z=EMT.L3, S=Speed}) EmitMoveStartHead( 2) -- eventuale preselezione successiva testa 1 PreselectNextDiffHead( EMT.MCHID, EMT.HEAD) @@ -909,7 +921,18 @@ function OnRapid() else --MyOutput( string.format( 'V1Pos=%.3f V2Pos=%.3f', EMT.V1POS, EMT.V2POS)) if not EMT.RELOAD and not EMT.ZMAX and #EMT.AUXCMD > 0 and EMT.TO_ZMAX then - EmitZmax( false, false, PrevR1, PrevR2) + -- caso speciale in cui bisogna solo cambiare presa aggregato lama sotto + if EMT.R3_CHANGED then + -- EmitZmax è fatta per essere chiamata con utensile attuale. In questo caso l'attuale è già quello con nuova rotazione + -- Allora salvo l'attuale e imposto il vecchio solo momentanemente, per poi ripristinarlo + local sBckTcPos = EMT.TCPOS + EMT.TCPOS = EMT.PREVTCPOSREAL_H2 + EmitZmax( false, false, PrevR1, PrevR2) + EMT.TCPOS = sBckTcPos + EMT.R3_CHANGED = nil + else + EmitZmax( false, false, PrevR1, PrevR2) + end EMT.ZMAX = true EMT.TO_ZMAX = nil PrevR1 = EgtGetAxisHomePos( EgtIf( nHSet == 1, 'C1', 'C2')) @@ -1074,26 +1097,19 @@ function OnRapid() EMT.TCPOSREAL = 'T' .. AdjustTcPos( false, EMT.TCPOS, EMT.R3) -- se utensile cambiato (controllo il reale perchè per aggregato dipende come è stato caricato) if EMT.PREVTCPOSREAL_H2 ~= EMT.TCPOSREAL then - if EMT.ZMAX then - -- se bisogna scrivere tutti gli assi - if WriteAllCoordsOnFirstM101 then - if EMT.HEAD == 'H22' then - EmitMoveDataHead( 2, { X=MinX2, Z=-CurrZ2, B=CurrB2, C=CurrC2, S=Speed}) - else - EmitMoveDataHead( 2, { X=SafeX2, Z=-CurrZ2, B=CurrB2, C=CurrC2, S=Speed}) - end - end - -- scrivo solo se gli assi rotanti sono cambiati - EmitMoveDataHead( 2, { Z=-dSafeZ2, S=Speed}) - if EMT.L2p > ParkMchY2 and ( CurrB2 ~= EMT.R2 or CurrC2 ~= EMT.R1) then - EmitMoveDataHead( 2, { X=ParkMchY2, Z=-dSafeZ2, B=CurrB2, C=CurrC2, S=Speed}) - end - else - -- scrivo solo se gli assi rotanti sono cambiati - if EMT.L2p > ParkMchY2 and ( CurrB2 ~= EMT.R2 or CurrC2 ~= EMT.R1) then - EmitMoveDataHead( 2, { X=ParkMchY2, Z=-dSafeZ2, B=CurrB2, C=CurrC2, S=Speed}) + -- se bisogna scrivere tutti gli assi + if WriteAllCoordsOnFirstM101 then + if EMT.HEAD == 'H22' then + EmitMoveDataHead( 2, { X=ParkSawX2, Z=-dSafeZ2, B=0, C=CurrC2, S=Speed}) + else + EmitMoveDataHead( 2, { X=SafeX2, Z=-dSafeZ2, B=CurrB2, C=CurrC2, S=Speed}) end end + -- scrivo solo se gli assi rotanti sono cambiati + EmitMoveDataHead( 2, { Z=-dSafeZ2, S=Speed}) + if EMT.HEAD ~= 'H22' and EMT.L2p > ParkMchY2 and ( CurrB2 ~= EMT.R2 or CurrC2 ~= EMT.R1) then + EmitMoveDataHead( 2, { X=ParkMchY2, Z=-dSafeZ2, B=CurrB2, C=CurrC2, S=Speed}) + end -- se stesso utensile vado già alla X di lavoro else -- scrivo solo se gli assi rotanti sono cambiati @@ -2131,12 +2147,13 @@ function AdjustTcPos( bLen3, sTcPos, dAxR3) if not dAxR3 then dAxR3 = EMT.R3 end if abs( dAxR3 - 0) < 0.1 then sPos = '201' - elseif abs( dAxR3 - 270) < 0.1 then - sPos = '202' - elseif abs( dAxR3 - 180) < 0.1 then - sPos = '203' elseif abs( dAxR3 - 90) < 0.1 then sPos = '204' + -- Lama su aggregato da sotto non può essere presa in queste posizioni per problemi di collisione durante parcheggio + --elseif abs( dAxR3 - 270) < 0.1 then + -- sPos = '202' + --elseif abs( dAxR3 - 180) < 0.1 then + -- sPos = '203' else EmtSetLastError( 1210, 'Saw orientation not allowed') end diff --git a/Common-PF1250.mlpe b/Common-PF1250.mlpe index 985569e..e8126b8 100644 --- a/Common-PF1250.mlpe +++ b/Common-PF1250.mlpe @@ -480,12 +480,14 @@ function OnSimulToolSelect( dPosA) end -- se lama su aggregato da sotto, imposto subito angolo scelto per asse virtuale A if EMT.HEAD == 'H22' then + -- se c'era un altro utensile, imposto subito asse virtuale + if EMT.PREVHEAD_H2 ~= 'H22' then + dPosA = dPosA or GetNextSawingVirtualAxis( EMT.MCHID) + end if dPosA then - -- valore dell'asse virtuale - dPosA = dPosA or GetNextSawingVirtualAxis( EMT.MCHID) -- imposto il valore di A EgtSetAxisPos( 'A2', dPosA) - -- imposto home dell'asse C1 (A2=0 -> T101, A2=90 -> T104) + -- imposto home dell'asse C1 (A2=0 -> T201, A2=90 -> T204) local MyParkSawC2 = GetSawCHomeFromVirtualAxis( dPosA) EmtModifyAxisHome( 'C2', MyParkSawC2) EgtSetAxisPos( 'C2', MyParkSawC2) @@ -531,7 +533,7 @@ function OnSimulToolDeselect( dPrevA) if nSetHead == 3 then SimulMoveAxis( 'X3', ParkX3, MCH_SIM_STEP.RAPID) -- per testa gruppo 2 - elseif nNextSetHead == 2 and EMT.PREVTCPOS_H2 then + elseif nNextSetHead == 2 then -- deposito lama su aggregato testa sotto if EMT.PREVHEAD_H2 == 'H22' then -- simulo movimento @@ -667,6 +669,10 @@ function OnSimulMachiningStart() local dPosA = tonumber( sVal:sub( 4)) or 0 if abs( dPosA - dPrevA) > 1 then ExecParkRoller( nil, nil, nil, nil, false, bAgg) + -- setto i valori per la funzione ToolDesel + EMT.NEXTHEAD = EMT.HEAD + EMT.NEXTTOOL = EMT.TOOL + EMT.NEXTEXIT = EMT.EXIT OnSimulToolDeselect( dPrevA) EgtSetStatus( EgtGetHeadId( EMT.HEAD), GDB_ST.ON) OnSimulToolSelect( dPosA) @@ -962,14 +968,14 @@ function OnSimulMoveStart() -- se bisogna scrivere tutti gli assi if WriteAllCoordsOnFirstM101 then if EMT.HEAD == 'H22' and EMT.PREVHEAD_H2 ~= EMT.HEAD then - SimulMoveAxes( 'X2', MinX2, MCH_SIM_STEP.RAPID, 'B2', B2Home, MCH_SIM_STEP.COLLROT, 'C2', C2Home, MCH_SIM_STEP.COLLROT) + SimulMoveAxes( 'X2', ParkSawX2, MCH_SIM_STEP.RAPID, 'B2', 0, MCH_SIM_STEP.COLLROT, 'C2', C2Home, MCH_SIM_STEP.COLLROT) else SimulMoveAxes( 'X2', SafeX2, MCH_SIM_STEP.RAPID, 'B2', B2Home, MCH_SIM_STEP.COLLROT, 'C2', C2Home, MCH_SIM_STEP.COLLROT) end end SimulMoveAxis( 'Z2', Z2Home, MCH_SIM_STEP.RAPID) -- Porto la X alla giusta quota - if X2Pos > ParkMchY2 and ( B2Pos ~= EMT.R2 or C2Pos ~= EMT.R1) then + if EMT.HEAD ~= 'H22' and X2Pos > ParkMchY2 and ( B2Pos ~= EMT.R2 or C2Pos ~= EMT.R1) then SimulMoveAxis( 'X2', ParkMchY2, MCH_SIM_STEP.RAPID) end else @@ -1895,6 +1901,19 @@ function LoadFirstTool( nHSet, sTcPosDef) -- carico l'utensile EgtLoadTool( sHead, 1, sTool) ShowToolInTcPos( sTcPos, false) + -- salvo utensili caricati + if nHSet == 1 then + EMT.PREVTOOL_H1 = sTool + EMT.PREVHEAD_H1 = sHead + EMT.PREVTCPOS_H1 = sTcPos + EMT.PREVTTOTLEN_H1 = sTTotLen + -- per gruppo testa 2 + elseif nHSet == 2 then + EMT.PREVTOOL_H2 = sTool + EMT.PREVHEAD_H2 = sHead + EMT.PREVTCPOS_H2 = sTcPos + EMT.PREVTTOTLEN_H2 = sTTotLen + end end return sTool end @@ -2318,8 +2337,13 @@ function FindFirstToolOnHeadSet( nHSet) if EgtTdbSetCurrTool( sTest) then sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) if GetHeadSet( sHead) == nHSet then - sTool = sTest sTcPos = EgtTdbGetCurrToolParam( MCH_TP.TCPOS) + -- aggregato lama non si può mai preselezionare e viene sempre scaricato, quindi non sarà mai già caricato + if nHSet == 2 and sTcPos == 'T201' then + sTcPos = nil + break + end + sTool = sTest sTTotLen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) sBlockedAxis = EgtGetMachiningParam( MCH_MP.BLOCKEDAXIS) break diff --git a/UpdateLog.txt b/UpdateLog.txt index a504bdb..211e362 100644 --- a/UpdateLog.txt +++ b/UpdateLog.txt @@ -1,5 +1,8 @@ ==== Common_PF1250 Update Log ==== +Versione 2.6e4 (15/05/2024) +- (SIM-GEN) Miglioramento gestione lama su aggregato da sotto + Versione 2.6e3 (09/05/2024) - (SIM) Corretto prelievo lama 2 (H16). Prima di visualizzare utensile, si sposta la Z alla quota massima. Prima trovava collisione in caso utensile precedente non lama (perchè era già oltre la quota massima). diff --git a/Version.lua b/Version.lua index a2a3685..12835bd 100644 --- a/Version.lua +++ b/Version.lua @@ -3,7 +3,7 @@ local InfoCommon_STD_PP = { NAME = 'Common_PF1250', -- nome script PP standard - VERSION = '2.6e3', -- versione script + VERSION = '2.6e4', -- versione script MIN_MACH_VER_PP_COMMON = '2.5k1' -- versione minima kernel }