Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
spindle-module [2017/01/25 17:29] arthur |
spindle-module [2019/05/06 18:52] (current) 89.134.146.217 [PWM Spindle] added hobby ESC block - V1pr |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | <callout type="info" icon="true"> | ||
- | The purpose of this page is to document the new spindle module that supports various spindle types. | ||
- | It is currently under development by **bouni**, the code can be found [[*https://github.com/Bouni/Smoothieware/tree/feature/spindle-refactor|here]]. | ||
- | </callout> | ||
- | |||
== Basics | == Basics | ||
Line 11: | Line 6: | ||
The spindle module supports different types of spindles which are described in the following subsections. | The spindle module supports different types of spindles which are described in the following subsections. | ||
+ | |||
+ | <callout type="info" icon="true"> | ||
+ | **NOTE** the spindle module is NOT compiled into the normal smoothie build, you need to use the CNC build. | ||
+ | </callout> | ||
=== General | === General | ||
Line 16: | Line 15: | ||
The spindle module has an option which lets you enable or disable the entire module: | The spindle module has an option which lets you enable or disable the entire module: | ||
- | [[code]] | + | <code> |
spindle.enable true # set this to false to disable the spindle module | spindle.enable true # set this to false to disable the spindle module | ||
- | [[/code]] | + | </code> |
=== G-code | === G-code | ||
Available G-code commands: | Available G-code commands: | ||
- | * {{M3}} will start the spindle. {{M3 S5000}} will start the spindle and set speed to 5000 RPM. | + | * <kbd>M3</kbd> will start the spindle. <kbd>M3 S5000</kbd> will start the spindle and set speed to 5000 RPM. |
- | * {{M5}} will stop the spindle. Last set RPM is remembered and used for next {{M3}} command if S argument is not given. | + | * <kbd>M5</kbd> will stop the spindle. Last set RPM is remembered and used for next <kbd>M3</kbd> command if S argument is not given. |
- | * {{M957}} will report the current spindle speed and PWM value. This returns not the actual value but the value that was set through M3. | + | * <kbd>M957</kbd> will report the current spindle speed and PWM value. This returns not the actual value but the value that was set through M3. |
- | * {{M958}} will report the current PID parameters. {{M958 Px.xxx Ix.xxx Dx.xxx}} will set them (to save the new values, you need to edit config file manually). | + | * <kbd>M958</kbd> will report the current PID parameters. <kbd>M958 Px.xxx Ix.xxx Dx.xxx</kbd> will set them (to save the new values, you need to edit config file manually). |
=== PWM Spindle | === PWM Spindle | ||
- | > TODO : Transfer the information of the old [[spindle-control]] into this section | ||
<callout type="info" icon="true"> | <callout type="info" icon="true"> | ||
Line 39: | Line 37: | ||
==== Example config options | ==== Example config options | ||
- | [[code]] | + | <code> |
spindle.type pwm # sets the spindle module to PWM mode | spindle.type pwm # sets the spindle module to PWM mode | ||
spindle.pwm_pin 2.5 # Big Mosfet Q7. Pin must be hardware PWM capable. | spindle.pwm_pin 2.5 # Big Mosfet Q7. Pin must be hardware PWM capable. | ||
Line 50: | Line 48: | ||
spindle.control_D 0.1 # default 0.0001. D value for the PID controller | spindle.control_D 0.1 # default 0.0001. D value for the PID controller | ||
spindle.control_smoothing 0.1 # default 0.1. This value is low pass filter time constant in seconds. | spindle.control_smoothing 0.1 # default 0.1. This value is low pass filter time constant in seconds. | ||
- | [[/code]] | + | </code> |
<callout type="info" icon="true"> | <callout type="info" icon="true"> | ||
Check the [[http://smoothieware.org/pinout |pinout]] to verify if a pin is capable for a certain functionality! | Check the [[http://smoothieware.org/pinout |pinout]] to verify if a pin is capable for a certain functionality! | ||
+ | </callout> | ||
+ | |||
+ | <callout type="info" icon="true" title="Hobby servo ESC as spindle control"> | ||
+ | Since I'm expiriencing with hobby esc+motor combos (1:8 scale 3 phase 4068 like motor) I wanted to share it's config. ESCs act like hobby servos - 20 ms period time, 1.5-2ms duty cycle time -, so insted of having modified the spindle code, I've created a switch for commands M3/M5. Due to the very small duty cycle window you won't have much control over the motor: S7.5 is neutral, S12.5 is "fastest" after calibrating the ESC manually with bCNC (read ESC's manual; below S7.5 is breaking for now). | ||
+ | |||
+ | The following code is working, setting neutral upon boot - ESC init. | ||
+ | <code> | ||
+ | switch.servo.enable true # Servo module for PWM control | ||
+ | switch.servo.input_on_command M3 | ||
+ | switch.servo.input_off_command M5 | ||
+ | switch.servo.output_pin 1.23o! # spare pin with PWM capability, 3.25 should also work from EXP2, maybe needed to set it to 1.23o! | ||
+ | switch.servo.output_type hwpwm | ||
+ | #switch.servo.pwm_period_ms 20 #set PWM period to 20ms (50 Hz) | ||
+ | switch.servo.startup_state true # turn on the output to have neutral for ESC | ||
+ | switch.servo.startup_value 7.5 # this is default_off_value | ||
+ | switch.servo.default_on_value 7.5 | ||
+ | switch.servo.failsafe_set_to 0 | ||
+ | </code> | ||
+ | |||
+ | </callout> | ||
+ | |||
+ | <callout type="default" icon="true" title="Going further"> | ||
+ | If you want to learn more about this module, or are curious how it works, Smoothie is Open-Source and you can simply go look at the code, [[https://github.com/Smoothieware/Smoothieware/blob/edge/src/modules/tools/spindle/PWMSpindleControl.cpp|here]]. | ||
</callout> | </callout> | ||
Line 68: | Line 89: | ||
==== Example config options | ==== Example config options | ||
- | [[code]] | + | <code> |
spindle.type analog # set the spindle type to analog, can also be used for ESC spindles controlled by a PWM | spindle.type analog # set the spindle type to analog, can also be used for ESC spindles controlled by a PWM | ||
spindle.max_rpm 24000 # set the max spindle speed that is achieved at 100% PWM | spindle.max_rpm 24000 # set the max spindle speed that is achieved at 100% PWM | ||
Line 74: | Line 95: | ||
spindle.pwm_period 1000 # the PWM frequency | spindle.pwm_period 1000 # the PWM frequency | ||
spindle.switch_on_pin 2.6 # the pin which is used to enable the VFD (optional) | spindle.switch_on_pin 2.6 # the pin which is used to enable the VFD (optional) | ||
- | [[/code]] | + | </code> |
==== PWM to analog converter circuit | ==== PWM to analog converter circuit | ||
Line 82: | Line 103: | ||
</callout> | </callout> | ||
- | <html><div style='width:640px'></html> | ||
- | <panel type="default" title="VFD adapter board"> | ||
- | <image shape="thumbnail"> | ||
<html> | <html> | ||
- | <img src="https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/analog-vfd-board-pcb.png" style="width:100%;"> | + | <div class='panel panel-default wrap_center' style='width:640px;padding:10px '> |
+ | <div class='panel-heading'><h4 class='panel-title'>VFD adapter board</h4></div> | ||
+ | <image src='https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/analog-vfd-board-pcb.png' width='620px'><br/> | ||
+ | Used to talk to your VFD via an analog signal | ||
+ | </div> | ||
</html> | </html> | ||
- | Used to talk to your VFD via an analog signal | ||
- | </image> | ||
- | </panel> | ||
- | <html></div></html> | ||
- | |||
- | [[div ]] | ||
This is an example of a small extension PCB that contains a circuit to convert the 3.3V PWM signal into a 0-10V analog signal. | This is an example of a small extension PCB that contains a circuit to convert the 3.3V PWM signal into a 0-10V analog signal. | ||
- | <html><div style='width:640px'></html> | ||
- | <panel type="default" title="VFD adapter board schematic"> | ||
- | <image shape="thumbnail"> | ||
<html> | <html> | ||
- | <img src="https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/analog-vfd-board-schematic.png" style="width:100%;"> | + | <div class='panel panel-default wrap_center' style='width:640px;padding:10px '> |
+ | <div class='panel-heading'><h4 class='panel-title'>VFD adapter board schematic</h4></div> | ||
+ | <image src='https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/analog-vfd-board-schematic.png' width='620px'><br/> | ||
+ | For the curious | ||
+ | </div> | ||
</html> | </html> | ||
- | For the curious | ||
- | </image> | ||
- | </panel> | ||
- | <html></div></html> | ||
- | [[div]] | ||
This is the related circuit diagram for the converter | This is the related circuit diagram for the converter | ||
- | <html><div style='width:640px'></html> | ||
- | <panel type="default" title="VFD adapter board wiring"> | ||
- | <image shape="thumbnail"> | ||
<html> | <html> | ||
- | <img src="https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/PWM-analog-wiring.png" style="width:100%;"> | + | <div class='panel panel-default wrap_center' style='width:640px;padding:10px '> |
+ | <div class='panel-heading'><h4 class='panel-title'>VFD adapter board wiring</h4></div> | ||
+ | <image src='https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/PWM-analog-wiring.png' width='620px'><br/> | ||
+ | How to connect it to your Smoothieboard and vfd | ||
+ | </div> | ||
</html> | </html> | ||
- | How to connect it to your Smoothieboard and vfd | ||
- | </image> | ||
- | </panel> | ||
- | <html></div></html> | ||
- | |||
- | [[div]] | ||
This example shows how to wire the Smoothieboard to an Huanyang VFD using the PCB shown above. | This example shows how to wire the Smoothieboard to an Huanyang VFD using the PCB shown above. | ||
Line 134: | Line 141: | ||
Unfortunately the circuit does not create a completely linear output signal. As you can see in the graph, the signal is better at the beginning and at the end. | Unfortunately the circuit does not create a completely linear output signal. As you can see in the graph, the signal is better at the beginning and at the end. | ||
- | <html><div style='width:640px'></html> | ||
- | <panel type="default" title="VFD analog signal linearity"> | ||
- | <image shape="thumbnail"> | ||
<html> | <html> | ||
- | <img src="https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/linearity-check.png" style="width:100%;"> | + | <div class='panel panel-default wrap_center' style='width:640px;padding:10px '> |
+ | <div class='panel-heading'><h4 class='panel-title'>VFD analog signal linearity</h4></div> | ||
+ | <image src='https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/linearity-check.png' width='620px'><br/> | ||
+ | |||
+ | </div> | ||
</html> | </html> | ||
+ | </callout> | ||
- | </image> | + | <callout type="default" icon="true" title="Going further"> |
- | </panel> | + | If you want to learn more about this module, or are curious how it works, Smoothie is Open-Source and you can simply go look at the code, [[https://github.com/Smoothieware/Smoothieware/blob/edge/src/modules/tools/spindle/AnalogSpindleControl.cpp|here]]. |
- | <html></div></html> | + | |
- | + | ||
</callout> | </callout> | ||
+ | |||
=== Modbus Spindle | === Modbus Spindle | ||
Line 159: | Line 166: | ||
==== Example config options | ==== Example config options | ||
- | [[code]] | + | <code> |
spindle.type modbus # set the spindle type to modbus/RS485 | spindle.type modbus # set the spindle type to modbus/RS485 | ||
spindle.vfd_type huanyang # set the VFD type, this is necessary because each inverter uses its own commands | spindle.vfd_type huanyang # set the VFD type, this is necessary because each inverter uses its own commands | ||
Line 165: | Line 172: | ||
spindle.tx_pin 2.4 # RX pin for the soft serial | spindle.tx_pin 2.4 # RX pin for the soft serial | ||
spindle.dir_pin 2.5 # RS485 is only half-duplex, so we need a pin to switch between sending and receiving | spindle.dir_pin 2.5 # RS485 is only half-duplex, so we need a pin to switch between sending and receiving | ||
- | [[/code]] | + | </code> |
==== Huanyang VFD Modbus Parameters | ==== Huanyang VFD Modbus Parameters | ||
Line 182: | Line 189: | ||
Like an analog spindle, the Modbus spindle needs a external circuit, but that is much simpler. | Like an analog spindle, the Modbus spindle needs a external circuit, but that is much simpler. | ||
- | <html><div style='width:640px'></html> | ||
- | <panel type="default" title="VFD Modbus signal adapter PCB"> | ||
- | <image shape="thumbnail"> | ||
<html> | <html> | ||
- | <img src="https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/modbus-vfd-board-pcb.png" style="width:100%;"> | + | <div class='panel panel-default wrap_center' style='width:640px;padding:10px '> |
- | </html> | + | <div class='panel-heading'><h4 class='panel-title'>VFD Modbus signal adapter PCB</h4></div> |
+ | <image src='https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/modbus-vfd-board-pcb.png' width='620px'><br/> | ||
Used to talk to your spindle over RS485 differential signals | Used to talk to your spindle over RS485 differential signals | ||
- | </image> | + | </div> |
- | </panel> | + | </html> |
- | <html></div></html> | + | |
Line 197: | Line 201: | ||
- | <html><div style='width:640px'></html> | ||
- | <panel type="default" title="VFD Modbus signal adapter schematic"> | ||
- | <image shape="thumbnail"> | ||
<html> | <html> | ||
- | <img src="https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/modbus-vfd-board-schematic.png" style="width:100%;"> | + | <div class='panel panel-default wrap_center' style='width:640px;padding:10px '> |
- | </html> | + | <div class='panel-heading'><h4 class='panel-title'>VFD Modbus signal adapter schematic</h4></div> |
+ | <image src='https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/modbus-vfd-board-schematic.png' width='620px'><br/> | ||
for the curious | for the curious | ||
- | </image> | + | </div> |
- | </panel> | + | </html> |
- | <html></div></html> | + | |
Line 216: | Line 217: | ||
- | <html><div style='width:640px'></html> | ||
- | <panel type="default" title="VFD Modbus wiring"> | ||
- | <image shape="thumbnail"> | ||
<html> | <html> | ||
- | <img src="https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/RS485-wiring.png" style="width:100%;"> | + | <div class='panel panel-default wrap_center' style='width:640px;padding:10px '> |
- | </html> | + | <div class='panel-heading'><h4 class='panel-title'>VFD Modbus wiring</h4></div> |
+ | <image src='https://raw.githubusercontent.com/Bouni/smoothieboard-doku/master/RS485-wiring.png' width='620px'><br/> | ||
How to connect it to the Smoothieboard and the VFD | How to connect it to the Smoothieboard and the VFD | ||
- | </image> | + | </div> |
- | </panel> | + | </html> |
- | <html></div></html> | + | |
[[div]] | [[div]] | ||
This example shows how to wire the Smoothieboard to an Huanyang VFD using the PCB shown above. | This example shows how to wire the Smoothieboard to an Huanyang VFD using the PCB shown above. | ||
+ | |||
+ | <callout type="default" icon="true" title="Going further"> | ||
+ | If you want to learn more about this module, or are curious how it works, Smoothie is Open-Source and you can simply go look at the code, [[https://github.com/Smoothieware/Smoothieware/blob/edge/src/modules/tools/spindle/ModbusSpindleControl.cpp|here]]. | ||
+ | </callout> | ||