Tải bản đầy đủ - 0 (trang)
TÀI LIỆU THAM KHẢO

TÀI LIỆU THAM KHẢO

Tải bản đầy đủ - 0trang

CODE ROBOT VẼ TRANH

1. Lựa chọn thư viện và chỉnh sửa các thông số cho phù hợp với kết cấu cơ khí của



máy:

#ifndef config_h

#define config_h

#include "grbl.h"

#define DEFAULTS_GENERIC

#define BAUD_RATE 115200

#define CPU_MAP_ATMEGA328P

#define CMD_STATUS_REPORT '?'

#define CMD_FEED_HOLD '!'

#define CMD_CYCLE_START '~'

#define CMD_RESET 0x18

#define CMD_SAFETY_DOOR '@'

#define HOMING_INIT_LOCK

#define HOMING_CYCLE_0 (1<
#define HOMING_CYCLE_1 ((1<
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)

#define N_STARTUP_LINE 2

#define N_DECIMAL_COORDVALUE_INCH 4

#define N_DECIMAL_COORDVALUE_MM 3

#define N_DECIMAL_RATEVALUE_INCH 1

#define N_DECIMAL_RATEVALUE_MM 0

#define N_DECIMAL_SETTINGVALUE



3



#define MESSAGE_PROBE_COORDINATES

#define SAFETY_DOOR_SPINDLE_DELAY 4000

#define SAFETY_DOOR_COOLANT_DELAY 1000

#define ACCELERATION_TICKS_PER_SECOND 100

#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING

#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS

50



#define VARIABLE_SPINDLE

#define SPINDLE_MAX_RPM 1000.0

#define SPINDLE_MIN_RPM 0.0

#define MINIMUM_JUNCTION_SPEED 0.0

#define MINIMUM_FEED_RATE 1.0

#define N_ARC_CORRECTION 12

#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7

#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)

#ifndef HOMING_CYCLE_0

#error "Required HOMING_CYCLE_0 not defined."

#endif

#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !

defined(VARIABLE_SPINDLE)

#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with

VARIABLE_SPINDLE enabled"

#endif

#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !

defined(CPU_MAP_ATMEGA328P)

#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p

processor"

#endif

#endif

2. Code hiệu chỉnh tốc độ và gia tốc cho động cơ từng trục



#ifndef defaults_h

#define defaults_h

// Description: X-Carve 3D Carver CNC mill with three 200 step/rev motors driven

by Synthetos

// grblShield at 24V.

#define MICROSTEPS_XY 8

#define STEP_REVS_XY 200

51



#define MM_PER_REV_XY (2.0*20) // 2mm belt pitch, 20 pulley teeth

#define MICROSTEPS_Z 2

#define STEP_REVS_Z 200

#define MM_PER_REV_Z 2.117 // ACME 3/8-12 Leadscrew

#define DEFAULT_X_STEPS_PER_MM

(MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)

#define DEFAULT_Y_STEPS_PER_MM

(MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)

#define DEFAULT_Z_STEPS_PER_MM

(MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z)

#define DEFAULT_X_MAX_RATE 8000.0 // mm/min

#define DEFAULT_Y_MAX_RATE 8000.0 // mm/min

#define DEFAULT_Z_MAX_RATE 500.0 // mm/min

#define DEFAULT_X_ACCELERATION (500.0*60*60) // 25*60*60 mm/min^2 =

25 mm/sec^2

#define DEFAULT_Y_ACCELERATION (500.0*60*60) // 25*60*60 mm/min^2 =

25 mm/sec^2

#define DEFAULT_Z_ACCELERATION (50.0*60*60) // 25*60*60 mm/min^2 = 25

mm/sec^2

#define DEFAULT_X_MAX_TRAVEL 740.0 // mm

#define DEFAULT_Y_MAX_TRAVEL 790.0 // mm

#define DEFAULT_Z_MAX_TRAVEL 100.0 // mm

#define DEFAULT_STEP_PULSE_MICROSECONDS 10

#define DEFAULT_STEPPING_INVERT_MASK 0

#define DEFAULT_DIRECTION_INVERT_MASK ((1<
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // msec (0-254, 255 keeps

steppers enabled)

#define DEFAULT_STATUS_REPORT_MASK

((BITFLAG_RT_STATUS_MACHINE_POSITION)|

(BITFLAG_RT_STATUS_WORK_POSITION))

52



#define DEFAULT_JUNCTION_DEVIATION 0.02 // mm

#define DEFAULT_ARC_TOLERANCE 0.002 // mm

#define DEFAULT_REPORT_INCHES 0 // false

#define DEFAULT_INVERT_ST_ENABLE 0 // false

#define DEFAULT_INVERT_LIMIT_PINS 0 // false

#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false

#define DEFAULT_HARD_LIMIT_ENABLE 0 // false

#define DEFAULT_HOMING_ENABLE 0 // false

#define DEFAULT_HOMING_DIR_MASK 3 // move positive dir

#define DEFAULT_HOMING_FEED_RATE 25.0 // mm/min

#define DEFAULT_HOMING_SEEK_RATE 750.0 // mm/min

#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)

#define DEFAULT_HOMING_PULLOFF 1.0 // mm

#endif

3. Code hiệu chỉnh thứ tự các chân kết nối với driver A4988 phù hợp với Shield V3



#ifdef GRBL_PLATFORM

#error "cpu_map already defined: GRBL_PLATFORM=" GRBL_PLATFORM

#endif

#define GRBL_PLATFORM "Atmega328p"

// Define serial port pins and interrupt vectors.

#define SERIAL_RX



USART_RX_vect



#define SERIAL_UDRE USART_UDRE_vect

#define STEP_DDR



DDRD



#define STEP_PORT



PORTD



#define X_STEP_BIT



2 // Uno Digital Pin 2



#define Y_STEP_BIT



3 // Uno Digital Pin 3



#define Z_STEP_BIT



4 // Uno Digital Pin 4



#define STEP_MASK



((1<


(1<
#define DIRECTION_DDR



DDRD

53



#define DIRECTION_PORT PORTD

#define X_DIRECTION_BIT 5 // Uno Digital Pin 5

#define Y_DIRECTION_BIT 6 // Uno Digital Pin 6

#define Z_DIRECTION_BIT 7 // Uno Digital Pin 7

#define DIRECTION_MASK ((1<
(1<
#define STEPPERS_DISABLE_DDR



DDRB



#define STEPPERS_DISABLE_PORT PORTB

#define STEPPERS_DISABLE_BIT 0 // Uno Digital Pin 8

#define STEPPERS_DISABLE_MASK (1<
#define LIMIT_DDR

#define LIMIT_PIN



DDRB

PINB



#define LIMIT_PORT



PORTB



#define X_LIMIT_BIT



1 // Uno Digital Pin 9



#define Y_LIMIT_BIT



2 // Uno Digital Pin 10



#ifdef VARIABLE_SPINDLE

#define Z_LIMIT_BIT



4 // Uno Digital Pin 12



#else

#define Z_LIMIT_BIT 3 // Uno Digital Pin 11

#endif

#define LIMIT_MASK



((1<


(1<
#define LIMIT_INT



PCIE0 // Pin change interrupt enable pin



#define LIMIT_INT_vect PCINT0_vect

#define LIMIT_PCMSK



PCMSK0 // Pin change interrupt register



#define SPINDLE_ENABLE_DDR



DDRB



#define SPINDLE_ENABLE_PORT PORTB

#ifdef VARIABLE_SPINDLE

#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN

#define SPINDLE_ENABLE_BIT 5

54



#else

#define SPINDLE_ENABLE_BIT 3 // Uno Digital Pin 11

#endif

#else

#define SPINDLE_ENABLE_BIT 4 // Uno Digital Pin 12

#endif

#ifndef USE_SPINDLE_DIR_AS_ENABLE_PIN

#define SPINDLE_DIRECTION_DDR DDRB

#define SPINDLE_DIRECTION_PORT PORTB

#define SPINDLE_DIRECTION_BIT 5 // Uno Digital Pin 13 (NOTE: D13 can't be

pulled-high input due to LED.)

#endif

#define COOLANT_FLOOD_DDR DDRC

#define COOLANT_FLOOD_PORT PORTC

#define COOLANT_FLOOD_BIT 3 // Uno Analog Pin 3

#ifdef ENABLE_M7 // Mist coolant disabled by default. See config.h to

enable/disable.

#define COOLANT_MIST_DDR DDRC

#define COOLANT_MIST_PORT PORTC

#define COOLANT_MIST_BIT 4 // Uno Analog Pin 4

#endif

#define CONTROL_DDR



DDRC



#define CONTROL_PIN



PINC



#define CONTROL_PORT

#define RESET_BIT



PORTC



0 // Uno Analog Pin 0



#define FEED_HOLD_BIT



1 // Uno Analog Pin 1



#define CYCLE_START_BIT 2 // Uno Analog Pin 2

#define SAFETY_DOOR_BIT 1

#define CONTROL_INT



PCIE1 // Pin change interrupt enable pin



#define CONTROL_INT_vect PCINT1_vect

55



#define CONTROL_PCMSK



PCMSK1 // Pin change interrupt register



#define CONTROL_MASK ((1<
(1<
#define CONTROL_INVERT_MASK CONTROL_MASK

#define PROBE_DDR

#define PROBE_PIN

#define PROBE_PORT

#define PROBE_BIT



DDRC

PINC

PORTC

5 // Uno Analog Pin 5



#define PROBE_MASK



(1<


#ifdef VARIABLE_SPINDLE

#define PWM_MAX_VALUE



255.0



#define TCCRA_REGISTER TCCR2A

#define TCCRB_REGISTER TCCR2B

#define OCR_REGISTER

#define COMB_BIT



OCR2A



COM2A1



#define WAVE0_REGISTER WGM20

#define WAVE1_REGISTER WGM21

#define WAVE2_REGISTER WGM22

#define WAVE3_REGISTER WGM23

#define SPINDLE_PWM_DDR



DDRB



#define SPINDLE_PWM_PORT PORTB

#define SPINDLE_PWM_BIT



3 // Uno Digital Pin 11



#endif // End of VARIABLE_SPINDLE



56



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

TÀI LIỆU THAM KHẢO

Tải bản đầy đủ ngay(0 tr)

×