Skip to content

Commit

Permalink
Merge branch 'driveboard'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Hechenberger committed Feb 22, 2013
2 parents baa1ac2 + 3f43aad commit b97937b
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 106 deletions.
28 changes: 28 additions & 0 deletions beaglebone_flash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Super Awesome LasaurGrbl python flash script.
#
# Copyright (c) 2011 Nortd Labs
# Open Source by the terms of the Gnu Public License (GPL3) or higher.

import os, sys


# Make sure you have avrdude installed on the beaglebone
# opkg install libreadline5_5.2-r8.9_armv4.ipk
# opkg install avrdude_5.10-r1.9_armv7a.ipk
# get the packages from http://www.angstrom-distribution.org/repo/

AVRDUDEAPP = "avrdude"
AVRDUDECONFIG = "/etc/avrdude.conf"
SERIAL_PORT = "/dev/ttyO1"
DEVICE = "atmega328p"
PROGRAMMER = "arduino" # use this for bootloader
SERIAL_OPTION = '-P %(port)s' % {'port':SERIAL_PORT}
BITRATE = "115200"
BUILDNAME = "LasaurGrbl"

# use beaglebone gpio2_7 to reset the atmege here

os.system('%(dude)s -c %(programmer)s -b %(bps)s %(serial_option)s -p %(device)s -C %(dudeconf)s -Uflash:w:%(product)s.hex:i' % {'dude':AVRDUDEAPP, 'programmer':PROGRAMMER, 'bps':BITRATE, 'serial_option':SERIAL_OPTION, 'device':DEVICE, 'dudeconf':AVRDUDECONFIG, 'product':BUILDNAME})
# os.system('%(dude)s -c %(programmer)s -b %(bps)s -P %(port)s -p %(device)s -C %(dudeconf)s -B 10 -F -U flash:w:%(product)s.hex:i' % {'dude':AVRDUDEAPP, 'programmer':PROGRAMMER, 'bps':BITRATE, 'port':SERIAL_PORT, 'device':DEVICE, 'dudeconf':AVRDUDECONFIG, 'product':BUILDNAME})


68 changes: 49 additions & 19 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

// Version number
// (must not contain capital letters)
#define LASAURGRBL_VERSION "12.08f"
#define LASAURGRBL_VERSION "13.02e"
// build for new driveboard hardware
#define DRIVEBOARD
#define BAUD_RATE 57600
// #define DEBUG_IGNORE_SENSORS // set for debugging

Expand All @@ -36,25 +38,36 @@
#define CONFIG_PULSE_MICROSECONDS 5
#define CONFIG_FEEDRATE 15000.0 // in millimeters per minute
#define CONFIG_SEEKRATE 5000.0
#define CONFIG_ACCELERATION 2400000.0 // mm/min^2, typically 1000000-8000000, divide by (60*60) to get mm/sec^2
#define CONFIG_ACCELERATION 1800000.0 // mm/min^2, typically 1000000-8000000, divide by (60*60) to get mm/sec^2
#define CONFIG_JUNCTION_DEVIATION 0.01 // mm
#define CONFIG_X_ORIGIN_OFFSET 5.0 // mm, x-offset of table origin from physical home
#define CONFIG_Y_ORIGIN_OFFSET 5.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_Z_AXIS 1 // 0 is regular, 1 inverts the y direction


#define LIMITS_OVERWRITE_DDR DDRD
#define LIMITS_OVERWRITE_PORT PORTD
#define LIMITS_OVERWRITE_BIT 7

#define SENSE_DDR DDRD
#define SENSE_PORT PORTD
#define SENSE_PIN PIND
#define POWER_BIT 2
#ifndef DRIVEBOARD
#define POWER_BIT 2
#endif
#define CHILLER_BIT 3
#define DOOR_BIT 5
#define DOOR_BIT 2

#ifdef DRIVEBOARD
#define ASSIST_DDR DDRD
#define ASSIST_PORT PORTD
#define AIR_ASSIST_BIT 4
#define AUX1_ASSIST_BIT 7
#define AUX2_ASSIST_BIT 5
#else
#define LIMITS_OVERWRITE_DDR DDRD
#define LIMITS_OVERWRITE_PORT PORTD
#define LIMITS_OVERWRITE_BIT 7
#endif

#define LIMIT_DDR DDRC
#define LIMIT_PORT PORTC
Expand All @@ -63,11 +76,15 @@
#define X2_LIMIT_BIT 1
#define Y1_LIMIT_BIT 2
#define Y2_LIMIT_BIT 3

#define AIRGAS_DDR DDRC
#define AIRGAS_PORT PORTC
#define AIR_BIT 4
#define GAS_BIT 5
#ifdef DRIVEBOARD
#define Z1_LIMIT_BIT 4
#define Z2_LIMIT_BIT 5
#else
#define ASSIST_DDR DDRC
#define ASSIST_PORT PORTC
#define AIR_ASSIST_BIT 4
#define AUX1_ASSIST_BIT 5
#endif

#define STEPPING_DDR DDRB
#define STEPPING_PORT PORTB
Expand All @@ -80,26 +97,39 @@




#define SENSE_MASK ((1<<POWER_BIT)|(1<<CHILLER_BIT)|(1<<DOOR_BIT))
#define LIMIT_MASK ((1<<X1_LIMIT_BIT)|(1<<X2_LIMIT_BIT)|(1<<Y1_LIMIT_BIT)|(1<<Y2_LIMIT_BIT))
#ifdef DRIVEBOARD
#define SENSE_MASK ((1<<CHILLER_BIT)|(1<<DOOR_BIT))
#define LIMIT_MASK ((1<<X1_LIMIT_BIT)|(1<<X2_LIMIT_BIT)|(1<<Y1_LIMIT_BIT)|(1<<Y2_LIMIT_BIT)|(1<<Z1_LIMIT_BIT)|(1<<Z2_LIMIT_BIT))
#else
#define SENSE_MASK ((1<<POWER_BIT)|(1<<CHILLER_BIT)|(1<<DOOR_BIT))
#define LIMIT_MASK ((1<<X1_LIMIT_BIT)|(1<<X2_LIMIT_BIT)|(1<<Y1_LIMIT_BIT)|(1<<Y2_LIMIT_BIT))
#endif
#define STEPPING_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT))
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))

// figure out INVERT_MASK
// careful! direction pins hardcoded here
// (1<<X_DIRECTION_BIT) | (1<<Y_DIRECTION_BIT)
#if CONFIG_INVERT_X_AXIS && CONFIG_INVERT_Y_AXIS
// careful! direction pins hardcoded here#if DRIVEBOARD
// (1<<X_DIRECTION_BIT) | (1<<Y_DIRECTION_BIT) | (1<<Y_DIRECTION_BIT)
#if CONFIG_INVERT_X_AXIS && CONFIG_INVERT_Y_AXIS && CONFIG_INVERT_Z_AXIS
#define INVERT_MASK 56U
#elif CONFIG_INVERT_X_AXIS && CONFIG_INVERT_Y_AXIS
#define INVERT_MASK 24U
#elif CONFIG_INVERT_Y_AXIS && CONFIG_INVERT_Z_AXIS
#define INVERT_MASK 48U
#elif CONFIG_INVERT_X_AXIS && CONFIG_INVERT_Z_AXIS
#define INVERT_MASK 40U
#elif CONFIG_INVERT_X_AXIS
#define INVERT_MASK 8U
#elif CONFIG_INVERT_Y_AXIS
#define INVERT_MASK 16U
#elif CONFIG_INVERT_Z_AXIS
#define INVERT_MASK 32U
#else
#define INVERT_MASK 0U
#endif



// The temporal resolution of the acceleration management subsystem. Higher number give smoother
// acceleration but may impact performance.
// NOTE: Increasing this parameter will help any resolution related issues, especially with machines
Expand Down
10 changes: 7 additions & 3 deletions flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@
def build():
DEVICE = "atmega328p"
CLOCK = "16000000"
PROGRAMMER = "arduino" # use this for bootloader
# PROGRAMMER = "usbtiny" # use this for programmer
if SERIAL_PORT == "usbtiny":
PROGRAMMER = "usbtiny" # use this for programmer
SERIAL_OPTION = ""
else:
PROGRAMMER = "arduino" # use this for bootloader
SERIAL_OPTION = '-P %(port)s' % {'port':SERIAL_PORT}
BITRATE = "115200"

BUILDNAME = "LasaurGrbl"
Expand All @@ -87,7 +91,7 @@ def build():

# os.system('%(objdump)s -t -j .bss main.elf' % {'objdump':AVROBJDUMPAPP})

os.system('%(dude)s -c %(programmer)s -b %(bps)s -P %(port)s -p %(device)s -C %(dudeconf)s -Uflash:w:%(product)s.hex:i' % {'dude':AVRDUDEAPP, 'programmer':PROGRAMMER, 'bps':BITRATE, 'port':SERIAL_PORT, 'device':DEVICE, 'dudeconf':AVRDUDECONFIG, 'product':BUILDNAME})
os.system('%(dude)s -c %(programmer)s -b %(bps)s %(serial_option)s -p %(device)s -C %(dudeconf)s -Uflash:w:%(product)s.hex:i' % {'dude':AVRDUDEAPP, 'programmer':PROGRAMMER, 'bps':BITRATE, 'serial_option':SERIAL_OPTION, 'device':DEVICE, 'dudeconf':AVRDUDECONFIG, 'product':BUILDNAME})
# os.system('%(dude)s -c %(programmer)s -b %(bps)s -P %(port)s -p %(device)s -C %(dudeconf)s -B 10 -F -U flash:w:%(product)s.hex:i' % {'dude':AVRDUDEAPP, 'programmer':PROGRAMMER, 'bps':BITRATE, 'port':SERIAL_PORT, 'device':DEVICE, 'dudeconf':AVRDUDECONFIG, 'product':BUILDNAME})


Expand Down
56 changes: 39 additions & 17 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@
#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_AUX1_ASSIST_ENABLE 8
#define NEXT_ACTION_AUX1_ASSIST_DISABLE 9
#ifdef DRIVEBOARD
#define NEXT_ACTION_AUX2_ASSIST_ENABLE 10
#define NEXT_ACTION_AUX2_ASSIST_DISABLE 11
#endif

#define OFFSET_G54 0
#define OFFSET_G55 1
Expand Down Expand Up @@ -239,10 +243,12 @@ void gcode_process_line() {
if (SENSE_CHILLER_OFF) {
printString("C"); // Warning: Chiller is off
}
// power
if (SENSE_POWER_OFF) {
printString("P"); // Power Off
}
#ifndef DRIVEBOARD
// power
if (SENSE_POWER_OFF) {
printString("P"); // Power Off
}
#endif
// limit
if (SENSE_LIMITS) {
if (SENSE_X1_LIMIT) {
Expand Down Expand Up @@ -316,9 +322,14 @@ 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 80: next_action = NEXT_ACTION_AIR_ASSIST_ENABLE;break;
case 81: next_action = NEXT_ACTION_AIR_ASSIST_DISABLE;break;
case 82: next_action = NEXT_ACTION_AUX1_ASSIST_ENABLE;break;
case 83: next_action = NEXT_ACTION_AUX1_ASSIST_DISABLE;break;
#ifdef DRIVEBOARD
case 84: next_action = NEXT_ACTION_AUX2_ASSIST_ENABLE;break;
case 85: next_action = NEXT_ACTION_AUX2_ASSIST_DISABLE;break;
#endif
default: FAIL(STATUS_UNSUPPORTED_STATEMENT);
}
break;
Expand Down Expand Up @@ -451,15 +462,26 @@ 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_ASSIST_DISABLE:
planner_control_air_assist_disable();
break;
case NEXT_ACTION_AIR_ENABLE:
planner_control_air_enable();
case NEXT_ACTION_AUX1_ASSIST_ENABLE:
planner_control_aux1_assist_enable();
break;
case NEXT_ACTION_GAS_ENABLE:
planner_control_gas_enable();
case NEXT_ACTION_AUX1_ASSIST_DISABLE:
planner_control_aux1_assist_disable();
break;
#ifdef DRIVEBOARD
case NEXT_ACTION_AUX2_ASSIST_ENABLE:
planner_control_aux2_assist_enable();
break;
case NEXT_ACTION_AUX2_ASSIST_DISABLE:
planner_control_aux2_assist_disable();
break;
#endif
}

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

// 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 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 TYPE_AIR_ASSIST_ENABLE 1
#define TYPE_AIR_ASSIST_DISABLE 2
#define TYPE_AUX1_ASSIST_ENABLE 3
#define TYPE_AUX1_ASSIST_DISABLE 4
#define TYPE_AUX2_ASSIST_ENABLE 5
#define TYPE_AUX2_ASSIST_DISABLE 6

#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_aux1_assist_enable() planner_command(TYPE_AUX1_ASSIST_ENABLE)
#define planner_control_aux1_assist_disable() planner_command(TYPE_AUX1_ASSIST_DISABLE)
#ifdef DRIVEBOARD
#define planner_control_aux2_assist_enable() planner_command(TYPE_AUX2_ASSIST_ENABLE)
#define planner_control_aux2_assist_disable() planner_command(TYPE_AUX2_ASSIST_DISABLE)
#endif

// 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 +80,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
Loading

0 comments on commit b97937b

Please sign in to comment.