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

От версии 1.1
отредактировано og
на 2019/08/05 11:22
Изменить комментарий: К данной версии нет комментариев
К версии 7.1
отредактировано writer
на 2023/03/01 11:50
Изменить комментарий: К данной версии нет комментариев

Сводка

Подробности

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