Permalink
Browse files

working on laser_enable_bit

  • Loading branch information...
1 parent af6c4a9 commit 8f9922b5d8d07c987380397039cc10cccfcdb90a @stefanix committed Mar 22, 2012
Showing with 16 additions and 9 deletions.
  1. +1 −1 config.h
  2. +2 −5 gcode.c
  3. +5 −1 sense_control.c
  4. +8 −2 stepper.c
View
@@ -58,7 +58,7 @@
// the intensity. On/off during G0 seek motions is instead achieved with an optical switch in the
// resonator which also might have a slight delay; hence the latency config. The firmware can accomodate.
#define CONFIG_USE_LASER_ENABLE_BIT 0 // whether (0 or 1) to use the laser enable pin on seeks (G0)
-#define CONFIG_LASER_ENABLE_LATENCY 0 // time (sec) it takes to enable the laser
+#define CONFIG_USE_LASER_ENABLE_LATENCY 0.5 // time (sec) it takes to enable the laser
#define LIMITS_OVERWRITE_DDR DDRD
View
@@ -296,10 +296,7 @@ uint8_t gcode_execute_line(char *line) {
switch (next_action) {
case NEXT_ACTION_SEEK: // G0
if (CONFIG_USE_LASER_ENABLE_BIT) {
- if (control_is_laser_enabled()) {
- // when path ends -> disable laser and dwell some time
- planner_control_laser_disable(CONFIG_LASER_ENABLE_LATENCY);
- }
+ planner_control_laser_disable(CONFIG_USE_LASER_ENABLE_LATENCY);
// seek - keep pwm up, laser is disabled via the LASER_ENABLE_BIT
planner_line( target[X_AXIS] + gc.offsets[3*gc.offselect+X_AXIS],
target[Y_AXIS] + gc.offsets[3*gc.offselect+Y_AXIS],
@@ -316,7 +313,7 @@ uint8_t gcode_execute_line(char *line) {
case NEXT_ACTION_FEED: // G1
if (CONFIG_USE_LASER_ENABLE_BIT && !control_is_laser_enabled()) {
// when a new path starts -> enable laser and dwell some time
- planner_control_laser_enable(CONFIG_LASER_ENABLE_LATENCY, gc.nominal_laser_intensity);
+ planner_control_laser_enable(CONFIG_USE_LASER_ENABLE_LATENCY, gc.nominal_laser_intensity);
}
planner_line( target[X_AXIS] + gc.offsets[3*gc.offselect+X_AXIS],
target[Y_AXIS] + gc.offsets[3*gc.offselect+Y_AXIS],
View
@@ -23,6 +23,7 @@
#include "stepper.h"
#include "planner.h"
+static bool laser_bit_enabled_flag;
void sense_init() {
@@ -69,13 +70,16 @@ void control_init() {
void control_laser_enable(bool enable) {
if (enable) {
LASER_PORT &= ~(1 << LASER_ENABLE_BIT);
+ laser_bit_enabled_flag = true;
} else {
LASER_PORT |= (1 << LASER_ENABLE_BIT);
+ laser_bit_enabled_flag = false;
}
}
bool control_is_laser_enabled() {
- return (LASER_PORT >> LASER_ENABLE_BIT) & 1;
+ // return (LASER_PORT >> LASER_ENABLE_BIT) & 1;
+ return laser_bit_enabled_flag;
}
void control_laser_intensity(uint8_t intensity) {
View
@@ -144,6 +144,10 @@ void stepper_go_idle() {
// Disable stepper driver interrupt
TIMSK1 &= ~(1<<OCIE1A);
control_laser_intensity(0);
+ if (CONFIG_USE_LASER_ENABLE_BIT) {
+ // in case a program ends in a G1
+ control_laser_enable(false);
+ }
}
// stop processing command blocks on next ISR call
@@ -258,7 +262,9 @@ ISR(TIMER1_COMPA_vect) {
} else { // TYPE_DWELL, ...
tick_counter = 0; // use tick_counter to keep track of dwell time
adjust_speed( 6000 ); // set stepper timer resolution to about 10ms (0.01s)
- control_laser_intensity(current_block->nominal_laser_intensity);
+ if (current_block->type == TYPE_DWELL || current_block->type == TYPE_LASER_ENABLE) {
+ control_laser_intensity(current_block->nominal_laser_intensity);
+ }
}
}
@@ -351,7 +357,7 @@ ISR(TIMER1_COMPA_vect) {
}
////////// END OF SPEED ADJUSTMENT
- } else { //TYPE_DWELL, TYPE_AIRGAS_DISABLE, TYPE_AIR_ENABLE, ...
+ } else { //TYPE_DWELL, TYPE_AIRGAS_DISABLE, ...
// on first entry do switching based on type
if (tick_counter == 0) {
switch (current_block->type) {

0 comments on commit 8f9922b

Please sign in to comment.