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

    Python control of Duet 2 via network?

    Scheduled Pinned Locked Moved
    General Discussion
    3
    8
    647
    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.
    • DocTruckerundefined
      DocTrucker
      last edited by DocTrucker

      Hi All,

      Looking to do some vision work on a Single Board Computer which will use OpenCV to locate a target start point and trigger a repeat print.

      This will be a repeated loop; scanning an image for a feature, moving the head to centralise the feature.

      What is the current best supported way to achieve the single board computer to duet communications? Just fire network commands as a prototype? The system is using an expansion board.

      Running 3 P3Steel with Duet 2. Duet 3 on the shelf looking for a suitable machine. One first generation Duet in a Logo/Turtle style robot!

      1 Reply Last reply Reply Quote 0
      • DocTruckerundefined
        DocTrucker
        last edited by

        After a couple of hours hunting I can see the direct method of connecting a Single Board Computer to the Duet 2 is not feasible. It involves removing the ethernet or wifi adaptor and making connections there.

        Looking for guidance on controlling a Duet 2 from a Python Script rather than through the DWC, or more accurately alongside a normal DWC connection. It's likely that the build process would be triggered by a Macros.

        Running 3 P3Steel with Duet 2. Duet 3 on the shelf looking for a suitable machine. One first generation Duet in a Logo/Turtle style robot!

        alankilianundefined 1 Reply Last reply Reply Quote 0
        • alankilianundefined
          alankilian @DocTrucker
          last edited by

          @doctrucker You can turn on the telnet server on the Duet board and make a socket connection and send GCODE commands.

          I don't know what you are trying to do, so I don't know if this helps or not.

          This is someone who wanted to read from the Duet using Python. You can both send and receive using this socket from Python.

          https://forum.duet3d.com/topic/27396/basic-telnet-connection-help/5?_=1645538054606

          SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

          DocTruckerundefined 1 Reply Last reply Reply Quote 2
          • DocTruckerundefined
            DocTrucker @alankilian
            last edited by

            @alankilian That'll do nicely thanks.

            I'll setup a macro that fires a message to the SBC then that will run a loop of imaging, calculating a required offset, and returning a G1 command until the required offset is within a set parameter. At that point the SBC will trigger a build gcode file and the process repeats a few times to copy a build at a number of semi-regular (hence need for camera) locations.

            Running 3 P3Steel with Duet 2. Duet 3 on the shelf looking for a suitable machine. One first generation Duet in a Logo/Turtle style robot!

            theolodianundefined 1 Reply Last reply Reply Quote 0
            • theolodianundefined
              theolodian @DocTrucker
              last edited by

              @doctrucker Most industrial CV for object location changes the coordinate system. In theory you can do this with the Duet, although I haven't looked into rotating the coordinate system yet. In this case the gcode from your SBC would change the translation and rotation values of the part coordinate system, and then the gcode file would stay the same.

              DocTruckerundefined 1 Reply Last reply Reply Quote 0
              • DocTruckerundefined
                DocTrucker @theolodian
                last edited by

                @theolodian I've tested a macro that uses the gcode variables and coding to read in a set location and adjust the G10 tool offsets to make the current location 0,0. This did a regular grid of prints, the computer vision will be used to fettle the expected position to account for work piece variance. There may be a more elegant way of doing it with co-ordinate systems too, but I have something functional to work from initially.

                Running 3 P3Steel with Duet 2. Duet 3 on the shelf looking for a suitable machine. One first generation Duet in a Logo/Turtle style robot!

                theolodianundefined 1 Reply Last reply Reply Quote 0
                • theolodianundefined
                  theolodian @DocTrucker
                  last edited by

                  @doctrucker OK, I may get corrected but: yes what you are doing will work if the parts are all in the same orientation. If you also need to rotate the print then you need to use coordinate system offsets instead, but otherwise it works in the same way that you are using tool offsets.

                  DocTruckerundefined 1 Reply Last reply Reply Quote 1
                  • DocTruckerundefined
                    DocTrucker @theolodian
                    last edited by DocTrucker

                    @theolodian good point, I'll read up on the coordinate system method another time. The printer is running in FFF rather than CNC mode which may complicate things a little, but can't see why you'd limit that feature to CNC - even if the request came from there.

                    As it happens I'm just aiming for the middle of a circular-ish feature, so rotation not an issue this time thankfully.

                    Here was what I had in the macro:

                    ; https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Variable_naming
                    ; https://duet3d.dozuki.com/Wiki/Object_Model_of_RepRapFirmware#Section_Uses
                    ; https://forum.duet3d.com/topic/26368/object-model-report-contents-of-object
                    ; https://forum.duet3d.com/topic/26370/sanity-check-tool-offsets-g10-p0-x
                    
                    var num_x_pattern = 3
                    var num_y_pattern = 2
                    var x_pattern_space = 50.0
                    var y_pattern_space = 25.0
                    
                    var tool_num = 0
                    var int_x = move.axes[0].machinePosition
                    var int_y = move.axes[1].machinePosition
                    var initial_x_offset = tools[var.tool_num].offsets[0]
                    var initial_y_offset = tools[var.tool_num].offsets[0]
                    
                    M98 P"0:/macros/intro.g"
                    
                    while true
                    	if iterations = (var.num_x_pattern * var.num_y_pattern)
                    		break
                    	else
                    		var x_i = mod(iterations, var.num_x_pattern)
                    		var y_i = ((iterations-var.x_i)/var.num_x_pattern)
                    		var x_pos = var.int_x + (var.x_i * var.x_pattern_space)
                    		var y_pos = var.int_y + (var.y_i * var.y_pattern_space)
                    		G10 P0 X{(-1 * var.x_pos)} Y{(-1 * var.y_pos)}
                    		M98 P"0:/gcodes/sample_build.g"
                    		continue 
                    G10 P0 X{(-1 * var.initial_x_offset)} Y{(-1 * var.initial_y_offset)}
                    
                    M98 P"0:/macros/extro.g"
                    

                    Running 3 P3Steel with Duet 2. Duet 3 on the shelf looking for a suitable machine. One first generation Duet in a Logo/Turtle style robot!

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    Unless otherwise noted, all forum content is licensed under CC-BY-SA