Unable to control Spindle with Duet 2 WiFi
-
Hi all,
This is my first post and am reaching out for assistance setting up my spindle motor via an SSR 40 DA relay, with speed control & ON/OFF via Heaters 4 & 5 in the Expansion Header. I would appreciate any assistance in setting this up, especially with the config.g file.I am getting the following error with my setup below:
Error: M3: No P parameter and no active tool with spindleWhen the spindle is connected directly to the PSU I have control over the speed via a manual potentiometer adjusting the voltage, however, once the relay is connected from the Duet 2 wifi I am unable to even turn ON/OFF.
I believe my issue is in the code, as I am confused about what items I need to create and activate. I.e. Drive, Pin, Tools etc and assigning the spindle to which and how to make active. The issue could also be with the Duet 2 board pins I have used being PWM when I need Analogue 5v outputs.I have connected the spindle as follows, please note I am yet to connect the speed control wiring as yet because I don't have on/off capability:
Current Relay Wiring:
Expansion Header Pin 18 (Heater 5) to + DC Input Terminal
Expansion Header Pin 42 (GND) to - DC Input TerminalNote: LED is not illuminated on relay at any point and DC input range 3-32VDC & AC input range 24-380VAC
AC Live to 1 AC Terminal
2 AC Terminal to AC Live on PSU
AC Neutral to AC Neutral on PSU
Earth to AC Earth on PSUCurrent Duet 2 Wiring:
Expansion Header Pins 1,2 & 8 (Heater 3) control BLTouch, which works.
X,Y & Z stepper motors, which all work
X,Y end stops, which all work
Input power is 12v - I have a 24v PSU to replace 12v if required.Proposed Duet 2 Wiring for PWM speed control:
Expansion Header Pin 13 (Heater 4) to Centre Pin PSU Potentiometer connector
Expansion Header Pin 30 (GND) to GND PSU Potentiometer connectorYoutube:
Video showing connection of relay and speed control to a random grbl board.
https://www.youtube.com/watch?v=012_TzJL6GIConfig.g
; Configuration file for Duet WiFi (firmware version 3)
; executed by the firmware on start-up
;
; generated by RepRapFirmware Configuration Tool v3.3.14 on Sun Nov 20 2022 11:58:49 GMT+1000 (Australian Eastern Standard Time); General preferences
G90 ; send absolute coordinates...
M83 ; ...but relative extruder moves
M550 P"WolfCNC" ; set printer name; Network
M552 S1 ; enable network
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 S0 ; Physical drive 1 goes backwards
M569 P2 S0 ; Physical drive 2 goes backwards
;M569 P3 S1 ; physical drive 3 goes forwardsM584 X0 Y1 Z2 E3 ; set drive mapping
M350 X16 Y16 Z16 E16 I1 ; configure microstepping with interpolation
M92 X800.00 Y800.00 Z800.00 E420.00 ; set steps per mm
M566 X900.00 Y900.00 Z60.00 E120.00 ; set maximum instantaneous speed changes (mm/min)
M203 X6000.00 Y6000.00 Z180.00 E1200.00 ; set maximum speeds (mm/min)
M201 X500.00 Y500.00 Z20.00 E250.00 ; set accelerations (mm/s^2)
M906 X2380 Y2380 Z2380 E800 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 X350 Y180 Z50 S0 ; set axis maxima; Endstops
M574 X1 S1 P"xstop" ; configure switch-type (e.g. microswitch) endstop for low end on X via pin xstop
M574 Y1 S1 P"ystop" ; configure switch-type (e.g. microswitch) endstop for low end on Y via pin ystop
M574 Z1 S2 ; configure Z-probe endstop for low end on Z; Z-Probe
M950 S0 C"exp.heater3" ; create servo pin 0 for BLTouch
M558 P9 C"^zprobe.in" H5 F120 T6000 ; set Z probe type to bltouch and the dive height + speeds
G31 P500 X0 Y0 Z2.5 ; set Z probe trigger value, offset and trigger height
M557 X5:215 Y5:180 S20 ; define mesh grid; Heaters
M140 H-1 ; Disable heated bed
;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
M950 P0 C"exp.heater4" ; create output/servo port 0 attached to heater 4 pin on expansion connector
M950 P1 C"exp.heater5" ; create output/servo port 1 attached to heater 5 pin on expansion connector
M950 R0 C"exp.heater4+exp.heater5" Q1000 L0:12000 ; spindle PWM on Heater 4 pin, on/off on Heater 5 pin, PWM frequency 100Hz
M563 P0 S"Spindle 0" R0 ; Create tool 0 with spindle 0 on Heater 5 and call it "Spindle 0"
M453;M563 P0 D0 H5 F0 ; define tool 0
;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
-
@wschuller
IIRC correctly, the Duet2 expansion header pins only deliver 3.3V signals. That might be to low for the SSR.
You can try to use a fan output instead (directly on the Duet2, not the expansion header)
They can be jumpered to 5V or Vin, but both should be OK for the SSR.If the spindle controller needs 0-10V analog speed input, there are 3rd party DAC-boards available just for this purpose.
Maybe someone can chime in here with a link? -
@wschuller can you post an output of M115 so we can see which firmware version you are running?
-
@jay_s_uk thanks for the reply. M115 reports the following:
FIRMWARE_NAME: RepRapFirmware for Duet 2 WiFi/Ethernet FIRMWARE_VERSION: 3.3 ELECTRONICS: Duet WiFi 1.02 or later FIRMWARE_DATE: 2021-06-15 21:45:03
I do admit I have had some difficulties with interpreting solutions provided with code used in older versions.
I did work out the error was due to not having T1 to select the tool. It might be helpful to add this as a note under M950 & M563, explaining the complete set of commands required. In any case I still am unable to control the spindle via the duet 2, and I will provide an update of changes I have made my reply to o_lampe's post.
-
@o_lampe said in Unable to control Spindle with Duet 2 WiFi:
IIRC correctly, the Duet2 expansion header pins only deliver 3.3V signals. That might be to low for the SSR.
You can try to use a fan output instead (directly on the Duet2, not the expansion header)
They can be jumpered to 5V or Vin, but both should be OK for the SSR.
If the spindle controller needs 0-10V analog speed input, there are 3rd party DAC-boards available just for this purpose.
Maybe someone can chime in here with a link?Yeah thanks o_lampe you're 100% right, but I thought it was because those expansion header pins were PWM. So I moved the connections to Heater 1 & 2, connected the spindle controller you mentioned to Heater 1 to control the relay ON/OFF function, and made code changes to the Config.g Tools Section as shown below:
; Tools
M453 ; set machine to CNC mode
M950 R0 C"e1heat+e0heat" Q1000 L1:12000 ; Create spindle index 0, with PWM on e1heat pin, with ON/OFF on e0heat and PWM frequency is 1000Hz & full RPM is 12000
M563 P1 S"Spindle" R0 ; Create tool 1 with Spindle 0 and call it "Spindle"
T1 ; select tool 1
Note: Here I was testing if L1 made a difference to L0, and it didn't.Now when I run M3 I get a green command response, no errors, but nothing happens with the spindle, and still no led on the relay. If my code updates above are correct, then I will need to verify every connection and test every device works. I was hoping it would be in my code.
-
Sorry if I haven't read this properly, but do you have a milling motor with a digital interface (like an AMB or Mafell/Soroted) or a 'proper' spindle with speed control?
I have the Sorotec SFM1000 PV-ER which is controlled via a PWM converter connected to the Duet board, but this link might help you with a spindle, although that also uses a PWM converter?
Happy to help if it's milling motor, though.
Good luck!
-
If I understand this right, your motor uses an analog voltage to determine the speed. A PWM signal is a digital signal (a square wave) at a single voltage with a variable duty cycle - it is not an analog signal that would control your speed.
However - it's not that hard to convert that digital PWM into an analog voltage. A simple low-pass filter (resistor and capacitor) can convert PWM to rough analog as a test, but as @Nightowl has noted you can get a PWM->Analog converter cheaply that will produce a solid DC analog output.
-
@markz said in Unable to control Spindle with Duet 2 WiFi:
u can get a PWM->Analog converter cheap
as in section connecting a spindle, https://docs.duet3d.com/User_manual/Machine_configuration/Configuration_CNCnotes it is better to buy the green PCB version, not the blue one, because the green one is opto-coupled, the blue one not.
-
@wschuller
On a Duet2 you can enable a pullup resistor to any PWM output by adding "^" in front of the pin name.M950 R0 C"e1heat+^e0heat" Q1000 L1:12000 ; pullup enabled for e0heat
I don't know, if that's necessary for the on/off switch.
Maybe you have to invert the signal as well with "!" ?M950 R0 C"e1heat+!^e0heat" Q1000 L1:12000 ; pullup enabled and inverted -
@JoergS5 said in Unable to control Spindle with Duet 2 WiFi:
@markz said in Unable to control Spindle with Duet 2 WiFi:
u can get a PWM->Analog converter cheap
as in section connecting a spindle, https://docs.duet3d.com/User_manual/Machine_configuration/Configuration_CNCnotes it is better to buy the green PCB version, not the blue one, because the green one is opto-coupled, the blue one not.
This is the one I got for mine.
-
@Nightowl said in Unable to control Spindle with Duet 2 WiFi:
this link
Thanks Nightowl, I have one of those Chinese 500w spindle motors, however, I have upgraded to a safer PSU and wired as per the Youtube link in my original post. The only difference is he uses a generic GRBL board and I am trying to connect the Duet 2 WiFi.
-
@markz Thanks for your reply, yes I have one of the GREEN PWM converters as specified in the Duet documentation mentioned. Sorry, I may have confused everyone calling it the Spindle Controller above.
-
@JoergS5 thanks for the link. I am using the GREEN PWM Converter shown.
-
@wschuller I have one additional comment, but you will probably already know it. The chinese spindles often have very bad grounding (or worse, the ground connector is not connected to the housing at all), in CNC forums are reports that they often need resoldering. If you'not done it, better measure that grounding works correctly.
-
@o_lampe thanks for the assistance. I tried all combinations of adding pull up resistor and inverting the signal and found no change. I will need to double check wiring, continuity, polarity etc and find out how to test devices such as the PWM converter, as I don't have an oscilloscope. Diving further down the rabbit hole!!!
-
@JoergS5 do you mean the PSU supplied with the spindle has bad grounding or do mean the actual spindle motor itself?
-
I have just been performing my happy dance for the last half hour having solved my particular dilemma. I changed from using heater pins to fan 1 & 2 and voila it all worked. I can only suggest that I have damaged the E0 & E1 terminals over tightening them with all the failed attempts over the last year.
A big thank you to those providing assistance. It clearly prompted me to try different things, which led to the breakthrough.
I understand it is difficult to diagnose issues remotely as you have no idea what state all the parts in the puzzle are in, nor all the pieces are present.
From my experience with this issue I have found it difficult to be 100% certain I have used all the correct devices, wired it up correctly and generated the correct code, as everything I tried from other posts failed, until today. I now know my devices, wiring and code are spot on.
I would like to create a solution page similar to this link: https://learn.ooznest.co.uk/Guide/Connect+a+AMB+Kress+or+Mafell+spindle+with+digital+control/161
If anyone has a suggestion as to where that should be posted, please let me know so I can create the solution to assist others.
-
@wschuller said in Unable to control Spindle with Duet 2 WiFi:
actual spindle motor itself
I mean the spindle itself. The housing is often not grounded correctly, see e.g. https://www.cnczone.com/forums/spindles-vfd/426990-cnc-forum.html and I mention it because it dangers life if not grounding. User mactec54 with black humour "This what they call in China population control. No Earth Ground Required". There is an additional danger, that aluminium oxidizes after a few minuts and is an isolator, so an aluminium holder is e.g. not useful for grounding.
-
@JoergS5
I want to clarify the terms used here:
"Erde" = PE (protection earth)
"Masse" = GND (ground)Worldwide, there are gazilion electronic housings not grounded, because they are plastic. But upwards from a certain power level the 230V/110V mains connector has to have PE.
-
@o_lampe thanks for clarifiying. In the CNC forum are some discussions about plastic, special rules for new zealand etc. I just wanted to warn, because it can harm health (very much!).
-