If you are not using a VFD, and your spindle motor is a DC motor of low enough power, you can control it directly using the MOSFETs on the Smoothieboard.
The power must be low enough in both voltage and current, including any current extremes when stalled.
MOSFETs are present on-board, but have limited current capacity (up to 12A).
They need to be protected by a ‘flyback’ diode when controlling a motor, electromechanical relay or other inductive load.
For more information, see:
Motors have the property of inductance, which is the electrical equivalent of inertia.
The motor current will continue to flow after the MOSFET is switched off, because the energy stored in the inductor by the current does not instantly disappear.
The current will decrease as the stored energy is dissipated.
This current flow results in the voltage across the motor reversing and increasing (or “spiking”) until the current finds a path to flow.
An appropriately connected ‘flyback’ diode with sufficient voltage and current ratings will provide a safe, intended path for the motor current.
Without a diode, when the MOSFET turns off the motor voltage will spike up until the current finds an unintended path.
Typically this degrades or immediately destroys the MOSFET and perhaps other circuitry such as that driving the MOSFET gate.
Connect the diode in reverse across the motor (when the MOSFET is on, it must NOT cause power to flow through the diode).
Connect the anode (‘arrow’) to the MOSFET Drain terminal and the cathode (‘bar’, often marked by a line on the package) to the motor power supply.
The diode rating should be rated with Voltage exceeding the maximum expected supply voltage by at least 20% (usually low cost to get a higher voltage rating).
And (conservatively) Current at least equal to half the motor current (the current through the diode will not be continuous).
An example part number is 6A4-T, rated 6A and 400V, under $1 USD.
The same considerations apply to other inductive loads such as solenoid valves and relay coils.
Solid state relays are controlled via a GPIO pin, and can control higher loads.
But are on/off only (no control of the exact amount of power sent via PWM).
For more information about SSRs, see this appendix.
A MOSFET cannot provide power if it is not provided power via an input.
Make sure you properly connect both the input power and output connections.
Smoothie has up to 6 MOSFET controls (6 on 5X, 4 on 4X, and 2 on 3X).
The MOSFETs act as switches to ground: loads must be connected between the power source and the MOSFET switched terminal.
When the MOSFET is switched on, power will be applied to the load.
When the MOSFET is switched off, power will be removed, because one load terminal will be essentially disconnected and current cannot flow.
The exception being inductive load ‘flyback’ switching transients, discussed above.
Connect your PSU to the power input connector for those FETs (providing power to the load), and connect your power-consuming element (be it heating element, spindle, etc.) between the power output terminal and the MOSFET terminal.
Smoothie connects/disconnects the element’s ground as needed to maintain temperature or as requested by G-codes.
There are three main pairs of MOSFETs on the board:
Big MOSFET pair: Their outputs are labeled P2_7 and P2_5 on the schematic, the input connector for them is found between them. They are found on the 4X and 5X boards. To power those MOSFETs, you need to provide them with power by wiring their power input to the power supply.
Small MOSFET pair: Their outputs are labeled P2_6 and P2_4 on the schematic, the input connector for them is found by their side, between P2_6 and P1_23. They are found on all of the boards. To power those MOSFETs, you need to provide them with power by wiring their power input to the power supply.
Mixed MOSFET pair: Their outputs are labeled P1_22 and P1_23 on the schematic. The pair is called “mixed” because it consists of one big MOSFET and one small MOSFET. They do not have a specific input, they take power directly from VBB (the Stepper motors power input described in the Stepper Motors chapter). To power those MOSFETs, you need to provide them with power by wiring their power input (which is the same as the one for the stepper motors) to the power supply.
MOSFETs list:
MOSFET group | MOSFET name | Controlling pin | Output connector | Input method | Voltage | Current |
---|---|---|---|---|---|---|
Big MOSFETs | First big MOSFET | 2.7 |
X15 | Big MOSFETs power input X13 | 12-24V | 12.5A max |
Big MOSFETs | Second big MOSFET | 2.5 |
X10 | Big MOSFETs power input X13 | 12-24V | 12.5A max |
Small MOSFETs | First small MOSFET | 2.4 |
X7 | Small MOSFETs power input X6 | 12-24V | 3A max |
Small MOSFETs | Second small MOSFET | 2.6 |
X8 | Small MOSFETs power input X6 | 12-24V | 3A max |
Mixed MOSFETs | Third big MOSFET | 1.23 |
X16 | VBB (motor) input | 12-24V | 12.5A max |
Mixed MOSFETs | Third small MOSFET | 1.22 |
X9 | VBB (motor) input | 12-24V | 3A max |
+
on that connector to +
on your PSU, and -
to -
on the PSU.
Never use the big MOSFETS for more than 12.5A (and monitor connector and MOSFET temperatures at that current use, too much heating can be a sign of a bad wire connection), and the small MOSFETS should never be used for more than 3A.
Trying to power a 40W (or more) hotend cartridge heater at 12V with the small FETs will destroy them, usually locking (melting) them to the “ON” state (shorted) and possibly destroying the circuitry driving the MOSFET gate.
If you need to control more than 12 Amps, you cannot do it with one of the MOSFETS on board, however, you can use a Solid State Relay.
For information see the Solid State Relay Appendix on this page.
In order to configure your Smoothieboard to use a specific MOSFET, you need to know which pin corresponds to which MOSFET.
Here is a recapitulating table to help you find that out:
This page documents the MOSFET outputs available on Smoothieboard and their specifications.
MOSFETs are used to control high-power devices like heated beds, hotends, fans, and other accessories.
MOSFET Pair | Big MOSFETS | Small MOSFETS | Mixed MOSFETS | |||
---|---|---|---|---|---|---|
Label on diagram | P2_7 | P2_5 | P2_4 | P2_6 | P1_23 | P1_22 |
Digital output pin | 2.7 |
2.5 |
2.4 |
2.6 |
1.23 |
1.22 |
Power Input | Between P2_7 and P2_5 |
Between P2_6 and P1_23 |
Taken from VBB | |||
Size | Big | Big | Small | Small | Big | Small |
Maximum current | 12A | 12A | 3A | 3A | 12A | 3A |
Used by default for | Heated bed | Hotend 0 | Fan | Hotend 1 |
Smoothieboard has three MOSFET pairs:
To configure a MOSFET output in your config file, use the appropriate pin number from the “Digital output pin” row.
Example for configuring a heated bed on P2_7:
temperature_control.bed.heater_pin 2.7
Example for configuring a hotend on P2_4:
temperature_control.hotend.heater_pin 2.4
TODO: diagram
Now that you have located which MOSFET you are going to use for Spindle control, and what GPIO pin it corresponds to, you need to add a spindle control section to your configuration file.
We will be doing this using the Switch module.
Add this to your configuration file:
# Spindle control Switch module
switch.spindle.enable true #
switch.spindle.input_on_command M3 #
switch.spindle.input_off_command M5 #
switch.spindle.output_pin 2.7 # Here we are using the first big MOSFET
switch.spindle.output_type pwm # pwm output settable with S parameter in the input_on_command
switch.spindle.max_pwm 255 # set max pwm for the pin default is 255
Now that everything is configured, you can use G-codes to control the Spindle.
You can do this either manually by sending G-codes directly to the board via serial or your host software, or add those G-codes to the beginning/end of your files.
You can choose the exact G-codes in the configuration.
Here we used the standard M3
to turn the Spindle ON, and M5
to turn the Spindle OFF.
If you need to choose the power (speed) of your Spindle, you can do so because the output is configured as PWM.
Simply do:
M3 S128
To set the spindle to half power/speed.
PWM values go from 0 to 255.
0 means no power to the spindle, and 255 means full power to the spindle.
Because the spindle can feed power back into the MOSFET and damage the MOSFET, you also need to wire a diode of sufficient size across the output.
See notes in the first section above.
To get more accurate RPM control, you can use a feedback sensor.
This can be optical or a hall effect sensor, which senses the rotation of the spindle.
Smoothie then measures the real RPM of the spindle and adjusts the PWM value accordingly.
To use this module, you need to connect your spindle to pins with proper hardware support:
| Option | Example value | Explanation | | —— | ————- | ———– |
The following table lists the deprecated configuration options for the old spindle module:
Parameter | Value | Description |
---|---|---|
spindle_enable |
true | If set to true, enables the Spindle module, which uses an encoder to PID-control a PWM-modulated spindle motor |
spindle_pwm_pin |
2.4 |
Output PWM pin (uses hardware PWM). Note: hardware PWM is available only on pins 2.0 to 2.5 , 1.18 , 1.20 , 1.21 , 1.23 , 1.24 , 1.26 , 3.25 and 3.26 |
spindle_pwm_period |
100 | PWM period to use in microseconds |
spindle_feedback_pin |
2.6 |
Feedback input pin (must be Port 0 or 2, meaning the pin number must be 2.x or 0.x ) |
spindle_pulses_per_rev |
3 | Number of feedback pulses per revolution on the feedback input pin |
spindle_default_rpm |
5000 | RPM to use if none given in M3 command, in rotations/minute |
spindle_control_P |
0.0002 | PID P factor (unit is 1 / RPM) |
spindle_control_I |
0.0001 | PID I factor (unit is 1 / ( RPM x seconds )) |
spindle_control_D |
0.000001 | PID D factor (unit is 1 / (R PM / seconds )) |
Available G-code commands for PID spindle control:
M3 S5000
will start the spindle and set speed to 5000 RPM.M3
command if S argument is not given.M958 Px.xxx Ix.xxx Dx.xxx
will set them (to save the new values, you need to edit config file manually).There is no PID autotuning for spindle parameters currently.
You can use the following process to manually tune the PID:
M958 P0.0001 I0 D0
M5
and make sure spindle is ready to run on next M3
command (i.e. power supply is on).M3 S100000
, which should start the spindle at maximum speed.M957
Now set the parameters to:
Some manual tuning may be needed after this.
Test speed changes using the M3
command and try loading the spindle to see if it reacts fast enough to load changes.