Assigning multiple Pins for CNC M3 command use?

  • Hiya - I'm wiring up a frequency drive to the Duet 2 via a PWM to 0-10v converter for spindle control. I've successfully done this using the P2 heater terminals and the M453 command. But I also need to trigger the forward spindle enable terminal on the VFD, which I'd like to do via a spare relay module and a separate heater terminal. I don't want to bridge the terminal on the frequency drive as this keep the on-board fan constantly running and a holding torque on the spindle with an annoying high pitch noise.

    I'd like to be able to send an M3 S# command and for heater 2 to control the spindle speed and for example, heater 1 to control the spindle enable.

    I've already disabled heater 1 and 2 with M307 H# A-1 C-1 D-1, and used M453 P2 R24000 F300 T1 for the PWM control, but I'm stuck on how to assign the M3 CNC function onto another pin on the duet.

    If someone could point me in the right direction I'd appreciate that. Cheers.

  • You can assign two pins to M453 to use forward and reverse

    Pfff:rrr Logical pin numbers used to drive the spindle motor in clockwise and counterclockwise directions. Omit the ":rrr" part if the spindle turns clockwise only.

  • @bearer said in Assigning multiple Pins for CNC M3 command use?:


    But if I want to assign two pins just for forward - where one uses PWM up to 24v, and the other is simply 0-5v without PWM?

  • Do you need to explicitly disable forward and not just set speed to 0?

    If you you probably need to use M42 before/after M3 to set the forward enable pin. Pretty much the same as this post

  • @bearer said in Assigning multiple Pins for CNC M3 command use?:


    Yes I think so. The VFD works by shorting the forward terminal to ground. I want to place the wire for that to the N/O terminals of a relay module and to switch that with a signal from the Duet.

    Does that mean I have to write a post processor to put M42 into Gcode directly?

  • if you can't assign the heater 2 pin to the reverse function and then use your relay to ensure the forward enable is pulled low whenever the duet is not in reverse then i think you need to do something custom yeah

  • @bearer Hmm I think I might move back to GRBL for CNC stuff - this is starting to feel like it's more work than it's worth.

  • I can certainly understand where you're coming from with that statement, I think when version 3 of the reprap firmware is ready for stable release things will be better.

    But others may have more insight. I think I'd go with M118 to telnet or paneldue port and send modbus to the vfd instead of using analog interface. modifying the fusion post isn't a big deal

  • @bearer Thanks for the input anyway. I'm reading about MODBUS and RS485, but it may be a little beyond my ability. I guess I'll wait for the version 3 firmware update.

  • administrators

    Can you explain why your VFD needs 2 pins? Isn't setting the PWM to 0 on the 24V PWM pin sufficient to turn the spindle off?

  • @dc42 Hiya. I'm using an NfLixin frequency drive - so a little different from the more common Huanyang ones. The frequency drive has an analogue 0-10v input to control the PWM speed, and separate programmable inputs for running the spindle forward, reverse, and other things including estop with a faster spindle breaking speed, and toggling between gcode to potentiometer for speed control.

    The PWM or analogue 0-10v signal only controls the RPM of the spindle. The forward movement only occurs when the forward terminal on the frequency drive is connected to digital ground. A lot of people are simply jumping the connection on their VFD's which isn't really how they are designed to be used. On my frequency drive, the on-board fan remains on instead of only turning on when reciving the spindle enable signal, and the spindle maintains a holding torque which builds up heat and makes an annoying noise.

    Another problem is if I want to toggle between gcode to a potentiometer for control speed - using a jumper cable on the forward input and dcom, will result in the spindle turning on when toggling to potentiometer mode.

    Having a seperate PWM or 0-10v terminals and spindle enable are common on GRBL boards - such as the Phoenix CNC controller, and Gradus M1 Pro.

    I've attached two manuals for VFD's which might help illustrate how they can be used.
    0_1566416415298_NfLixin 9000 VFD SKU1618411 - small.pdf

  • administrators

    @EducatingSavvas, thanks for the info.

    Currently, in the M453 command, RRF3 allows you to specify e.g. C"out3" if you have just one spindle control output (which is assumed to be for forward motion and PWM capable), or C"out3+out4" if you have two (which are assumed to be separate pins for forwards and reverse, both PWM-capable). I could extend it to allow C"out3+out4+out5" where the first 2 pins are assumed to be on/off pins for forward and reverse, and the third pin is assumed to be the PWM control pin for both directions. Do you think that would cover all eventualities? if the controller had separate on/off and PWM pins but no reverse function, you could use C"out3+nil+out5".

  • @dc42 That sounds great. Glad this will be implemented in the next firmware update.

  • Hi - I just wanted to write an update on this issue. I'm still the older firmware and in the end I used the post processor in Vectric to send the signal to a PWM to analogue converter - which in turn triggers a relay module which connected the spindle enabled terminals on the VFD. I used a M307 H1 A-1 C-1 D-1 I0 command in my config file to disable the E0 heater and a M42 P1 S1 command in the post processor to enable the spindle. It all seems to be working providing I use the custom post processor. That said I have noticed that the previous spindle speed is not saved during a job pause, so after resuming it doesn't turn until the next segment in the code. I can add an arbitrary M3S## command but this will not reflect original speed - which may be material specific. Such as slower for plastics and faster for MDF.

Log in to reply