jukebox42 / Octoprint-PrusaMMU

An Octoprint plugin that adds MMU support.
GNU Affero General Public License v3.0
17 stars 2 forks source link

MMU not found #43

Closed Anubis1971 closed 3 months ago

Anubis1971 commented 7 months ago

Behaviors:

Perhaps Octoprint not recognizing MMU3 is the problem. If not, then I believe when single color printing, the filament select should appear regardless of the profile used.

jukebox42 commented 3 months ago

Ha def is, mostly because I have no way to test any of this myself so makes debugging tricky.

I realize somewhere in there, I broke the filament detection but I'm ignoring that for now until we can figure out the printing problem, I think folks would rather have that feature anyways :).

Ok, this one may feel a little awkward but I just want to see if the M863 stuff works if we send it before the print starts.

I've swapped what clicking the MMU nav item does.

What you will need to do:

If this works, I'll see if I can integrate it better, I couldn't find an easy way to hijack the print start button and prevent it from sending the print command.

Octoprint-PrusaMmu.zip

BlueFyre commented 3 months ago

Thinking out loud. I wonder if there's some kind of code causing a reset of the tool mapping. I did notice that there's a tool mapping to be reset. Might be worth modifying the start gcode to include multiple outputs of the tool mapping to hopefully see what's going on in terms of timing

Another idea is to perhaps hard code the tool mapping commands in the start gcode (ie outside of the plugin) to verify that it actually works as intended

jukebox42 commented 3 months ago

@BlueFyre, that's a good idea. To test it manually, you can send these commands to your printer.

Here's how it's supposed to work now: (assuming you picked filament 3)

Breaking the codes down:

It's possible we have the P and L backward, so you could try the reverse, but it was suspiciously not working that way in the tests we tried earlier. You'd flip them like this:

M863 E1
M863 P0 L2
M863 P1 L2
M863 P3 L2
M863 P4 L2

If you want to see what's been mapped sending M863 without a command will have the printer echo the current mapping. It would be good to try sending this and see what happens before you select a print. I think when you pick a print the printer only tells you about the tools being used, and not all of the ones available.

Edited to remove the reset.

BlueFyre commented 3 months ago

@jukebox42 I think I found the problem. M863 R will actually set enabled = false See https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/ce6d58b80c995dd8d5923d39688b195a6ac10b1e/lib/Marlin/Marlin/src/module/prusa/tool_mapper.cpp#L82

You'll need to rearrange the lines :)

jukebox42 commented 3 months ago

@BlueFyre 🤦 good catch. Let me just pull the reset on start. I don't think I need it. We'll try it with the button before first, and then I can try to pull it back into start.

jukebox42 commented 3 months ago

@BlueFyre actually, Before I push another one can you confirm if the override commands (without reset) work?

BlueFyre commented 3 months ago

@jukebox42 found the problem. you're missing M in your commands:

Send: M863 M P2 L0
Recv: ok
[...]
Send: M863
Recv: Tool mapping:
Recv:   Tool 0 -> 2
Recv:   Tool 1 -> 1
Recv:   Tool 2 -> <none>
Recv:   Tool 3 -> 3
Recv:   Tool 4 -> 4
Recv: Enabled: 0

Needs to be M863 M P2 L0 as shown there. I can confirm M863 will echo though I haven't found time to actually load all the spools to my printer to test but running a few commands doesn't take much time. Hope it helps!

jukebox42 commented 3 months ago

Fair enough, here is a version that removes the reset. Same interaction, you click the menu to pick a filament, then you start a print after that. If this works I'll revert back to the menu on start and we can see if that fixes it.

Octoprint-PrusaMmu.zip

BlueFyre commented 3 months ago

@jukebox42 what's expected to work in this latest build? and what did you want people to test? I'll try to make time this week to give it a go

[Edit] I took a look through the code and it looks like it tries to map all the tools to a single one. I don't think that works as expected as I was playing around with M863 in the console and it only allows you to swap stuff around. You can only have stuff mapped 1-1 (or 1 to none)

Looking at my sample output above, it maps physical 2 to logical 0, meaning anything with T0 will print with 2. But logical 2 is unmapped after that (and you can't put it back to 2 without unsetting 0)

Quite limited functionality I suppose but that's what there is...

MysticGringo commented 3 months ago

Hey Jukebox...

I loaded the latest plugin and tried it. Object sliced with tool 5... chose tool 2 before the print, then sent object to print. It did not load any filament at all, and started printing empty.

Here's the M863:

Send: N23 M863*31 Recv: Tool mapping: Recv: Tool 0 -> 0 Recv: Tool 1 -> 1 Recv: Tool 2 -> 2 Recv: Tool 3 -> 3 Recv: Tool 4 -> 4 Recv: Enabled: 0 Recv: ok

Edit to add: This seems similar to how the MK4/MMU3 works when slicing WITHOUT the MMU profile. There's a bit of discussion on Prusa forums about slicing without the MMU profile when you have one installed and turned on that it will just print with no filament loaded.

jukebox42 commented 3 months ago

@BlueFyre That's unfortunate. That tells me I'm probably not going to have much success with trying to use tool rewriting without parsing the files ahead of time. Something I've been really trying to avoid. Thanks for digging deeper into how it works.

@MysticGringo Appreciate you giving this one another try, I suspect it's caused by the problem @BlueFyre is noting. Because I try to map all the tools to a single one, Tool 2 was likely not mapped to anything since tool 4 would have been mapped last.

I'm working on a more direct approach, keeping the same style of selecting ahead of the print. This will hijack the T commands and rewrite them before the printer gets them. It's less elegant but should not suffer the same problem. Don't worry about trying to check the M863 on this one since I've disabled it in my try.

I need to wait for a print to finish, I should be able to test this change with my MK3 since the T commands are the same. If it works I'll share it here.

Appricate you all still sticking with me, I'm sure these tests are getting old :)

jukebox42 commented 3 months ago

Octoprint-PrusaMmu.zip

Alright, I've tested this as best i could mocking an MK4 with the virtual printer.

How to test:

You should expect it will replace all instanced of T# with the tool you chose, it overwrites it in the gcode queue function.

I had an issue with prompt selection that should be fixed now.

I've got an idea of how I can map this to print starts so you don't need to do the two steps, but it's a bit more work and I'd like to verify this method works, since I haven't had one yet.

Thanks in advance!

MysticGringo commented 3 months ago

BOOM!!! That works! Model sliced with tool 1, chose tool 3 prior to print, hit print, and tool 3 loaded and printed!

Thank you for all the efforts! It is very much appreciated!

The M863 shows all tools mapped as normal.

Send: N513 M863*41 Recv: Tool mapping: Recv: Tool 0 -> 0 Recv: Tool 1 -> 1 Recv: Tool 2 -> 2 Recv: Tool 3 -> 3 Recv: Tool 4 -> 4 Recv: Enabled: 0 Recv: ok

jukebox42 commented 3 months ago

@MysticGringo excellent! I have an idea on how to make it easier to use. Let me get started on that now that we have a working solution :)

jukebox42 commented 3 months ago

Alright, this is hopefully my last request for testing. This version uses print start to pause the print, prompt you for filament change, and then uses the technique in the version you tested to rewrite the print.

Using this should work as you'd expect. Pick a multi-sliced print and click print, the modal will pop up. No need to click nav ahead of it. I've removed all the M863 code.

Thanks in advance!

Octoprint-PrusaMmu.zip

BlueFyre commented 3 months ago

I wanted to clarify what to expect in the future since it seems like you've found your approach. Is the plan to support mapping everything to a single tool and being able to remap stuff flexibly as well?

jukebox42 commented 3 months ago

@BlueFyre yeah exactly, for this initial release: When you select a print you'll get the popup. Picking a filament in the list will overwrite all tools to that tool. The down side is you always have to slice in multi, and you will always get the filament selection dialog ( you can click skip), but I think that's better than having to click two buttons to prime then print (I know I'd forget).

If you want it to print like normal, you can either let the popup timeout, or you can click the new "skip" option in the popup.

In settings you do have a way to remap each tool to a different one as well. It's tucked under advanced. It uses the same strategy I'm using for mk4. It won't reset after a print and it won't be used if you select a filament, only works when you click skip.

A few things I can do in the future to make this better:

  1. Detect if the gcode only has one tool defined in it (I'd have to preprocess like the thumbnail plugin) so you don't get a popup on every print
  2. Make the remap easier to manipulate for multi tool prints if that's something folks really want
BlueFyre commented 3 months ago

Thanks for the update and efforts. Agree that it's better to always prompt than it is to have more than one step or bad timing

Side idea would be that there's just an option that can be turned on/off to show that prompt. Though only relevant for the 3.5/3.9/4 (and probably the XL if you choose to pursue that). There's probably some folks out there who would like to only see the MMU status/error and don't really worry about the prompt/mapping anyhow

Also, for me, I definitely am leaning more towards item 2 in your list (flexible remapping). Makes sense to prioritize that only if it's in demand though (and better to have a separate issue to track that than to derail this one). Item 1 would be a logical precursor anyhow

At the very least, I would think that now that you've chosen your approach it's a bit easier to develop. It should work to have either detection for the Tc for the MK3 single mode or it's the multi mode for the rest of the printers. I think the newer sliced code should be consistent between the 3 and 4 so that your effort there wouldn't be duplicated or hard to test on your own so you don't need to wait for someone to try it out

Anyhow, just sharing some thoughts. Hope it's useful discussion Cheers

MysticGringo commented 3 months ago

Yep... this works!

Awesome job! I know that had to be annoying, I appreciate your efforts.

jukebox42 commented 3 months ago

@BlueFyre when you are thinking option within settings to turn the popup on/off or something more visible like in the header? It would be fairly trivial to add one to the settings page, the popup logic is fairly isolated.

You are right that this option will be easier to test on my own. I can replicate a lot of this with the virtual printer. Aside from the nav messages, hopefully those are working again when I pulled out the other logic. Folks will tell me if they are not :).

@MysticGringo thanks for the confirmation, and all your trsting! I'll do some regression testing on my mk3 to make sure that's still working as expected and publish a release. Next release version will include this.

BlueFyre commented 3 months ago

I was thinking within the settings since then people could just turn it off all together. I'm assuming the other functionality of the plugin still is valuable enough even if people don't need the tool selection portion (and don't want to be prompted)

jukebox42 commented 3 months ago

Oh yeah easy enough. I'll add a setting for it in this release

jukebox42 commented 3 months ago

Hey All,

I've just released this version. I'm going to close this thread. Thank you all for the help. If you find issues please report them :)

graelo commented 3 months ago

@jukebox42, Thank you so much for the hard work!

MysticGringo commented 3 months ago

Awesome! Glad you were able to figure it out.

Maybe one more "feature"... add a timer showing how long till the selection times out.