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.

Tags:
  1. Tubal

    Tubal Well-Known
    Builder

    Joined:
    Apr 19, 2019
    Messages:
    1
    Likes Received:
    2
    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:

    Code:
    ; 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.

    20190421_205013.jpg

    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.
    Code:
    +---------------------------------------------------
    +  Commands output at the start of the file
    +---------------------------------------------------
    
    begin HEADER
    
    "T1"
    +"G17" Not supported in RepRap- Duet
    "G21"
    "G90"
    "G0[ZH]"
    "G0[XH][YH][S]"
    "M3[S]"
    +----------
    + Wait for spindle to get to speed
    +----------
    "G4S15"
    


    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.

    Thanks!
     
    #1 Tubal, Apr 22, 2019
    Last edited: Apr 23, 2019
    GeoffH and sharmstr like this.
  2. GeoffH

    GeoffH Veteran
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    117
    Likes Received:
    83
    Good stuff, just about to tackle the same problem on a Duet board. I noticed that you have specified a PWM frequency of 100Hz and that the PWM to analog convertor is rated 1-3KHz. Not being an electronics expert in any shape at all, is this ok? Geoff
     
  3. GeoffH

    GeoffH Veteran
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    117
    Likes Received:
    83
    To clarify Duet connection to PWM to Analog board which is tricky to confirm without a scope

    upload_2019-6-17_10-21-19.png
     
  4. RV6APilot

    RV6APilot Journeyman
    Builder

    Joined:
    Apr 23, 2019
    Messages:
    30
    Likes Received:
    22
    So I have been controlling my spindle from the VFD and wondering if anyone has done this with a BlackBox?
     
  5. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Resident Builder Project Maker Builder

    Joined:
    Mar 1, 2017
    Messages:
    1,392
    Likes Received:
    739
    Yip, check the BlackBox thread, was a couple posts earlier this week or late last week regarding
     
    RV6APilot likes this.
  6. GeoffH

    GeoffH Veteran
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    117
    Likes Received:
    83
    Sorry don't know about Blackbox, but coming back to Duet, I found another problem with M5 (spindle stop), this is executed before finishing buffered moves, so
    M400 (or G4...)
    M5
    is needed.
     
  7. GeoffH

    GeoffH Veteran
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    117
    Likes Received:
    83
    Ignore my last post, I am assured that this isn't necessary - the problem may have been from "Out of Limits" error that turns off the spindle whilst finishing the move (disaster!!)
     

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