Spindle control for cnc milling using Repetier

I'm not new to using Repetier-Host for printing, but I'm very new to using it as a cnc mill.
I am using a router which has a controller compatible with Mach3 PWM.  The PWM has two electrical connections, GND and PMW. 

I have no idea where to start to make this compatible with Repetier.  Can Repetier send a PWM signal to the router controller and not step/dir, and if so, how would I do this?

Comments

  • Hi,

    latest repetier-firmware allows it to write events to control. The basic cnc code implemented has only enable and direction signal. So you need to extend it using the event system and create the pwm signals on your own, so I hope you have some programming skills or someone else does this. PWMs are quite troulesome as every board has different pins with different pwm timers and firmware uses internally also timers 0-2(3 for sound). So not all pins can be used for hardware pwm.
  • Thank you for your reply.  I am using a RUMBA and possibly the pwm for the 3rd extruder heater can be used but it sounds like trying to integrate this with Repetier is way more trouble than it's worth at the moment.  possibly in the future.
  • Most will use it with a cheaper mill, that can only handle on/off and that works and is enough. This was never meant to replace real cnc mills, which can do way more complex things then you do with a printer.
  • Thank you again for your help!

    I very much appreciate it.  This has been very helpful.

    I have a follow-up question I posted as a new discussion, "Clarification needed on "High Pin Enables" when setting up Laser/CNC in Repetier firmware".  Which I could use some help on.

    As an aside, you would be VERY surprised what a basic CNC can do.  I use a Bridgeport BOSS 6 made in 1979, and it's a brute.  It's also very stupid.  It's CPU is much less capable than the RUMBA board and it uses a completely manual speed control, no z probe, etc.  Yet I can make fantastic things with it.  I expect Repetier will be even better!
  • Thank you for your reply.  I am using a RUMBA and possibly the pwm for the 3rd extruder heater can be used but it sounds like trying to integrate this with Repetier is way more trouble than it's worth at the moment.  possibly in the future.
    I have successfully  tested the PWM on Marlin using the 3rd extruder, but I much prefer Repetier, code is clean and organised. I however cannot find any information on even the enable/direction pins? Did you manage to solve the problem?

  • Thank you for your reply.  I am using a RUMBA and possibly the pwm for the 3rd extruder heater can be used but it sounds like trying to integrate this with Repetier is way more trouble than it's worth at the moment.  possibly in the future.
    Its working rather nicely, I had to do the following steps.

    1. Fix RUMBA pin definitions to get HE0,1,2 and HB on the right PWM channels
    2. Configure HE2 as a PWM THERMO_FAN with configuration tool.
    3. In EXTRUDER.cpp substitute spindleSpeed instead of T2 in HE2 control loop.
    4. In DRIVERS.cpp modified quite a bit but nothing to do with the CNC PWM control purely buggy as spindleSpeed     and RPM didnt always update after a M3,M40 Sxxx or M5 command

    /***********   DJC MODIFIED ****************************/

    void CNCDriver::spindleOff()
    {
        spindleRpm=0;
        spindleSpeed=0;
        if(direction == 0) return; // already off
        if(EVENT_SPINDLE_OFF){
          #if CNC_ENABLE_PIN > -1
            WRITE(CNC_ENABLE_PIN,!CNC_ENABLE_WITH);
          #endif
        }
        HAL::delayMilliseconds(CNC_WAIT_ON_DISABLE);
    direction = 0;
    }
    /** 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_CW(rpm)
    */

    void CNCDriver::spindleOnCW(int32_t rpm)
      if  (rpm > CNC_RPM_MAX)
        rpm=CNC_RPM_MAX;
     
      spindleSpeed=map(rpm,0,CNC_RPM_MAX,0,CNC_PWM_MAX);  // linear interpolation
      spindleRpm=rpm;                                     // for display
      if(direction == 1)
            return;
        // 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)
    { if  (rpm > CNC_RPM_MAX)
        rpm=CNC_RPM_MAX;
      spindleSpeed=map(rpm,0,CNC_RPM_MAX,0,CNC_PWM_MAX);  // linear interpolation
      spindleRpm=rpm;                                     // for display
      if(direction == -1)
          return;
      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);
    }

Sign In or Register to comment.