Skip to content

Commit

Permalink
working on laser_enable_bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Hechenberger committed Mar 22, 2012
1 parent af6c4a9 commit 8f9922b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
Expand Down
6 changes: 5 additions & 1 deletion sense_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "stepper.h"
#include "planner.h"

static bool laser_bit_enabled_flag;


void sense_init() {
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions stepper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8f9922b

Please sign in to comment.