Skip to content

Commit

Permalink
yag enable functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Hechenberger committed Mar 18, 2012
1 parent 79519b5 commit 97e3bcf
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
9 changes: 7 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#define CONFIG_X_ORIGIN_OFFSET 10.0 // mm, x-offset of table origin from physical home
#define CONFIG_Y_ORIGIN_OFFSET 10.0 // mm, y-offset of table origin from physical home
#define CONFIG_Z_ORIGIN_OFFSET 0.0 // mm, z-offset of table origin from physical home
#define CONFIG_INVERT_X_AXIS 1 // 0 is regular, 1 inverts the x direction
#define CONFIG_INVERT_Y_AXIS 1 // 0 is regular, 1 inverts the y direction
#define CONFIG_INVERT_X_AXIS 0 // 0 is regular, 1 inverts the x direction
#define CONFIG_INVERT_Y_AXIS 0 // 0 is regular, 1 inverts the y direction


#define LIMITS_OVERWRITE_DDR DDRD
Expand All @@ -62,6 +62,11 @@
#define Y1_LIMIT_BIT 2
#define Y2_LIMIT_BIT 3

#define LASER_DDR DDRD
#define LASER_PORT PORTD
#define LASER_ENABLE_BIT 4
// #define LASER_PWM_BIT 6

#define AIRGAS_DDR DDRC
#define AIRGAS_PORT PORTC
#define AIR_BIT 4
Expand Down
10 changes: 10 additions & 0 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#define NEXT_ACTION_AIRGAS_DISABLE 6
#define NEXT_ACTION_AIR_ENABLE 7
#define NEXT_ACTION_GAS_ENABLE 8
#define NEXT_ACTION_LASER_ON 9
#define NEXT_ACTION_LASER_OFF 10

#define STATUS_OK 0
#define STATUS_BAD_NUMBER_FORMAT 1
Expand Down Expand Up @@ -233,6 +235,8 @@ uint8_t gcode_execute_line(char *line) {
case 7: next_action = NEXT_ACTION_AIR_ENABLE;break;
case 8: next_action = NEXT_ACTION_GAS_ENABLE;break;
case 9: next_action = NEXT_ACTION_AIRGAS_DISABLE;break;
case 140: next_action = NEXT_ACTION_LASER_ON;break;
case 141: next_action = NEXT_ACTION_LASER_OFF;break;
default: FAIL(STATUS_UNSUPPORTED_STATEMENT);
}
break;
Expand Down Expand Up @@ -363,6 +367,12 @@ uint8_t gcode_execute_line(char *line) {
case NEXT_ACTION_GAS_ENABLE:
planner_control_gas_enable();
break;
case NEXT_ACTION_LASER_ON:
planner_control_laser_on();
break;
case NEXT_ACTION_LASER_OFF:
planner_control_laser_off();
break;
}

// As far as the parser is concerned, the position is now == target. In reality the
Expand Down
4 changes: 4 additions & 0 deletions planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
#define TYPE_AIRGAS_DISABLE 1
#define TYPE_AIR_ENABLE 2
#define TYPE_GAS_ENABLE 3
#define TYPE_LASER_ON 4
#define TYPE_LASER_OFF 5

#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)
#define planner_control_laser_on() planner_command(TYPE_LASER_ON)
#define planner_control_laser_off() planner_command(TYPE_LASER_OFF)


// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
Expand Down
12 changes: 12 additions & 0 deletions sense_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ void control_init() {
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

//// laser on/off pin
LASER_DDR |= (1 << LASER_ENABLE_BIT); // set as output pin
control_laser(false);

//// air and gas assist control
AIRGAS_DDR |= (1 << AIR_BIT); // set as output pin
AIRGAS_DDR |= (1 << GAS_BIT); // set as output pin
Expand All @@ -61,6 +65,14 @@ void control_init() {
}


void control_laser(bool enable) {
if (enable) {
LASER_PORT &= ~(1 << LASER_ENABLE_BIT);
} else {
LASER_PORT |= (1 << LASER_ENABLE_BIT);
}
}

void control_laser_intensity(uint8_t intensity) {
OCR0A = intensity;
}
Expand Down
1 change: 1 addition & 0 deletions sense_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void sense_init();

void control_init();

void control_laser(bool enable);
void control_laser_intensity(uint8_t intensity); //0-255 is 0-100%

void control_air(bool enable);
Expand Down
14 changes: 13 additions & 1 deletion stepper.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,19 @@ ISR(TIMER1_COMPA_vect) {
control_gas(true);
current_block = NULL;
planner_discard_current_block();
break;
break;

case TYPE_LASER_ON:
control_laser(true);
current_block = NULL;
planner_discard_current_block();
break;

case TYPE_LASER_OFF:
control_laser(false);
current_block = NULL;
planner_discard_current_block();
break;
}

busy = false;
Expand Down

0 comments on commit 97e3bcf

Please sign in to comment.