Duet3 - Python - Preliminary class for interfacing

  • I've created a preliminary module/class to allow Python programs on the Pi attached to a Duet3 to interact with the printer. It does so via the "Duet Control Server" socket (not websocket) connection in the "Duet Software Framework".

    It is available on Github https://github.com/DanalEstes/PythonDSF

    This is an early implementation and it may radically change in the near future. Nonetheless, if you are thinking about Python scripting, give it a try.

    There is also an example script. This script is intended to do tool-to-tool measurement to derive offsets on a "Tool Changing" 3D printer of the E3D tool-changer type. Specifically, it is for my Jubilee. There are some instructions in the README about how all this works. This is a whole topic in and of itself.

    A very minimal example of use might look something like this:

    #!/usr/bin/env python3
    import pythondcs
    dcs = pythondcs.PythonDCS()
    dcs.gCode('G0 Z10       F1000')          # Lower bed to avoid collision with square hole plate.
    dcs.gCode('G0      Y225 F10000')        # Move nozzle to avoid other tools
    print("X position ="+r[0])

    There are several other modules, including a "r=getPos()" that returns a Python list containing the current position of the printer, in mm. See the example script.

  • Nice! Is it only working for Duet3, or also for Duet2 running RRF3?

  • @fma said in Duet3 - Python - Preliminary class for interfacing:

    Is it only working for Duet3

    for now only Duet 3 support Raspberry Pi and this class interfaces to a unix socket on the Pi; so this only works for Duet 3 + raspberry pi (i.e. not Duet 3 in stand alone mode)

  • Ok, I though you where connected on a Duet socket...

  • @fma said in Duet3 - Python - Preliminary class for interfacing:

    Ok, I though you where connected on a Duet socket...

    Correct, a socket, NOT a websocket.

    The stack for a Duet 3 with a Pi is roughly:

    Browser on PC or Mobile
    <Wifi or Ethernet TCP/IP network - Websocket protocol>
    Duet Software Framework Web Server on Pi
    <Linux internal - Socket protocol>*
    Duet Software Framework Control Server on Pi
    <Ribbon Cable - SPI Protocol>
    Firmware on Duet 3 6HC board

    The * indicates where this python connects; Therefore it must run on the Pi where that socket resides.

    If enough people are interested, I can look into a Websocket version. This could theoretically run on any machine that has TCP/IP network connectivity to the Pi or a stand-alone D3.

Log in to reply