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

New codes for use in RRC3.3 M3,M4,M5

Scheduled Pinned Locked Moved
CNC
4
12
947
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
    Handymanpa54
    last edited by Handymanpa54 31 Jul 2021, 22:24

    I found some M codes I'd like to use but how? What output will they control? I have a Duet 2 Ethernet. Maybe these codes are only for Duet 3 Mainboard 6HC??
    I have my Duet 2 Ethernet controlling the axis on my CNC and I'm working on getting the Spindle to go. I bought one of those PWM to variable voltage out boards. I was reading the link on the forum about that. I was looking into Gcodes and Mcodes on how to run it.
    What about M3, M4, and M5??
    I found M950. Can this be assigned to any output? (Like E0 or E1)
    My 2.2KW spindle has a max RPM of 24,000. At the moment I have a PWM to 0 to 10Volt converter board hooked to the AIN.
    I'd like to try sending a trial code to see it turn on just to get a response. Then I could put that into the config.g file if it works.

    Mark

    code_text
    M950 R0 C"!exp.heater3" L12000 ; Spindle 0 uses exp.heater3 as RPM pin and has a max RPM of 12000

    Mark

    1 Reply Last reply Reply Quote 0
    • undefined
      cjm
      last edited by cjm 8 Aug 2021, 20:24 1 Aug 2021, 23:09

      As you’ve already figured out, M950 allows one of the PWM capable pins on the Duet2 to be designated as the input to a PWM to analogue converter board for spindle RPM control. However, not all Duet2 pins are PWM capable so it’s best to refer to the Duet2 wiring diagram to check. IIRC various of the fan pins as well as the heated bed and extruder heater outputs are PWM capable.

      With RRF3.3 and newer firmware, once the spindle control pin has been defined using M950, you then assign it to a tool using M563 and enable CNC mode, like this, for example:

      M950 R0 C"exp.13" Q2000 L0:20000 ; Create spindle index 0, PWM frequency 2KHz,
      ; Lmin:max rpm ranges from 0rpm at PWM=0% to 20000rpm at 100% PWM
      ; spindle speed PWM pin : exp.13
      M563 P0 R0 S"Spindle" ; Create Tool 0 with Spindle 0 and call it Spindle
      T0 ; Select Tool 0 (or make sure generated by CAM)
      ; CNC Mode
      M453

      After this a M3 S8000 command will set the spindle RPM to 8000 rpm (for example) and M3 S0 stops the spindle. It’s possible that M5 may also stop the spindle with this setup but I haven’t checked this, so someone else would need to comment.

      However, if your spindle VFD has a RUN input, then M950 can be used to define a Duet pin to control the RUN state and in this case the M5 command can definitely be used to stop the spindle:

      M950 R0 C"exp.13+exp.8" Q2000 L0:20000 ; Create spindle index 0, PWM frequency 2KHz,
      ; Lmin:max rpm ranges from 0rpm at PWM=0% to 20000rpm at 100% PWM
      ; spindle speed PWM pin : exp.13
      ; spindle run pin : exp.8

      If your VFD has a DIR input then M950 can also be used to configure a pin for this too:

      M950 R0 C"exp.13+exp.8+exp.14" Q2000 L0:20000 ; Create spindle index 0, PWM frequency 2KHz,
      ; Lmin:max rpm ranges from 0rpm at PWM=0% to 20000rpm at 100% PWM
      ; spindle speed PWM pin : exp.13
      ; spindle run pin : exp.8
      ; spindle direction pin : exp.14

      With the DIR pin connected, M3 S8000 runs the spindle in a clockwise direction at 8000rpm and M4 S8000 runs the spindle at 8000rpm in a counterclockwise direction.

      A couple of other points to note:

      A) VFDs generally require higher control voltages than the Duet outputs provide, so some extra circuitry (e.g relays or opto-isolators) is needed to match the Duet control outputs to the VFD inputs

      B) Some VFDs have FWD and REV inputs instead of RUN and DIR inputs. In my case (an “AskPower” unit from eBay) I found that wiring RUN -> FWD and DIR -> REV worked fine. However, this may not be a universal solution.

      Edit 7/8/2021 - Closing quotation marks corrected - thanks to @Wurke for spotting this.

      undefined 2 Replies Last reply 2 Aug 2021, 00:09 Reply Quote 2
      • undefined
        Handymanpa54 @cjm
        last edited by 2 Aug 2021, 00:09

        @cjm Hello CJM,
        This is exactly what I needed. When you dive into unfamiliar territory it's good to have and idea whats going on.
        Thanks so much!

        undefined 1 Reply Last reply 2 Aug 2021, 22:11 Reply Quote 0
        • undefined
          cjm @Handymanpa54
          last edited by 2 Aug 2021, 22:11

          @handymanpa54 Happy to help. Let us all know how you get on…

          undefined 1 Reply Last reply 6 Aug 2021, 12:36 Reply Quote 0
          • undefined
            Wurke
            last edited by 6 Aug 2021, 11:47

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • undefined
              Wurke @cjm
              last edited by 6 Aug 2021, 12:36

              @cjm This is really useful. I've done this but the spindle doesn't show in DWC under the spindles pane? Should it or is there more that needs configuring?

              I'm starting a fresh with a Duet WiFi so I've updated it to RRF 3.3, updated the DWC to the CNC version and my config is almost completely blank except the above code and the network configs.

              undefined 1 Reply Last reply 6 Aug 2021, 19:54 Reply Quote 0
              • undefined
                cjm @Wurke
                last edited by 6 Aug 2021, 19:54

                @bonjipoo As mentioned eslewhere, if you're using the CNC version of DWC then I believe this is a known issue that @sindarius plans to fix.

                https://forum.duet3d.com/topic/20416/preview-version-of-cnc-optimized-dwc/143?_=1628279224253

                undefined 1 Reply Last reply 7 Aug 2021, 01:14 Reply Quote 1
                • undefined
                  Sindarius @cjm
                  last edited by 7 Aug 2021, 01:14

                  @cjm said in New codes for use in RRC3.3 M3,M4,M5:

                  @bonjipoo As mentioned eslewhere, if you're using the CNC version of DWC then I believe this is a known issue that @sindarius plans to fix.

                  https://forum.duet3d.com/topic/20416/preview-version-of-cnc-optimized-dwc/143?_=1628279224253

                  As @cjm mentioned it is an issue that I need to address. I believe there were some OM changes that happened which caused the panel to not show the spindles anymore. I am working on a fix for this issue.

                  1 Reply Last reply Reply Quote 2
                  • undefined
                    Handymanpa54 @cjm
                    last edited by 9 Aug 2021, 23:13

                    @cjm said in New codes for use in RRC3.3 M3,M4,M5:

                    C"exp.13"

                    Hello CJM,

                    I have things hooked up properly and I think I have code in Config.g proper, but no signal out to the PWM converter board. I checked with an O-scope. I tried sending M3 P0 S2000. No response.

                    code_text
                    ; Configuration file for Duet WiFi (firmware version 3)
                    ; executed by the firmware on start-up
                    ;
                    ; generated by RepRapFirmware Configuration Tool v3.2.3 on Fri Jul 30 2021 11:14:49 GMT-0400 (Eastern Daylight Time)
                    ; General preferences
                    G90 ; send absolute coordinates...
                    M83 ; ...but relative extruder moves
                    M550 P"CNC 6040" ; set printer name
                    ; Network
                    M552 P192.168.1.14 S1 ; enable network and set IP address
                    M553 P255.255.255.0 ; set netmask
                    M554 P192.168.1.2 ; set gateway
                    M586 P0 S1 ; enable HTTP
                    M586 P1 S0 ; disable FTP
                    M586 P2 S0 ; disable Telnet
                    ; Drives
                    M569 P0 S1 ; physical drive 0 goes forwards
                    M569 P1 S1 ; physical drive 1 goes forwards
                    M569 P2 S1 ; physical drive 2 goes forwards
                    M569 P3 S1 ; physical drive 3 goes forwards
                    M584 X0 Y1 Z2 E3 ; set drive mapping
                    M350 X16 Y16 Z16 E16 I1 ; configure microstepping with interpolation
                    M92 X640.00 Y640.00 Z640.00 E420.00 ; set steps per mm
                    M566 X400.00 Y400.00 Z80.00 E120.00 ; set maximum instantaneous speed changes (mm/min)
                    M203 X2500.00 Y2500.00 Z240.00 E1200.00 ; set maximum speeds (mm/min)
                    M201 X300.00 Y300.00 Z20.00 E250.00 ; set accelerations (mm/s^2)
                    M906 X1300 Y1300 Z1300 E500 I30 ; set motor currents (mA) and motor idle factor in per cent
                    M84 S30 ; Set idle timeout
                    ; Axis Limits
                    M208 X0 Y0 Z0 S1 ; set axis minima
                    M208 X390 Y590 Z68 S0 ; set axis maxima
                    ; Endstops
                    M574 X1 S1 P"^xstop" ; configure active-high endstop for low end on X via pin ^xstop
                    M574 Y1 S1 P"^ystop" ; configure active-high endstop for low end on Y via pin ^ystop
                    M574 Z1 S1 P"^zstop" ; configure active-high endstop for low end on Z via pin ^zstop
                    ; Z-Probe
                    M558 P0 H5 F120 T6000 ; disable Z probe but set dive height, probe speed and travel speed
                    M557 X15:215 Y15:195 S20 ; define mesh grid
                    M950 R0 C"exp.heater4" Q2000 L0:24000 ; Create spindle index 0, PWM frequency 2KHz,
                    ; Lmin:max rpm ranges from 0rpm at PWM=0% to 24000rpm at 100% PWM
                    ; spindle speed PWM pin : exp.13
                    M563 P0 R0 S"Spindle" ; Create Tool 0 with Spindle 0 and call it Spindle
                    T0 ; Select Tool 0 (or make sure generated by CAM)
                    M453 ; CNC Mode
                    ; Heaters
                    ;M308 S0 P"bedtemp" Y"thermistor" T100000 B4138 ; configure sensor 0 as thermistor on pin bedtemp
                    ;M950 H0 C"bedheat" T0 ; create bed heater output on bedheat and map it to sensor 0
                    ;M307 H0 B1 S1.00 ; enable bang-bang mode for the bed heater and set PWM limit
                    ;M140 H0 ; map heated bed to heater 0
                    ;M143 H0 S120 ; set temperature limit for heater 0 to 120C
                    ;M308 S1 P"e0temp" Y"thermistor" T100000 B4138 ; configure sensor 1 as thermistor on pin e0temp
                    ;M950 H1 C"e0heat" T1 ; create nozzle heater output on e0heat and map it to sensor 1
                    ;M307 H1 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
                    ;M143 H1 S280 ; set temperature limit for heater 1 to 280C
                    ; Fans
                    ;M950 F0 C"fan0" Q500 ; create fan 0 on pin fan0 and set its frequency
                    ;M106 P0 S0 H-1 ; set fan 0 value. Thermostatic control is turned off
                    ;M950 F1 C"fan1" Q500 ; create fan 1 on pin fan1 and set its frequency
                    ;M106 P1 S1 H1 T45 ; set fan 1 value. Thermostatic control is turned on
                    ; Tools
                    M563 P0 S"CNC6040" D0 H1 F0 ; define tool 0
                    M453 S0 C"out1" R24000 Q100 T0
                    M563 S"XYZ-Probe" P1 ; define XYZ Touch Probe tool 1
                    G10 P0 X0 Y0 Z0 ; set tool 0 axis offsets
                    G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
                    ; Custom settings are not defined
                    ; Miscellaneous
                    M575 P1 S1 B57600 ; enable support for PanelDue
                    M501 ; load saved parameters from non-volatile memory
                    M911 S10 R11 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss
                    ; select first tool
                    code_text
                    8/9/2021, 7:11:15 PM m122
                    === Diagnostics ===
                    RepRapFirmware for Duet 2 WiFi/Ethernet version 3.3 (2021-06-15 21:44:54) running on Duet Ethernet 1.02 or later
                    Board ID: 0JD0M-9P6B2-NJ4S4-6JTD2-3S46K-KU0LM
                    Used output buffers: 1 of 24 (13 max)
                    === RTOS ===
                    Static ram: 23876
                    Dynamic ram: 70264 of which 0 recycled
                    Never used RAM 20276, free system stack 150 words
                    Tasks: NETWORK(ready,25.2%,237) HEAT(delaying,0.0%,390) Move(notifyWait,0.1%,309) MAIN(running,74.6%,449) IDLE(ready,0.2%,29), total 100.0%
                    Owned mutexes:
                    === Platform ===
                    Last reset 00:08:25 ago, cause: power up
                    Last software reset at 2021-08-09 18:46, reason: User, GCodes spinning, available RAM 20276, slot 1
                    Software reset code 0x0003 HFSR 0x00000000 CFSR 0x00000000 ICSR 0x0041f000 BFAR 0xe000ed38 SP 0x00000000 Task MAIN Freestk 0 n/a
                    Error status: 0x00
                    Aux0 errors 0,0,0
                    Step timer max interval 0
                    MCU temperature: min 28.9, current 39.7, max 40.2
                    Supply voltage: min 23.8, current 23.8, max 23.9, under voltage events: 0, over voltage events: 0, power good: yes
                    Heap OK, handles allocated/used 0/0, heap memory allocated/used/recyclable 0/0/0, gc cycles 0
                    Driver 0: position 0, standstill, SG min/max 0/1023
                    Driver 1: position 0, standstill, SG min/max 0/1023
                    Driver 2: position 0, standstill, SG min/max not available
                    Driver 3: position 0, standstill, SG min/max not available
                    Driver 4: position 0, standstill, SG min/max not available
                    Driver 5: position 0
                    Driver 6: position 0
                    Driver 7: position 0
                    Driver 8: position 0
                    Driver 9: position 0
                    Driver 10: position 0
                    Driver 11: position 0
                    Date/time: 2021-08-09 19:11:12
                    Cache data hit count 4294967295
                    Slowest loop: 9.14ms; fastest: 0.14ms
                    I2C nak errors 0, send timeouts 0, receive timeouts 0, finishTimeouts 0, resets 0
                    === Storage ===
                    Free file entries: 10
                    SD card 0 detected, interface speed: 20.0MBytes/sec
                    SD card longest read time 3.3ms, write time 0.0ms, max retries 0
                    === Move ===
                    DMs created 83, maxWait 490658ms, bed compensation in use: none, comp offset 0.000
                    === MainDDARing ===
                    Scheduled moves 5, completed moves 5, hiccups 0, stepErrors 0, LaErrors 0, Underruns [0, 0, 0], CDDA state -1
                    === AuxDDARing ===
                    Scheduled moves 0, completed moves 0, hiccups 0, stepErrors 0, LaErrors 0, Underruns [0, 0, 0], CDDA state -1
                    === Heat ===
                    Bed heaters = -1 -1 -1 -1, chamberHeaters = -1 -1 -1 -1
                    === GCodes ===
                    Segments left: 0
                    Movement lock held by null
                    HTTP is idle in state(s) 0
                    Telnet is idle in state(s) 0
                    File is idle in state(s) 0
                    USB is idle in state(s) 0
                    Aux is idle in state(s) 0
                    Trigger is idle in state(s) 0
                    Queue is idle in state(s) 0
                    LCD is idle in state(s) 0
                    Daemon is idle in state(s) 0
                    Autopause is idle in state(s) 0
                    Code queue is empty.
                    === Network ===
                    Slowest loop: 14.94ms; fastest: 0.02ms
                    Responder states: HTTP(0) HTTP(0) HTTP(0) HTTP(0) FTP(0) Telnet(0), 0 sessions
                    HTTP sessions: 1 of 8
                    Interface state active, link 100Mbps full duplex
                    undefined 1 Reply Last reply 10 Aug 2021, 07:09 Reply Quote 0
                    • undefined
                      cjm @Handymanpa54
                      last edited by cjm 8 Oct 2021, 18:33 10 Aug 2021, 07:09

                      @handymanpa54
                      I notice you have two M563 commands defining the spindle.
                      Perhaps try removing the second one, because I think this might redefine tool 0 and so disconnect it from the spindle?

                      M563 P0 S"CNC6040" D0 H1 F0 ; define tool 0

                      undefined 1 Reply Last reply 10 Aug 2021, 19:13 Reply Quote 0
                      • undefined
                        Handymanpa54 @cjm
                        last edited by 10 Aug 2021, 19:13

                        @cjm
                        I trimmed the code and have one instance of M563. Still no luck. Maybe it's easier to get an output on Fan0 output?
                        I'm wondering if I can get an output off of the fan connectors or E0 Heater connector? Using the expansion connector is not so easy.

                        My config.g

                        code_text
                        ; Configuration file for Duet WiFi (firmware version 3)
                        ; executed by the firmware on start-up
                        ;
                        ; generated by RepRapFirmware Configuration Tool v3.2.3 on Fri Jul 30 2021 11:14:49 GMT-0400 (Eastern Daylight Time)
                        ; General preferences
                        G90 ; send absolute coordinates...
                        M83 ; ...but relative extruder moves
                        M550 P"CNC 6040" ; set printer name
                        ; Network
                        M552 P192.168.1.14 S1 ; enable network and set IP address
                        M553 P255.255.255.0 ; set netmask
                        M554 P192.168.1.2 ; set gateway
                        M586 P0 S1 ; enable HTTP
                        M586 P1 S0 ; disable FTP
                        M586 P2 S0 ; disable Telnet
                        ; Drives
                        M569 P0 S1 ; physical drive 0 goes forwards
                        M569 P1 S1 ; physical drive 1 goes forwards
                        M569 P2 S1 ; physical drive 2 goes forwards
                        M569 P3 S1 ; physical drive 3 goes forwards
                        M584 X0 Y1 Z2 E3 ; set drive mapping
                        M350 X16 Y16 Z16 E16 I1 ; configure microstepping with interpolation
                        M92 X640.00 Y640.00 Z640.00 E420.00 ; set steps per mm
                        M566 X400.00 Y400.00 Z80.00 E120.00 ; set maximum instantaneous speed changes (mm/min)
                        M203 X2500.00 Y2500.00 Z240.00 E1200.00 ; set maximum speeds (mm/min)
                        M201 X300.00 Y300.00 Z20.00 E250.00 ; set accelerations (mm/s^2)
                        M906 X1300 Y1300 Z1300 E500 I30 ; set motor currents (mA) and motor idle factor in per cent
                        M84 S30 ; Set idle timeout
                        ; Axis Limits
                        M208 X0 Y0 Z0 S1 ; set axis minima
                        M208 X390 Y590 Z68 S0 ; set axis maxima
                        ; Endstops
                        M574 X1 S1 P"^xstop" ; configure active-high endstop for low end on X via pin ^xstop
                        M574 Y1 S1 P"^ystop" ; configure active-high endstop for low end on Y via pin ^ystop
                        M574 Z1 S1 P"^zstop" ; configure active-high endstop for low end on Z via pin ^zstop
                        ; Z-Probe
                        M558 P0 H5 F120 T6000 ; disable Z probe but set dive height, probe speed and travel speed
                        M557 X15:215 Y15:195 S20 ; define mesh grid
                        M950 R0 C"^fan0" Q2000 L0:24000 ; Create spindle index 0, PWM frequency 2KHz,
                        ; Lmin:max rpm ranges from 0rpm at PWM=0% to 24000rpm at 100% PWM
                        ; spindle speed PWM pin : exp.13
                        M563 P0 R0 S"Spindle" ; Create Tool 0 with Spindle 0 and call it Spindle
                        T0 ; Select Tool 0 (or make sure generated by CAM)
                        M453 ; CNC Mode
                        ; Heaters
                        ;M308 S0 P"bedtemp" Y"thermistor" T100000 B4138 ; configure sensor 0 as thermistor on pin bedtemp
                        ;M950 H0 C"bedheat" T0 ; create bed heater output on bedheat and map it to sensor 0
                        ;M307 H0 B1 S1.00 ; enable bang-bang mode for the bed heater and set PWM limit
                        ;M140 H0 ; map heated bed to heater 0
                        ;M143 H0 S120 ; set temperature limit for heater 0 to 120C
                        ;M308 S1 P"e0temp" Y"thermistor" T100000 B4138 ; configure sensor 1 as thermistor on pin e0temp
                        ;M950 H1 C"e0heat" T1 ; create nozzle heater output on e0heat and map it to sensor 1
                        ;M307 H1 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
                        ;M143 H1 S280 ; set temperature limit for heater 1 to 280C
                        ; Fans
                        ;M950 F0 C"fan0" Q500 ; create fan 0 on pin fan0 and set its frequency
                        ;M106 P0 S0 H-1 ; set fan 0 value. Thermostatic control is turned off
                        ;M950 F1 C"fan1" Q500 ; create fan 1 on pin fan1 and set its frequency
                        ;M106 P1 S1 H1 T45 ; set fan 1 value. Thermostatic control is turned on
                        ; Tools
                        ; define tool 0
                        ;M453 S0 C"out1" R24000 Q100 T0
                        M563 S"XYZ-Probe" P1 ; define XYZ Touch Probe tool 1
                        G10 P0 X0 Y0 Z0 ; set tool 0 axis offsets
                        G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
                        ; Custom settings are not defined
                        ; Miscellaneous
                        M575 P1 S1 B57600 ; enable support for PanelDue
                        M501 ; load saved parameters from non-volatile memory
                        M911 S10 R11 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss
                        ; select first tool
                        undefined 1 Reply Last reply 10 Aug 2021, 21:50 Reply Quote 0
                        • undefined
                          cjm @Handymanpa54
                          last edited by 10 Aug 2021, 21:50

                          @handymanpa54 Both fan and heater PWM outputs are easily accessible but they are also open drain outputs so a pull-up resistor is needed to enable a PWM signal to be generated.

                          If you connect a 3K9 or 4K7 resistor between the FAN0 pin and the adjacent V_FAN pin on the FAN0 header, you should see the PWM signal on the FAN0 pin with your ‘scope.

                          1 Reply Last reply Reply Quote 0
                          6 out of 12
                          • First post
                            6/12
                            Last post
                          Unless otherwise noted, all forum content is licensed under CC-BY-SA