diff --git a/Makefile b/Makefile index 9bc5615..d825ee5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Part of Grbl # # Copyright (c) 2009-2011 Simen Svale Skogsrud -# Copyright (c) 2012 Sungeun K. Jeon +# Copyright (c) 2012-2015 Sungeun K. Jeon # # Grbl is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,9 +31,11 @@ DEVICE ?= atmega328p CLOCK = 16000000 PROGRAMMER ?= -c avrisp2 -P usb -OBJECTS = main.o motion_control.o gcode.o spindle_control.o coolant_control.o serial.o \ - protocol.o stepper.o eeprom.o settings.o planner.o nuts_bolts.o limits.o \ - print.o probe.o report.o system.o +SOURCE = main.c motion_control.c gcode.c spindle_control.c coolant_control.c serial.c \ + protocol.c stepper.c eeprom.c settings.c planner.c nuts_bolts.c limits.c \ + print.c probe.c report.c system.c +BUILDDIR = build +SOURCEDIR = grbl # FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m FUSES = -U hfuse:w:0xd2:m -U lfuse:w:0xff:m @@ -42,22 +44,24 @@ FUSES = -U hfuse:w:0xd2:m -U lfuse:w:0xff:m AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -B 10 -F COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -I. -ffunction-sections +OBJECTS = $(addprefix $(BUILDDIR)/,$(notdir $(SOURCE:.c=.o))) + # symbolic targets: all: grbl.hex -.c.o: +$(BUILDDIR)/%.o: $(SOURCEDIR)/%.c $(COMPILE) -c $< -o $@ - @$(COMPILE) -MM $< > $*.d + @$(COMPILE) -MM $< > $(BUILDDIR)/$*.d .S.o: - $(COMPILE) -x assembler-with-cpp -c $< -o $@ + $(COMPILE) -x assembler-with-cpp -c $< -o $(BUILDDIR)/$@ # "-x assembler-with-cpp" should not be necessary since this is the default # file type for the .S (with capital S) extension. However, upper case # characters are not always preserved on Windows. To ensure WinAVR # compatibility define the file type manually. -.c.s: - $(COMPILE) -S $< -o $@ +#.c.s: + $(COMPILE) -S $< -o $(BUILDDIR)/$@ flash: all $(AVRDUDE) -U flash:w:grbl.hex:i @@ -73,25 +77,25 @@ load: all bootloadHID grbl.hex clean: - rm -f grbl.hex main.elf $(OBJECTS) $(OBJECTS:.o=.d) + rm -f grbl.hex $(BUILDDIR)/* # file targets: -main.elf: $(OBJECTS) - $(COMPILE) -o main.elf $(OBJECTS) -lm -Wl,--gc-sections +$(BUILDDIR)/main.elf: $(OBJECTS) + $(COMPILE) -o $(BUILDDIR)/main.elf $(OBJECTS) -lm -Wl,--gc-sections -grbl.hex: main.elf +grbl.hex: $(BUILDDIR)/main.elf rm -f grbl.hex - avr-objcopy -j .text -j .data -O ihex main.elf grbl.hex - avr-size --format=berkeley main.elf + avr-objcopy -j .text -j .data -O ihex $(BUILDDIR)/main.elf grbl.hex + avr-size --format=berkeley $(BUILDDIR)/main.elf # If you have an EEPROM section, you must also create a hex file for the # EEPROM and add it to the "flash" target. # Targets for code debugging and analysis: disasm: main.elf - avr-objdump -d main.elf + avr-objdump -d $(BUILDDIR)/main.elf cpp: - $(COMPILE) -E main.c + $(COMPILE) -E $(SOURCEDIR)/main.c # include generated header dependencies --include $(OBJECTS:.o=.d) +-include $(BUILDDIR)/$(OBJECTS:.o=.d) diff --git a/README.md b/README.md index 1183789..1cfa679 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ _**Archives:**_ - **New Grbl SIMULATOR! (by @jgeisler and @ashelly):** A completely independent wrapper of the Grbl main source code that may be compiled as an executable on a computer. No Arduino required. Simply simulates the responses of Grbl as if it was on an Arduino. May be used for many things: checking out how Grbl works, pre-process moves for GUI graphics, debugging of new features, etc. Much left to do, but potentially very powerful, as the dummy AVR variables can be written to output anything you need. - **Configurable Real-time Status Reporting:** Users can now customize the type of real-time data Grbl reports back when they issue a '?' status report. This includes data such as: machine position, work position, planner buffer usage, serial RX buffer usage. - **Updated Homing Routine:** Sets workspace volume in all negative space regardless of limit switch position. Common on pro CNCs. But, the behavior may be changed by a compile-time option though. Now tied directly into the main planner and stepper modules to reduce flash space and allow maximum speeds during seeking. + - **CoreXY Support:** Grbl now supports CoreXY kinematics on an introductory-level. Most functions have been verified to work, but there may be bugs here or there. Please report any problems you find! + - **Full Limit and Control Pin Configurability:** Limits and control pins operation can now be interpreted by Grbl however you'd like, with the internal pull-up resistors enabled or disabled, or reading a high or low as a trigger. This should cover all wiring and NO or NC switch scenarios. - **Optional Limit Pin Sharing:** Limit switches can be combined to share the same pins to free up precious I/O pins for other purposes. When combined, users must adjust the homing cycle mask in config.h to not home the axes on a shared pin at the same time. Don't worry; hard limits and the homing cycle still work just like they did before. - **Optional Variable Spindle Speed Output:** Available only as a compile-time option through the config.h file. Enables PWM output for 'S' g-code commands. Enabling this feature will swap the Z-limit D11 pin and spindle enable D12 pin to access the hardware PWM on pin D12. The Z-limit pin, now on D12, should work just as it did before. - **Additional Compile-Time Feature Options:** Line number tracking, real-time feed rate reporting. @@ -68,6 +70,7 @@ List of Supported G-Codes in Grbl v0.9 - Distance Modes: G90, G91 - Plane Select Modes: G17, G18, G19 - Tool Length Offset Modes: G43.1, G49 + - Cutter Compensation Modes: G40 - Coordinate System Modes: G54, G55, G56, G57, G58, G59 - Program Flow: M0, M1, M2, M30* - Coolant Control: M7*, M8, M9 diff --git a/examples/Grbl/Grbl.ino b/examples/Grbl/Grbl.ino deleted file mode 100644 index caf26fd..0000000 --- a/examples/Grbl/Grbl.ino +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include diff --git a/config.h b/grbl/config.h similarity index 98% rename from config.h rename to grbl/config.h index 0a0d886..a5c7f4e 100644 --- a/config.h +++ b/grbl/config.h @@ -185,9 +185,10 @@ // needs to connect a normal-open switch, but if inverted, this means the user should connect a // normal-closed switch. // The following options disable the internal pull-up resistors, sets the pins to a normal-low -// operation, and switches much be now connect to Vcc instead of ground. This also flips the meaning +// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning // of the invert pin Grbl setting, where an inverted setting now means the user should connect a // normal-open switch and vice versa. +// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes. // WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors! //#define DISABLE_LIMIT_PIN_PULL_UP //#define DISABLE_PROBE_PIN_PULL_UP @@ -202,7 +203,7 @@ // enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled. // NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch! // The hardware PWM output on pin D11 is required for variable spindle output voltages. -// #define VARIABLE_SPINDLE // Default disabled. Uncomment to enable. +#define VARIABLE_SPINDLE // Default disabled. Uncomment to enable. // Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed // "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and diff --git a/coolant_control.c b/grbl/coolant_control.c similarity index 100% rename from coolant_control.c rename to grbl/coolant_control.c diff --git a/coolant_control.h b/grbl/coolant_control.h similarity index 100% rename from coolant_control.h rename to grbl/coolant_control.h diff --git a/cpu_map.h b/grbl/cpu_map.h similarity index 100% rename from cpu_map.h rename to grbl/cpu_map.h diff --git a/defaults.h b/grbl/defaults.h similarity index 100% rename from defaults.h rename to grbl/defaults.h diff --git a/eeprom.c b/grbl/eeprom.c similarity index 100% rename from eeprom.c rename to grbl/eeprom.c diff --git a/eeprom.h b/grbl/eeprom.h similarity index 100% rename from eeprom.h rename to grbl/eeprom.h diff --git a/grbl/examples/grblUpload/grblUpload.ino b/grbl/examples/grblUpload/grblUpload.ino new file mode 100644 index 0000000..581b6b3 --- /dev/null +++ b/grbl/examples/grblUpload/grblUpload.ino @@ -0,0 +1,29 @@ +/*********************************************************************** +This sketch compiles and uploads Grbl to your 328p-based Arduino! + +To use: +- First make sure you have imported Grbl source code into your Arduino + IDE. There are details on our Github website on how to do this. + +- Select your Arduino Board and Serial Port in the Tools drop-down menu. + NOTE: Grbl only officially supports 328p-based Arduinos, like the Uno. + Using other boards will likely not work! + +- Then just click 'Upload'. That's it! + +For advanced users: + If you'd like to see what else Grbl can do, there are some additional + options for customization and features you can enable or disable. + Navigate your file system to where the Arduino IDE has stored the Grbl + source code files, open the 'config.h' file in your favorite text + editor. Inside are dozens of feature descriptions and #defines. Simply + comment or uncomment the #defines or alter their assigned values, save + your changes, and then click 'Upload' here. + +Copyright (c) 2015 Sungeun K. Jeon +Released under the MIT-license. See license.txt for details. +***********************************************************************/ + +#include + +// Do not alter this file! diff --git a/grbl/examples/grblUpload/license.txt b/grbl/examples/grblUpload/license.txt new file mode 100644 index 0000000..1abcdb9 --- /dev/null +++ b/grbl/examples/grblUpload/license.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Sungeun K. Jeon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/gcode.c b/grbl/gcode.c similarity index 100% rename from gcode.c rename to grbl/gcode.c diff --git a/gcode.h b/grbl/gcode.h similarity index 100% rename from gcode.h rename to grbl/gcode.h diff --git a/grbl.h b/grbl/grbl.h similarity index 82% rename from grbl.h rename to grbl/grbl.h index 6295e7c..dc331bf 100644 --- a/grbl.h +++ b/grbl/grbl.h @@ -1,5 +1,5 @@ /* - grbl.h - include file + grbl.h - main Grbl include file Part of Grbl v0.9 Copyright (c) 2015 Sungeun K. Jeon @@ -18,13 +18,10 @@ along with Grbl. If not, see . */ -// NOTE: This is not used by the 'make' compiling method. This is currently only used for -// simplifying compiling through the Arduino IDE at the moment. However, it may eventually -// turn into a central include file for the overall system. - #ifndef grbl_h #define grbl_h +// Grbl versioning system #define GRBL_VERSION "0.9h" #define GRBL_VERSION_BUILD "20150210" @@ -41,7 +38,7 @@ #include #include -// Define the Grbl system include files. +// Define the Grbl system include files. NOTE: Do not alter organization. #include "config.h" #include "nuts_bolts.h" #include "settings.h" diff --git a/limits.c b/grbl/limits.c similarity index 99% rename from limits.c rename to grbl/limits.c index a8a2583..a8b2996 100644 --- a/limits.c +++ b/grbl/limits.c @@ -161,14 +161,14 @@ void limits_go_home(uint8_t cycle_mask) // Set target location for active axes and setup computation for homing rate. if (bit_istrue(cycle_mask,bit(idx))) { n_active_axis++; - if (!approach) { - // Set target direction based on cycle mask - if (bit_istrue(settings.homing_dir_mask,bit(idx))) { target[idx] += max_travel; } - else { target[idx] -= max_travel; } - } else { + if (approach) { // Set target direction based on cycle mask if (bit_istrue(settings.homing_dir_mask,bit(idx))) { target[idx] -= max_travel; } else { target[idx] += max_travel; } + } else { + // Set target direction based on cycle mask + if (bit_istrue(settings.homing_dir_mask,bit(idx))) { target[idx] += max_travel; } + else { target[idx] -= max_travel; } } } diff --git a/limits.h b/grbl/limits.h similarity index 100% rename from limits.h rename to grbl/limits.h diff --git a/main.c b/grbl/main.c similarity index 100% rename from main.c rename to grbl/main.c diff --git a/motion_control.c b/grbl/motion_control.c similarity index 100% rename from motion_control.c rename to grbl/motion_control.c diff --git a/motion_control.h b/grbl/motion_control.h similarity index 100% rename from motion_control.h rename to grbl/motion_control.h diff --git a/nuts_bolts.c b/grbl/nuts_bolts.c similarity index 100% rename from nuts_bolts.c rename to grbl/nuts_bolts.c diff --git a/nuts_bolts.h b/grbl/nuts_bolts.h similarity index 100% rename from nuts_bolts.h rename to grbl/nuts_bolts.h diff --git a/planner.c b/grbl/planner.c similarity index 100% rename from planner.c rename to grbl/planner.c diff --git a/planner.h b/grbl/planner.h similarity index 100% rename from planner.h rename to grbl/planner.h diff --git a/print.c b/grbl/print.c similarity index 100% rename from print.c rename to grbl/print.c diff --git a/print.h b/grbl/print.h similarity index 100% rename from print.h rename to grbl/print.h diff --git a/probe.c b/grbl/probe.c similarity index 100% rename from probe.c rename to grbl/probe.c diff --git a/probe.h b/grbl/probe.h similarity index 100% rename from probe.h rename to grbl/probe.h diff --git a/protocol.c b/grbl/protocol.c similarity index 100% rename from protocol.c rename to grbl/protocol.c diff --git a/protocol.h b/grbl/protocol.h similarity index 100% rename from protocol.h rename to grbl/protocol.h diff --git a/report.c b/grbl/report.c similarity index 100% rename from report.c rename to grbl/report.c diff --git a/report.h b/grbl/report.h similarity index 100% rename from report.h rename to grbl/report.h diff --git a/serial.c b/grbl/serial.c similarity index 100% rename from serial.c rename to grbl/serial.c diff --git a/serial.h b/grbl/serial.h similarity index 100% rename from serial.h rename to grbl/serial.h diff --git a/settings.c b/grbl/settings.c similarity index 100% rename from settings.c rename to grbl/settings.c diff --git a/settings.h b/grbl/settings.h similarity index 100% rename from settings.h rename to grbl/settings.h diff --git a/spindle_control.c b/grbl/spindle_control.c similarity index 100% rename from spindle_control.c rename to grbl/spindle_control.c diff --git a/spindle_control.h b/grbl/spindle_control.h similarity index 100% rename from spindle_control.h rename to grbl/spindle_control.h diff --git a/stepper.c b/grbl/stepper.c similarity index 100% rename from stepper.c rename to grbl/stepper.c diff --git a/stepper.h b/grbl/stepper.h similarity index 100% rename from stepper.h rename to grbl/stepper.h diff --git a/system.c b/grbl/system.c similarity index 100% rename from system.c rename to grbl/system.c diff --git a/system.h b/grbl/system.h similarity index 100% rename from system.h rename to grbl/system.h