Doodle3D / doodle3d-client

The Doodle3D web interface that people can access on computers or tablets to draw doodles and control the Doodle3D WiFi box.
www.doodle3d.com
GNU General Public License v2.0
3 stars 8 forks source link

Improve Makerbot end movements #242

Closed peteruithoven closed 9 years ago

peteruithoven commented 10 years ago

Currently the bed moves up if you stop a print. This can destroy the print. It should lower the bed and then home the head.

peteruithoven commented 10 years ago

Default Makerware endgcode:

M73 P100; 
; End of print
G1 X5.759 Y-11.537 Z54.800 F1500 A5033.36058; Short Retract Extruder: A
M18 A B(Turn off A and B Steppers)
G1 Z155 F900
G162 X Y F2000
M18 X Y Z(Turn off steppers after a build)
M109 S0 T0
M104 S0 T0
M73 P100 (end  build progress )
M70 P5 (We <3 Making Things!)
M72 P1  ( Play Ta-Da song )
M137 (build end notification)

Our current gcode:

M73 P100
G92 A0 B0 ;reset extruder position to prevent retraction
M18 A B(Turn off A and B Steppers)
G1 Z155 F900
G162 X Y F2000
M18 X Y Z(Turn off steppers after a build)
{if heatedBed}M140 S{preheatBedTemp} T0
M104 S{preheatTemp} T0
M73 P100 (end  build progress )
M72 P1  ( Play Ta-Da song )
M137 (build end notification)
peteruithoven commented 10 years ago

So I've made a little start gcode file that I send and then send the end commands separately, to check what works and what doesn't. I used p3d for this, the commandline frontend to print3d. The start gcode I use:

;@printer r2x
M136
M73 P0
G162 X Y F2000
G161 Z F900
G92 X0 Y0 Z0 A0 B0
G1 Z5.0 F900
G161 Z F100
G92 X0 Y0 Z0 A0 B0
G1 Z1.0 F900
G1 X-264 Y-145 Z0 F3300.0
G92 X0 Y0 Z0 A0 B0
G0 Z20 F2000
G1 X20 Y20 Z0 F900
G1 X30 Y20 Z0 F900

Doing the test I noticed it doesn't respond to the M73 and M72.

M73 (change build percentage) I've tried M73 P100, M73 P50, M73 P1 but it doesn't change the percentage on the display, I do see a little flash so I think it does receive something. Verbose print3D log:

01-01 00:04:29  [SRV] read 0 bytes from client with fd 6
01-01 00:04:29  [SRV] read 4 bytes from client with fd 6
01-01 00:04:29  [IPC] command: [>>gcodeClear]
01-01 00:04:29  [CDH] received clear gcode command
01-01 00:04:29  [IPC] command: [<<ok]
01-01 00:04:29  [SRV] read 16 bytes from client with fd 6
01-01 00:04:29  [IPC] command: [>>gcodeAppend:"M73 P100]
01-01 00:04:29  [CDH] received append gcode command with argument length 8
01-01 00:04:29  [ABD] setState(): 3:idle > 4:buffering
01-01 00:04:29  [MBD] appended 23 bytes of gpx data (bufsize now 23)
01-01 00:04:29  [IPC] command: [<<ok]
01-01 00:04:29  [SRV] read 4 bytes from client with fd 6
01-01 00:04:29  [IPC] command: [>>gcodeStartPrint]
01-01 00:04:29  [CDH] received start print gcode command
01-01 00:04:29  [ABD] startPrint
01-01 00:04:29  [ABD] resetPrint()
01-01 00:04:29  [ABD] setState(): 4:buffering > 3:idle
01-01 00:04:29  [ABD] setState(): 3:idle > 5:printing
01-01 00:04:29  [IPC] command: [<<ok]
01-01 00:04:29  [MBD] ingored response for cmd: 134 (toolcmd: -1, len: 1)
01-01 00:04:29  [MBD] processed 4 cmds (size=0), printbuf: 512 => 493
01-01 00:04:29  [ABD] setState(): 5:printing > 3:idle
01-01 00:04:29  [MBD] Print queue empty. Done!

M72 (play song)

01-01 00:05:52  [SRV] read 0 bytes from client with fd 6
01-01 00:05:52  [SRV] read 4 bytes from client with fd 6
01-01 00:05:52  [IPC] command: [>>gcodeClear]
01-01 00:05:52  [CDH] received clear gcode command
01-01 00:05:52  [IPC] command: [<<ok]
01-01 00:05:52  [SRV] read 14 bytes from client with fd 6
01-01 00:05:52  [IPC] command: [>>gcodeAppend:"M72 P1]
01-01 00:05:52  [CDH] received append gcode command with argument length 6
01-01 00:05:52  [ABD] setState(): 3:idle > 4:buffering
01-01 00:05:52  [MBD] appended 2 bytes of gpx data (bufsize now 2)
01-01 00:05:52  [IPC] command: [<<ok]
01-01 00:05:52  [SRV] read 4 bytes from client with fd 6
01-01 00:05:52  [IPC] command: [>>gcodeStartPrint]
01-01 00:05:52  [CDH] received start print gcode command
01-01 00:05:52  [ABD] startPrint
01-01 00:05:52  [ABD] resetPrint()
01-01 00:05:52  [ABD] setState(): 4:buffering > 3:idle
01-01 00:05:52  [ABD] setState(): 3:idle > 5:printing
01-01 00:05:52  [IPC] command: [<<ok]
01-01 00:05:52  [MBD] processed 1 cmds (size=0), printbuf: 512 => 510
01-01 00:05:52  [ABD] setState(): 5:printing > 3:idle
01-01 00:05:52  [MBD] Print queue empty. Done!

I also tried sending the commands after changing the printer type from r2x to r and r2, but that doesn't make a difference.

Another problem is that the display sticks at "Build finished!" (M137) even when sending a new print.

peteruithoven commented 10 years ago

The reason M72 (play song) didn't work was that the sounds where disabled on the printer. It also required a restart for this setting to apply.

peteruithoven commented 10 years ago

I tried adding M200 to the end.gcode, but it didn't seem to do anything. http://replicat.org/mcodes

peteruithoven commented 10 years ago

I've tried debugging gpx, but it seems to parse the M73 as it should. I don't follow the logic yet, but adding a M70 (Display message on machine) seems to clear the screen and have it update to the monitor mode when a new print is started. But, it does add a issue, probably buffer related, it suddenly takes a while before a new print is started. To be more spefic I added the following command to the end gcode: M70 P5 (We <3 Making Things!)

Actually we removed the M70 because it was causing issues: #178

peteruithoven commented 10 years ago

Using M70 P5 () causes the display to stick at Build finished! again. Using M70 P1 (We <3 Making Things!) clears the display but delays the next print. (the P parameter should specify the time the message should be displayed) Using M70 P1 (W) clears the display but delays the next print. Using M70 (We <3 Making Things!) clears the display but delays the next print. Putting M70 (We <3 Making Things!) clears the display but delays the next print.

According to the gpx code the maxLength for the message is 20 characters and We <3 Making Things! is exactly 20 characters, so that shouldn't be a problem

peteruithoven commented 10 years ago

There seems to be a buffer issue with M70, when you don't send 20 the buffer doesn't clear.

Sending 20 characters M70 P3 (xxxxxxxxxxxxxxxxxxxx):

05-06 11:39:07  [MBD]   hTemps: 26/0, bTemps: 19/0, cmdbuf: 2/0/2, prbuf space: 512
05-06 11:39:08  [CDH] received clear gcode command
05-06 11:39:08  [CDH] received append gcode command with argument length 29
05-06 11:39:08  [ABD] setState(): 3:idle > 4:buffering
05-06 11:39:08  [MBD] appended 26 bytes of gpx data (bufsize now 26)
05-06 11:39:08  [CDH] received start print gcode command
05-06 11:39:08  [ABD] setState(): 4:buffering > 3:idle
05-06 11:39:08  [ABD] setState(): 3:idle > 5:printing
05-06 11:39:08  [MBD] processed 2 cmds (size=0), printbuf: 512 => 490
05-06 11:39:08  [ABD] setState(): 5:printing > 3:idle
05-06 11:39:08  [MBD] Print queue empty. Done!
05-06 11:39:08  [MBD]   hTemps: 26/0, bTemps: 19/0, cmdbuf: 2/0/2, prbuf space: 490
05-06 11:39:09  [MBD]   hTemps: 26/0, bTemps: 18/0, cmdbuf: 2/0/2, prbuf space: 512

Sending fewer M70 P3 (xxxx):

05-06 11:39:37  [MBD]   hTemps: 26/0, bTemps: 19/0, cmdbuf: 2/0/2, prbuf space: 512
05-06 11:39:38  [CDH] received clear gcode command
05-06 11:39:38  [CDH] received append gcode command with argument length 13
05-06 11:39:38  [ABD] setState(): 3:idle > 4:buffering
05-06 11:39:38  [MBD] appended 10 bytes of gpx data (bufsize now 10)
05-06 11:39:38  [CDH] received start print gcode command
05-06 11:39:38  [ABD] setState(): 4:buffering > 3:idle
05-06 11:39:38  [ABD] setState(): 3:idle > 5:printing
05-06 11:39:38  [MBD] processed 2 cmds (size=0), printbuf: 512 => 506
05-06 11:39:38  [ABD] setState(): 5:printing > 3:idle
05-06 11:39:38  [MBD] Print queue empty. Done!
05-06 11:39:38  [MBD]   hTemps: 26/0, bTemps: 19/0, cmdbuf: 2/0/2, prbuf space: 506
05-06 11:39:39  [MBD]   hTemps: 26/0, bTemps: 18/0, cmdbuf: 2/0/2, prbuf space: 507
05-06 11:39:40  [MBD]   hTemps: 26/0, bTemps: 18/0, cmdbuf: 2/0/2, prbuf space: 507
peteruithoven commented 10 years ago

There don't seem to be any clear / finish / reset gcode commands. Beside M70 or M71 (which makes users press a button) there are no commands that display something on the screen.

peteruithoven commented 10 years ago

When printing through Makerware the printer seems to clear the Build finished! message before starting a new one. So maybe there is something in the gcode /x3g we don't add.
I've created a 2x2x0.5mm cube and sliced this in Makerware: gcode: http://www.tempfiles.net/download/201406/348306/cube.html s3g: http://www.tempfiles.net/download/201406/348307/cube.html x3g: http://www.tempfiles.net/download/201406/348308/cube.html

peteruithoven commented 10 years ago

Running the s3g through GPX's s3g-decompiler.py, it finds:

0:  [153] Start build, steps 0: cube
1:  [150] Set build percent 0%, ignore 0
2:  [132] Home maximum on 3, feedrate 338, timeout 20 s
3:  [131] Home minimum on 4, feedrate 166, timeout 20 s
4:  [140] Set extended position as (0,0,-2000,0,0)
5:  [139] Absolute move to (0,0,0,0,0) at DDA 166
6:  [131] Home minimum on 4, feedrate 1500, timeout 20 s
7:  [144] Recall home position for axes 31
8:  [140] Set extended position as (13463,6377,0,0,0)
9:  [139] Absolute move to (-9920,-6465,60000,0,0) at DDA 128
10:     [145] Set pot axis 1 to 20
11:     [145] Set pot axis 0 to 20
12:     [145] Set pot axis 4 to 20
13:     [145] Set pot axis 3 to 20
14:     [134] Change extruder 0
15:     [136] Extruder(0) [3] set target temperature = 230
16:     [135] Wait until extruder 0 ready (100 ms between polls, 600 s timeout
17:     [145] Set pot axis 1 to 127
18:     [145] Set pot axis 0 to 127
19:     [145] Set pot axis 4 to 127
20:     [145] Set pot axis 3 to 127
21:     [139] Absolute move to (9335,-6554,108,0,0) at DDA 128
22:     [139] Absolute move to (-9920,-6465,108,-2406,0) at DDA 378
23:     [140] Set extended position as (-9920,-6465,108,0,0)
24:     [139] Absolute move to (-9920,-6465,0,0,0) at DDA 150
25:     [140] Set extended position as (-9920,-6465,0,0,0)
26:     [134] Change extruder 0
27:     [136] Extruder(0) [3] set target temperature = 230
28:     [139] Absolute move to (-9920,-6465,0,125,0) at DDA 415
29:     [139] Absolute move to (-9920,-6465,40,125,0) at DDA 128
30:     [150] Set build percent 0%, ignore 0
...

So no special reset...

peteruithoven commented 10 years ago

Removed early set build percentage to 100%

G92 A0 B0
M18 A B
G1 Z155 F900
G162 X Y F2000
M18 X Y Z
M72 P1
M73 P100
M137

"Build finished!" sticks, next print not delayed.

Removed M73 (set build percentage), "build finished!" sticks, next print not delayed.

peteruithoven commented 10 years ago

Sending the cube.gcode (generated by Makerware) the machine displays "Build finished!" and after a moment goes back to the menu. When I then (after 5 minutes) send the same file again it sets the display in monitoring mode as it should. After completing this print and trying to send the same print again right away the print is delayed.

When I send a print using Makerware the "Build finished!" doesn't stick and sending the next print isn't delayed.

So the problem probably lies with the x3g that GPX generates.

peteruithoven commented 10 years ago

Wouter started tweaking our GPX fork to align it's output to the output of Makerware. https://github.com/Doodle3D/GPX/commit/7be25d74e183013188642dd2568c68a35b85e1ff

peteruithoven commented 10 years ago

Using GPS's s3g-decompiler.py I tried to decompile the Makerbot X3G and GPX X3G output. I used our x3g-output-behaviour branch for this. GPX's decompiled X3G:

0:  [153] Start build, steps 0: cube.gcode
1:  [134] Change extruder 0
2:  [150] Set build percent 0%, ignore 0
3:  [132] Home maximum on 3, feedrate 479, timeout 20 s
4:  [131] Home minimum on 4, feedrate 167, timeout 20 s
5:  [140] Set extended position as (0,0,-2000,0,0)
6:  [155] Move to (0,0,0,0,0) dda_rate: 5999 (relative: 18) distance: 5.000000 feedrateX64: 960
7:  [131] Home minimum on 4, feedrate 1500, timeout 20 s
8:  [144] Recall home position for axes 31
9:  [140] Set extended position as (13463,6377,0,0,0)
...
154:    [137] Enable/disable steppers 18
155:    [155] Move to (2223,2224,62000,0,0) dda_rate: 6000 (relative: 18) distance: 154.500000 feedrateX64: 960
156:    [132] Home maximum on 3, feedrate 479, timeout 20 s
157:    [137] Enable/disable steppers 7
158:    [136] Extruder(0) [3] set target temperature = 0
159:    [150] Set build percent 100%, ignore 0
160:    [149] Display message, options 0x2 at 0,0 timeout 5
 'We <3 Making Things!'
161:    [151] Queue song 1
162:    [154] End build, flags 0x0

Makerbot's decompiled X3G:

0:  [157] Stream version 1.0 (0 0 45077 0 0 0 0)
1:  [153] Start build, steps 0: cube
2:  [150] Set build percent 0%, ignore 0
3:  [132] Home maximum on 3, feedrate 338, timeout 20 s
4:  [131] Home minimum on 4, feedrate 166, timeout 20 s
5:  [140] Set extended position as (0,0,-2000,0,0)
6:  [155] Move to (0,0,0,0,0) dda_rate: 6000 (relative: 0) distance: 5.000000 feedrateX64: 960
7:  [131] Home minimum on 4, feedrate 1500, timeout 20 s
8:  [144] Recall home position for axes 31
9:  [140] Set extended position as (13463,6377,0,0,0)
...
156:    [137] Enable/disable steppers 18
157:    [155] Move to (2222,2224,62000,37,0) dda_rate: 6000 (relative: 0) distance: 154.500000 feedrateX64: 960
158:    [132] Home maximum on 3, feedrate 338, timeout 20 s
159:    [137] Enable/disable steppers 7
160:    [136] Extruder(0) [3] set target temperature = 0
161:    [150] Set build percent 100%, ignore 0
162:    [149] Display message, options 0x2 at 0,0 timeout 5
 'We <3 Making Things!)
'
163:    [151] Queue song 1
164:    [154] End build, flags 0x0

Main differences:

I also tried changing the GCODE flavor to "Reprap" and "Makerbot/ReplicatorG", but looking at the decompiled output they don't differ.

peteruithoven commented 10 years ago

I moved the issue that "Build finished!" sticks around to a separate issue #253. It's less of a problem than the reason for starting this issue; When sending a Doodle through the web interface and then stopping it, the bed moves up instead of down and homes it's xy axis straight through the doodle.

peteruithoven commented 10 years ago

Using the following end gcode

G92 A0 B0
M18 A B
G1 Z155 F900
G162 X Y F2000
M18 X Y Z
{if heatedBed}M140 S{preheatBedTemp} T0
M104 S{preheatTemp} T0
M73 P100
M72 P1
M137

I started experimenting with the Z move sinse that seemed to be ignores. G1 Z155 F900 Moves to Z0, then homes G1 Z50 F900 Doesn’t move Z, then homes G1 Z30 F900 Doesn’t move Z, then homes G1 Z155 F900 G1 Z30 F900 G1 Z50 F900 Moves down (not to 155) Move up (further than bed) Then down again But now it doesn’t home

I'm going to try this again with our new print3D feature/mb-gcodebuffer branch to see if that makes a difference.

peteruithoven commented 10 years ago

Using print3D feature/mb-gcodebuffer branch:

G1 Z155 F900
G1 Z30 F900
G1 Z50 F900

Tried same again

G1 Z155 F900

G1 Z155 F900
G1 X10 Y10 F900
G1 X20 Y10 F900
G1 X20 Y20 F900
G1 X10 Y20 F900
G1 X10 Y10 F900
G1 X50 Y50 F900
G1 X60 Y50 F900
G1 X60 Y60 F900
G1 X50 Y60 F900
G1 X50 Y50 F900
peteruithoven commented 9 years ago

Fixed: https://github.com/Doodle3D/doodle3d-firmware/commit/df4f1702a921527ba7001526fac04a79f5b1aee6