Изменения документа Макрос для формирования карты высот
Редактировал(а) Edgar Allan Poe 2024/11/14 17:01
Сводка
-
Свойства страницы (3 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Родительский документ
-
... ... @@ -1,1 +1,1 @@ 1 -Руководство пользователя.Описание M-кодов.Примеры макросов.WebHome 1 +PUMPUBLIC.Руководство пользователя.Описание M-кодов.Примеры макросов.WebHome - Автор документа
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. Knetyaga1 +XWiki.abolgov - Содержимое
-
... ... @@ -1,81 +1,85 @@ 1 1 Для определённых задач (например, фрезеровки печатных плат) возникает необходимость сканирования поверхности с последующей корректировкой неровностей по Z. Карта высот подготавливается с помощью макроса (пример ниже), и на основе этой карты высот модифицируется G-код. Сформировать G-код с готовыми координатами можно, например, в программе G-Code Ripper. 2 2 3 -{{code language="lua"}}3 +{{code}} 4 4 function m155() 5 - local XWidth = 70 6 - local YWidth = 50 7 - local SafeZ = 3 8 - local ProbeZ = -3 9 - local StepX = 15 10 - local StepY = 15 11 - local Feed = 50 12 - local TipHeight = 0 13 - local ProbeFilename = "C:\temp\probe.txt" 14 - 15 - PushCurrentDistanceMode() 16 - PushCurrentMotionMode() 17 - 18 - if (IsProbingPinConfigured()) then 19 - file, msg = io.open(ProbeFilename, "w") -- open the file 20 - 21 - if (file == nil) then 22 - DisplayMessage("Could not open probe output file ("..msg..")") 23 - Stop() 24 - return 25 - end 26 - 27 - ExecuteMDI("F "..Feed) 28 - ExecuteMDI("G90 G38.2 Z-100") 29 - 30 - ExecuteMDI("G92 X0Y0Z0") -- set the current location to 0,0,0 31 - ExecuteMDI("G0 Z"..SafeZ) 32 - 33 - local direction = 0 34 - for y = 0, YWidth, StepY do 35 - if (direction == 1) then 36 - direction = 0 37 - else 38 - direction = 1 39 - end 40 - 41 - for x = 0, XWidth, StepX do 42 - if (direction == 1) then 43 - ExecuteMDI("G0 X"..x.." Y"..y.." Z"..SafeZ) 44 - else 45 - ExecuteMDI("G0 X"..(XWidth - x).." Y"..y.." Z"..SafeZ) 46 - end 47 - 48 - ExecuteMDI("G38.2 Z"..ProbeZ) 49 - LogCurrentPos(TipHeight) 50 - ExecuteMDI("G0 Z"..SafeZ) 51 - end 52 - end 53 - 54 - if (direction == 1) then 55 - ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ) 56 - else 57 - ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ) 58 - end 59 - 60 - local HighZ = 5 61 - ExecuteMDI("G0 Z"..HighZ) 62 - ExecuteMDI("G0 X0Y0") 63 - 64 - file:close() 65 - else 66 - DisplayMessage("Probe input is not configured") 67 - return 68 - end 5 + local XWidth = 70 6 + local YWidth = 50 7 + local SafeZ = 3 8 + local ProbeZ = -3 9 + local StepX = 15 10 + local StepY = 15 11 + local Feed = 50 12 + local TipHeight = 0 13 + local ProbeFilename = "C:\temp\probe.txt" 14 + 15 + PushCurrentDistanceMode() 16 + PushCurrentMotionMode() 17 + 18 + if (IsProbingPinConfigured()) then 19 + -- open the file 20 + file, msg = io.open(ProbeFilename, "w") 21 + 22 + if (file == nil) then 23 + DisplayMessage("Could not open probe output file ("..msg..")") 24 + Stop() 25 + return 26 + end 27 + 28 + ExecuteMDI("F "..Feed) 29 + ExecuteMDI("G90 G38.2 Z-100") 30 + 31 + -- set the current location to 0,0,0 32 + ExecuteMDI("G92 X0Y0Z0") 33 + ExecuteMDI("G0 Z"..SafeZ) 34 + 35 + local direction = 0 36 + for y = 0, YWidth, StepY do 37 + if (direction == 1) then 38 + direction = 0 39 + else 40 + direction = 1 41 + end 42 + 43 + for x = 0, XWidth, StepX do 44 + if (direction == 1) then 45 + ExecuteMDI("G0 X"..x.." Y"..y.." Z"..SafeZ) 46 + else 47 + ExecuteMDI("G0 X"..(XWidth - x).." Y"..y.." Z"..SafeZ) 48 + end 49 + 50 + ExecuteMDI("G38.2 Z"..ProbeZ) 51 + LogCurrentPos(TipHeight) 52 + ExecuteMDI("G0 Z"..SafeZ) 53 + end 54 + end 55 + 56 + if (direction == 1) then 57 + ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ) 58 + else 59 + ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ) 60 + end 61 + 62 + local HighZ = 5 63 + ExecuteMDI("G0 Z"..HighZ) 64 + ExecuteMDI("G0 X0Y0") 65 + 66 + file:close() 67 + else 68 + DisplayMessage("Probe input is not configured") 69 + return 70 + end 69 69 end 70 70 71 71 function LogCurrentPos(tipHeight) 72 - 73 - 74 - 75 - 76 - 77 - 74 + local CurrX = AxisGetPos(Axis.X) 75 + local CurrY = AxisGetPos(Axis.Y) 76 + local CurrZ = AxisGetPos(Axis.Z) 77 + 78 + local fmt = "%.5f" 79 + file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..","..string.format(fmt, CurrZ - tipHeight), "\n") 78 78 end 79 79 {{/code}} 80 80 81 -[[Скачать макрос>>attach:M155.pm]] 83 + 84 + 85 +{{view-file att--filename="M155.pm" name="" height="250"/}}