Версия 5.1 от writer на 2023/01/26 13:53

Последние авторы
1 Для определённых задач (например, фрезеровки печатных плат) возникает необходимость сканирования поверхности с последующей корректировкой неровностей по Z. Карта высот подготавливается с помощью макроса (пример ниже), и на основе этой карты высот модифицируется G-код. Сформировать G-код с готовыми координатами можно, например, в программе G-Code Ripper.
2
3 {{code language="lua"}}
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
69 end
70
71 function LogCurrentPos(tipHeight)
72 local CurrX = AxisGetPos(Axis.X)
73 local CurrY = AxisGetPos(Axis.Y)
74 local CurrZ = AxisGetPos(Axis.Z)
75
76 local fmt = "%.5f"
77 file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..","..string.format(fmt, CurrZ - tipHeight), "\n")
78 end
79 {{/code}}
80
81 [[Скачать макрос>>attach:M155.pm]]