Macro subroutine collection for Eding's Computerized Numerical Controllers, specialized for Sorotec portal milling machines
Please visit my website for an in-depth introduction into CNC macros.
"A Macro or subroutine is a collection of instructions written for the CNC interpreter to perform actions. They are often used to automate recurring operations."
There are many good third party resources out there to learn about writing them, e.g. cnccookbook, too.
The macros provided in this repository are somewhat narrowed to EdingCNC's interpreter and are starting off a 'fork' of the non-version-controlled Standard_Macro_V2-1e
by Sorotec.
⚠️ Warning: Usage and tryout of macros on a physical machine are kind of risky. There's no safety net. One variable entered incorrectly, a parameter with a wrongly placed decimal separator, or simply a line with an error may lead to severe damage of machine, material, and even injuries. Use the provided macros carefully and at your own risk. I do not take any liability.
💡 Idea: When you write a new routine, use of Code M00
might simplify testing your routine. This code will pause the macro and wait for user input (Cycle Start) to continue.
This repository has two folders for assets:
dialogPictures
that keeps images presented in the dialog message boxesop_f_key
that keeps icons of 'user' macro's function buttonsThe images are pulled by EdingCNC based on their file names. For dialog pictures, e.g. the dlgmsg
's title parameter has to exactly match the corresponding file name in dialogPictures
.
Within the user
folder, icon names have to match the corresponding user macro number, e.g. U3
for user sub user_3
.
Uses a tool length sensor (alternatively, a 3D edge finder) to detect workpiece surface height.
Sets local G92
working coordinate offset to Z=0
at this place.
Determines tool length in the sense of how long it protrudes from the spindle collet.
Basically this routine is intended to re-check an endmill's length after a given job, compare it with the value before, and notify the user in case the tool has become "shorter".
Some spindle manufacturers specify a spindle warmup profile. Dwell times and spindle speed can be entered using a config
routine so the requested ramp can be executed.
Calls change_tool
, continue reading on my blog
Just asks the operator to manipulate the tool, will apply the tool length offset for that tool (no measurement here!)
Geometrical detection of the center of a bore.
In here, you can define where on the machine tool length measurements shall take place, How high the tool length sensor is, enter the position of the spindle collet, define spindle warmup ramp parameters, etc.
Calls all active axes' home routine, order is ZYX
ABC
As per EdingCNC handbook R4.03
chapter 3.1
"Systemparameters/ -variables", RS274 NGC defines variables in the range of #1...#5400
. Some of those parameters are read-only, some system-specific, some volatile and some others permanent. Let's shed some light here:
#5999
.#100 = 47.11
which assigns the number 47.11
to the parameter with ID #100
.IF [[#5011] == [#5008]] THEN ...
for a deeper syntax overview, please refer to the EdingCNC handbook.Variables in range #26...#3999
are volatile and can be used by the programmer to store data temporarily. The data assigned in this range is deleted on power off or in the event of an alarm/emergency stop.
The variable range #4000...#4999
are stored permanently on the system. They are free to be used.
They keep their value also when powered down, after an emergency stop etc.
EdingCNC uses some of these variables per default, e.g. #4995...#4999
.
ID | name | description |
---|---|---|
#4995 | toolLengthSensorHeight | Saves height of tool length sensor for correctly setting Z-zero |
#4996 | toolLengthSensorFlyover | Safety height above tool length sensor (recommended: machine Z0) |
#4997 | toolLengthSensorPosX | X-position of the tool length sensor |
#4998 | toolLengthSensorPosY | Y-position of the tool length sensor |
#4999 | toolLengthSensorChuck | Switching point of the tool length sensor when no tool in spindle |
Generally speaking, the variable range from #5000...#5999
should be avoided by the programmer - most of them are used system-internally or have intentionally been left blank.
#1=A
, #26=Z
. Can be used in subroutines and macros.#5001=X-axis
and so on.true
if sensor has triggered during a Z-sensing run G38.2
S
in r/sec
MCA
Machine Change Area negative limit: Area the machine may not penetrate in normal operation, e.g. to protect vicesMCA
Machine Change Area positive limitTCA
Tool Change Area negative limit: Area the machine may only access for tool changesTCA
Tool Change Area positive limit1 = Trivial/Cartesian
2 = 4th axys cylinder as Y-axis
Virtual C-axis
4-17 = reserved
18-30 = user defined
ZHC
Z-height compensation status where true = active
true = on
G28
parking position one's axis values (machine coordinates)G30
parking position two's axis values (machine coordinates)G68
flag showing rotation of coordinate system where true = active
G51
scaling of coordinate system where true = active
always 1.0
M90 = 0
M91 = 0
M92 = 2
, M93 = 3
, default 00...3
@TODO: Add asset folder for icons and show images of macro execution within EdingCNC.