Welcome to Our Community

Some features disabled for guests. Register Today.

Workbee CNC w/Duet2 and chinese spindle control

Discussion in 'CNC Mills/Routers' started by Tubal, Apr 22, 2019.

  1. Tubal

    Tubal Well-Known

    Apr 19, 2019
    Likes Received:
    Hi all,

    I spent a couple weekends trying to piece together how to set this up, and couldn't find all the info in one place, so I thought I'd post it here in case anyone else is looking for this info.

    This is on a workbee 1000mmx1500mm and a duet2 wifi v1.04 using Oozenest's latest firmware, with a 2.2kw water cooled spindle and an HY 110V VFD. The duet was being run from a 24V power supply using openbuilds opencase kit which makes things so much nicer, and I had the fans set to get power from the VIN (24v) rather than using the built in 5V supply.

    I bought the VFD and spindle together from TwoWin on aliexpress. There are several versions in this link, and my understanding is that the HY converter, though more expensive, is much better. The vendor had set the VFD settings to match the spindle, so it was all configured to run the spindle from the vfd front panel when I got it.

    The first thing was wiring the VFD and the spindle, which is pretty straight forward. Your 110V power from the wall connects to R, S and ground. Your spindle connection has 4 pins labeled 1,2,3 and 4. 1 connects to U, 2 connects to V, 3 connects to W, and if you use 4, it goes to ground, but you'll want to open the top of your spindle and see if there is anything connected to pin 4. If not, you'll want to run a short wire from the pin to your spindle body. If your spindle will be grounded on your machine you don't necessarily need this 4th wire.

    Next was figuring out how to set up the Duet to assign a heater output to a tool. I used E0 Heater 1 and added/updated the following in my config.g to use it:

    ; Tools
    ;M563 P1 S"XYZ-Probe"          ; Define XYZ Touch Probe Tool
    M563 S"Spindle" P0 D0 H              ; Define Tool 0 (our Spindle)
    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
    M564 S1 H1              ; Disable jog commands when not homed
    M140 H-1              ; Disable heated bed
    M501                          ; Load Stored Parameters
    ; CNC
    M106 P2 I-1                         ; Disable Fan2
    M307 H1 A-1 C-1 D-1          ; Disable Heater 1 so we can use it for a tool
    M453 P1 R24000 F100        ; Set to CNC mode, using Tool 0, 24000 Max RPM, PWM Frequency 100hz

    Make sure the M501 command is before your M307 command. The M501 will reload/re-enable your heaters, so your M453 command will fail if the heaters are enabled when you run it.

    After I did this, I was getting a variable output voltage from the heater pins by sending the M3 Sxxx command (i.e. M3 S12000 to get 1/2 voltage, M3 S24000 to get full voltage, etc) from the Gcode console, which means I now had Duet control over the spindle.

    Now how to send this variable voltage to the VFD? I had to get a PWM to analog converter to convert this voltage to 10v. I got one on amazon for around $10.

    I fed the variable voltage from the Duet Heater output into the PWM input. The PWM converter required voltage to power on, which you can get from your duet power supply, but the VFD conveniently had 24V output, so I just pulled 24V from there using the 24V and DCM pins, and sent the analog voltage from the converter to the VI and ACM pins on the VFD.


    My VFD had a potentiometer on the front, which meant i had to move a jumper to move this control from the potentiometer to the pins. I also had to change a couple of settings on the VFD:

    • PD001 from 0 to 1 to change spindle on/off from "operator" control to "external" control.
    • PD002 was already set to 1, which is "external" control, but until you switch the jumper, the "external" is the potentiometer on the control panel. Once you move the jumper to the left, it will use the pins.
    • PD070 from 1 to 0 to change the input voltage it's looking for from 0-5v to 0-10v. Before I changed this, the spindle speed was double what I was sending. i.e. I'd send M3 S12000 and the spindle would go to 24000RPM.
    The next thing I had to figure out was how to send the "spindle on" command, which is a separate signal from the speed. I was just going to get a relay to use the voltage from the heater output, but I decided to just try jumping the FOR (forward) and DCM (digital common) pins, which would mean the spindle would always be "on" on the VFD, but without a voltage going into the speed control, this spindle wasn't getting any power anyway, so I decided to just jump this so it was always be "on". I don't think this will hurt anything, but if I notice anything bad, I'll update this.

    So now I had on and speed control from the duet by running the M3 Sxxx command.

    I just stuffed the pwm converter into the bottom of my vfd, so the only lines I had going into it was the line from the heater output on the duet, the spindle cable, and the 110V from the wall.

    I use Vectric vCarve Pro, and for the workbee they say to use the grbl (mm) post processor. This sends the xyz coordinates and feed rate fine, but it doesn't send the spindle speed. So I had to modify the post processor code in Vectric to send this.

    To do this, i went to the installation directory, found the grbl_mm.pp file, made a copy, and edited it with the following:

    • Change POST_NAME to something else (I used "Grbl (mm) (speed) (*.gcode)")
    • In the header, change "M3" to "M3[S]" to add the speed to the M3 command
    • After your "M3[S]" line, add a new line "G4S15". When I first tested the new grbl processor, my job positioned itself and started moving before the spindle was fully up to speed. This tells it to wait for 15 seconds before it starts moving so your spindle will have time to spin up all the way.
    • Save your file as something else. Make sure the file ends in .pp or Vectric won't load it.
    +  Commands output at the start of the file
    begin HEADER
    +"G17" Not supported in RepRap- Duet
    + Wait for spindle to get to speed

    Now the next time you open your software, your new post processor will be shown, and you can save your tool path with the new post processor to get speed control.

    Hopefully this will save someone some time. If you have any questions or if you see anything I did the hard way, let me know.

    #1 Tubal, Apr 22, 2019
    Last edited: Apr 23, 2019
    sharmstr likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice