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
a2d5cd5d
Commit
a2d5cd5d
authored
Dec 07, 2011
by
kliment
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #122 from kliment/master
Merge fixes added to master into experimental
parents
a2d08fd7
d9193e44
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
183 additions
and
133 deletions
+183
-133
README.md
README.md
+2
-1
calibrateextruder.py
calibrateextruder.py
+66
-36
printcore.py
printcore.py
+1
-1
pronsole.py
pronsole.py
+113
-94
pronterface.py
pronterface.py
+1
-1
No files found.
README.md
View file @
a2d5cd5d
...
@@ -23,7 +23,8 @@ Download the following, and install in this order:
...
@@ -23,7 +23,8 @@ Download the following, and install in this order:
## Mac OS X Lion
## Mac OS X Lion
1.
Ensure that the active Python is the system version. (
`brew uninstall python`
or other appropriate incantations)
1.
Ensure that the active Python is the system version. (
`brew uninstall python`
or other appropriate incantations)
2.
Download an install
[
wxPython version 2.9-Carbon
](
http://wxpython.org/download.php#unstable
)
(
the
Cocoa version doesn't work)
2.
Download an install
[
wxPython2.8-osx-unicode
]
matching to your python version (most likely 2.7 on Lion,
check with: python --version) from: http://wxpython.org/download.php#stable
3.
Download and unpack pyserial from http://pypi.python.org/packages/source/p/pyserial/pyserial-2.5.tar.gz
3.
Download and unpack pyserial from http://pypi.python.org/packages/source/p/pyserial/pyserial-2.5.tar.gz
4.
In a terminal, change to the folder you unzipped to, then type in:
`sudo python setup.py install`
4.
In a terminal, change to the folder you unzipped to, then type in:
`sudo python setup.py install`
...
...
calibrateextruder.py
View file @
a2d5cd5d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#Interactive RepRap e axis calibration program
#Interactive RepRap e axis calibration program
#(C) Nathan Zadoks 2011
#(C) Nathan Zadoks 2011
#Licensed under CC-BY-SA or GPLv2 and higher - Pick your poison.
#Licensed under CC-BY-SA or GPLv2 and higher - Pick your poison.
t
=
60
#Time to wait for extrusion
s
=
300
#Extrusion speed (mm/min)
n
=
100
#Default length to extrude
n
=
100
#Default length to extrude
m
=
0
#User-entered measured extrusion length
m
=
0
#User-entered measured extrusion length
k
=
300
#Default amount of steps per mm
k
=
300
#Default amount of steps per mm
...
@@ -11,6 +11,8 @@ temp=210 #Default extrusion temperature
...
@@ -11,6 +11,8 @@ temp=210 #Default extrusion temperature
tempmax
=
250
#Maximum extrusion temperature
tempmax
=
250
#Maximum extrusion temperature
t
=
int
(
n
*
60
)
/
s
#Time to wait for extrusion
try
:
try
:
from
printdummy
import
printcore
from
printdummy
import
printcore
except
ImportError
:
except
ImportError
:
...
@@ -42,6 +44,37 @@ def w(s):
...
@@ -42,6 +44,37 @@ def w(s):
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
def
heatup
(
p
,
temp
,
s
=
0
):
curtemp
=
gettemp
(
p
)
p
.
send_now
(
'M109 S
%03
d'
%
temp
)
p
.
temp
=
0
if
not
s
:
w
(
"Heating extruder up.."
)
f
=
False
while
curtemp
<=
(
temp
-
1
):
p
.
send_now
(
'M105'
)
time
.
sleep
(
0.5
)
if
not
f
:
time
.
sleep
(
1.5
)
f
=
True
curtemp
=
gettemp
(
p
)
if
curtemp
:
w
(
u"
\r
Heating extruder up..
%3
d
\xb0
C"
%
curtemp
)
if
s
:
print
else
:
print
"
\n
Ready."
def
gettemp
(
p
):
try
:
p
.
logl
except
:
setattr
(
p
,
'logl'
,
0
)
try
:
p
.
temp
except
:
setattr
(
p
,
'temp'
,
0
)
for
n
in
range
(
p
.
logl
,
len
(
p
.
log
)):
line
=
p
.
log
[
n
]
if
'T:'
in
line
:
try
:
setattr
(
p
,
'temp'
,
int
(
line
.
split
(
'T:'
)[
1
]
.
split
()[
0
]))
except
:
print
line
p
.
logl
=
len
(
p
.
log
)
return
p
.
temp
if
not
os
.
path
.
exists
(
port
):
if
not
os
.
path
.
exists
(
port
):
port
=
0
port
=
0
...
@@ -83,39 +116,36 @@ print "Length extruded: %3d mm"%n
...
@@ -83,39 +116,36 @@ print "Length extruded: %3d mm"%n
print
print
print
"Serial port:
%
s"
%
(
port
if
port
else
'auto'
)
print
"Serial port:
%
s"
%
(
port
if
port
else
'auto'
)
#Connect to printer
p
=
None
w
(
"Connecting to printer.."
)
try
:
try
:
#Connect to printer
w
(
"Connecting to printer.."
)
try
:
p
=
printcore
(
port
,
115200
)
p
=
printcore
(
port
,
115200
)
except
:
except
:
print
'Error.'
print
'Error.'
raise
raise
while
not
p
.
online
:
while
not
p
.
online
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
w
(
'.'
)
w
(
'.'
)
print
" connected."
print
" connected."
def
sendcb
(
self
,
l
):
heatup
(
p
,
temp
)
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
#Calibration loop
while
n
!=
m
:
while
n
!=
m
:
heatup
(
p
,
temp
,
True
)
p
.
send_now
(
"G92 E0"
)
#Reset e axis
p
.
send_now
(
"G92 E0"
)
#Reset e axis
p
.
send_now
(
"G1 E
%
d F100"
%
int
(
n
))
#Extrude length of filament
p
.
send_now
(
"G1 E
%
d F
%
d"
%
(
n
,
s
))
#Extrude length of filament
wait
(
t
,
'Extruding.. '
)
wait
(
t
,
'Extruding.. '
)
m
=
float_input
(
"How many millimeters of filament were extruded? "
)
m
=
float_input
(
"How many millimeters of filament were extruded? "
)
if
m
==
0
:
continue
if
n
!=
m
:
if
n
!=
m
:
k
=
(
n
/
m
)
*
k
k
=
(
n
/
m
)
*
k
p
.
send_now
(
"M92 E
%
d"
%
int
(
round
(
k
)))
#Set new step count
p
.
send_now
(
"M92 E
%
d"
%
int
(
round
(
k
)))
#Set new step count
print
"Steps per mm:
%3
d steps"
%
k
#Tell user
print
"Steps per mm:
%3
d steps"
%
k
#Tell user
print
'Calibration completed.'
#Yay!
print
'Calibration completed.'
#Yay!
p
.
disconnect
()
except
KeyboardInterrupt
:
pass
finally
:
if
p
:
p
.
disconnect
()
printcore.py
View file @
a2d5cd5d
...
@@ -72,7 +72,7 @@ class printcore():
...
@@ -72,7 +72,7 @@ class printcore():
"""This function acts on messages from the firmware
"""This function acts on messages from the firmware
"""
"""
self
.
clear
=
True
self
.
clear
=
True
time
.
sleep
(
0.5
)
time
.
sleep
(
1.0
)
self
.
send_now
(
"M105"
)
self
.
send_now
(
"M105"
)
while
(
True
):
while
(
True
):
if
(
not
self
.
printer
or
not
self
.
printer
.
isOpen
):
if
(
not
self
.
printer
or
not
self
.
printer
.
isOpen
):
...
...
pronsole.py
View file @
a2d5cd5d
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
import
cmd
,
printcore
,
sys
import
cmd
,
printcore
,
sys
import
glob
,
os
,
time
import
glob
,
os
,
time
import
sys
,
subprocess
import
sys
,
subprocess
import
math
from
math
import
sqrt
from
math
import
sqrt
if
os
.
name
==
"nt"
:
if
os
.
name
==
"nt"
:
try
:
try
:
import
_winreg
import
_winreg
...
@@ -65,7 +67,6 @@ def measurements(g):
...
@@ -65,7 +67,6 @@ def measurements(g):
Ytot
=
Ymax
-
Ymin
Ytot
=
Ymax
-
Ymin
Ztot
=
Zmax
-
Zmin
Ztot
=
Zmax
-
Zmin
return
(
Xtot
,
Ytot
,
Ztot
,
Xmin
,
Xmax
,
Ymin
,
Ymax
,
Zmin
,
Zmax
)
return
(
Xtot
,
Ytot
,
Ztot
,
Xmin
,
Xmax
,
Ymin
,
Ymax
,
Zmin
,
Zmax
)
def
totalelength
(
g
):
def
totalelength
(
g
):
...
@@ -87,58 +88,76 @@ def get_coordinate_value(axis, parts):
...
@@ -87,58 +88,76 @@ def get_coordinate_value(axis, parts):
return
float
(
i
[
1
:])
return
float
(
i
[
1
:])
return
None
return
None
def
hypot3d
(
X1
,
Y1
,
Z1
,
X2
=
0.0
,
Y2
=
0.0
,
Z2
=
0.0
):
return
math
.
hypot
(
X2
-
X1
,
math
.
hypot
(
Y2
-
Y1
,
Z2
-
Z1
))
def
estimate_duration
(
g
):
def
estimate_duration
(
g
):
extra_cost_per_movement
=
0.02
total_duration
=
0.0
lastx
=
lasty
=
lastz
=
laste
=
lastf
=
0.0
feedrate
=
0.0
x
=
y
=
z
=
e
=
f
=
0.0
avg_feedrate
=
0.0
currenttravel
=
0.0
last_feedrate
=
0.0
totaltravel
=
0.0
X_last_position
=
0.0
moveduration
=
0.0
Y_last_position
=
0.0
totalduration
=
0.0
Z_last_position
=
0.0
acceleration
=
1500.0
#mm/s/s ASSUMING THE DEFAULT FROM SPRINTER !!!!
layerduration
=
0.0
layerbeginduration
=
0.0
#TODO:
# get device caps from firmware: max speed, acceleration/axis (including extruder)
# calculate the maximum move duration accounting for above ;)
print
".... estimating ...."
for
i
in
g
:
for
i
in
g
:
i
=
i
.
split
(
";"
)[
0
]
if
"G4"
in
i
or
"G1"
in
i
:
if
"G1"
in
i
and
(
"X"
in
i
or
"Y"
in
i
or
"F"
in
i
or
"E"
in
i
):
if
"G4"
in
i
:
#if "G1" in i and ("X" in i or "Y" in i or "Z" in i or "F" in i or "E" in i):
parts
=
i
.
split
(
" "
)
parts
=
i
.
split
(
" "
)
X
=
get_coordinate_value
(
"X"
,
parts
[
1
:])
moveduration
=
get_coordinate_value
(
"P"
,
parts
[
1
:])
Y
=
get_coordinate_value
(
"Y"
,
parts
[
1
:])
if
moveduration
is
None
:
#Z = get_coordinate_value("Z", parts[1:])
continue
F
=
get_coordinate_value
(
"F"
,
parts
[
1
:])
else
:
E
=
get_coordinate_value
(
"E"
,
parts
[
1
:])
moveduration
/=
1000.0
if
"G1"
in
i
:
if
(
F
is
not
None
):
parts
=
i
.
split
(
" "
)
feedrate
=
(
last_feedrate
+
(
F
/
60.0
))
/
2.0
x
=
get_coordinate_value
(
"X"
,
parts
[
1
:])
distance
=
0
if
x
is
None
:
x
=
lastx
if
(
X
is
None
and
Y
is
None
and
E
is
not
None
):
y
=
get_coordinate_value
(
"Y"
,
parts
[
1
:])
distance
=
abs
(
E
)
if
y
is
None
:
y
=
lasty
elif
(
X
is
not
None
and
Y
is
None
):
z
=
get_coordinate_value
(
"Z"
,
parts
[
1
:])
distance
=
X
-
X_last_position
if
z
is
None
:
z
=
lastz
X_last_position
=
X
e
=
get_coordinate_value
(
"E"
,
parts
[
1
:])
elif
(
X
is
None
and
Y
is
not
None
):
if
e
is
None
:
e
=
laste
distance
=
Y
-
Y_last_position
f
=
get_coordinate_value
(
"F"
,
parts
[
1
:])
Y_last_position
=
Y
if
f
is
None
:
f
=
lastf
elif
(
X
is
not
None
and
Y
is
not
None
):
else
:
f
/=
60.0
# mm/s vs mm/m
X_distance
=
X
-
X_last_position
Y_distance
=
Y
-
Y_last_position
# given last feedrate and current feedrate calculate the distance needed to achieve current feedrate.
distance
=
sqrt
(
X_distance
*
X_distance
+
Y_distance
*
Y_distance
)
# if travel is longer than req'd distance, then subtract distance to achieve full speed, and add the time it took to get there.
X_last_position
=
X
# then calculate the time taken to complete the remaining distance
Y_last_position
=
Y
#if (Z is not None):
currenttravel
=
hypot3d
(
x
,
y
,
z
,
lastx
,
lasty
,
lastz
)
# Z_distance = Z - Z_last_position
distance
=
2
*
((
lastf
+
f
)
*
(
f
-
lastf
)
*
0.5
)
/
acceleration
#2x because we have to accelerate and decelerate
# if not(distance == 0.0):
if
distance
<=
currenttravel
:
# distance = sqrt(Z_distance * Z_distance + distance * distance )
moveduration
=
2
*
distance
/
(
lastf
+
f
)
# else:
currenttravel
-=
distance
# distance = Z_distance
moveduration
+=
currenttravel
/
f
# Z_last_position = Z
else
:
moveduration
=
math
.
sqrt
(
2
*
distance
/
acceleration
)
if
(
feedrate
==
0.0
or
distance
==
0.0
):
continue
totalduration
+=
moveduration
time_for_move
=
distance
/
feedrate
total_duration
+=
time_for_move
+
extra_cost_per_movement
if
z
>
lastz
:
if
(
F
is
not
None
):
feedrate
=
F
/
60.0
print
"layer z: "
,
lastz
,
" will take: "
,
time
.
strftime
(
'
%
H:
%
M:
%
S'
,
time
.
gmtime
(
totalduration
-
layerbeginduration
))
return
time
.
strftime
(
'
%
H:
%
M:
%
S'
,
time
.
gmtime
(
total_duration
/
60.0
))
layerbeginduration
=
totalduration
lastx
=
x
lasty
=
y
lastz
=
z
laste
=
e
lastf
=
f
print
"Total Duration: "
#, time.strftime('%H:%M:%S', time.gmtime(totalduration))
return
time
.
strftime
(
'
%
H:
%
M:
%
S'
,
time
.
gmtime
(
totalduration
))
class
Settings
:
class
Settings
:
#def _temperature_alias(self): return {"pla":210,"abs":230,"off":0}
#def _temperature_alias(self): return {"pla":210,"abs":230,"off":0}
#def _temperature_validate(self,v):
#def _temperature_validate(self,v):
...
...
pronterface.py
View file @
a2d5cd5d
...
@@ -403,7 +403,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -403,7 +403,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
serialport
.
Clear
()
self
.
serialport
.
Clear
()
self
.
serialport
.
AppendItems
(
portslist
)
self
.
serialport
.
AppendItems
(
portslist
)
try
:
try
:
if
self
.
settings
.
port
in
scan
:
if
os
.
path
.
exists
(
self
.
settings
.
port
)
:
self
.
serialport
.
SetValue
(
self
.
settings
.
port
)
self
.
serialport
.
SetValue
(
self
.
settings
.
port
)
elif
len
(
portslist
)
>
0
:
elif
len
(
portslist
)
>
0
:
self
.
serialport
.
SetValue
(
portslist
[
0
])
self
.
serialport
.
SetValue
(
portslist
[
0
])
...
...
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