diff --git a/config.h b/config.h
index db42f7e43..419a03e72 100644
--- a/config.h
+++ b/config.h
@@ -1,23 +1,20 @@
/*
config.h - compile time configuration
- Part of Grbl
+ Part of LasaurGrbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun K. Jeon
Copyright (c) 2011 Stefan Hechenberger
- Grbl is free software: you can redistribute it and/or modify
+ LasaurGrbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ LasaurGrbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
*/
#ifndef config_h
@@ -31,9 +28,9 @@
#define BAUD_RATE 9600
-#define LIMIT_OVERWRITE_DDR DDRD
-#define LIMIT_OVERWRITE_PORT PORTD
-#define LIMIT_OVERWRITE_BIT 7
+#define LIMITS_OVERWRITE_DDR DDRD
+#define LIMITS_OVERWRITE_PORT PORTD
+#define LIMITS_OVERWRITE_BIT 7
#define SENSE_DDR DDRD
#define SENSE_PORT PORTD
@@ -64,11 +61,13 @@
#define Z_DIRECTION_BIT 5
+#define SENSE_MASK ((1<
@@ -26,11 +28,10 @@ GNU General Public License for more details.
#include "gcode.h"
#include "config.h"
#include "serial.h"
-#include "input_control.h"
-#include "output_control.h"
+#include "io_control.h"
+#include "planner.h"
#include "stepper.h"
-
#define MM_PER_INCH (25.4)
#define NEXT_ACTION_NONE 0
@@ -303,7 +304,7 @@ uint8_t gcode_execute_line(char *line) {
gc.seek_rate, 0 );
break;
case NEXT_ACTION_HOMING_CYCLE:
- limits_homing_cycle();
+ stepper_homing_cycle();
// now that we are at the physical home
// zero all the position vectors
clear_vector(gc.position);
@@ -327,13 +328,13 @@ uint8_t gcode_execute_line(char *line) {
}
break;
case NEXT_ACTION_AIRGAS_DISABLE:
- planner_airgas_disable();
+ planner_control_airgas_disable();
break;
case NEXT_ACTION_AIR_ENABLE:
- planner_air_enable();
+ planner_control_air_enable();
break;
case NEXT_ACTION_GAS_ENABLE:
- planner_gas_enable();
+ planner_control_gas_enable();
break;
}
diff --git a/input_control.c b/input_control.c
deleted file mode 100644
index 58578fc83..000000000
--- a/input_control.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- limits.h - code pertaining to limit-switches and performing the homing cycle
- Part of Grbl
-
- Copyright (c) 2009-2011 Simen Svale Skogsrud
-
- Grbl is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Grbl is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
-*/
-
-#include
-#include
-#include "config.h"
-#include "stepper.h"
-#include "planner.h"
-#include "input_control.h"
-
-
-void limits_overwrite_disable();
-
-
-void limits_init() {
- LIMIT_DDR &= ~(LIMIT_MASK);
- LIMIT_PORT |= LIMIT_MASK; //activate pull-up resistors
-
- // define as output pin
- LIMIT_OVERWRITE_DDR |= 1<.
-*/
-
-#ifndef input_control_h
-#define input_control_h
-
-// initialize the limits module
-void limits_init();
-
-// perform the homing cycle
-void limits_homing_cycle();
-
-// dis/enable if controller can still
-// move while a limit switch is triggering
-void limits_overwrite_enable();
-void limits_overwrite_disable();
-
-#endif
\ No newline at end of file
diff --git a/main.c b/main.c
index 56348191c..3ed768bb8 100644
--- a/main.c
+++ b/main.c
@@ -1,21 +1,18 @@
/*
main.c - An embedded CNC Controller with rs274/ngc (g-code) support
- Part of Grbl
+ Part of LasaurGrbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
- Grbl is free software: you can redistribute it and/or modify
+ LasaurGrbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ LasaurGrbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
*/
#include
@@ -25,8 +22,7 @@
#include "config.h"
#include "planner.h"
#include "stepper.h"
-#include "input_control.h"
-#include "output_control.h"
+#include "io_control.h"
#include "gcode.h"
#include "serial.h"
@@ -34,13 +30,12 @@
int main() {
sei(); //enable interrupts
serial_init();
+ gcode_init();
planner_init();
stepper_init();
- laser_init();
- airgas_init();
- gcode_init();
- limits_init();
-
+ sense_init();
+ control_init();
+
while(true) {
gcode_process_line();
}
diff --git a/output_control.c b/output_control.c
deleted file mode 100644
index e08bd1ca2..000000000
--- a/output_control.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- output_control.c - high level interface for issuing motion commands
- Part of Grbl
-
- Copyright (c) 2009-2011 Simen Svale Skogsrud
- Copyright (c) 2011 Sungeun K. Jeon
- Copyright (c) 2011 Stefan hechenberger
-
- Grbl is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Grbl is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
-*/
-
-#include
-#include
-#include
-#include
-#include "config.h"
-#include "input_control.h"
-#include "output_control.h"
-#include "stepper.h"
-#include "planner.h"
-
-
-
-void laser_init() {
- // Setup Timer0 for a 31.25kH "phase correct PWM" wave (assuming a 16Mhz clock)
- // Timer0 can pwm either PD5 (OC0B) or PD6 (OC0A), we use PD6
- // TCCR0A and TCCR0B are the registers to setup Timer0
- // see chapter "8-bit Timer/Counter0 with PWM" in Atmga328 specs
- // OCR0A sets the duty cycle 0-255 corresponding to 0-100%
- DDRD |= (1 << DDD6); // set PD6 as an output
- OCR0A = 0; // set PWM to a 0% duty cycle
- TCCR0A |= (1 << COM0A1); // set non-inverting mode on OC0A, PD6, Arduino pin 6
- TCCR0A |= (1 << WGM00); // set phase correct PWM mode, has half the freq of fast PWM
- TCCR0B |= (1 << CS00); // prescaler to 1, PWMfreq = 16000/(2*256*1) = 31.25kH
-
- // Setup laser enable pin.
- // LASER_ENABLE_DDR |= (1 << LASER_ENABLE_BIT);
- // laser_enable();
-}
-
-void laser_enable() {
- // sinking the pin enables the laser
- // LASER_ENABLE_PORT &= ~(1<.
-*/
-
-#ifndef output_control_h
-#define output_control_h
-
-#include
-#include "config.h"
-#include "planner.h"
-#include "stepper.h"
-
-
-void laser_init();
-void set_laser_intensity(uint8_t intensity); //0-255 is 0-100%
-
-void airgas_init();
-void airgas_disable();
-void air_enable();
-void gas_enable();
-
-
-#endif
diff --git a/planner.c b/planner.c
index 5bec02462..640be67f7 100644
--- a/planner.c
+++ b/planner.c
@@ -1,26 +1,22 @@
/*
planner.c - buffers movement commands and manages the acceleration profile plan
- Part of Grbl
+ Part of LasaurGrbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun K. Jeon
-
- Grbl is free software: you can redistribute it and/or modify
+ Copyright (c) 2011 Stefan Hechenberger
+
+ LasaurGrbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ LasaurGrbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
*/
-/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */
-
#include
#include
#include
diff --git a/planner.h b/planner.h
index 4078dab50..d97d0d2aa 100644
--- a/planner.h
+++ b/planner.h
@@ -1,24 +1,23 @@
/*
- planner.h - buffers movement commands and manages the acceleration profile plan
- Part of Grbl
+ planner.c - buffers movement commands and manages the acceleration profile plan
+ Part of LasaurGrbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
- Copyright (c) 2011 Sungeun K. Jeon
+ Copyright (c) 2011 Sungeun K. Jeon
+ Copyright (c) 2011 Stefan Hechenberger
- Grbl is free software: you can redistribute it and/or modify
+ LasaurGrbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ LasaurGrbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
*/
+
#ifndef planner_h
#define planner_h
@@ -33,9 +32,9 @@
#define TYPE_GAS_ENABLE 4
#define planner_stop() planner_command(TYPE_STOP)
-#define planner_airgas_disable() planner_command(TYPE_AIRGAS_DISABLE)
-#define planner_air_enable() planner_command(TYPE_AIR_ENABLE)
-#define planner_gas_enable() planner_command(TYPE_GAS_ENABLE)
+#define planner_control_airgas_disable() planner_command(TYPE_AIRGAS_DISABLE)
+#define planner_control_air_enable() planner_command(TYPE_AIR_ENABLE)
+#define planner_control_gas_enable() planner_command(TYPE_GAS_ENABLE)
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
diff --git a/serial.c b/serial.c
index 69fb803d5..d87e25015 100644
--- a/serial.c
+++ b/serial.c
@@ -1,26 +1,25 @@
/*
- serial.c - Low level functions for sending and recieving bytes via the serial port
- Part of Grbl
+ serial.c - Low level functions for sending and recieving bytes via the serial port.
+ Part of LasaurGrbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
+ Copyright (c) 2011 Sungeun K. Jeon
+ Copyright (c) 2011 Stefan Hechenberger
- Grbl is free software: you can redistribute it and/or modify
+ Inspired by the wiring_serial module by David A. Mellis which
+ used to be a part of the Arduino project.
+
+ LasaurGrbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ LasaurGrbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
*/
-/* This code was initially inspired by the wiring_serial module by David A. Mellis which
- used to be a part of the Arduino project. */
-
#include
#include
#include
diff --git a/serial.h b/serial.h
index 7a056cdb6..be6caa95c 100644
--- a/serial.h
+++ b/serial.h
@@ -1,26 +1,25 @@
/*
- serial.c - Low level functions for sending and recieving bytes via the serial port
- Part of Grbl
+ serial.c - Low level functions for sending and recieving bytes via the serial port.
+ Part of LasaurGrbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
+ Copyright (c) 2011 Sungeun K. Jeon
+ Copyright (c) 2011 Stefan Hechenberger
- Grbl is free software: you can redistribute it and/or modify
+ Inspired by the wiring_serial module by David A. Mellis which
+ used to be a part of the Arduino project.
+
+ LasaurGrbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ LasaurGrbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
*/
-/* This code was initially inspired by the wiring_serial module by David A. Mellis which
- used to be a part of the Arduino project. */
-
#ifndef serial_h
#define serial_h
diff --git a/stepper.c b/stepper.c
index b07bcd347..681c194bc 100644
--- a/stepper.c
+++ b/stepper.c
@@ -7,7 +7,6 @@
Copyright (c) 2011 Stefan Hechenberger
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun K. Jeon
- Copyright (c) 2011 Arthur Wolf
Inspired by the 'RepRap cartesian firmware' by Zack Smith and
Philipp Tiefenbacher.
@@ -49,8 +48,7 @@
#include "stepper.h"
#include "config.h"
#include "planner.h"
-#include "input_control.h"
-#include "output_control.h"
+#include "io_control.h"
#define CYCLES_PER_MICROSECOND (F_CPU/1000000) //16000000/1000000 = 16
@@ -144,7 +142,7 @@ void stepper_go_idle() {
current_block = NULL;
// Disable stepper driver interrupt
TIMSK1 &= ~(1<nominal_laser_intensity);
+ control_laser_intensity(current_block->nominal_laser_intensity);
}
+
+static void homing_cycle(bool x_axis, bool y_axis, bool z_axis, bool reverse_direction, uint32_t microseconds_per_pulse) {
+
+ uint32_t step_delay = microseconds_per_pulse - CONFIG_PULSE_MICROSECONDS;
+ uint8_t out_bits = DIRECTION_MASK;
+ uint8_t limit_bits;
+
+ if (x_axis) { out_bits |= (1<