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
321548a7
Commit
321548a7
authored
Nov 03, 2011
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Naive implementation to estimate the duration of a print
parent
3f600061
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
duration.py
duration.py
+68
-0
No files found.
duration.py
0 → 100755
View file @
321548a7
#!/usr/bin/env python
from
math
import
sqrt
of
=
open
(
"../PrusaMendel/stl/calibration_export.gcode"
)
g
=
[
i
.
replace
(
"
\n
"
,
""
)
.
replace
(
"
\r
"
,
""
)
for
i
in
of
]
of
.
close
def
get_value
(
axis
,
parts
):
for
i
in
parts
:
if
(
axis
in
i
):
return
float
(
i
[
1
:])
return
None
total_duration
=
0
starting_velocity
=
0
global_feedrate
=
0
initial_feedrate
=
0
X_last_position
=
0
Y_last_position
=
0
for
i
in
g
:
if
"G1"
in
i
and
(
"X"
in
i
or
"Y"
in
i
or
"F"
in
i
):
parts
=
i
.
split
(
" "
)
X
=
get_value
(
"X"
,
parts
[
1
:])
Y
=
get_value
(
"Y"
,
parts
[
1
:])
F
=
get_value
(
"F"
,
parts
[
1
:])
if
(
X
is
None
and
Y
is
None
and
F
is
not
None
):
global_feedrate
=
F
continue
feedrate
=
0
if
(
F
is
None
):
feedrate
=
global_feedrate
else
:
feedrate
=
F
distance
=
0
if
(
X
is
not
None
and
Y
is
None
):
distance
=
X
-
X_last_position
X_last_position
=
X
elif
(
X
is
None
and
Y
is
not
None
):
distance
=
Y
-
Y_last_position
Y_last_position
=
Y
elif
(
X
is
not
None
and
Y
is
not
None
):
X_distance
=
X
-
X_last_position
Y_distance
=
Y
-
Y_last_position
distance
=
sqrt
(
X_distance
*
X_distance
+
Y_distance
*
Y_distance
)
X_last_position
=
X
Y_last_position
=
Y
time_for_move
=
distance
/
(
feedrate
/
60
)
acceleration
=
(
feedrate
-
initial_feedrate
)
/
time_for_move
halfway_feedrate
=
initial_feedrate
+
acceleration
*
time_for_move
/
2
duration
=
0
if
(
halfway_feedrate
==
feedrate
):
time_full_feedrate
=
(
feedrate
-
initial_feedrate
)
/
acceleration
distance_full_feedrate
=
(
0.5
*
(
feedrate
+
initial_feedrate
))
*
time_full_feedrate
duration
=
time_full_feedrate
*
2
+
(
distance
-
distance_full_feedrate
*
2
)
/
feedrate
else
:
duration
=
(
halfway_feedrate
*
2
-
initial_feedrate
)
/
acceleration
total_duration
+=
duration
print
(
"Total duration (in minutes): {0}"
.
format
(
total_duration
/
60
))
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