Skip to content

Commit

Permalink
air/gas assist renamed to air/aux assist, they also can be switch off…
Browse files Browse the repository at this point in the history
… with independant Mcodes; M8/M9 is on/off air; M10/M11 is on/off aux
  • Loading branch information
Stefan Hechenberger committed Oct 3, 2012
1 parent 27cf0d2 commit 6e4677e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 53 deletions.
18 changes: 9 additions & 9 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Version number
// (must not contain capital letters)
#define LASAURGRBL_VERSION "12.08ng"
// #define DRIVEBOARD // use changes for new driveboard hardware
#define DRIVEBOARD // use changes for new driveboard hardware
#define BAUD_RATE 57600
// #define DEBUG_IGNORE_SENSORS // set for debugging

Expand Down Expand Up @@ -59,10 +59,10 @@
#define DOOR_BIT 5

#ifdef DRIVEBOARD
#define AIRGAS_DDR DDRD
#define AIRGAS_PORT PORTD
#define AIR_BIT 4
#define GAS_BIT 7
#define ASSIST_DDR DDRD
#define ASSIST_PORT PORTD
#define AIR_ASSIST_BIT 4
#define AUX_ASSIST_BIT 7
#else
#define LIMITS_OVERWRITE_DDR DDRD
#define LIMITS_OVERWRITE_PORT PORTD
Expand All @@ -80,10 +80,10 @@
#define Z1_LIMIT_BIT 4
#define Z2_LIMIT_BIT 5
#else
#define AIRGAS_DDR DDRC
#define AIRGAS_PORT PORTC
#define AIR_BIT 4
#define GAS_BIT 5
#define ASSIST_DDR DDRC
#define ASSIST_PORT PORTC
#define AIR_ASSIST_BIT 4
#define AUX_ASSIST_BIT 5
#endif

#define STEPPING_DDR DDRB
Expand Down
29 changes: 17 additions & 12 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
#define NEXT_ACTION_DWELL 3
#define NEXT_ACTION_HOMING_CYCLE 4
#define NEXT_ACTION_SET_COORDINATE_OFFSET 5
#define NEXT_ACTION_AIRGAS_DISABLE 6
#define NEXT_ACTION_AIR_ENABLE 7
#define NEXT_ACTION_GAS_ENABLE 8
#define NEXT_ACTION_AIR_ASSIST_ENABLE 6
#define NEXT_ACTION_AIR_ASSIST_DISABLE 7
#define NEXT_ACTION_AUX_ASSIST_ENABLE 8
#define NEXT_ACTION_AUX_ASSIST_DISABLE 9


#define OFFSET_G54 0
Expand Down Expand Up @@ -318,9 +319,10 @@ uint8_t gcode_execute_line(char *line) {
break;
case 'M':
switch(int_value) {
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 8: next_action = NEXT_ACTION_AIR_ASSIST_ENABLE;break;
case 9: next_action = NEXT_ACTION_AIR_ASSIST_DISABLE;break;
case 10: next_action = NEXT_ACTION_AUX_ASSIST_ENABLE;break;
case 11: next_action = NEXT_ACTION_AUX_ASSIST_DISABLE;break;
default: FAIL(STATUS_UNSUPPORTED_STATEMENT);
}
break;
Expand Down Expand Up @@ -453,15 +455,18 @@ uint8_t gcode_execute_line(char *line) {
}
}
break;
case NEXT_ACTION_AIRGAS_DISABLE:
planner_control_airgas_disable();
case NEXT_ACTION_AIR_ASSIST_ENABLE:
planner_control_air_assist_enable();
break;
case NEXT_ACTION_AIR_ENABLE:
planner_control_air_enable();
case NEXT_ACTION_AIR_ASSIST_DISABLE:
planner_control_air_assist_disable();
break;
case NEXT_ACTION_GAS_ENABLE:
planner_control_gas_enable();
case NEXT_ACTION_AUX_ASSIST_ENABLE:
planner_control_aux_assist_enable();
break;
case NEXT_ACTION_AUX_ASSIST_DISABLE:
planner_control_aux_assist_disable();
break;
}

// As far as the parser is concerned, the position is now == target. In reality the
Expand Down
18 changes: 10 additions & 8 deletions planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@

// Command types the planner and stepper can schedule for execution
#define TYPE_LINE 0
#define TYPE_AIRGAS_DISABLE 1
#define TYPE_AIR_ENABLE 2
#define TYPE_GAS_ENABLE 3
#define TYPE_AIR_ASSIST_ENABLE 1
#define TYPE_AIR_ASSIST_DISABLE 2
#define TYPE_AUX_ASSIST_ENABLE 3
#define TYPE_AUX_ASSIST_DISABLE 4

#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_air_assist_enable() planner_command(TYPE_AIR_ASSIST_ENABLE)
#define planner_control_air_assist_disable() planner_command(TYPE_AIR_ASSIST_DISABLE)
#define planner_control_aux_assist_enable() planner_command(TYPE_AUX_ASSIST_ENABLE)
#define planner_control_aux_assist_disable() planner_command(TYPE_AUX_ASSIST_DISABLE)


// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
// the source g-code and may never actually be reached if acceleration management is active.
typedef struct {
uint8_t type; // Type of command, eg: TYPE_LINE, TYPE_AIR_ENABLE
uint8_t type; // Type of command, eg: TYPE_LINE, TYPE_AIR_ASSIST_ENABLE
// Fields used by the bresenham algorithm for tracing the line
uint32_t steps_x, steps_y, steps_z; // Step count along each axis
uint8_t direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
Expand Down Expand Up @@ -73,7 +75,7 @@ void planner_line(double x, double y, double z, double feed_rate, uint8_t nomina
void planner_dwell(double seconds, uint8_t nominal_laser_intensity);

// Add a non-motion command to the queue.
// Typical types are: TYPE_AIRGAS_DISABLE, TYPE_AIR_ENABLE, TYPE_GAS_ENABLE
// Typical types are: TYPE_AIR_ASSIST_ENABLE, TYPE_AIR_ASSIST_DISABLE, ...
// This call is blocking when the block buffer is full.
void planner_command(uint8_t type);

Expand Down
24 changes: 12 additions & 12 deletions sense_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


void sense_init() {
//// power, chiller, door
//// chiller, door, (power)
SENSE_DDR &= ~(SENSE_MASK); // set as input pins
// SENSE_PORT |= SENSE_MASK; //activate pull-up resistors

Expand All @@ -49,11 +49,11 @@ 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

//// air and gas assist control
AIRGAS_DDR |= (1 << AIR_BIT); // set as output pin
AIRGAS_DDR |= (1 << GAS_BIT); // set as output pin
control_air(false);
control_gas(false);
//// air and aux assist control
ASSIST_DDR |= (1 << AIR_ASSIST_BIT); // set as output pin
ASSIST_DDR |= (1 << AUX_ASSIST_BIT); // set as output pin
control_air_assist(false);
control_aux_assist(false);
#ifndef DRIVEBOARD
//// limits overwrite control
LIMITS_OVERWRITE_DDR |= 1<<LIMITS_OVERWRITE_BIT; // define as output pin
Expand All @@ -68,19 +68,19 @@ void control_laser_intensity(uint8_t intensity) {



void control_air(bool enable) {
void control_air_assist(bool enable) {
if (enable) {
AIRGAS_PORT |= (1 << AIR_BIT);
ASSIST_PORT |= (1 << AIR_ASSIST_BIT);
} else {
AIRGAS_PORT &= ~(1 << AIR_BIT);
ASSIST_PORT &= ~(1 << AIR_ASSIST_BIT);
}
}

void control_gas(bool enable) {
void control_aux_assist(bool enable) {
if (enable) {
AIRGAS_PORT |= (1 << GAS_BIT);
ASSIST_PORT |= (1 << AUX_ASSIST_BIT);
} else {
AIRGAS_PORT &= ~(1 << GAS_BIT);
ASSIST_PORT &= ~(1 << AUX_ASSIST_BIT);
}
}

Expand Down
10 changes: 6 additions & 4 deletions sense_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@


void sense_init();
#define SENSE_CHILLER_OFF !((SENSE_PIN >> CHILLER_BIT) & 1)
#define SENSE_DOOR_OPEN !((SENSE_PIN >> DOOR_BIT) & 1)
#define SENSE_X1_LIMIT !((LIMIT_PIN >> X1_LIMIT_BIT) & 1)
#define SENSE_X2_LIMIT !((LIMIT_PIN >> X2_LIMIT_BIT) & 1)
#define SENSE_Y1_LIMIT !((LIMIT_PIN >> Y1_LIMIT_BIT) & 1)
#define SENSE_Y2_LIMIT !((LIMIT_PIN >> Y2_LIMIT_BIT) & 1)
#define SENSE_Z1_LIMIT !((LIMIT_PIN >> Z1_LIMIT_BIT) & 1)
#define SENSE_Z2_LIMIT !((LIMIT_PIN >> Z2_LIMIT_BIT) & 1)
#define SENSE_CHILLER_OFF !((SENSE_PIN >> CHILLER_BIT) & 1)
#ifdef DRIVEBOARD
// invert door, remove power, add z_limits
#define SENSE_DOOR_OPEN ((SENSE_PIN >> DOOR_BIT) & 1)
#define SENSE_LIMITS (SENSE_X1_LIMIT || SENSE_X2_LIMIT || SENSE_Y1_LIMIT || SENSE_Y2_LIMIT || SENSE_Z1_LIMIT || SENSE_Z2_LIMIT)
#define SENSE_ANY (SENSE_LIMITS || SENSE_CHILLER_OFF || SENSE_DOOR_OPEN)
#else
#define SENSE_DOOR_OPEN !((SENSE_PIN >> DOOR_BIT) & 1)
#define SENSE_POWER_OFF !((SENSE_PIN >> POWER_BIT) & 1)
#define SENSE_LIMITS (SENSE_X1_LIMIT || SENSE_X2_LIMIT || SENSE_Y1_LIMIT || SENSE_Y2_LIMIT)
#define SENSE_ANY (SENSE_LIMITS || SENSE_POWER_OFF || SENSE_CHILLER_OFF || SENSE_DOOR_OPEN)
Expand All @@ -43,8 +45,8 @@ void control_init();

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

void control_air(bool enable);
void control_gas(bool enable);
void control_air_assist(bool enable);
void control_aux_assist(bool enable);


#ifndef DRIVEBOARD
Expand Down
21 changes: 13 additions & 8 deletions stepper.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,24 +360,29 @@ ISR(TIMER1_COMPA_vect) {

break;

case TYPE_AIRGAS_DISABLE:
control_air(false);
control_gas(false);
case TYPE_AIR_ASSIST_ENABLE:
control_air_assist(true);
current_block = NULL;
planner_discard_current_block();
break;

case TYPE_AIR_ENABLE:
control_air(true);
case TYPE_AIR_ASSIST_DISABLE:
control_air_assist(false);
current_block = NULL;
planner_discard_current_block();
break;

case TYPE_GAS_ENABLE:
control_gas(true);
case TYPE_AUX_ASSIST_ENABLE:
control_aux_assist(true);
current_block = NULL;
planner_discard_current_block();
break;
break;

case TYPE_AUX_ASSIST_DISABLE:
control_aux_assist(false);
current_block = NULL;
planner_discard_current_block();
break;
}

busy = false;
Expand Down

0 comments on commit 6e4677e

Please sign in to comment.