Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge chamnit/v0_7 with grbl/master
  • Loading branch information
chamnit committed Jan 18, 2012
1 parent 74576a8 commit 9713f90
Show file tree
Hide file tree
Showing 32 changed files with 1,552 additions and 1,014 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -30,8 +30,8 @@
DEVICE = atmega328p
CLOCK = 16000000
PROGRAMMER = -c avrisp2 -P usb
OBJECTS = main.o motion_control.o gcode.o spindle_control.o wiring_serial.o serial_protocol.o stepper.o \
eeprom.o settings.o planner.o
OBJECTS = main.o motion_control.o gcode.o spindle_control.o serial.o protocol.o stepper.o \
eeprom.o settings.o planner.o nuts_bolts.o limits.o print.o
# FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m
FUSES = -U hfuse:w:0xd2:m -U lfuse:w:0xff:m
# update that line with this when programmer is back up:
Expand Down
58 changes: 47 additions & 11 deletions config.h
Expand Up @@ -3,6 +3,7 @@
Part of Grbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun K. Jeon
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -21,14 +22,16 @@
#ifndef config_h
#define config_h

// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.

#define BAUD_RATE 9600

// Updated default pin-assignments from 0.6 onwards
// (see bottom of file for a copy of the old config)

#define STEPPERS_ENABLE_DDR DDRB
#define STEPPERS_ENABLE_PORT PORTB
#define STEPPERS_ENABLE_BIT 0
#define STEPPERS_DISABLE_DDR DDRB
#define STEPPERS_DISABLE_PORT PORTB
#define STEPPERS_DISABLE_BIT 0

#define STEPPING_DDR DDRD
#define STEPPING_PORT PORTD
Expand All @@ -40,7 +43,7 @@
#define Z_DIRECTION_BIT 7

#define LIMIT_DDR DDRB
#define LIMIT_PORT PORTB
#define LIMIT_PIN PINB
#define X_LIMIT_BIT 1
#define Y_LIMIT_BIT 2
#define Z_LIMIT_BIT 3
Expand All @@ -53,17 +56,51 @@
#define SPINDLE_DIRECTION_PORT PORTB
#define SPINDLE_DIRECTION_BIT 5

// The temporal resolution of the acceleration management subsystem. Higher number
// give smoother acceleration but may impact performance
#define ACCELERATION_TICKS_PER_SECOND 40L
// This parameter sets the delay time before disabling the steppers after the final block of movement.
// A short delay ensures the steppers come to a complete stop and the residual inertial force in the
// CNC axes don't cause the axes to drift off position. This is particularly important when manually
// entering g-code into grbl, i.e. locating part zero or simple manual machining. If the axes drift,
// grbl has no way to know this has happened, since stepper motors are open-loop control. Depending
// on the machine, this parameter may need to be larger or smaller than the default time.
// NOTE: If defined 0, the delay will not be compiled.
#define STEPPER_IDLE_LOCK_TIME 25 // (milliseconds) - Integer >= 0

// 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
// requiring very high accelerations and/or very fast feedrates. In general, this will reduce the
// error between how the planner plans the motions and how the stepper program actually performs them.
// However, at some point, the resolution can be high enough, where the errors related to numerical
// round-off can be great enough to cause problems and/or it's too fast for the Arduino. The correct
// value for this parameter is machine dependent, so it's advised to set this only as high as needed.
// Approximate successful values can range from 30L to 100L or more.
#define ACCELERATION_TICKS_PER_SECOND 50L

// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
// of the buffer and all stops. This should not be much greater than zero and should only be changed
// if unwanted behavior is observed on a user's machine when running at very slow speeds.
#define MINIMUM_PLANNER_SPEED 0.0 // (mm/min)

// Minimum stepper rate. Sets the absolute minimum stepper rate in the stepper program and never runs
// slower than this value, except when sleeping. This parameter overrides the minimum planner speed.
// This is primarily used to guarantee that the end of a movement is always reached and not stop to
// never reach its target. This parameter should always be greater than zero.
#define MINIMUM_STEPS_PER_MINUTE 800 // (steps/min) - Integer value only

// Number of arc generation iterations by small angle approximation before exact arc trajectory
// correction. This parameter maybe decreased if there are issues with the accuracy of the arc
// generations. In general, the default value is more than enough for the intended CNC applications
// of grbl, and should be on the order or greater than the size of the buffer to help with the
// computational efficiency of generating arcs.
#define N_ARC_CORRECTION 25 // Integer (1-255)

#endif

// Pin-assignments from Grbl 0.5

// #define STEPPERS_ENABLE_DDR DDRD
// #define STEPPERS_ENABLE_PORT PORTD
// #define STEPPERS_ENABLE_BIT 2
// #define STEPPERS_DISABLE_DDR DDRD
// #define STEPPERS_DISABLE_PORT PORTD
// #define STEPPERS_DISABLE_BIT 2
//
// #define STEPPING_DDR DDRC
// #define STEPPING_PORT PORTC
Expand All @@ -87,4 +124,3 @@
// #define SPINDLE_DIRECTION_DDR DDRD
// #define SPINDLE_DIRECTION_PORT PORTD
// #define SPINDLE_DIRECTION_BIT 7

30 changes: 30 additions & 0 deletions doc/planner-maths.txt
@@ -0,0 +1,30 @@
Reasoning behind the mathematics in 'planner' module (in the key of 'Mathematica')
==================================================================================


s == speed, a == acceleration, t == time, d == distance

Basic definitions:

Speed[s_, a_, t_] := s + (a*t)
Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t]

Distance to reach a specific speed with a constant acceleration:

Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t]
d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance()

Speed after a given distance of travel with constant acceleration:

Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t]
m -> Sqrt[2 a d + s^2]

DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2]

When to start braking (di) to reach a specified destionation speed (s2) after accelerating
from initial speed s1 without ever stopping at a plateau:

Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di]
di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()

IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
2 changes: 1 addition & 1 deletion doc/resources.txt
Expand Up @@ -3,7 +3,7 @@ Allocation of AVR peripherals in Grbl

See config.h for pin allocation.

The UART is handled by 'wiring_serial' and used primarily for streaming gcode
The UART is handled by 'serial' and used primarily for streaming gcode

16 bit Timer 1 and the TIMER1_COMPA interrupt is used by the 'stepper' module to handle step events

Expand Down
8 changes: 5 additions & 3 deletions doc/structure.txt
Expand Up @@ -3,10 +3,10 @@ The general structure of Grbl

The main processing stack:

'serial_protocol' : Accepts command lines from the serial port and passes them to 'gcode' for execution.
'protocol' : Accepts command lines from the serial port and passes them to 'gcode' for execution.
Provides status responses for each command.

'gcode' : Recieves gcode from 'serial_protocol', parses it according to the current state
'gcode' : Recieves gcode from 'protocol', parses it according to the current state
of the parser and issues commands via '..._control' modules

'spindle_control' : Commands for controlling the spindle.
Expand Down Expand Up @@ -36,4 +36,6 @@ Supporting files:

'nuts_bolts.h' : A tiny collection of useful constants and macros used everywhere

'wiring_serial' : Low level serial library initially from an old version of the Arduino software
'serial' : Low level serial communications

'print' : Functions to print strings of different formats (using serial)

0 comments on commit 9713f90

Please sign in to comment.