Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Hubert
/
spindel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e6bcc9b2
authored
Oct 01, 2014
by
hubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
milling directions fixed, removed invalid parts in head
1 parent
367ee5b2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
53 deletions
spindel.py
spindel.py
View file @
e6bcc9b
...
@@ -29,24 +29,36 @@ def main(argv):
...
@@ -29,24 +29,36 @@ def main(argv):
,
default
=
False
,
default
=
False
,
help
=
"Durchmesser in mm des gewaehlten Fraesers"
,
help
=
"Durchmesser in mm des gewaehlten Fraesers"
)
)
parser
.
add_option
(
"-r"
,
"--fraseradius"
parser
.
add_option
(
"-d"
,
"--durchmesser"
,
dest
=
"durchmesser"
,
type
=
"float"
,
default
=
False
,
help
=
"Durchmesser in mm des zu fraesenden Kreises, beruecksichtigt den Fraeserdurchmesser"
)
parser
.
add_option
(
"-R"
,
"--radius"
,
dest
=
"radius"
,
dest
=
"radius"
,
type
=
"float"
,
type
=
"float"
,
default
=
False
,
default
=
False
,
help
=
"Radius in mm des zu fraesenden Kreises, beruecksichtigt den Fraeserradius"
,
help
=
"Radius in mm des zu fraesenden Kreises, beruecksichtigt den Fraeserdurchmesser"
)
parser
.
add_option
(
"-F"
,
"--vorschub"
,
dest
=
"vorschub"
,
type
=
"int"
,
default
=
100
,
help
=
"Vorschubgeschwindigkeit in mm/min"
)
)
parser
.
add_option
(
"-v"
,
"--versatz"
parser
.
add_option
(
"-v"
,
"--versatz"
,
dest
=
"versatz"
,
dest
=
"versatz"
,
type
=
"float"
,
type
=
"float"
,
help
=
"Versatz in mm, den Der Fraeser bei jedem durchlauf in das Material eintaucht"
,
help
=
"Versatz in mm, den Der Fraeser bei jedem durchlauf in das Material eintaucht"
)
)
parser
.
add_option
(
"-
x
"
,
"--offset_x"
parser
.
add_option
(
"-
X
"
,
"--offset_x"
,
dest
=
"x"
,
dest
=
"x"
,
type
=
"float"
,
type
=
"float"
,
default
=
0
,
,
default
=
0
,
help
=
"offset "
help
=
"offset "
)
)
parser
.
add_option
(
"-
y
"
,
"--offset_y"
parser
.
add_option
(
"-
Y
"
,
"--offset_y"
,
dest
=
"y"
,
dest
=
"y"
,
type
=
"float"
,
type
=
"float"
,
default
=
0
,
default
=
0
...
@@ -58,48 +70,101 @@ def main(argv):
...
@@ -58,48 +70,101 @@ def main(argv):
,
default
=
0
,
default
=
0
,
help
=
"Start at radius <>"
,
help
=
"Start at radius <>"
)
)
parser
.
add_option
(
"-
d"
,
"--direction
"
parser
.
add_option
(
"-
G"
,
"--drehrichtung
"
,
dest
=
"d
irection
"
,
dest
=
"d
rehrichtung
"
,
type
=
"str"
,
type
=
"str"
,
default
=
'CCW'
,
default
=
'CCW'
,
help
=
"Rotate d
irection, 'CW', default: 'CCW'
"
,
help
=
"Rotate d
rehrichtung, 'CW', default: 'CCW', or G-Code Number (2/3)
"
)
)
(
options
,
args
)
=
parser
.
parse_args
()
(
options
,
args
)
=
parser
.
parse_args
()
if
not
options
.
fraeser
:
if
not
options
.
fraeser
:
parser
.
error
(
'Fraeserdurchmesser nicht angegeben'
)
parser
.
error
(
'Fraeserdurchmesser nicht angegeben'
)
if
not
options
.
radius
:
if
not
(
options
.
radius
or
options
.
durchmesser
):
parser
.
error
(
'Radius nicht angegeben'
)
parser
.
error
(
'Radius oder Durchmesser nicht angegeben'
)
if
options
.
radius
and
options
.
durchmesser
:
parser
.
error
(
'Entweder Radius oder Durchmesser angegeben, nicht beides zusammen'
)
if
options
.
drehrichtung
.
lower
()
==
'ccw'
or
options
.
drehrichtung
==
'03'
or
options
.
drehrichtung
==
'3'
or
options
.
drehrichtung
.
lower
()
==
'g03'
:
drehrichtung
=
'ccw'
elif
options
.
drehrichtung
.
lower
()
==
'cw'
or
options
.
drehrichtung
==
'02'
or
options
.
drehrichtung
==
'2'
or
options
.
drehrichtung
.
lower
()
==
'g02'
:
drehrichtung
=
'cw'
else
:
parser
.
error
(
'drehrichtung "
%
s" unbekannt'
%
(
options
.
drehrichtung
))
spindel
=
Spindel
(
fraeser
=
options
.
fraeser
spindel
=
Spindel
(
fraeser
=
options
.
fraeser
,
radius
=
options
.
radius
,
radius
=
options
.
radius
,
durchmesser
=
options
.
durchmesser
,
versatz
=
options
.
versatz
if
options
.
versatz
else
options
.
fraeser
/
2
,
versatz
=
options
.
versatz
if
options
.
versatz
else
options
.
fraeser
/
2
,
x
=
options
.
x
,
x
=
options
.
x
,
y
=
options
.
y
,
y
=
options
.
y
,
startradius
=
options
.
startradius
,
startradius
=
options
.
startradius
,
direction
=
options
.
direction
,
drehrichtung
=
drehrichtung
,
vorschub
=
options
.
vorschub
)
)
spindel
.
head
(
spindel
.
direction
)
spindel
.
head
()
spindel
.
makeSpindel
(
spindel
.
position
)
spindel
.
makeSpindel
(
spindel
.
position
)
class
Spindel
:
class
Spindel
:
"""Super Duper Spindel Gcode Generator"""
"""Super Duper Spindel Gcode Generator"""
### SETUP
### SETUP
def
__init__
(
self
,
fraeser
=
0
,
radius
=
0
,
versatz
=
None
,
x
=
0
,
y
=
0
,
startradius
=
0
,
direction
=
'CCW'
):
def
__init__
(
self
,
fraeser
=
0
,
radius
=
None
,
durchmesser
=
None
,
versatz
=
None
,
x
=
0
,
y
=
0
,
startradius
=
0
,
drehrichtung
=
'cw'
,
vorschub
=
100
):
self
.
tool
=
{}
self
.
setTool
(
self
.
target
=
{}
fraeser
self
.
setTool
(
fraeser
,
versatz
)
,
versatz
self
.
setTarget
(
radius
,
x
,
y
)
,
drehrichtung
,
vorschub
)
self
.
setTarget
(
radius
if
radius
else
durchmesser
/
2
,
x
,
y
)
self
.
setPosition
(
startradius
,
startradius
,
0
)
self
.
validateInput
()
def
setTool
(
self
,
fraeser
,
versatz
=
None
,
drehrichtung
=
'cw'
,
vorschub
=
'100'
):
self
.
tool
=
{
'fraeser'
:
float
(
fraeser
),
'versatz'
:
float
(
versatz
)
if
versatz
else
fraeser
/
2.
,
'drehrichtung'
:
{
'name'
:
'cw'
if
drehrichtung
==
'cw'
else
'ccw'
,
'gcode'
:
'G02'
if
drehrichtung
==
'cw'
else
'G03'
},
'vorschub'
:
int
(
vorschub
)
}
def
setTarget
(
self
,
radius
,
x
,
y
):
self
.
target
=
{
'radius'
:
float
(
radius
-
self
.
tool
[
'fraeser'
]
/
2
),
'x'
:
float
(
x
),
'y'
:
float
(
y
)
}
def
setPosition
(
self
,
startradius
,
x
,
y
):
self
.
position
=
{
self
.
position
=
{
'radius'
:
startradius
,
'radius'
:
startradius
,
'x'
:
startradius
,
'x'
:
startradius
,
'y'
:
0
'y'
:
0
}
}
self
.
direction
=
direction
self
.
validateInput
()
def
printPosition
(
self
,
position
):
print
'
%
s Y
%
s X
%
s R
%
s F
%
s'
%
(
self
.
tool
[
'drehrichtung'
][
'gcode'
]
,
position
[
'y'
]
+
self
.
target
[
'y'
]
,
position
[
'x'
]
+
self
.
target
[
'x'
]
,
position
[
'radius'
]
,
self
.
tool
[
'vorschub'
]
)
return
position
def
validateInput
(
self
):
def
validateInput
(
self
):
if
self
.
tool
[
'versatz'
]
>
self
.
tool
[
'fraeser'
]
/
2
:
if
self
.
tool
[
'versatz'
]
>
self
.
tool
[
'fraeser'
]
/
2
:
...
@@ -115,41 +180,17 @@ Der Versatz ist groesser als der Fraeserdurchmesser\n
...
@@ -115,41 +180,17 @@ Der Versatz ist groesser als der Fraeserdurchmesser\n
Fraeserradius:
%
s
\n
Versatz:
%
s
Fraeserradius:
%
s
\n
Versatz:
%
s
'''
%
(
self
.
tool
[
'fraeser'
],
self
.
tool
[
'versatz'
]))
'''
%
(
self
.
tool
[
'fraeser'
],
self
.
tool
[
'versatz'
]))
def
setTool
(
self
,
fraeser
,
versatz
=
None
):
self
.
tool
=
{
'fraeser'
:
float
(
fraeser
),
'versatz'
:
float
(
versatz
)
if
versatz
else
fraeser
/
2.
}
def
setTarget
(
self
,
radius
,
x
,
y
):
self
.
target
=
{
'radius'
:
float
(
radius
-
self
.
tool
[
'fraeser'
]
/
2
),
'x'
:
float
(
x
),
'y'
:
float
(
y
)
}
def
printPosition
(
self
,
position
):
print
'Y
%
s X
%
s R
%
s'
%
(
position
[
'y'
]
+
self
.
target
[
'y'
],
position
[
'x'
]
+
self
.
target
[
'x'
],
position
[
'radius'
]
)
return
position
### GENERATE
### GENERATE
def
head
(
self
,
direction
):
def
head
(
self
):
print
'G00 G43 H1'
print
'G21'
#MM mode (G71 on older controls)
print
'G21'
#MM mode (G71 on older controls)
print
'G0 Y
%
s X
%
s'
%
(
print
'G54'
#Work coordinate shift,offset #1
self
.
position
[
'y'
]
+
self
.
target
[
'y'
],
self
.
position
[
'x'
]
+
self
.
target
[
'x'
]
)
if
direction
==
'CW'
:
print
'G01 Y
%
s X
%
s F
%
s'
%
(
print
'G02'
#Circular move CW
self
.
position
[
'y'
]
+
self
.
target
[
'y'
]
else
:
,
self
.
position
[
'x'
]
+
self
.
target
[
'x'
]
print
'G03 F100'
#Circular move CCW
,
self
.
tool
[
'vorschub'
]
)
def
increaseArc
(
self
,
position
,
versatz
):
def
increaseArc
(
self
,
position
,
versatz
):
diameter
=
(
position
[
'x'
]
*
2
)
+
(
0
if
position
[
'x'
]
>
0
else
-
versatz
)
diameter
=
(
position
[
'x'
]
*
2
)
+
(
0
if
position
[
'x'
]
>
0
else
-
versatz
)
...
@@ -170,14 +211,14 @@ Fraeserradius: %s\nVersatz: %s
...
@@ -170,14 +211,14 @@ Fraeserradius: %s\nVersatz: %s
#print(self.target['radius'] - position['radius']);
#print(self.target['radius'] - position['radius']);
# print('// closing radius: %s') %(self.target['radius'] - position['radius'])
# print('// closing radius: %s') %(self.target['radius'] - position['radius'])
self
.
increaseArc
(
position
,
self
.
target
[
'radius'
]
-
position
[
'radius'
])
self
.
increaseArc
(
position
,
self
.
target
[
'radius'
]
-
position
[
'radius'
])
# make a nice border
# make a nice border
self
.
increaseArc
(
position
,
self
.
target
[
'radius'
]
-
position
[
'radius'
])
self
.
increaseArc
(
position
,
self
.
target
[
'radius'
]
-
position
[
'radius'
])
self
.
increaseArc
(
position
,
self
.
target
[
'radius'
]
-
position
[
'radius'
])
self
.
increaseArc
(
position
,
self
.
target
[
'radius'
]
-
position
[
'radius'
])
print
'M00'
#Program stop
#
print 'M00' #Program stop
print
'M01'
#Optional program stop
#
print 'M01' #Optional program stop
print
'M02'
#End of program (no rewind or return to start of program)
print
'M02'
#End of program (no rewind or return to start of program)
#print 'M30' #End of program (no rewind or return to start of program)
#
#
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment