Change spindle pwm pin in GRBL-Mega1.1

Results 1 to 4 of 4

Thread: Change spindle pwm pin in GRBL-Mega1.1

  1. #1
    Member dportero's Avatar
    Join Date
    Aug 2021
    Posts
    2
    Downloads
    0
    Uploads
    0

    Default Change spindle pwm pin in GRBL-Mega1.1

    Hello, long-time lurker here with a question that I cannot for the life of me solve on my own. I have been at this for a couple weeks now and I am hoping that I can solicit some help here.

    I have learned lots about GRBL in the past weeks, but most of it is thinks I was doing wrong and teaching me that I don't like the way grbl is supposed to be compiled, or how the pins are called out.

    I have a laser that I am wanting to control with pwm using the GRBL-Mega fork. I am using a MKS Gen L board, so the default pin 8 for PWM spindle control is too high of a voltage. My other problem is that pin 6 is also not working and therefore I need to switch to another PWM pin. I have Pin 11 free right now, but even if I switch the DDR and PORT to B and the PWM-Bit to 5, nothing happens on pin 11. I am assuming that it has something to do with the other lines above that make no sense to me.

    Does anyone have a good method or resource for changing the pins used in grbl? I would be forever indebted to you as this is a project for my wife and she is not happy that I cannot get it working.

    Thanks

    Similar Threads:


  2. #2
    Member
    Join Date
    Mar 2015
    Location
    Netherlands
    Posts
    409
    Downloads
    1
    Uploads
    0

    Default Re: Change spindle pwm pin in GRBL-Mega1.1

    I had a short look at the Grbl-Mega code
    void spindle_init()
    {
    // Configure variable spindle PWM and enable pin, if required.
    SPINDLE_PWM_DDR |= (1<<SPINDLE_PWM_BIT); // Configure as PWM output pin.
    SPINDLE_TCCRA_REGISTER = SPINDLE_TCCRA_INIT_MASK; // Configure PWM output compare timer
    SPINDLE_TCCRB_REGISTER = SPINDLE_TCCRB_INIT_MASK;
    SPINDLE_OCRA_REGISTER = SPINDLE_OCRA_TOP_VALUE; // Set the top value for 16-bit fast PWM mode
    SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
    SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.

    pwm_gradient = SPINDLE_PWM_RANGE/(settings.rpm_max-settings.rpm_min);
    spindle_stop();
    }
    It seems the PWM signal is generated by a hardware timer. The PWM pin can't be changed without changing the Timer.

    If the voltage level of the default pin is the only problem, use a level converter to solve this problem.
    https://www.sparkfun.com/products/12009



  3. #3
    Member dportero's Avatar
    Join Date
    Aug 2021
    Posts
    2
    Downloads
    0
    Uploads
    0

    Default Re: Change spindle pwm pin in GRBL-Mega1.1

    Unfortunately I would be converting 24V to 5V. So that level converter won't work.

    Do you have any idea if there are resources on how to change the timer to work with the changed pin? I know some arduino, but not this much.



  4. #4
    Member
    Join Date
    Mar 2015
    Location
    Netherlands
    Posts
    409
    Downloads
    1
    Uploads
    0

    Default Re: Change spindle pwm pin in GRBL-Mega1.1

    I googled your MKS Gen L board board. It seems to be a ramps compatible board and could run on grbl-mega or Marlin firmware. On my Mega board and ramps shield (1.4 & 1.6) the output is 12V because the ramps shield is powered by 12V!
    The proposed level converter can handle an input of 20V and a supply voltage of 50V


    - You could drive an optocoupler board (may need a resistor in series, depending of the optocoupler board) as level converter
    - You could solder a wire on the FET input than you have 5V PWM
    - You could power your board by 20V and use the proposed level converter

    If you google
    ramps pwm laser
    you can find more info for remapping pins for laser support



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Change spindle pwm pin in GRBL-Mega1.1

Change spindle pwm pin in GRBL-Mega1.1