Basic arduino grbl code question

Hi there, I’m newer to coding with the Arduino uno. Was able to download the gbrlUpload sketch from the link attached below , but when I attempted to upload it to the Arduino many warnings came back including: #define min(a,b) (((a) < (b)) ? (a) : (b)), #define min(a,b) ((a)<(b)?(a):(b)), #define bit(n) (1 << n), and #define bit(b) (1UL << (b)). Each warning displayed the location of the file that included the #define… As a result, when I open the serial monitor, no text is displayed except “⸮$⸮⸮”. Any help would be greatly appreciated.

I suggest you download GRBL from GRBL github. you will probably want to decide if you want dual homing or pwm spindle/laser.

v1.1h has dual homing but at the expense of disabling PWM for a spindle or laser on clone Arduino boards -
v1.1f has pwm for a laser or spindle but no dual homing.

These are pre-compiled .hex files for loading with XLoader. Info here.

1 Like

Warnings won’t stop the compiler (unless you have configured it to fail on any warning). So the short story is that you can just build it and ignore the warnings.

Long story:

Warnings are generally a good indication of a potential problem. I try to write code with zero warnings. But not everyone agrees with that. A lot of the warnings are not going to ever cause problems, so developers will ignore them after inspecting them. This is probably the case with grbl. Unless you have edited the code yourself. In that case, you need to look into any new warnings you’ve created.

The way macros and the C compiler work is that there is a step called a preprocessor. It removes comments, and replaces macros with the code, and does some other things. Any lines that start with # are preprocessor macros (like #define). They get executed in the preprocessor and then are gone, replaced with the code they were told to use.

The compiler then goes over the file and tries to check and convert the code to assembly and ultimately machine code. This is where it looks for warnings. But it doesn’t have knowledge of the files before the macros were processed, so it can’t point to the original lines. This is a good reason to not use macros. But embedded code needs to be small to run on these tiny devices and macros are a common way to keep it to the minimum size.

1 Like