minor edits after verifying refactored grbl on real hardware
This commit is contained in:
parent
b9c3ea02fb
commit
58ad1ba509
11
config.h
11
config.h
@ -23,9 +23,10 @@
|
||||
|
||||
#define VERSION "0.5"
|
||||
|
||||
#define X_STEPS_PER_MM (94.488188976378*16)
|
||||
#define Y_STEPS_PER_MM (94.488188976378*16)
|
||||
#define Z_STEPS_PER_MM (94.488188976378*16)
|
||||
#define MICROSTEPS 8
|
||||
#define X_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
||||
#define Y_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
||||
#define Z_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
||||
|
||||
#define STEP_PULSE_MICROSECONDS 30
|
||||
|
||||
@ -74,12 +75,12 @@
|
||||
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT))
|
||||
|
||||
// Use this line for default operation (step-pulses high)
|
||||
#define STEPPING_INVERT_MASK 0
|
||||
#define STEPPING_INVERT_MASK 0
|
||||
// Uncomment this line for inverted stepping (step-pulses low, rest high)
|
||||
// #define STEPPING_INVERT_MASK (STEP_MASK)
|
||||
// Uncomment this line to invert all step- and direction bits
|
||||
// #define STEPPING_INVERT_MASK (STEPPING_MASK)
|
||||
// Or bake your own like this adding any step-bits or directions you want to invert:
|
||||
// #define STEPPING_INVERT_MASK (STEP_MASK | (1<<Z_DIRECTION_BIT))
|
||||
// #define STEPPING_INVERT_MASK (STEP_MASK | (1<<X_DIRECTION_BIT) | (1<<Y_DIRECTION_BIT))
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@ G0X0.000Y0.000S8000M3
|
||||
G0X0.000Y-33.519Z6.000
|
||||
G1Z-1.000
|
||||
G1X0.327Y-33.521
|
||||
F120.0
|
||||
F800.0
|
||||
X0.654Y-33.526
|
||||
X0.980Y-33.534
|
||||
X1.304Y-33.546
|
||||
|
1
main.c
1
main.c
@ -38,6 +38,7 @@ int main(void)
|
||||
spindle_init(); // initialize spindle controller
|
||||
gc_init(); // initialize gcode-parser
|
||||
sp_init(); // initialize the serial protocol
|
||||
// sd_raw_init());
|
||||
|
||||
DDRD |= (1<<3)|(1<<4)|(1<<5);
|
||||
|
||||
|
@ -73,7 +73,6 @@ void mc_line(double x, double y, double z, float feed_rate, int invert_feed_rate
|
||||
memcpy(position, target, sizeof(target)); // position[] = target[]
|
||||
}
|
||||
|
||||
|
||||
// Execute an arc. theta == start angle, angular_travel == number of radians to go along the arc,
|
||||
// positive angular_travel means clockwise, negative means counterclockwise. Radius == the radius of the
|
||||
// circle in millimeters. axis_1 and axis_2 selects the circle plane in tool space. Stick the remaining
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/opt/local/bin/ruby
|
||||
require 'stream'
|
||||
require 'script/stream'
|
31
stepper.c
31
stepper.c
@ -46,11 +46,11 @@ volatile int line_buffer_head = 0;
|
||||
volatile int line_buffer_tail = 0;
|
||||
|
||||
// Variables used by SIG_OUTPUT_COMPARE1A
|
||||
uint8_t out_bits;
|
||||
struct Line *current_line;
|
||||
volatile int32_t counter_x, counter_y, counter_z;
|
||||
uint32_t iterations;
|
||||
volatile busy;
|
||||
uint8_t out_bits; // The next stepping-bits to be output
|
||||
struct Line *current_line; // A pointer to the line currently being traced
|
||||
volatile int32_t counter_x, counter_y, counter_z; // counter variables for the bresenham line tracer
|
||||
uint32_t iterations; // The number of iterations left to complete the current_line
|
||||
volatile busy; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
|
||||
|
||||
void config_step_timer(uint32_t microseconds);
|
||||
|
||||
@ -62,8 +62,7 @@ void st_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_t
|
||||
// If the buffer is full: good! That means we are well ahead of the robot.
|
||||
// Nap until there is room in the buffer.
|
||||
while(line_buffer_tail == next_buffer_head) { sleep_mode(); }
|
||||
|
||||
// setup line
|
||||
// Setup line record
|
||||
struct Line *line = &line_buffer[line_buffer_head];
|
||||
line->steps_x = labs(steps_x);
|
||||
line->steps_y = labs(steps_y);
|
||||
@ -83,28 +82,26 @@ void st_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_t
|
||||
TIMSK1 |= (1<<OCIE1A);
|
||||
}
|
||||
|
||||
// This timer interrupt is executed at the pace set with st_buffer_pace. It pops one instruction from
|
||||
// This timer interrupt is executed at the rate set with config_step_timer. It pops one instruction from
|
||||
// the line_buffer, executes it. Then it starts timer2 in order to reset the motor port after
|
||||
// five microseconds.
|
||||
SIGNAL(SIG_OUTPUT_COMPARE1A)
|
||||
{
|
||||
if(busy){ return; } // The busy-flag is used to avoid retriggering this interrupt.
|
||||
if(busy){ return; } // The busy-flag is used to avoid reentering this interrupt
|
||||
|
||||
PORTD |= (1<<3);
|
||||
// Set the direction pins a cuple of nanoseconds before we step the steppers
|
||||
STEPPING_PORT = (STEPPING_PORT & ~DIRECTION_MASK) | (out_bits & DIRECTION_MASK);
|
||||
// Then pulse the stepping pins
|
||||
STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | out_bits;
|
||||
// Reset step pulse reset timer
|
||||
// Reset step pulse reset timer so that SIG_OVERFLOW2 can reset the signal after
|
||||
// exactly STEP_PULSE_MICROSECONDS microseconds.
|
||||
TCNT2 = -(((STEP_PULSE_MICROSECONDS-2)*TICKS_PER_MICROSECOND)/8);
|
||||
|
||||
busy = TRUE;
|
||||
sei();
|
||||
sei(); // Re enable interrupts (normally disabled while inside an interrupt handler)
|
||||
// We re-enable interrupts in order for SIG_OVERFLOW2 to be able to be triggered
|
||||
// and reset the stepper signal even before this handler is done. Needed
|
||||
// to generate a clean stepper-signal in the event that this is going to be a time consuming
|
||||
// time around in this interrupt e.g. if we just completed a line and need to
|
||||
// set up another.
|
||||
// at exactly the right time even if we occasionally spend a lot of time inside this handler.
|
||||
|
||||
// If there is no current line, attempt to pop one from the buffer
|
||||
if (current_line == NULL) {
|
||||
@ -115,7 +112,7 @@ SIGNAL(SIG_OUTPUT_COMPARE1A)
|
||||
// Retrieve a new line and get ready to step it
|
||||
current_line = &line_buffer[line_buffer_tail];
|
||||
config_step_timer(current_line->rate);
|
||||
counter_x = -(current_line->maximum_steps/2);
|
||||
counter_x = -(current_line->maximum_steps >> 1);
|
||||
counter_y = counter_x;
|
||||
counter_z = counter_x;
|
||||
iterations = current_line->maximum_steps;
|
||||
@ -213,7 +210,7 @@ void st_flush()
|
||||
sei();
|
||||
}
|
||||
|
||||
// Configures the prescaler and ceiling of timer 1 to produce the given pace as accurately as possible.
|
||||
// Configures the prescaler and ceiling of timer 1 to produce the given rate as accurately as possible.
|
||||
void config_step_timer(uint32_t microseconds)
|
||||
{
|
||||
uint32_t ticks = microseconds*TICKS_PER_MICROSECOND;
|
||||
|
Loading…
Reference in New Issue
Block a user