Spindle control PWM output pin. etc.

I'm trying to adjust Repetier firmware for CNC 3018 milling (offline mode).

1) I already configured D4 and D5 pins for discrete on/off spindle switching by M-commands.

Now I’m trying to provide spindle speed conrol PWM output to pin D6 according to this code: M03 S125?

I did not found any line in the TOOLS menu, which allow me to set spindle PWM to this pin.

I also tried to find this PWM output Pin in the sketches texts, but without success.

Please inform how to do spindle PWM output to D6 pin?

 2) How to provide emergency E-stop button in the RAMPS 1.4 board? What line of Repetier Firmware configurator allow to assign pin for this button? If for example, CNC works in offline mode and cutter/engraver broke. I push E-stop. Is it possible to remember tool position before E-stop pushing and come several lines back? Maybe under Repetier Host only?

 3) Please inform how to connect and use Z-probe with RAMPS 1.4? Does it work in manual table height sensing mode or auto leveling also? I need some manual for Z-probe use.






Comments

  • 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);
    #if CNC_ENABLE_PIN > -1
    WRITE(CNC_ENABLE_PIN, CNC_ENABLE_WITH);
    }
    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);
    #if CNC_ENABLE_PIN > -1
    WRITE(CNC_ENABLE_PIN, CNC_ENABLE_WITH);
    }
    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.
  • Repetier said:
    1) PWM control is not implemented also the speed is send to the driver function.
    ......................................................
    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.
    CNC mill does not use bed and hotend heaters. Is it possible to use them as PWM channels for spindle or PCB cooler speed control? I mean the same:



    Repetier said:

    2) Best is to use reset pin for immediate stop.
    The result will be the same like switch OFF power control for whole printer. Is it possible to create "Pause" button that will stop work without losing information. After PAUSE pressing, use manual axis movements  and go outside. Then install a new cutter and press "resume". The cutter will return to its original location and continue work.
    Do you have such actions? Maybe online work under Repeater Host is able to do it or even come several lines back in the program?







  • The fans and heaters use software PWM with normally 15Hz. With reduced precision it can be increased to 64Hz. Not sure if that is enough for the spindle controller. You can make it a fan and control it with M106/M107.

    In ui.h you see all the actions you can put on buttons.
    #define UI_ACTION_SD_PRINT 1013
    #define UI_ACTION_SD_PAUSE 1014

    Is what you want. You can assign it a custom key connected. A paused print can be continued. There is also a park position that is assumed when you hit pause. Make sure to raise Z before moving. For FDM not required but if you are cutting it would be bad.
  • Many thanks for your help. I will try to do experiments and build custom design.

Sign In or Register to comment.