Редактировал(а) Edgar Allan Poe 2024/11/14 17:01

От версии 6.1
отредактировано writer
на 2023/01/26 14:12
Изменить комментарий: К данной версии нет комментариев
К версии 4.1
отредактировано writer
на 2022/06/23 14:50
Изменить комментарий: К данной версии нет комментариев

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -1,65 +1,62 @@
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"
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 14  
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
15 + PushCurrentDistanceMode()
16 + PushCurrentMotionMode()
17 +
18 + if (IsProbingPinConfigured()) then
19 + -- open the file
20 + file, msg = io.open(ProbeFilename, "w")
24 24  
25 25   if (file == nil) then
26 - DisplayMessage("Could not open probe output file ("..msg..")")
27 - Stop()
28 - return
23 + DisplayMessage("Could not open probe output file ("..msg..")")
24 + Stop()
25 + return
29 29   end
30 30  
31 31   ExecuteMDI("F "..Feed)
32 32   ExecuteMDI("G90 G38.2 Z-100")
33 33  
34 - ExecuteMDI("G92 X0Y0Z0") -- set the current location to 0,0,0
31 + -- set the current location to 0,0,0
32 + ExecuteMDI("G92 X0Y0Z0")
35 35   ExecuteMDI("G0 Z"..SafeZ)
36 36  
37 37   local direction = 0
38 38   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
39 39   if (direction == 1) then
40 - direction = 0
45 + ExecuteMDI("G0 X"..x.." Y"..y.." Z"..SafeZ)
41 41   else
42 - direction = 1
47 + ExecuteMDI("G0 X"..(XWidth - x).." Y"..y.." Z"..SafeZ)
43 43   end
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
51 51  
52 - ExecuteMDI("G38.2 Z"..ProbeZ)
53 - LogCurrentPos(TipHeight)
54 - ExecuteMDI("G0 Z"..SafeZ)
55 - end
56 -
50 + ExecuteMDI("G38.2 Z"..ProbeZ)
51 + LogCurrentPos(TipHeight)
52 + ExecuteMDI("G0 Z"..SafeZ)
53 + end
57 57   end
58 58  
59 59   if (direction == 1) then
60 - ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ)
57 + ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ)
61 61   else
62 - ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ)
59 + ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ)
63 63   end
64 64  
65 65   local HighZ = 5
... ... @@ -67,16 +67,19 @@
67 67   ExecuteMDI("G0 X0Y0")
68 68  
69 69   file:close()
67 + else
68 + DisplayMessage("Probe input is not configured")
69 + return
70 + end
70 70  end
71 71  
72 72  function LogCurrentPos(tipHeight)
73 - local CurrX = AxisGetPos(Axis.X)
74 - local CurrY = AxisGetPos(Axis.Y)
75 - local CurrZ = AxisGetPos(Axis.Z)
74 + local CurrX = AxisGetPos(Axis.X)
75 + local CurrY = AxisGetPos(Axis.Y)
76 + local CurrZ = AxisGetPos(Axis.Z)
76 76  
77 - local fmt = "%.5f"
78 - file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..","..
79 - string.format(fmt, CurrZ - tipHeight), "\n")
78 + local fmt = "%.5f"
79 + file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..","..string.format(fmt, CurrZ - tipHeight), "\n")
80 80  end
81 81  {{/code}}
82 82