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 New
    Builder

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

    GeoffH Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    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 Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    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 Well-Known
    Builder

    Joined:
    Apr 23, 2019
    Messages:
    29
    Likes Received:
    23
    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 Builder Resident Builder

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

    GeoffH Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    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 Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    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!!)
     
  8. ollari

    ollari New
    Builder

    Joined:
    Oct 4, 2019
    Messages:
    5
    Likes Received:
    1
    Good tutorial, thanks. But I have weird stuff going on. Maybe someone could help me. I have all the connections done and I can control RPM from software. But if I put let's say M3S24000 in duet, vfd only outputs 50hz to motor. M3S12000 outputs 25hz. VFD is stepperonline brand not Huangyang. I have vfd setup done, and everything looks totally fine. If using pot on the vfd, it goes to 400hz as supposed. But with external control 50hz max.

    Thanks
     
  9. GeoffH

    GeoffH Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    Sounds like you are nearly there, can you measure the voltage output from the PWM to Analogue board for the 2 speeds that you mentioned. The higher one needs to match whatever maximum analogue voltage you have set the vfd up for.
    Presumably you have something like
    M453 P1 R30000 F1000 ; Set to CNC mode, using Tool 0, 30000 Max RPM, PWM Frequency 1khz
    in config.sys?
    I'm not familiar with the stepperonline type.
     
  10. ollari

    ollari New
    Builder

    Joined:
    Oct 4, 2019
    Messages:
    5
    Likes Received:
    1
    From analogue board it outputs correct voltage. I have 24000rpm spindle and if I write m3S12000 I get 5 volts and m3S24000 I get 10volts.
    VFD is set to accept 0-10volts.
    M453 P1 R30000 F1000 ; Set to CNC mode, using Tool 0, 30000 Max RPM, PWM Frequency 1khz - It seems that my problem might be in this line. I will check that.
    Thanks for info!
     
  11. GeoffH

    GeoffH Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    Sounds all correct to me:confused:, must be the vfd voltage configuration, I guess??
     
  12. magus021

    magus021 New
    Builder

    Joined:
    Sep 4, 2019
    Messages:
    4
    Likes Received:
    0
    Hi!
    I have something different. I want to control a duet I/O pins (or a fan pins) to switch a motor on and off.
    I don't want to set the speed. Could someone help me about that?
     
  13. GeoffH

    GeoffH Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    Is this to turn the Router on/off?
     
  14. magus021

    magus021 New
    Builder

    Joined:
    Sep 4, 2019
    Messages:
    4
    Likes Received:
    0
  15. magus021

    magus021 New
    Builder

    Joined:
    Sep 4, 2019
    Messages:
    4
    Likes Received:
    0
    I have a solution in my mind:
    • Make a new post processor for Vetrick and adding a fan switching command (M106 S1/S0) (Begin Header/Footer)
    • Wire out the fan pins to a relay what can switch the router
    I don't know what else required for proper working.
    Do I need to modify something in the config.g file?
     
  16. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,767
    Likes Received:
    1,356
  17. GeoffH

    GeoffH Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
    Yes, I guess you can use a fan output as you say, and you probably have to use a non-standard M code. If you want to use M3 M5 then I think you have to use one of the heaters as described above with a PWM to Analogue board driving the Relay.
    I don't know if there is a software way to link M3 M5 to the Fan outputs?
     
    Alex Chambers likes this.
  18. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,767
    Likes Received:
    1,356
    Fans can have PWM output, so could be used with appropriate interface to control router speed. As this involves mains voltage I cannot elaborate further for liability reasons. Openbuilds will not be responsible if you fry your electrics or yourself!
    Alex.
     
  19. GeoffH

    GeoffH Journeyman
    Builder

    Joined:
    Mar 11, 2017
    Messages:
    178
    Likes Received:
    107
  20. beickybeer

    Builder

    Joined:
    Feb 17, 2020
    Messages:
    3
    Likes Received:
    2
    Hi Tubal, thanks to you (and this topic) my amb kress spindle is set up on my ooznest workbee! Many thanks, if this topic wouldn't exist, I don't think I was able to get the spindle working ;);)

    Greetings,

    Christophe
     
  21. beickybeer

    Builder

    Joined:
    Feb 17, 2020
    Messages:
    3
    Likes Received:
    2
    For those who came to this topic with their questions to install an AMB Kress or Mafell spindle (with digital control) to the duet, I have wrote a guide on the ooznest learn portal.
    Connect a AMB Kress or Mafell spindle with digital control

    Tubal, I have credited you in the links as you obviously made it easier for me to set up and understand what I was doing ;)

    Greetings,

    Christophe
     
    Alex Chambers likes this.
  22. Arron

    Arron New
    Builder

    Joined:
    Mar 22, 2017
    Messages:
    2
    Likes Received:
    0
    might be some thread necromancy... but curious if anyone has seen the output of this setup waver up and down?... all "works" as intended, but the rpm on the spindle goes up and down constantly, by a large enough range that during a job the router can get stuck. If I put the VFD back to work off its potentiometer, it just sits on the RPM like a rock. I guess I should sit there with a multimeter and see if the variance is coming out of the duet or the voltage converter?
     
  23. beickybeer

    Builder

    Joined:
    Feb 17, 2020
    Messages:
    3
    Likes Received:
    2
    Hi Arron,

    You can change the frequency of the pwm signal in the gcode, today (well that's really a coincidence!!) a friend who I was helping with to set up a AMB kress spindle had the same issue and by setting the frequency lower it was solved! Think he lowered it down to 350 Hz (not kHz) but try a bit and see what's working best.

    Cheers
     
    Arron likes this.
  24. Arron

    Arron New
    Builder

    Joined:
    Mar 22, 2017
    Messages:
    2
    Likes Received:
    0
    you're a gentleman and a scholar :) ...working pretty well now, many thanks!
     

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