CUSTOM GRBL PINOUT FOR CUSTOM GRBL BOARD - Page 1
Forum section: electronics / projects

author: SebastianEspende
author_rank: Newbie
timestamp: December 09, 2024, 01:15:08 am
content: Hi, im a student from Argentina. Im looking to modify grbl to suit my needs for making my own GRBL Board for Arduino Uno.Im having a problem with changing the pins on the cpu_map.Basically i've already made my own board which pins are not setup the way grbl boards are setup normally, this isnt a thing i've done on purpose its just i didnt know enough when making the board.GRBL Pinout works by using Port groups, which you can see when checking the arduino uno pinout, the problem is my board does not do this.How can i modify the code to make it so that i can set any pin i want?Before anyone tells me to just buy a standard GRBL Board, i cant, this is part of my final project for my secondary school, which requires me to make my own, and im a bit short on time to make a new one with the correct pin arrangement.Here is what i would like the pinout to beX_STEP_BIT to be pin 12Y_STEP_BIT to be pin 11Z_STEP_BIT to be pin 3X_DIR_BIT to be pin 13Y_DIR_BIT to be pin 10Z_DIR_BIT to be pin 2Here is how its currently setup by default on the cpu_map:Code:// Define step pulse output pins. NOTE: All step bit pins must be on the same port.#define STEP_DDR DDRD#define STEP_PORT PORTD#define X_STEP_BIT 2 // Uno Digital Pin 2#define Y_STEP_BIT 3 // Uno Digital Pin 3#define Z_STEP_BIT 4 // Uno Digital Pin 4#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits// Define step direction output pins. NOTE: All direction pins must be on the same port.#define DIRECTION_DDR DDRD#define DIRECTION_PORT PORTD#define X_DIRECTION_BIT 5 // Uno Digital Pin 5#define Y_DIRECTION_BIT 6 // Uno Digital Pin 6#define Z_DIRECTION_BIT 7 // Uno Digital Pin 7#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bitsAny help is apreciated, thanks.Please dont be mean

author: SebastianEspende
author_rank: Newbie
timestamp: December 09, 2024, 01:22:15 am
content: im new to this forum, have i posted this on the wrong place?Should it be on the microcontrollers tab?

author: moffy
author_rank: Super Contributor
timestamp: December 09, 2024, 02:17:10 am
content: I don't think you can do that, because the groups e.g. X,Y,Z Direction; X,Y,Z Step etc. are coded at quite a low level in the standard GRBL, it would require a significant rewrite of the code and be a performance hit. However GRBLHal:https://github.com/grblHALis a rewrite of GRBL that can basically do what you ask, but I don't think it would run on the UNO, not enough program space, GRBL barely fits as is in the UNO, also the hardware abstraction has quite a performance hit as it is really meant for faster processors e.g. ARM etc.

author: abeyer
author_rank: Frequent Contributor
timestamp: December 09, 2024, 02:25:00 am
content: Can you just cut some traces and bodge the connections on your board? That seems like the simpler fix here.

author: Ian.M
author_rank: Super Contributor
timestamp: December 09, 2024, 02:38:20 am
content: GRBL's stepper pin handling is (mostly) in stepper.c. ATmega328P Port D was chosen because it had six free GPIOs, enough for three axes, the UART on PD0:1 wouldn't conflict,, and it didn't tie up any peripherals needed elsewhere in the GRBL code. If you wanted to remap those pins as you propose, you'd have to rewrite stepper.c to split the pins across multiple ports which would have knock-on effects on the code size and ISR execution time, and you'd have to be very careful to avoid disrupting other inputs and outputs which would then share a port with a stepper pin.Chamnit, the lead maintainer of the GRBL project reckons it isn't possible:https://github.com/gnea/grbl/issues/325If you are a more experienced and skilled AVR developer than Chamnit, you may have a chance, but its weeks or months of work with no guarantee of success. However if you had the skills you wouldn't be asking how to do it here!For the rest of us, if faced with a MCU pin allocation f.up with a tight deadline without time for a new PCB, we'd start cutting tracks and fitting bodge-wires to rearrange the pins to meet the existing firmware constraints. Done right, it doesn't even look too bad!Good luck - you are going to need it . . .

author: SebastianEspende
author_rank: Newbie
timestamp: December 09, 2024, 07:48:45 am
content: Well im certainly not a better developer than Chamnit so, i guess ill be cutting traces tomorrow, thank you guys for the nice answers!

author: phil from seattle
author_rank: Super Contributor
timestamp: December 10, 2024, 01:53:12 am
content: A suggestion - take a look atgrblHAL. It is the 32 bit version of Grbl and runs on all sorts of32 bit ARM chips. If you are familiar with Grbl, grblHAL will be very easy. There are a number of advantages to this approach: faster chips, more RAM/Flash, more flexibility, currently in active development. The developer is approachable and very helpful. The ARM chips aren't maxed out like the ATMega. In particular, I would look at STM32F4xx or the RasPi RP2040 (Pico). Both are plentiful and cost less than the ATMega chips do. If you pick the right pinout, you could use thegrblHAL Web Builderto build your firmware binary. The web builder will give you the pin mappings for any board you select. The RasPi RP2040 doesn't require any special hardware or software to load the firmware - just a USB cable. You could prototype with a Pico which is $4 USD.FWIW I make and sell a grblHAL breakout board based on the Pico used for a number of different CNC machines including Mills, Router and Lathes. It's a 2 layer board.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: December 14, 2024, 10:53:26 am
content: These look like arduino pin numbers. (Yuch).Quote from: SebastianEspende on December 09, 2024, 01:15:08 amWhile these very likely are the real register names and pins of the controller itself, and the comment "// Uno Digital Pin 2" is a lie. "Arduino pin numbers" can not be shifted and added in the way as in#define STEP_MASKwhile this is the way to do it with the hardware register and pin names.Quote from: SebastianEspende on December 09, 2024, 01:15:08 am