Версия 5.2 от writer на 2023/01/26 14:11

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