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
213b230d
Commit
213b230d
authored
May 12, 2011
by
Nathan Zadoks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added extruder calibration program.
parent
ee101f0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
calibrateextruder.py
calibrateextruder.py
+85
-0
No files found.
calibrateextruder.py
0 → 100644
View file @
213b230d
#!/usr/bin/python
#Interactive RepRap e axis calibration program
#(C) Nathan Zadoks 2011
#Licensed under CC-BY-SA or GPLv2 and higher - Pick your poison.
t
=
60
#Time to wait for extrusion
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
try
:
from
printdummy
import
printcore
except
ImportError
:
from
printcore
import
printcore
import
time
,
getopt
,
sys
def
float_input
(
prompt
=
''
):
import
sys
f
=
None
while
f
==
None
:
s
=
raw_input
(
prompt
)
try
:
f
=
float
(
s
)
except
ValueError
:
sys
.
stderr
.
write
(
"Not a valid floating-point number.
\n
"
)
sys
.
stderr
.
flush
()
return
f
def
wait
(
t
,
m
=
''
):
import
time
,
sys
sys
.
stdout
.
write
(
m
+
'['
+
(
' '
*
t
)
+
']
\r
'
+
m
+
'['
)
sys
.
stdout
.
flush
()
for
i
in
range
(
t
):
for
s
in
[
'|
\b
'
,
'/
\b
'
,
'-
\b
'
,
'
\\\b
'
,
'|'
]:
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
flush
()
time
.
sleep
(
1.0
/
5
)
print
#Parse options
help
=
"""
%
s [ -l DISTANCE ] [ -s STEPS ] [ -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)
-p --port Serial port the printer is connected to (default:
%
s)
-h --help This cruft.
"""
[
1
:
-
1
]
%
(
sys
.
argv
[
0
],
n
,
k
,
port
)
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hl:s:p:"
,[
"help"
,
"length="
,
"steps="
,
"port="
])
except
getopt
.
GetoptError
,
err
:
print
str
(
err
)
print
help
sys
.
exit
(
2
)
for
o
,
a
in
opts
:
if
o
in
(
'-h'
,
'--help'
):
print
help
sys
.
exit
()
elif
o
in
(
'-l'
,
'--length'
):
n
=
float
(
a
)
elif
o
in
(
'-s'
,
'--steps'
):
k
=
int
(
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
#Connect to printer
print
"Connecting to printer.."
,
p
=
printcore
(
port
,
115200
)
print
"connected."
#Calibration loop
while
n
!=
m
:
p
.
send_now
(
"G92 E0"
)
#Reset e axis
p
.
send_now
(
"G1 E
%
d F100"
%
int
(
n
))
#Extrude length of filament
wait
(
t
,
'Extruding.. '
)
m
=
float_input
(
"How many millimeters of filament were extruded? "
)
if
n
!=
m
:
k
=
(
n
/
m
)
*
k
p
.
send_now
(
"M92 E
%
d"
%
int
(
round
(
k
)))
#Set new step count
print
"Steps per mm:
%3
d steps"
%
k
#Tell user
print
'Calibration completed.'
#Yay!
p
.
disconnect
()
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