1) PWM control is not implemented also the speed is send to the driver function. You must add the pwm function in the cnc on/off function in
void CNCDriver::spindleOnCW(int32_t rpm) {
spindleSpeed = map(rpm, 0, CNC_RPM_MAX, 0, CNC_PWM_MAX); // linear interpolation
if (direction == 1 && spindleRpm == rpm)
return;
if (direction == -1) {
spindleOff();
}
spindleRpm = rpm; // for display
direction = 1;
if (EVENT_SPINDLE_CW(rpm)) {
#if CNC_DIRECTION_PIN > -1
WRITE(CNC_DIRECTION_PIN, CNC_DIRECTION_CW);
#endif
#if CNC_ENABLE_PIN > -1
WRITE(CNC_ENABLE_PIN, CNC_ENABLE_WITH);
#endif
}
HAL::delayMilliseconds(CNC_WAIT_ON_ENABLE);
}
/** Turns spindle on. Default implementation uses a enable pin CNC_ENABLE_PIN.
If CNC_DIRECTION_PIN is not -1 it sets direction to !CNC_DIRECTION_CW. rpm is
ignored. To override with event system, return false for the event
EVENT_SPINDLE_CCW(rpm)
*/
void CNCDriver::spindleOnCCW(int32_t rpm) {
spindleSpeed = map(rpm, 0, CNC_RPM_MAX, 0, CNC_PWM_MAX); // linear interpolation
if (direction == -1 && spindleRpm == rpm)
return;
if (direction == 1) {
spindleOff();
}
spindleRpm = rpm; // for display
direction = -1;
if (EVENT_SPINDLE_CCW(rpm)) {
#if CNC_DIRECTION_PIN > -1
WRITE(CNC_DIRECTION_PIN, !CNC_DIRECTION_CW);
#endif
#if CNC_ENABLE_PIN > -1
WRITE(CNC_ENABLE_PIN, CNC_ENABLE_WITH);
#endif
}
HAL::delayMilliseconds(CNC_WAIT_ON_ENABLE);
}
As you see you can do this in a custom routine EVENT_SPINDLE_CCW that return false. Then you can do it. Problem is that most timers are in use for controlling motors/temperatures/servos/beeper/software pwm. So you need to use timer 4 or 5 on the arduino with a matching pin as output. If pwm frequency does not matter you can use analogWrite to set it.
2) Best is to use reset pin for immediate stop. There is no function to remember position for offline prints so that would not help anyway if you use the internal function. There is a kill action you can put on a key that you configure if you want software solution but it is always slower and no real gain to reset button.
3) Not sure what you want here. Just connect to a end stop pin and configure firmware with that pin.
You can use it for autoleveling if you have no z min endstop (so z min endstop and z probe pin are identical) or if you home to z max instead.
With G30 you can also use it to probe material height and make that Z=0 - see G30 description in repetier.ino:
- G30 P<0..3> - Single z-probe at current position P = 1 first measurement, P =
2 Last measurement P = 0 or 3 first and last measurement
- G30 H<height> R<offset> Make probe define new Z and z offset (R) at trigger
point assuming z-probe measured an object of H height.