Trumpf TruLaser 2030 Post Processor WIP

–[[
TRUMPF TruLaser .lst → SheetCam TNG post
Estructura alineada con TruTops. Maquina de carga manual:
SHEET_LOAD reducido al minimo. Sin bloque SHEET_UNLOAD.

Orden de bloques:
EINRICHTEPLAN_INFO → SHEET_TECH → SHEET_LOAD (minimo)
→ LTT_CALLS → PROGRAMM → ED

Kerf: lo aplica SheetCam en la trayectoria (NO se usa TC_LASERCORR_ON).

Version: 1
]]

– ===================== CONFIG =====================
postVersion = “1”
machineCode = “L82” – sale como “TruLaser 2030 (L82)”
machineModel = “TruLaser 2030”
company = “A&H Metals”
programmer = “Manuel”

– TC_LASER_ON: parametros finales. Verificar contra docs TRUMPF.
laserOnParam1 = 10
laserOnParam2 = 100

– ---- ESPECIFICO DE MAQUINA ----
controlName = “Sin 840D” – correcto: tu 2030 fiber usa Siemens 840D
machineName = “L2510” – RELLENO del foro. Reemplazar con tu Radan.
includeFeed = 1 – 1 = emitir F de arranque
programFeed = 11102 – RELLENO del foro. Reemplazar, o poner 0 si sale de la LTT.
flagTops = 0 – 0 = programa externo. No es ToPs.


– =================================================

lttName = “”

function matInfo(name)
local m = string.sub(name, 1, 2)
if m == “SS” then return 0.286, “Stainless”
elseif m == “AL” then return 0.0975, “Aluminum”
elseif m == “ST” then return 0.284, “Mild Steel”
elseif m == “GV” then return 0.284, “Galvanized”
end
return 0.284, “Steel”
end

– Coordenada de corte: snap a cero limpio, 4 decimales
function num(v)
if math.abs(v) < 0.00005 then v = 0 end
post.Number(v, “0.0000”)
end

function N()
post.Text(“N”)
post.Number(lineNumber, “0”)
lineNumber = lineNumber + 10
end

function OnNewLine()
end

function OnComment(text)
N(); post.Text(“;”, text, “\n”)
end

function OnInit()
lineNumber = 10
toolChangeCount = 0
bigArcs = 1
minArcSize = 0.05

progName = string.gsub(fileName, “%.%w+$”, “”)

post.Text(“BD\n”)
if scale == metric then post.Text(“SET_METRIC\n”) else post.Text(“SET_INCH\n”) end
end

function OnToolChange()
toolChangeCount = toolChangeCount + 1
if toolChangeCount > 1 then
post.Warning(“Este post soporta una sola herramienta por job. La herramienta extra se ignoro. Usa una sola LTT.”)
return
end

lttName = toolName

– Tamano y espesor de chapa (materialX1..Y2, materialThick siempre en mm)
sheetX, sheetY, sheetThick = 0, 0, 0
if materialX1 ~= nil and materialX2 ~= nil then sheetX = (materialX2 - materialX1) * scale end
if materialY1 ~= nil and materialY2 ~= nil then sheetY = (materialY2 - materialY1) * scale end
if materialThick ~= nil then sheetThick = materialThick * scale end
if sheetX <= 0 or sheetY <= 0 then
post.Warning(“Tamano de chapa cero o indefinido. Define el material en el job de SheetCam.”)
end

dens, matName = matInfo(lttName)
local weight = sheetX * sheetY * sheetThick * dens
local u = “in”
if scale == metric then u = “mm” end

– ---------- EINRICHTEPLAN_INFO (28 campos, estructura TruTops) ----------
post.Text(“BEGIN_EINRICHTEPLAN_INFO\n”)
post.Text(“ZA,MM,28\n”)
post.Text(“MM,AT,1, 10,1,1,‘Maschine’ ,‘’,T\n”)
post.Text(“MM,AT,1, 20,1,1,‘Typ’ ,‘’,Z\n”)
post.Text(“MM,AT,1, 30,1,1,‘Steuerung’ ,‘’,T\n”)
post.Text(“MM,AT,1, 40,1,1,‘Variante’ ,‘’,Z\n”)
post.Text(“MM,AT,1, 50,1,1,‘Firma’ ,‘’,T\n”)
post.Text(“MM,AT,1, 60,1,1,‘Programmnummer’ ,‘’,T\n”)
post.Text(“MM,AT,1, 70,1,1,‘Bearbeiter’ ,‘’,T\n”)
post.Text(“MM,AT,1, 80,1,1,‘Datum’ ,‘’,T\n”)
post.Text(“MM,AT,1, 90,1,1,‘Auftragsname’ ,‘’,T\n”)
post.Text(“MM,AT,1, 100,1,1,‘Anzahl der Programmdurchlaeufe’ ,‘’,Z\n”)
post.Text(“MM,AT,1, 110,1,1,‘Tafelname’ ,‘’,T\n”)
post.Text(“MM,AT,1, 120,1,1,‘Speicherbedarf’ ,‘’,Z\n”)
post.Text(“MM,AT,1, 130,1,1,‘Material-ID’ ,‘’,T\n”)
post.Text(“MM,AT,1, 140,1,1,‘Tafelgewicht’ ,‘lbs’,Z\n”)
post.Text(“MM,AT,1, 150,1,1,‘Maschinenzeit’ ,‘min’,Z\n”)
post.Text(“MM,AT,1, 160,1,1,‘Bemerkung’ ,‘’,T\n”)
post.Text(“MM,AT,1, 170,1,1,‘Flag Automatisiert’ ,‘Bool’,Z\n”)
post.Text(“MM,AT,1, 180,1,1,‘Flag ToPsxxx-Programm’ ,‘Bool’,Z\n”)
post.Text(“MM,AT,1, 190,1,1,‘Einrichteplanfilename’ ,‘’,T\n”)
post.Text(“MM,AT,1, 200,1,1,‘Lagergutbezeichnung’ ,‘’,T\n”)
post.Text(“MM,AT,1, 210,1,1,‘Palettierungsflag’ ,‘Bool’,Z\n”)
post.Text(“MM,AT,1, 220,1,1,‘Palettierungmodus’ ,‘’,Z\n”)
post.Text(“MM,AT,1, 230,1,1,‘Palette putzen’ ,‘Bool’,Z\n”)
post.Text(“MM,AT,1, 240,1,1,‘Sauger putzen’ ,‘Bool’,Z\n”)
post.Text(“MM,AT,1, 250,1,1,‘SystemPalletType’ ,‘’,T\n”)
post.Text(“MM,AT,1, 260,1,1,‘Bearbeitungszeit PierceLine’ ,‘min’,Z\n”)
post.Text(“MM,AT,1, 270,1,1,‘Schneidlaenge’ ,‘”, u, “’,Z\n”)
post.Text(“MM,AT,1, 280,1,1,‘viewer name machine’ ,‘’,T\n”)
post.Text(“ZA,DA,1\n”)
post.Text(“DA,‘”, machineName, “‘,1,’”, controlName, “‘,1,’”, company, “‘,’”, progName, “‘,’”, programmer, “’,\n”)
post.Text(“* ‘”, date, “‘,’’,1,\n”)
post.Text(“* ‘’,0,\n”)
post.Text(“* ‘”, matName, “’,”); post.Number(weight, “0.000”)
post.Text(“,0.00,‘’,0,”); post.Number(flagTops, “0”)
post.Text(“,‘’,‘’,0,0,0,0,‘’,0.00,0.000,‘”, machineModel, " (", machineCode, “)’\n”)
post.Text(“ENDE_EINRICHTEPLAN_INFO\n”)
post.Text(“C\n”)

– ---------- SHEET_TECH (9 campos) ----------
post.Text(“BEGIN_SHEET_TECH\n”)
post.Text(“C\n”)
post.Text(“ZA,MM,9\n”)
post.Text(“MM,AT,1, 10,1,1,‘Tabellenidentifikator’ ,‘’,T\n”)
post.Text(“MM,AT,1, 20,1,1,‘Blechmass X’ ,‘”, u, “’,Z\n”)
post.Text(“MM,AT,1, 30,1,1,‘Blechmass Y’ ,‘”, u, “’,Z\n”)
post.Text(“MM,AT,1, 40,1,1,‘Blechmass Z’ ,‘”, u, “’,Z\n”)
post.Text(“MM,AT,1, 200,1,1,‘TRUMPF-Kennung’ ,‘’,Z\n”)
post.Text(“MM,AT,1, 220,1,1,‘Blechmass X real’ ,‘”, u, “’,Z\n”)
post.Text(“MM,AT,1, 230,1,1,‘Blechmass Y real’ ,‘”, u, “’,Z\n”)
post.Text(“MM,AT,1, 240,1,1,‘Materialkennung’ ,‘’,T\n”)
post.Text(“MM,AT,1, 260,1,1,‘Werkstoffdichte’ ,‘’,Z\n”)
post.Text(“C\n”)
post.Text(“ZA,DA,1\n”)
post.Text(“DA,‘SHT-1’,”)
post.Number(sheetX,“0.000”); post.Text(“,”)
post.Number(sheetY,“0.000”); post.Text(“,”)
post.Number(sheetThick,“0.000”); post.Text(“,1,”)
post.Number(sheetX,“0.000”); post.Text(“,”)
post.Number(sheetY,“0.000”); post.Text(“,‘”, matName, “’,”)
post.Number(dens,“0.000”); post.Text(“\n”)
post.Text(“C\n”)
post.Text(“ENDE_SHEET_TECH\n”)
post.Text(“C\n”)

– ---------- SHEET_LOAD (minimo, carga manual) ----------
post.Text(“BEGIN_SHEET_LOAD\n”)
post.Text(“C\n”)
post.Text(“ZA,MM,1\n”)
post.Text(“MM,AT,1, 10,1,1,‘Tabellenidentifikator’ ,‘’,T\n”)
post.Text(“C\n”)
post.Text(“ZA,DA,1\n”)
post.Text(“DA,‘SHL-1’\n”)
post.Text(“C\n”)
post.Text(“ENDE_SHEET_LOAD\n”)
post.Text(“C\n”)

– ---------- LTT_CALLS ----------
post.Text(“BEGIN_LTT_CALLS\n”)
post.Text(“C\n”)
post.Text(“ZA,MM,1\n”)
post.Text(“MM,AT,1, 10,1,1,‘Tabellenidentifikator’ ,T\n”)
post.Text(“C\n”)
post.Text(“ZA,DA,1\n”)
post.Text(“DA,‘”, lttName, “’\n”)
post.Text(“C\n”)
post.Text(“ENDE_LTT_CALLS\n”)
post.Text(“C\n”)
post.Text(“C\n”)

– ---------- PROGRAMM ----------
post.Text(“BEGIN_PROGRAMM\n”)
post.Text(“C\n”)
post.Text(“ZA,MM,5\n”)
post.Text(“MM,AT,1, 10,1,1,‘Programmnummer’ ,‘’,T\n”)
post.Text(“MM,AT,1, 20,1,1,‘Programmtyp’ ,‘’,T\n”)
post.Text(“MM,AT,1, 30,1,1,‘Bemerkung’ ,‘’,T\n”)
post.Text(“MM,AT,1, 40,1,1,‘Bearbeitungszeit’ ,‘min’,Z\n”)
post.Text(“MM,AT,1, 50,1,1,‘Dateityp’ ,‘’,T\n”)
post.Text(“C\n”)
post.Text(“ZA,DA,1\n”)
post.Text(“DA,‘”, progName, “‘,‘HP’,’’,0.00,‘LST’\n”)
post.Text(“START_TEXT\n”)

N(); post.Text(“MSG( “MAIN PROGRAMME NUMBER,”, progName, “” )\n”)
N(); post.Text(“MSG( “DIMENSION OF SHEET: “)
post.Number(sheetThick,“0.000”); post.Text(” X “)
post.Number(sheetX,“0.000”); post.Text(” X “)
post.Number(sheetY,“0.000”); post.Text(” MATERIAL ID: “, matName, “” )\n”)
N(); post.Text(“G90\n”)
N(); if scale == metric then post.Text(“G71\n”) else post.Text(“G70\n”) end
if includeFeed == 1 then
N(); post.Text(“F”); post.Number(programFeed, “0”); post.Text(”\n”)
end
N(); post.Text(“TC_POS_LEVEL(1.0)\n”)
N(); post.Text(“TC_SHEET_TECH(“SHT-1”)\n”)
N(); post.Text(“TC_SHEET_LOAD(“SHL-1”)\n”)
N(); post.Text(“TC_LASER_OFF(1)\n”)
end

function OnPenDown()
N(); post.Text(“;ENTRY_LASER:\n”)
N(); post.Text(“TC_LASER_ON(1,“”, lttName, “”,”)
post.Number(laserOnParam1, “0”); post.Text(“,”)
post.Number(laserOnParam2, “0”); post.Text(“)\n”)
end

function OnPenUp()
N(); post.Text(“TC_LASER_OFF(1)\n”)
end

function OnRapid()
if math.abs(endX) > 1e7 or math.abs(endY) > 1e7 then return end
if endX == currentX and endY == currentY then return end
N(); post.Text(“G00X”); num(endXscale)
post.Text(“Y”); num(endY
scale); post.Text(“\n”)
end

function OnMove()
if endX == currentX and endY == currentY then return end
N(); post.Text(“G01X”); num(endXscale)
post.Text(“Y”); num(endY
scale); post.Text(“\n”)
end

function OnArc()
N()
if arcAngle < 0 then post.Text(“G03”) else post.Text(“G02”) end
post.Text(“X”); num(endXscale)
post.Text(“Y”); num(endY
scale)
post.Text(“I”); num((arcCentreX-currentX)*scale)
post.Text(“J”); num((arcCentreY-currentY)*scale)
post.Text(“\n”)
end

function OnFinish()
N(); post.Text(“M30\n”)
post.Text(“STOP_TEXT\n”)
post.Text(“ENDE_PROGRAMM\n”)
post.Text(“ED\n”)
end