• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

[3.6.0-rc.2] M596 Multiple Motion Systems

Scheduled Pinned Locked Moved Solved
Beta Firmware
4
21
802
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    davidjryan
    last edited by 1 Apr 2025, 16:03

    My setup:
    1 6HC - @ 3.6.0-rc.2 (was 3.5.4)
    3 3HC - all @ 3.6.0-rc.2 (was 3.5.4)
    System has 13 stepper axes across the 4 boards (X, Y, Z, A, B, C, D, W, a, b, d, e, f)
    System is set to CNC mode M453. This is a non-printer application
    RPi 4, 4GB in SBC mode

    I'm still having trouble getting multiple motion system to work again. Everything is fine in 3.5.4. Ever since 3.6.x, it has stopped working.

    It seems the Duet will not release multiple motion axes after moves are complete. The DWC always reports out:
    Error: in file macro line 18: G1: Drive A is already used by a different motion system
    when trying to move an axis in a new motion system that it wasn't previously attached to.

    I've got a test board set up with 2 axes and I'm running a very simple motion test.

    config.g

    ; General preferences
    M453 ; set CNC mode
    M550 P"A2000-xx" ; set name of controller
    G90 ; set absolute coordinates
    G4 P1000 ; 1s delay for CAN comms
    ; Drives
    ; Motors are wired to Duet A-A, B-B - motor directions are flipped here
    M569 P0.0 S0 ; physical drive 0.0 goes forward
    M569 P0.2 S0 ; physical drive 0.1 goes forward
    ; Set motion system queue parameters
    M595 P100 R50 Q0 ; set motion system queue 0 to 100 steps
    M595 P100 R50 Q1 ; set motion system queue 1 to 100 steps
    ; Set drive mapping
    M584 X0.0 R0 ; set linear drive mapping for gantry
    M584 A0.2 R0 ; set linear drive mapping for gantry
    ; Set microstepping interpolation
    M350 X16 A16 I1 ; configure microstepping with interpolation for linear motors
    ; Set axes scale values
    M92 X250 A250 ; set steps per mm
    ; Set max speed change values
    M566 X400.00 A400.00 ; set maximum instantaneous speed changes (mm/min)
    ; Set max speeds
    M203 X10000.00 A10000.00 ; set maximum speeds (mm/min)
    ; Set accelerations
    M201 X3000.00 A3000.00 ; set accelerations (mm/s^2)
    ; Set motor currents and idle factor
    M906 X2000 A2000 I5 ; set motor currents (mA) and motor idle factor in per cent
    ; Axis Limits - minimum
    M208 X-200 A-200 S1 ; set linear axis minimum
    ; Axis Limits - maximum
    M208 X1000 A1000 S0 ; set linear axis maximum

    Test program:

    M400
    M598
    M596 P1
    G90 G1 A100 F2000
    M596 P0
    G90 G1 X200 F3000
    M400
    M598
    M596 P1
    G90 G1 A0 F2000
    M596 P0
    G90 G1 X0 F3000
    M400
    M598
    M596 P0
    G90 G1 X100 A100 F2000

    When I run the program, X goes to 100mm and A goes to 200mm, both starting pretty much at the same time but stopping at different times because of the feed rates.

    X and A then return to 0mm, again, starting pretty much simultaneously, but stopping at different times because of the feed rates. All expected behavior.

    When the system tries to add axis A back to motion system 0 on line 20, I get:

    417757fb-02b2-4bac-a98d-4a61fc82c544-image.png

    and the program stops so axis X nor axis A move to 100mm.

    I didn't see any change in the documentation for coding multiple motion systems, so let me know if I am using the M595, M596, and M598 incorrectly.

    I am able to run any desired test pretty quickly on my test board so let me know if there is anything else I can do to help debug the issue.

    undefined 1 Reply Last reply 1 Apr 2025, 16:11 Reply Quote 0
    • undefined
      dc42 administrators @davidjryan
      last edited by 1 Apr 2025, 16:11

      @davidjryan does it help if you add another M400 command at line 13, to release the A axis while you still have motion system 1 selected?

      Duet WiFi hardware designer and firmware engineer
      Please do not ask me for Duet support via PM or email, use the forum
      http://www.escher3d.com, https://miscsolutions.wordpress.com

      undefined 1 Reply Last reply 1 Apr 2025, 17:10 Reply Quote 0
      • undefined
        davidjryan @dc42
        last edited by 1 Apr 2025, 17:10

        @dc42 now that worked but it also caused axis X to wait until A finished it's move to 0mm before axis X started it's move to 0mm.

        Macro:

        M400
        M598
        M596 P1
        G90 G1 A100 F2000
        M596 P0
        G90 G1 X200 F3000
        M400
        M598
        M596 P1
        G90 G1 A0 F2000
        M400
        M596 P0
        G90 G1 X0 F3000
        M400
        M598
        M596 P0
        G90 G1 X100 A100 F2000

        But........

        Following your logic... if I do this, it works as desired:

        M598
        M596 P0
        G90 G1 X0 A0 F2000
        M400
        M598
        M596 P1
        G90 G1 A100 F2000
        M596 P0
        G90 G1 X200 F3000
        M400
        M596 P1
        G90 G1 A0 F2000
        M596 P0
        G90 G1 X0 F3000
        M596 P1
        M400
        M598
        M596 P0
        G90 G1 X100 A100 F2000
        G90 G1 X0 A0 F4000
        M400
        M598

        So I switch back to P1 after starting P0 on it's move to 0mm and issue M400. Once all axes are stopped, issue M598, then go back to P0 and add axis A back in. In all of the instances where I use multiple motion systems, I know if P0 will finish before P1 or vice-versa, so I can add this workaround to my macros.

        I'll upgrade one of my runtime systems to 3.6.0-RC2 in the next day or so to see if the code change will solve the issue.

        Will we get back to where M400 waits for both motion systems to stop, and then M598 will release the axes?

        undefined undefined 2 Replies Last reply 2 Apr 2025, 10:02 Reply Quote 0
        • undefined
          dc42 administrators @davidjryan
          last edited by 2 Apr 2025, 10:02

          @davidjryan it appears to me that it might be useful to have a variant of M400 that only waits for the current motion system to stop (and releases axes).

          Duet WiFi hardware designer and firmware engineer
          Please do not ask me for Duet support via PM or email, use the forum
          http://www.escher3d.com, https://miscsolutions.wordpress.com

          undefined 1 Reply Last reply 2 Apr 2025, 13:12 Reply Quote 0
          • undefined
            davidjryan @dc42
            last edited by 2 Apr 2025, 13:12

            @dc42 But as is stands, M400 waits for both motions systems to stop motion and also prevents one from loading up the second motion system with moves to be executed independent of the first motion system. Could M598 be a "wait for all motion systems to stop and then release axes"? Per the description in the documentation, that's what it should do, but it doesn't unless you wrap some M400's around it.

            As you suggest, if M400 was a wait just for that motion system and the processor kept reading code to allow moves in the other motions system, that could work. We would just need a list of G/M codes that stop the processor from further reading code to be processed by the second motion system. I.e., a G4 Px does the same thing as M400 if it's in M598 P0 or P1; further processing stops until the wait is over, then it continues.

            I hope to get to my testing today.

            undefined 1 Reply Last reply 2 Apr 2025, 16:21 Reply Quote 0
            • undefined
              davidjryan @davidjryan
              last edited by 2 Apr 2025, 16:21

              @dc42 I can confirm 3.6.0-rc2 multiple motion system works with the code adjustments.

              1 Reply Last reply Reply Quote 0
              • undefined
                dwuk3d
                last edited by dwuk3d 4 Mar 2025, 07:01 3 Apr 2025, 06:57

                Not sure if I have quite understood what you are trying to do with the M400's, but in my multiple motion system macros (which I am still learning) I have tended to do the following.

                1. At the start of the print avoid using multiple motion systems for things like homing. - I run the below ClearAllocs.g macro
                2. Before starting the print release all of the axis from any motion systems they are allocated to by doing the ClearAllocs.g macro
                ;ClearAllocs.g
                ;echo "ClearAllocs.g"
                M400
                M596 P0
                T-1
                M400
                M596 P1
                T-1
                M400
                M596 P0
                1. At the start of the print I then do a
                M606 S1 ; Fork Input File reader - for parallel printing
                1. I then use M596 P0, T1, G1 U V..., M596 P1, T0, G1 X Y..., M598. - i.e. No M400's

                2. Then at the end before shutting everything off I do my ClearAllocs.g macro again.

                This all worked with 3.5.4, but stopped working for 3.6.0 until the recent fix which seems to now be releasing the motion systems.

                PS/ I am working on a new version of M596 that can be used in all of my Macro's - which optionally ignores the motion system switches when not needed - something like this.

                ;M596.1,g
                ;M596.1 P-1 ; Ignore M596.1 commands until P-2
                if exists(global.M596_stat) == false
                global M596_stat = -2
                if exists(param.P)
                if param.P < 0
                set global.M596_stat = param.P
                else
                if global.M596_stat == -2
                M596 P{param.P}
                1 Reply Last reply Reply Quote 0
                • undefined
                  droftarts administrators @davidjryan
                  last edited by 3 Apr 2025, 14:14

                  @davidjryan If your 2nd motion system commands start getting longer, you may need to include M606 S1 to enable the job/macro file to be read by the motion systems separately. Without this, the two motion systems share the primary queue, so one motion system may be starved of commands until the other motion system has processed commands. From the 3.5.1 update notes https://github.com/Duet3D/RepRapFirmware/wiki/Changelog-RRF-3.x#reprapfirmware-351-stable-changes-since-346 :

                  [Duet 3] When processing job files, commands for both motion systems are now processed by the primary file stream by default. The secondary file stream is only activated if the M606 command is used, which can be done in the job file or in the start.g.file. When the job completes the secondary file stream is closed and commands in the stop.g file for both motion systems are executed by the primary stream.
                  [Duet 3] New M606 command supported to fork the input stream when running a job from SD card. This command must be used in the job file if you want the second input stream to execute commands for the second movement system; otherwise commands for both movement system are executed by the primary file stream.

                  Ian

                  Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

                  undefined 1 Reply Last reply 4 Apr 2025, 12:42 Reply Quote 0
                  • undefined
                    davidjryan @droftarts
                    last edited by 4 Apr 2025, 12:42

                    @droftarts @dwuk3d

                    Well, holy fork!

                    I totally missed the addition of the M606 command in the firmware changelogs. I'll give the above suggestions a shot.

                    As usual, self-inflicted wounds do the most damage...

                    undefined 1 Reply Last reply 4 Apr 2025, 12:58 Reply Quote 0
                    • undefined
                      droftarts administrators @davidjryan
                      last edited by 4 Apr 2025, 12:58

                      @davidjryan I think M606 is only needed if there are more Gcode commands for one motion system than can fit in the Gcode queue, as the other motion system may run out of commands and pause. So it really depends on what you're doing. Though I'm not sure if there are any downsides to running with the file input split, perhaps only on memory.

                      Ian

                      Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

                      undefined undefined 2 Replies Last reply 4 Apr 2025, 13:47 Reply Quote 0
                      • undefined
                        davidjryan @droftarts
                        last edited by 4 Apr 2025, 13:47

                        @droftarts

                        Here is my test code:
                        testma.g

                        M606 S1
                        M596 P0
                        M400
                        M596 P1
                        M400
                        M596 P0
                        G90 G1 X0 A0 F2000
                        M400
                        M596 P1
                        M400
                        G90 G1 A100 F2000
                        G90 G1 A0 F2000
                        G90 G1 A100 F2000
                        M596 P0
                        G90 G1 X200 F3000
                        G90 G1 X0 F3000
                        G90 G1 X200 F3000
                        M596 P1
                        G90 G1 A500 F5000
                        G90 G1 A100 F3000
                        M596 P0
                        G90 G1 X500 F5000
                        G90 G1 X100 F3000
                        M400
                        M596 P1
                        M400
                        M598
                        M596 P0
                        G90 G1 X0 A0 F4000
                        M400

                        Everything works as expected but I get:

                        5988c2b3-fb57-4355-884f-2dad616cbf70-image.png

                        as soon as I run the macro. The axes perform the motions in the macro but I get the M606 No file is selected error right away and then the green "complete" or "file processed" message.

                        My start.g and stop.g files exist but are both empty. I thought it was trying to call one of those so I created them but left them blank.

                        I've read this a couple of times now:
                        https://docs.duet3d.com/User_manual/RepRapFirmware/Multiple_motion_systems

                        I still can't figure out what M606 error is all about.

                        System is 6HC in SBC mode, CNC mode, and I am sending M98 P"testma.g" from the DWC

                        undefined undefined 2 Replies Last reply 4 Apr 2025, 14:04 Reply Quote 0
                        • undefined
                          dwuk3d @droftarts
                          last edited by 4 Apr 2025, 13:56

                          @droftarts said in [3.6.0-rc.2] M596 Multiple Motion Systems:

                          @davidjryan I think M606 is only needed if there are more Gcode commands for one motion system than can fit in the Gcode queue, as the other motion system may run out of commands and pause. So it really depends on what you're doing. Though I'm not sure if there are any downsides to running with the file input split, perhaps only on memory.

                          Ian

                          Ian - I only ever got up to 5 commands to run in parallel, irrespective of queue size before I started using M606.

                          More notes here if anyone is interested
                          https://forum.duet3d.com/post/352058

                          1 Reply Last reply Reply Quote 0
                          • undefined
                            dwuk3d @davidjryan
                            last edited by dwuk3d 4 Apr 2025, 14:07 4 Apr 2025, 14:04

                            @davidjryan Worth trying invoking your Macro with M606 in a Job if you are not already doing that - as I think that might be relevant.

                            You might actually need the M606 to be in the Job file and not in a macro - that's the way I have always used it.

                            Plus note that there are some complications with global variables and macro's mentioned in the @dc42 post that resulted in M606 being introduced - mainly as an option to switch off file forking by default I think.

                            Also - My M606 is not right at the top of the file - but only where I need to start going parallel, plus I don't have any M400's - just M598's in the parallel section after the end of the 2nd presented parallel stream.

                            I also have a Tool Selection after every M596 too - but not sure if that relevant in your case if you are not extruding.

                            undefined 1 Reply Last reply 4 Apr 2025, 14:32 Reply Quote 0
                            • undefined
                              davidjryan @dwuk3d
                              last edited by 4 Apr 2025, 14:32

                              @dwuk3d

                              My system is not a printer, so I don't run job files. I have 50+ macro files that perform each part of my process that I call as needed when needed via a custom python GUI running on the Pi. The custom GUI continuously reads the object model and based on the current state of the sensors connected to the Duet 6HC, I execute the required macros to perform an assembly process.

                              My motion queues are set to 100 steps each. So, I believe with the M606 S1, the queues are "filling", switching between each other, and "filling" with more commands. I do not see any motion stutter or stopping/waiting of one axis over the other. Granted, I only have 3 commands per motion system, then 2 per while switching between them. I'll try to tax them a bit more with more motion commands to see if/when the queues are affected by quantity of commands.

                              When I run the above macro, line 15 (G90 G1 A100 F2000) starts a second or two before line 20 (G90 G1 X200 F3000) starts. So the two motion systems don't start simultaneously but it's close enough for what I am trying to do (reduce cycle time by running independent processes simultaneously).

                              Now, if I do this (at line 15 start P1 with 1 move, switch to P0 and start it with some moves, then go back to P1 and add the removed moves (old lines 16 and 17) to it's queue (lines 23 and 24)):

                              M606 S1
                              M596 P0
                              M400
                              M596 P1
                              M400
                              M596 P0
                              G90 G1 X0 A0 F2000
                              M400
                              M596 P1
                              M400
                              G90 G1 A100 F2000
                              M596 P0
                              G90 G1 X200 F3000
                              G90 G1 X0 F3000
                              G90 G1 X200 F3000
                              M596 P1
                              G90 G1 A0 F2000
                              G90 G1 A100 F2000
                              G90 G1 A500 F5000
                              G90 G1 A100 F3000
                              M596 P0
                              G90 G1 X500 F5000
                              G90 G1 X100 F3000
                              M400
                              M596 P1
                              M400
                              M596 P0
                              G90 G1 X0 A0 F4000
                              M400

                              the 2 axes start pretty much simultaneously. So, it's safe to say there will be a lag before the 2nd queue starts when filling up the 1st queue with it's initial moves/commands, which is totally understandable.

                              I just need clarification on what the M606 error is all about. What "file" is it referring to?

                              undefined 1 Reply Last reply 4 Apr 2025, 15:00 Reply Quote 0
                              • undefined
                                davidjryan @davidjryan
                                last edited by 4 Apr 2025, 15:00

                                @dwuk3d @droftarts

                                Modified test macro:

                                ;M606 S1
                                M596 P0
                                M400
                                M596 P1
                                M400
                                M596 P0
                                G90 G1 X0 A0 F2000
                                M400
                                M596 P1
                                M400
                                G90 G1 A100 F2000
                                G90 G1 A0 F2000
                                M596 P0
                                G90 G1 X200 F3000
                                G90 G1 X0 F3000
                                M596 P1
                                G90 G1 A100 F2000
                                G90 G1 A500 F5000
                                G90 G1 A100 F2000
                                M596 P0
                                G90 G1 X200 F3000
                                G90 G1 X0 F3000
                                G4 P1000
                                echo "X stopped"
                                G90 G1 X200 F3000
                                G90 G1 X500 F5000
                                G90 G1 X100 F3000
                                G90 G1 X500 F5000
                                M596 P1
                                G4 P1000
                                echo "A stopped"
                                G90 G1 A500 F5000
                                G90 G1 A100 F3000
                                G90 G1 A500 F5000
                                G90 G1 A100 F2000
                                G90 G1 A500 F5000
                                G90 G1 A100 F3000
                                M596 P0
                                G90 G1 X100 F5000
                                G90 G1 X500 F5000
                                G90 G1 X100 F5000
                                M400
                                M596 P1
                                M400
                                M596 P0
                                G90 G1 X0 A0 F4000
                                M400

                                So, I am playing with the number of move commands and adding in G4 P1000 with echo between the motion systems. I wanted to see if a G4 in one motion system would affect the other motion system and it does not. Again, as expected per the multiple motion system documentation. I am trusting but verifying... 😉

                                Everything works as desired as long as I don't let either motion system "run dry" of commands. If one motion system runs out of commands, the axis sits and waits until the next M596 Px and gets more to do... totally understandable and expected per the documents.

                                Also of note, running with or without M606 S1, the functionality seems to be the the same, just no M606 error without the M606 S1.

                                1 Reply Last reply Reply Quote 0
                                • undefined
                                  droftarts administrators @davidjryan
                                  last edited by 4 Apr 2025, 15:31

                                  @davidjryan said in [3.6.0-rc.2] M596 Multiple Motion Systems:

                                  Everything works as expected but I get:
                                  5988c2b3-fb57-4355-884f-2dad616cbf70-image.png

                                  ...

                                  I still can't figure out what M606 error is all about.

                                  One for @dc42!

                                  Ian

                                  Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

                                  undefined 1 Reply Last reply 4 Apr 2025, 15:53 Reply Quote 0
                                  • undefined
                                    dwuk3d @droftarts
                                    last edited by 4 Apr 2025, 15:53

                                    @droftarts

                                    I get
                                    M98 P"0:/macros/M606 Test.g"
                                    Warning: this command is valid only when running a job from a stored file

                                    When I try including an M606 in a macro - which I run from the console, or if I type it directly in.

                                    I think it only works in Jobs.

                                    The only way I found of having more than 5 commands queued was to use M606 - but if @davidjryan is managing to get more commands than that queued then great.

                                    I haven't tried anything like initiating commands from python or having a SBC connected - so I guess there might be quite different behavour running that way.

                                    Looking back on my notes - it also looks like M598's only work for jobs too - so I can understand now why @davidjryan is needing to do M400's

                                    I might end up needing to do something like he is doing at some point kicking things off from something like deamon.g - because when one motion system finishes its current batch of work quite a long while before the other one I will need the print head to park and cool down. But then just before the other one has finished I need to find a way to kick off the idle motion system again to reheat and prime - ready for it to start work on its next batch (layer) once the other one has finished.

                                    undefined 1 Reply Last reply 8 Apr 2025, 14:45 Reply Quote 0
                                    • undefined
                                      davidjryan @dwuk3d
                                      last edited by 8 Apr 2025, 14:45

                                      I've gone a few days now and the multiple motion systems is working well. I'll call this one closed.

                                      Thanks for the assist!

                                      undefined undefined 2 Replies Last reply 8 Apr 2025, 15:05 Reply Quote 1
                                      • undefined davidjryan has marked this topic as solved 8 Apr 2025, 14:45
                                      • undefined
                                        dc42 administrators @davidjryan
                                        last edited by 8 Apr 2025, 15:05

                                        @davidjryan thanks for confirming!

                                        Duet WiFi hardware designer and firmware engineer
                                        Please do not ask me for Duet support via PM or email, use the forum
                                        http://www.escher3d.com, https://miscsolutions.wordpress.com

                                        1 Reply Last reply Reply Quote 0
                                        • undefined
                                          droftarts administrators @davidjryan
                                          last edited by droftarts 4 Aug 2025, 15:13 8 Apr 2025, 15:12

                                          @davidjryan @dwuk3d Re M606 in macros, @dc42 replied this when I asked him:

                                          M606 only works in job files. The full functionality of M598 only makes sense in job files (or in macro files called from job files) after M606 has been used, but using M598 should be harmless in other situations.

                                          Ian

                                          Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

                                          undefined 1 Reply Last reply 8 Apr 2025, 15:39 Reply Quote 0
                                          3 out of 21
                                          • First post
                                            3/21
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA