## Bresenham's Algorithm & GRBL

Discussion about the arduino based g-code interpreter, grbl
GurneyHalleck
Posts: 22
Joined: Tue Mar 12, 2019 1:24 am
Location: Chicago - Southwest Suburbs

### Bresenham's Algorithm & GRBL

I've been trying to understand how the CAD and CAM software work. While learning how an SVG line is rendered onto a computer screen, I learned about Bresenham's Line Algorithm. I was really stumped when Bresenham is mentioned numerous times in the comments of GRBL's Stepper.c file.

I tried to find info on the web as to how Bresenham's Line Algorithm would be used with stepper motors, but found nothing on what is happening on the x & y axis as the algorithm plays out. I think I'm missing something fundamental, but Bresenham's Line Algorithm was developed as an efficient way to choose which pixels to light up when drawing a line on a computer screen. With stepper motors, I think we would need to know on which 'Shapeoko pixels' are the start and end points of the line segment. But the tool path would just plow through the corners of the intermediate 'pixels' (in my mind). You would just need the ratio of how many steps on the long axis before you step on the minor axis, which is where Bresenham comes in, I guess. (And, I'm ignoring AMASS for the moment, at my own peril, as it just confuses the issue for me right now.) Now, all my thinking is based on allowing simultaneous steps in the x & y axis. The most obvious example being a line at 45 degrees, where each step in x is matched by a step in y.

Is GRBL capable of moving each axis simultaneously?
Just purchased a Shapeoko 3.

Posts: 8583
Joined: Mon Apr 09, 2012 6:11 pm
Location: Pennsylvania --- south of the Turnpike, East of US-15
Contact:

### Re: Bresenham's Algorithm & GRBL

Yes, Grbl can move all three axes in unison --- you just have to come up with the code which will do so.

esp. see the commands G17, G18, and G19 at: https://wiki.shapeoko.com/index.php/G-Code
Shapeoko 3XL #0006 w/ Carbide Compact Router w/0.125″ and ¼″ Carbide 3D precision collets
Nomad 883 Pro #596 (bamboo)

GurneyHalleck
Posts: 22
Joined: Tue Mar 12, 2019 1:24 am
Location: Chicago - Southwest Suburbs

### Re: Bresenham's Algorithm & GRBL

Thanks! That's a big help in trying to understand what is happening internally.
Just purchased a Shapeoko 3.