grbl for GT2560 Rev A

Hello, in that version of GRBL-5x I put the pwm pin on pin 44 of the Mega. If you want to change the pwm pin you just have to change it in cpu_map.h.

In your board pwm fan is on PH4 (D7- Timer T4B), you can change this here:

//Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board
#define SPINDLE_TCCRA_REGISTER TCCR5A
#define SPINDLE_TCCRB_REGISTER TCCR5B
#define SPINDLE_OCR_REGISTER OCR5C —> OCR4B
#define SPINDLE_COMB_BIT COM5C1

// 1/8 Prescaler, 16-bit Fast PWM mode
#define SPINDLE_TCCRA_INIT_MASK ((1<<WGM40) | (1<<WGM41))
#define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS41))
#define SPINDLE_OCRA_REGISTER OCR5A // 16-bit Fast PWM mode requires top reset value stored here.
#define SPINDLE_OCRA_TOP_VALUE 0x0400 // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.

// Define spindle output pins.
#define SPINDLE_PWM_DDR DDRL —>DDRH
#define SPINDLE_PWM_PORT PORTL —> PORTH
#define SPINDLE_PWM_BIT 5 —> 4

It should work.

1 Like

In the board that I use (GT2560) I want to use hotebed pwm, is the physical pin 1 (D4), changes are below but still not working…

#define SPINDLE_PWM_MAX_VALUE 255 // Translates to about 1.9 kHz PWM frequency at 1/8 prescaler
#ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
#define SPINDLE_PWM_OFF_VALUE 0
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)

//Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board
#define SPINDLE_TCCRA_REGISTER TCCR5A
#define SPINDLE_TCCRB_REGISTER TCCR5B
#define SPINDLE_OCR_REGISTER OCR0B //OCR5C ***********************
#define SPINDLE_COMB_BIT COM5C1

// 1/8 Prescaler, 16-bit Fast PWM mode
#define SPINDLE_TCCRA_INIT_MASK ((1<<WGM40) | (1<<WGM41))
#define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS41))
#define SPINDLE_OCRA_REGISTER OCR5A // 16-bit Fast PWM mode requires top reset value stored here.
#define SPINDLE_OCRA_TOP_VALUE 255 // 0x0400 // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.

// Define spindle output pins.
#define SPINDLE_PWM_DDR DDRG //DDRL ****************************
#define SPINDLE_PWM_PORT DDRG //PORTL ****************************
#define SPINDLE_PWM_BIT 5 // MEGA2560 Digital Pin 44

What am I missing here? Should I change something in “Define spindle enable and spindle direction output pins” section?

In this scheme it indicates the ports and numbers that correspond to each pin. For D4 it would be PG5 and the timer that controls that PWM output is the T0B. As I indicated in the previous post you must change these values.

It should look like this:

//Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board
#define SPINDLE_TCCRA_REGISTER TCCR5A
#define SPINDLE_TCCRB_REGISTER TCCR5B
#define SPINDLE_OCR_REGISTER OCR0B ///////////////
#define SPINDLE_COMB_BIT COM0B1 ////////////////

// 1/8 Prescaler, 16-bit Fast PWM mode
#define SPINDLE_TCCRA_INIT_MASK ((1<<WGM40) | (1<<WGM41))
#define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS41))
#define SPINDLE_OCRA_REGISTER OCR5C // 16-bit Fast PWM mode requires top reset value stored here.
#define SPINDLE_OCRA_TOP_VALUE 0x0400 // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.

// Define spindle output pins.
#define SPINDLE_PWM_DDR DDRG ////////////
#define SPINDLE_PWM_PORT PORTG ////////////
#define SPINDLE_PWM_BIT 5 // MEGA2560 Digital Pin 4

It should work.

1 Like

I found an error on my assignments but still not working… I have this pinout also, for GT2560 and is the same like yours.

Maybe the problem is in the values in previous section of cpu_map file? I just copy the file just to check, I dont know what else could I do …

#ifdef CPU_MAP_GT2560_REV_A // (Arduino Mega 2560) with GT2560 Rev. A Board
#include “nuts_bolts.h”

// Serial port interrupt vectors
#define SERIAL_RX USART0_RX_vect
#define SERIAL_UDRE USART0_UDRE_vect

// Define ports and pins
#define DDR(port) DDR##port
#define _DDR(port) DDR(port)
#define PORT(port) PORT##port
#define _PORT(port) PORT(port)
#define PIN(pin) PIN##pin
#define _PIN(pin) PIN(pin)

// Define step pulse output pins.

#define STEP_PORT_0 A
#define STEP_PORT_1 C
#define STEP_PORT_2 C
#if N_AXIS > 3
#define STEP_PORT_3 L // Axis number 4 (Ramps E0)
#endif
#if N_AXIS > 4
#define STEP_PORT_4 L // Axis number 5 (Ramps E1)
#endif
#if N_AXIS > 5
#define STEP_PORT_5 L // Axis number 6 (Ramps Aux-3 D49)
#endif
#define STEP_BIT_0 3 // X Step
#define STEP_BIT_1 6 // Y Step
#define STEP_BIT_2 0 // Z Step
#if N_AXIS > 3
#define STEP_BIT_3 6 // Axis number 4 Step
#endif
#if N_AXIS > 4
#define STEP_BIT_4 0 // Axis number 5 Step
#endif
#if N_AXIS > 5
#define STEP_BIT_5 0 // Axis number 6 Step
#endif
#define STEP_BIT(i) STEP_BIT##i
#define STEP_BIT(i) _STEP_BIT(i)
#define STEP_DDR(i) DDR(STEP_PORT##i)
#define _STEP_PORT(i) PORT(STEP_PORT##i)
#define STEP_PORT(i) _STEP_PORT(i)
#define STEP_PIN(i) PIN(STEP_PORT##i)

// Define step direction output pins.
#define DIRECTION_PORT_0 A // X_Dir
#define DIRECTION_PORT_1 C // Y_Dir
#define DIRECTION_PORT_2 G // Z_Dir
#if N_AXIS > 3
#define DIRECTION_PORT_3 L // Axis number 4 E0_Dir
#endif
#if N_AXIS > 4
#define DIRECTION_PORT_4 L // Axis number 5 E1_Dir
#endif
#if N_AXIS > 5
#define DIRECTION_PORT_5 B // Axis number 6 (Ramps Aux-3 D51)
#endif
#define DIRECTION_BIT_0 1 // X Dir
#define DIRECTION_BIT_1 4 // Y Dir
#define DIRECTION_BIT_2 2 // Z Dir
#if N_AXIS > 3
#define DIRECTION_BIT_3 4 // Axis number 4 Dir - Pin D28
#endif
#if N_AXIS > 4
#define DIRECTION_BIT_4 2 // Axis number 5 Dir - Pin D34
#endif
#if N_AXIS > 5
#define DIRECTION_BIT_5 2 // Axis number 6 Dir - Pin D51
#endif
#define DIRECTION_BIT(i) DIRECTION_BIT##i
#define DIRECTION_BIT(i) _DIRECTION_BIT(i)
#define DIRECTION_DDR(i) DDR(DIRECTION_PORT##i)
#define _DIRECTION_PORT(i) PORT(DIRECTION_PORT##i)
#define DIRECTION_PORT(i) _DIRECTION_PORT(i)
#define DIRECTION_PIN(i) PIN(DIRECTION_PORT##i)

// Define stepper driver enable/disable output pin.
#define STEPPER_DISABLE_PORT_0 A
#define STEPPER_DISABLE_PORT_1 A
#define STEPPER_DISABLE_PORT_2 C
#if N_AXIS > 3
#define STEPPER_DISABLE_PORT_3 G // Axis number 4 (Ramps E0)
#endif
#if N_AXIS > 4
#define STEPPER_DISABLE_PORT_4 L // Axis number 5 (Ramps E1)
#endif
#if N_AXIS > 5
#define STEPPER_DISABLE_PORT_5 B // Axis number 5 (Ramps Aux-3 D53)
#endif
#define STEPPER_DISABLE_BIT_0 5 // X Enable - Pin D38
#define STEPPER_DISABLE_BIT_1 7 // Y Enable - Pin A2
#define STEPPER_DISABLE_BIT_2 2 // Z Enable - Pin A8
#if N_AXIS > 3
#define STEPPER_DISABLE_BIT_3 0 // Axis number 4 Step - Pin D24
#endif
#if N_AXIS > 4
#define STEPPER_DISABLE_BIT_4 1 // Axis number 5 Step - Pin D30
#endif
#if N_AXIS > 5
#define STEPPER_DISABLE_BIT_5 0 // Axis number 5 Step - Pin D53
#endif
#define STEPPER_DISABLE_BIT(i) STEPPER_DISABLE_BIT_##i
#define STEPPER_DISABLE_DDR(i) DDR(STEPPER_DISABLE_PORT##i)
#define STEPPER_DISABLE_PORT(i) PORT(STEPPER_DISABLE_PORT##i)
#define STEPPER_DISABLE_PIN(i) PIN(STEPPER_DISABLE_PORT##i)

// Define homing/hard limit switch input pins and limit interrupt vectors.
#define MIN_LIMIT_PORT_0 H
#define MIN_LIMIT_PORT_1 H
#define MIN_LIMIT_PORT_2 H
#if N_AXIS > 3
#define MIN_LIMIT_PORT_3 H
#endif
#if N_AXIS > 4
#define MIN_LIMIT_PORT_4 H
#endif
#if N_AXIS > 5
#define MIN_LIMIT_PORT_5 F // (Ramps Aux-1 D57)
#endif
#define MIN_LIMIT_BIT_0 7 // X Limit Min - Random (no known mapping)
#define MIN_LIMIT_BIT_1 7 // Y Limit Min - Random (no known mapping)
#define MIN_LIMIT_BIT_2 7 // Z Limit Min - Random (no known mapping)
#if N_AXIS > 3
#define MIN_LIMIT_BIT_3 7 // Axis number 4 : Random (no known mapping)
#endif
#if N_AXIS > 4
#define MIN_LIMIT_BIT_4 7 // Axis number 5 : Random (no known mapping)
#endif
#if N_AXIS > 5
#define MIN_LIMIT_BIT_5 3 // Axis number 6 : RAMPS AUX2 pin D57
#endif
#define MIN_LIMIT_BIT(i) MIN_LIMIT_BIT##i
#define MIN_LIMIT_BIT(i) _MIN_LIMIT_BIT(i)
#define MIN_LIMIT_DDR(i) DDR(MIN_LIMIT_PORT##i)
#define MIN_LIMIT_PORT(i) PORT(MIN_LIMIT_PORT##i)
#define MIN_LIMIT_PIN(i) PIN(MIN_LIMIT_PORT##i)
#define MAX_LIMIT_PORT_0 A
#define MAX_LIMIT_PORT_1 A
#define MAX_LIMIT_PORT_2 C
#if N_AXIS > 3
#define MAX_LIMIT_PORT_3 A
#endif
#if N_AXIS > 4
#define MAX_LIMIT_PORT_4 A
#endif
#if N_AXIS > 5
#define MAX_LIMIT_PORT_5 F // (Ramps Aux-3 D58)
#endif
#define MAX_LIMIT_BIT_0 0 // X Limit Max - X_Min
#define MAX_LIMIT_BIT_1 4 // Y Limit Max - Y_Min
#define MAX_LIMIT_BIT_2 5 // Z Limit Max - Z_Max
#if N_AXIS > 3
#define MAX_LIMIT_BIT_3 2 // Axis number 4 : X_Max
#endif
#if N_AXIS > 4
#define MAX_LIMIT_BIT_4 6 // Axis number 5 : Y_Max
#endif
#if N_AXIS > 5
#define MAX_LIMIT_BIT_5 4 // Axis number 6 : RAMPS AUX2 pin D58
#endif
#define MAX_LIMIT_BIT(i) MAX_LIMIT_BIT##i
#define MAX_LIMIT_BIT(i) _MAX_LIMIT_BIT(i)
#define MAX_LIMIT_DDR(i) DDR(MAX_LIMIT_PORT##i)
#define MAX_LIMIT_PORT(i) PORT(MAX_LIMIT_PORT##i)
#define MAX_LIMIT_PIN(i) PIN(MAX_LIMIT_PORT##i)

// #define LIMIT_INT PCIE0 // Pin change interrupt enable pin
// #define LIMIT_INT_vect PCINT0_vect
// #define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
// #define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)) // All limit bits
#define DISABLE_HW_LIMITS_INTERUPT

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_DDR DDRG
#define SPINDLE_ENABLE_PORT PORTG
#define SPINDLE_ENABLE_BIT 5 // MEGA2560 Digital Pin 4 - Ramps 1.4 Servo 4 Signal pin (D4)
#define SPINDLE_DIRECTION_DDR DDRE
#define SPINDLE_DIRECTION_PORT PORTE
#define SPINDLE_DIRECTION_BIT 3 // MEGA2560 Digital Pin 5 - Ramps 1.4 Servo 3 Signal pin (D5)

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_DDR DDRE
#define COOLANT_FLOOD_PORT PORTE
#define COOLANT_FLOOD_BIT 4 // MEGA2560 Digital Pin 10 - HEAT-0
#define COOLANT_MIST_DDR DDRE
#define COOLANT_MIST_PORT PORTE
#define COOLANT_MIST_BIT 5 // MEGA2560 Digital Pin 9 - HEAT-1

// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR DDRK
#define CONTROL_PIN PINK
#define CONTROL_PORT PORTK
#define CONTROL_RESET_BIT 1 // Pin A9 - RAMPS Aux 2 Port
#define CONTROL_FEED_HOLD_BIT 2 // Pin A10 - RAMPS Aux 2 Port
#define CONTROL_CYCLE_START_BIT 3 // Pin A11 - RAMPS Aux 2 Port
#define CONTROL_SAFETY_DOOR_BIT 4 // Pin A12 - RAMPS Aux 2 Port
#define CONTROL_INT PCIE2 // Pin change interrupt enable pin
#define CONTROL_INT_vect PCINT2_vect
#define CONTROL_PCMSK PCMSK2 // Pin change interrupt register
#define CONTROL_MASK ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))

// Define probe switch input pin.
#define PROBE_DDR DDRC
#define PROBE_PIN PINC
#define PROBE_PORT PORTC
#define PROBE_BIT 7 // GT2560 Rev A Z_Min(30)
#define PROBE_MASK (1<<PROBE_BIT)

// Advanced Configuration Below You should not need to touch these variables
// Set Timer up to use TIMER5B which is attached to Digital Pin 44 - Ramps 1.4 AUX-2
#define SPINDLE_PWM_MAX_VALUE 255 // Translates to about 1.9 kHz PWM frequency at 1/8 prescaler
#ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
#define SPINDLE_PWM_OFF_VALUE 0
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)

//Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board
#define SPINDLE_TCCRA_REGISTER TCCR5A
#define SPINDLE_TCCRB_REGISTER TCCR5B
#define SPINDLE_OCR_REGISTER OCR0B //OCR5C ***********************
#define SPINDLE_COMB_BIT COM0B1 //COM5C1

// 1/8 Prescaler, 16-bit Fast PWM mode
#define SPINDLE_TCCRA_INIT_MASK ((1<<WGM40) | (1<<WGM41))
#define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS41))
#define SPINDLE_OCRA_REGISTER OCR5C //A // 16-bit Fast PWM mode requires top reset value stored here.
#define SPINDLE_OCRA_TOP_VALUE 255 // 0x0400 // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.

// Define spindle output pins.
#define SPINDLE_PWM_DDR DDRG //DDRL ****************************
#define SPINDLE_PWM_PORT PORTG //PORTL ****************************
#define SPINDLE_PWM_BIT 5 // MEGA2560 Digital Pin 44

#endif

#endif

Hello, I think you have not understood me, I modified this file to adapt GRBL 5x to our MPCNC wiring (Marlin wiring), then John adapted my code to work on your board (GT2560 -ver-A), but this part of the code is unmodified .
Change the values that I indicated in the previous post and try it.

P.D. Your board is basically an integration RAMPS + Arduino Mega, so it share the pinout with the arduino mega.

Hello again,
Sorry for my insist, I have just basic knowledge to change things in the file. I test the values that you suggest but nothing happens. I tried also to change another pin to drive the laser (in my schematic pwm1 with proper values in your suggestion lines), but in M3-M5 commands, the laser pin pwm3 (not pwm1!) still power on and off the laser at full power only
It seems that is ignoring pwm function in general.

“It seems that is ignoring pwm function in general.”

and in this section is the proof!

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_DDR DDRG
#define SPINDLE_ENABLE_PORT PORTG
#define SPINDLE_ENABLE_BIT 5 // MEGA2560 Digital Pin 4 - Ramps 1.4 Servo 4 Signal pin (D4)

What else could I try?

You are my last hope before break my board! :disappointed_relieved:

Hi, you have to modify only the lines that I have indicated. You have modified SPINDLE_ENABLE. But you have to modify SPINDLE_PWM.

I did it already but nothing. Beside this SPINDLE_ENABLE and SPINDLE_PWM have the same pin and port.

ENABLE and PWM can’t have the same pin, put the old bit and port in SPINDKE_ENABLE.

Nothing…

I followed all the instructions you gave me. I assume that something is not the same among 2560+RAMPS and GT2560

I’m sorry, I can’t help you.

Final result: Every try modifying firmware to use bed pin, heater 1 pin or heater 2 pin for laser pin assignment failured. So, without any change from the original firmware from Soren, I use the physical pin 40 on the chip (hard to solder in this mainboard, done with microscope), and everything works fine!
Thank you all for your help.

1 Like

Do you know if this will work with later revisions of the GT2560? such as the v3 or v4. I believe the pin out between v3 and 4 are the same but dont know about earlier versions.

hi i have a similar problem of ksdfpr i have a gt2560 rev A. i need to check the laser output in pwm but 5v can someone help me?