UltiPrint.py Utility

Erwin Rieger edited this page Jan 5, 2015 · 9 revisions

UltiPrint.py - Simple UltiGCode print utility.

This is a simple python program to store or print UM2 UltiGCode files over USB.

To use this you need a modified UM2 firmware: UltiPrint

To download the file it uses the M28 <file> gcode command, to start the print the gcode command M623 <file> is sent. Gcode M29 is used to end the file download.

There is "command-resend" and some error checking, the printer is stopped and reset if a non-recoverable error is encountered.

Note:

The destination filename on the SD card in the UM2 is currently hardcoded, it's always: "USB.G". Existing files with this name will be overwritten without a request.

Note:

The following usage examples assume you are running a linux/unix operating system.

On Windows systems things will be slightly diffent (and it would be nice to hear about your experience with this tool under Windows).

Note:

Starting ultiprint.py in a mode that connects to the printer (all commands besides preprocess) WILL RESET your printer. This is a Arduino hardware feature that can't be circumvented, this is also true for any other tool that opens a serial connection to the UM2-Arduino. So don't do this while a printjob is running...

Its a good idea to store the output of the ultiprint.py utility in a file for later diagnosis. You could use a command like this:

#> ./ultiprint.py <options> 2>&1 | tee /tmp/print.log

This will output the messages from the program to the console and store it in the /tmp/print.log log file also.

Usage

As you can see in the following example, the ultiprint.py util supports several different modes:

#> ./ultiprint.py -h

usage: ultiprint.py [-h] [-d DEVICE] {mon,print,store,reset,pre} ...

UltiPrint, print on UM2 over USB.

positional arguments:
{mon,print,store,reset,pre}
                        Mode: mon(itor)|print|store|reset|pre(process).
    mon                 Monitor printer.
    print               Print file.
    store               Store file as USB.G on sd-card.
    reset               Try to stop/reset printer.
    pre                 Preprocess gcode, for debugging purpose.

optional arguments:
-h, --help            show this help message and exit
-d DEVICE             Device to use, default: /dev/ttyACM0.

You will be using the store and print function most of the time.

Monitor mode mon listens on the usbserial device (given by the -d option) and print out the messages it receives from the printer. See the example at the end of this document.

Reset mode does exactly what its name suggests: it resets the printer and homes the head and bed.

Preprocess mode is mainly for testing purposes, the given GCode is preprocessed and compressed and some statistics about compression ratio and so on are output to the console, see example below.

An additional future mode could be sdprint to print UltiGCode files that are already present on the sd-card. But that's not implemented yet.

Storing files on SD-Card

Use store mode to download a file to the SD card of your UM2 printer:

#> ./ultiprint.py store -h

usage: ultiprint.py store [-h] gfile

positional arguments:
gfile       Input GCode file.

optional arguments:
-h, --help  show this help message and exit

Example:

#> ./ultiprint.py store UltimakerRobot_support.gcode

Initial read:


Preprocessing: UltimakerRobot_support.gcode
Preprocessing 71390 gcode lines...
done...
Reply:  start
Reply:  echo:Marlin 1.0.0
Reply:  echo: Last Updated: Dec 21 2014 23:53:16 | Author: ERRI 14.12.1-UP3
Reply:  Compiled: Dec 21 2014
Reply:  echo: Free Memory: 1802  PlannerBufferBytes: 1232
Reply:  echo:Stored settings retrieved
Reply:  echo:Steps per unit:
Reply:  echo:  M92 X80.00 Y80.00 Z200.00 E282.00
Reply:  echo:Maximum feedrates (mm/s):
Reply:  echo:  M203 X300.00 Y300.00 Z40.00 E45.00
Reply:  echo:Maximum Acceleration (mm/s2):
Reply:  echo:  M201 X9000 Y9000 Z100 E10000
Reply:  echo:Acceleration: S=acceleration, T=retract acceleration
Reply:  echo:  M204 S3000.00 T3000.00
Reply:  echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s),  Z=maximum Z jerk (mm/s),  E=maximum E jerk (mm/s)
Reply:  echo:  M205 S0.00 T0.00 B20000 X20.00 Z0.40 E5.00
Reply:  echo:Home offset (mm):
Reply:  echo:  M206 X0.00 Y0.00 Z-15.50
Reply:  echo:PID settings:
Reply:  echo:   M301 P10.00 I2.50 D100.00
Got Required reply:  echo:SD card ok

Send:  N0 M110*35
ACK
Got Required reply:  ok

Send:  N1 M28 usb.g*21
ACK
Reply:  Writing to file: USB.G
Reply:  openfile(USB.G), opencount:  1
Got Required reply:  ok

Send:  N2 ;FLAVOR:UltiGCode*19
ACK

Send:  N3 ;TIME:2061*76
ACK

Send:  N4 ;MATERIAL:2711*85
ACK

Send:  N5 ;MATERIAL2:0*83
ACK

Send:  N6 ;Layer count: 336*79
ACK

Send:  N7 ;LAYER:0*43
ACK

Send:  N8 M107*45
ACK
.
.
.
<many lines follow...>
.
.
.
Send:  0268d7a39e42ae4790427b722945d71601005c0a
ACK

Send:  N71384 M107*44
ACK

Send:  01f02823d7a39e42ae47904233331b42d9160100fe0a
ACK

Send:  N71386 M25 ;Stop reading from this point on.*61
ACK

Send:  N71387 M29*18
ACK
Reply:  closefile(USB.G), opencount:  0
Got Required reply:  Done saving file.

-----------------------------------------------
Store statistics:
-----------------------------------------------

Sent 71388 commands in 296.6 seconds, 240.7 commands/second.

waiting 10.00 seconds for more messages...
end-reply received, exiting...

-----------------------------------------------
Preprocessor statistics:
-----------------------------------------------

Size of unpacked commands: 2700775 bytes
Size of   packed commands: 1288498 bytes
Compression ratio: 47.7%
# Uncompressed commands:
M106      :     2
M107      :     2
<comment> :  1148
M25       :     1
M110      :     1
M28       :     1
M29       :     1

Your UM2 display will show the message Printing with USB, this is a bit misleading, since the file will not be printed.

This downloaded file (named USB.G) can be printed throught the normal UM2 print menu then. Or you could start the print of this file with a M623 <file> gcode command. This is what the print mode uses.

Printing files over USB

Use print mode to download a file to the SD card of your UM2 printer and print it instantly at the same time:

#> ./ultiprint.py print -h

usage: ultiprint.py print [-h] gfile

positional arguments:
gfile       Input GCode file.

optional arguments:
-h, --help  show this help message and exit

Example:

#> ./ultiprint.py print sony_stand.gcode

Initial read:


Preprocessing: sony_stand.gcode
Preprocessing 58934 gcode lines...
done...
Reply:  start
Reply:  echo:Marlin 1.0.0
Reply:  echo: Last Updated: Dec 21 2014 23:53:16 | Author: ERRI 14.12.1-UP3
Reply:  Compiled: Dec 21 2014
Reply:  echo: Free Memory: 1802  PlannerBufferBytes: 1232
Reply:  echo:Stored settings retrieved
Reply:  echo:Steps per unit:
Reply:  echo:  M92 X80.00 Y80.00 Z200.00 E282.00
Reply:  echo:Maximum feedrates (mm/s):
Reply:  echo:  M203 X300.00 Y300.00 Z40.00 E45.00
Reply:  echo:Maximum Acceleration (mm/s2):
Reply:  echo:  M201 X9000 Y9000 Z100 E10000
Reply:  echo:Acceleration: S=acceleration, T=retract acceleration
Reply:  echo:  M204 S3000.00 T3000.00
Reply:  echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s),  Z=maximum Z jerk (mm/s),  E=maximum E jerk (mm/s)
Reply:  echo:  M205 S0.00 T0.00 B20000 X20.00 Z0.40 E5.00
Reply:  echo:Home offset (mm):
Reply:  echo:  M206 X0.00 Y0.00 Z-15.50
Reply:  echo:PID settings:
Reply:  echo:   M301 P10.00 I2.50 D100.00
Got Required reply:  echo:SD card ok

Send:  N0 M110*35
ACK
Got Required reply:  ok

Send:  N1 M623 usb.g*40
ACK
Got Required reply:  ok

Send:  N2 M28 usb.g*22
ACK
Reply:  Writing to file: USB.G
Reply:  openfile(USB.G), opencount:  1
Got Required reply:  ok

Send:  N3 ;FLAVOR:UltiGCode*18
ACK

Send:  N4 ;TIME:3205*74
ACK

Send:  N5 ;MATERIAL:6120*84
ACK

Send:  N6 ;MATERIAL2:0*80
ACK

Send:  N7 ;Layer count: 198*72
ACK

Send:  N8 ;LAYER:0*36
ACK

Send:  N9 M107*44
ACK
.
.
.
<many lines follow...>
.
.
.
Send:  026c142e0e430ad7c142777dd843ee09310a
ACK

Send:  026c33330e433333c242d87ed843ef09780a
Reply:  File opened: USB.G Size: 37633
Reply:  File selected
Reply:  openfile(USB.G), opencount:  2
Reply:  closefile(USB.G), opencount:  1
Reply:  File opened: USB.G Size: 37633
Reply:  File selected
Reply:  openfile(USB.G), opencount:  2
Reply:  closefile(USB.G), opencount:  1
Reply:  File opened: USB.G Size: 37633
Reply:  File selected
Reply:  openfile(USB.G), opencount:  2
Reply:  echo:enqueing "G28"
Reply:  echo:enqueing "G1 F12000 X5 Y10"
ACK

Send:  026c33330e435c8fc2423280d843f009a00a
ACK
.
.
.
<many lines follow...>
.
.
.

Send:  01e4282348210143a4707c422ee6e70a
ACK

Send:  N58927 M107*36
ACK

Send:  030430e6d10a
ACK

Send:  017448210143a4707c420000c84131e6ea0a
ACK

Send:  N58930 M25 ;Stop reading from this point on.*49
ACK

Send:  N58931 M29*30
ACK
Reply:  closefile(USB.G), opencount:  1
Got Required reply:  Done saving file.

-----------------------------------------------
Store statistics:
-----------------------------------------------

Sent 58932 commands in 310.3 seconds, 189.9 commands/second.

Reply:  Done printing file
Reply:  echo:0 hours 49 minutes
Reply:  closefile(USB.G), opencount:  0
Reply:  echo:enqueing "M84 X Y Z E"
Reply:  echo:enqueing "G92 E127"
Reply:  echo:enqueing "G1 F1500 E0"
Reply:  echo:enqueing "G28"
Reply:  echo:enqueing "M84"
waiting 10.00 seconds for more messages...
end-reply received, exiting...

-----------------------------------------------
Preprocessor statistics:
-----------------------------------------------

Size of unpacked commands: 2121808 bytes
Size of   packed commands: 984463 bytes
Compression ratio: 46.4%
# Uncompressed commands:
M28       :     1
M107      :     2
<comment> :   600
M25       :     1
M110      :     1
M623      :     1
M106      :     2
M29       :     1

Your UM2 display will show the message Printing with USB for the first 5 seconds of the print. Then for the next 5 seconds a new screen will appear: Waiting for <file> and a five seconds countdown. After this the display will work exactly the same as if the printjob has been started manually.

Examples

Monitor mode:

Monitoring the serial output from the printer firmware looks like this:

#> ./ultiprint.py mon
Initial read:


Reply:  start
Reply:  echo:Marlin 1.0.0
Reply:  echo: Last Updated: Dec 21 2014 23:53:16 | Author: ERRI 14.12.1-UP3
Reply:  Compiled: Dec 21 2014
Reply:  echo: Free Memory: 1802  PlannerBufferBytes: 1232
Reply:  echo:Stored settings retrieved
Reply:  echo:Steps per unit:
Reply:  echo:  M92 X80.00 Y80.00 Z200.00 E282.00
Reply:  echo:Maximum feedrates (mm/s):
Reply:  echo:  M203 X300.00 Y300.00 Z40.00 E45.00
Reply:  echo:Maximum Acceleration (mm/s2):
Reply:  echo:  M201 X9000 Y9000 Z100 E10000
Reply:  echo:Acceleration: S=acceleration, T=retract acceleration
Reply:  echo:  M204 S3000.00 T3000.00
Reply:  echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s),  Z=maximum Z jerk (mm/s),  E=maximum E jerk (mm/s)
Reply:  echo:  M205 S0.00 T0.00 B20000 X20.00 Z0.40 E5.00
Reply:  echo:Home offset (mm):
Reply:  echo:  M206 X0.00 Y0.00 Z-15.50
Reply:  echo:PID settings:
Reply:  echo:   M301 P10.00 I2.50 D100.00
Got Required reply:  echo:SD card ok
Reply:  echo:SD card ok
Reply:  File opened: USB.G Size: 803453
Reply:  File selected
Reply:  openfile(USB.G), opencount:  1
Reply:  closefile(USB.G), opencount:  0
Reply:  File opened: LEVELT5.G Size: 2665
Reply:  File selected
Reply:  openfile(LEVELT5.G), opencount:  1
Reply:  closefile(LEVELT5.G), opencount:  0

Reset mode:

With the reset mode you can send some resetting gcodes to your UM2 (home axes, cool down heaters ...). This is normally not needed. Just in case something goes wrong...

#> ./ultiprint.py reset


Initial read:

Resetting printer
Preprocessing 6 gcode lines...
done...
Reset code sequence:  [('N0 M110*35\n', 'ok'), ('N1 M29*25\n', None), ('N2 G28*17\n', None), ('N3 M84*28\n', None), ('N4 M104 S0*97\n', None), ('N5 M140 S0*96\n', None)]
waiting 5.00 seconds for more messages...
Reply:  start
Reply:  echo:Marlin 1.0.0
Reply:  echo: La Reply:  st Updated: Dec 21 2014 23:53:16 | Author: ERRI 1 Reply:  4.12.1-UP3
Reply:  Compiled: Dec 21 2014
Reply:  echo: Free Memo Reply:  ry: 1802  PlannerBufferBytes: 1232
Reply:  echo:Sto Reply:  red settings retrieved
Reply:  echo:Steps per unit:
Reply:  echo Reply:  :  M92 X80.00 Y80.00 Z200.00 E282.00
Reply:  echo: Reply:  Maximum feedrates (mm/s):
Reply:  echo:  M203 X300.00  Reply:  Y300.00 Z40.00 E45.00
Reply:  echo:Maximum Accelerati Reply:  on (mm/s2):
Reply:  echo:  M201 X9000 Y9000 Z100 E Reply:  10000
Reply:  echo:Acceleration: S=acceleration, T=retr Reply:  act acceleration
Reply:  echo:  M204 S3000.00 T3000 Reply:  .00
Reply:  echo:Advanced variables: S=Min feedrate (mm/ Reply:  s), T=Min travel feedrate (mm/s), B=minimum segm Reply:  ent time (ms), X=maximum XY jerk (mm/s),  Z=maxi Reply:  mum Z jerk (mm/s),  E=maximum E jerk (mm/s)
Reply:  echo: Reply:    M205 S0.00 T0.00 B20000 X20.00 Z0.40 E5.00 Reply: 0x0a
Reply:  echo:Home offset (mm):
Reply:  echo:  M206 X0.00 Y0.00  Reply:  Z-15.50
Reply:  echo:PID settings:
Reply:  echo:   M301 P10.00 Reply:   I2.50 D100.00

Send:  N0 M110*35
waiting 2.50 seconds for more messages...
Reply:  echo:SD card ok
Reply: 0x060a
Reply:  ok

Send:  N1 M29*25
waiting 2.50 seconds for more messages...
Reply: 0x060a
Reply:  ok

Send:  N2 G28*17
waiting 2.50 seconds for more messages...
Reply: 0x060a
Reply:  ok

Send:  N3 M84*28
waiting 2.50 seconds for more messages...
Reply: 0x060a
Reply:  ok

Send:  N4 M104 S0*97
waiting 2.50 seconds for more messages...
Reply: 0x060a
Reply:  ok

Send:  N5 M140 S0*96
waiting 2.50 seconds for more messages...
Reply: 0x060a
Reply:  ok

Preprocess mode:

#> ./ultiprint.py pre UltimakerRobot_support.gcode


Preprocessing: UltimakerRobot_support.gcode
Preprocessing 71390 gcode lines...
done...

-----------------------------------------------
Preprocessor statistics:
-----------------------------------------------

Size of unpacked commands: 2700775 bytes
Size of   packed commands: 1288498 bytes
Compression ratio: 47.7%
# Uncompressed commands:
M106      :     2
M107      :     2
<comment> :  1148
M25       :     1
M110      :     1
M28       :     1
M29       :     1

Copyright (C) 2014 erwin.rieger@ibrieger.de

$LastChangedDate: 2015-01-05 01:21:28 +0100 (Mo, 05. Jan 2015) $
$Rev: 157 $
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.