Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
9b1b45d0
Commit
9b1b45d0
authored
Jul 28, 2011
by
kliment
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20 from FrozenFire/master
Sensible defaults for calibration script
parents
7abc2d59
a040eb77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
9 deletions
+45
-9
calibrateextruder.py
calibrateextruder.py
+45
-9
No files found.
calibrateextruder.py
View file @
9b1b45d0
...
...
@@ -7,12 +7,15 @@ n=100 #Default length to extrude
m
=
0
#User-entered measured extrusion length
k
=
300
#Default amount of steps per mm
port
=
'/dev/ttyUSB0'
#Default serial port to connect to printer
temp
=
210
#Default extrusion temperature
tempmax
=
250
#Maximum extrusion temperature
try
:
from
printdummy
import
printcore
except
ImportError
:
from
printcore
import
printcore
import
time
,
getopt
,
sys
import
time
,
getopt
,
sys
,
os
def
float_input
(
prompt
=
''
):
import
sys
...
...
@@ -35,17 +38,24 @@ def wait(t,m=''):
sys
.
stdout
.
flush
()
time
.
sleep
(
1.0
/
5
)
print
def
w
(
s
):
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
flush
()
if
not
os
.
path
.
exists
(
port
):
port
=
0
#Parse options
help
=
"""
%
s [ -l DISTANCE ] [ -s STEPS ] [ -p PORT ]
help
=
u
"""
%
s [ -l DISTANCE ] [ -s STEPS ] [ -
t TEMP ] [ -
p PORT ]
-l --length Length of filament to extrude for each calibration step (default:
%
d mm)
-s --steps Initial amount of steps to use (default:
%
d steps)
-t --temp Extrusion temperature in degrees Celsius (default:
%
d
\xb0
C, max
%
d
\xb0
C)
-p --port Serial port the printer is connected to (default:
%
s)
-h --help This cruft.
"""
[
1
:
-
1
]
%
(
sys
.
argv
[
0
],
n
,
k
,
port
)
"""
[
1
:
-
1
]
.
encode
(
'utf-8'
)
%
(
sys
.
argv
[
0
],
n
,
k
,
temp
,
tempmax
,
port
if
port
else
'auto'
)
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hl:s:
p:"
,[
"help"
,
"length="
,
"steps
="
,
"port="
])
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hl:s:
t:p:"
,[
"help"
,
"length="
,
"steps="
,
"temp
="
,
"port="
])
except
getopt
.
GetoptError
,
err
:
print
str
(
err
)
print
help
...
...
@@ -58,18 +68,44 @@ for o,a in opts:
n
=
float
(
a
)
elif
o
in
(
'-s'
,
'--steps'
):
k
=
int
(
a
)
elif
o
in
(
'-t'
,
'--temp'
):
temp
=
int
(
a
)
if
temp
>=
tempmax
:
print
(
u'
%
d
\xb0
C? Are you insane?'
.
encode
(
'utf-8'
)
%
temp
)
+
(
" That's over nine thousand!"
if
temp
>
9000
else
''
)
sys
.
exit
(
255
)
elif
o
in
(
'-p'
,
'--port'
):
port
=
a
#Show initial parameters
print
"Initial parameters"
print
"Steps per mm:
%3
d steps"
%
k
print
"Length extruded:
%3
d mm"
%
n
print
print
"Serial port:
%
s"
%
port
print
"Serial port:
%
s"
%
(
port
if
port
else
'auto'
)
#Connect to printer
print
"Connecting to printer.."
,
p
=
printcore
(
port
,
115200
)
print
"connected."
w
(
"Connecting to printer.."
)
try
:
p
=
printcore
(
port
,
115200
)
except
:
print
'Error.'
raise
while
not
p
.
online
:
time
.
sleep
(
1
)
w
(
'.'
)
print
" connected."
def
sendcb
(
self
,
l
):
if
l
==
'G92 E0'
:
self
.
hot
=
True
w
(
"Heating extruder up.."
)
setattr
(
p
,
'hot'
,
False
)
p
.
sendcb
=
sendcb
p
.
send_now
(
'M109 S
%03
d'
%
temp
)
while
not
p
.
hot
:
time
.
sleep
(
1
)
w
(
'.'
)
print
" ready."
#Calibration loop
while
n
!=
m
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment