converted the STEPPER_ENABLE_PIN to a STEPPER_DISABLE_PIN as per the request of Alden Hart of Grbl Shield fame.

This commit is contained in:
Simen Svale Skogsrud 2011-05-31 13:08:42 +02:00
parent 74dcf58c5c
commit c2aec12004
3 changed files with 26 additions and 21 deletions

View File

@ -26,9 +26,9 @@
// Updated default pin-assignments from 0.6 onwards // Updated default pin-assignments from 0.6 onwards
// (see bottom of file for a copy of the old config) // (see bottom of file for a copy of the old config)
#define STEPPERS_ENABLE_DDR DDRB #define STEPPERS_DISABLE_DDR DDRB
#define STEPPERS_ENABLE_PORT PORTB #define STEPPERS_DISABLE_PORT PORTB
#define STEPPERS_ENABLE_BIT 0 #define STEPPERS_DISABLE_BIT 0
#define STEPPING_DDR DDRD #define STEPPING_DDR DDRD
#define STEPPING_PORT PORTD #define STEPPING_PORT PORTD
@ -61,9 +61,9 @@
// Pin-assignments from Grbl 0.5 // Pin-assignments from Grbl 0.5
// #define STEPPERS_ENABLE_DDR DDRD // #define STEPPERS_DISABLE_DDR DDRD
// #define STEPPERS_ENABLE_PORT PORTD // #define STEPPERS_DISABLE_PORT PORTD
// #define STEPPERS_ENABLE_BIT 2 // #define STEPPERS_DISABLE_BIT 2
// //
// #define STEPPING_DDR DDRC // #define STEPPING_DDR DDRC
// #define STEPPING_PORT PORTC // #define STEPPING_PORT PORTC

3
main.c
View File

@ -20,6 +20,7 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/sleep.h> #include <avr/sleep.h>
#include <avr/interrupt.h>
#include <util/delay.h> #include <util/delay.h>
#include "planner.h" #include "planner.h"
#include "stepper.h" #include "stepper.h"
@ -46,6 +47,8 @@ int main(void)
gc_init(); gc_init();
limits_init(); limits_init();
sei();
for(;;){ for(;;){
sleep_mode(); // Wait for it ... sleep_mode(); // Wait for it ...
protocol_process(); // ... process the serial protocol protocol_process(); // ... process the serial protocol

View File

@ -43,9 +43,6 @@
#define MINIMUM_STEPS_PER_MINUTE 1200 // The stepper subsystem will never run slower than this, exept when sleeping #define MINIMUM_STEPS_PER_MINUTE 1200 // The stepper subsystem will never run slower than this, exept when sleeping
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
static block_t *current_block; // A pointer to the block currently being traced static block_t *current_block; // A pointer to the block currently being traced
// Variables used by The Stepper Driver Interrupt // Variables used by The Stepper Driver Interrupt
@ -82,8 +79,17 @@ static uint32_t trapezoid_adjusted_rate; // The current rate of step_events
static void set_step_events_per_minute(uint32_t steps_per_minute); static void set_step_events_per_minute(uint32_t steps_per_minute);
void st_wake_up() { void st_wake_up() {
STEPPERS_ENABLE_PORT |= (1<<STEPPERS_ENABLE_BIT); // Enable steppers by resetting the stepper disable port
ENABLE_STEPPER_DRIVER_INTERRUPT(); STEPPERS_DISABLE_PORT &= ~(1<<STEPPERS_DISABLE_BIT);
// Enable stepper driver interrupt
TIMSK1 |= (1<<OCIE1A);
}
static void st_go_idle() {
// Disable steppers by setting stepper disable
STEPPERS_DISABLE_PORT |= (1<<STEPPERS_DISABLE_BIT);
// Disable stepper driver interrupt
TIMSK1 &= ~(1<<OCIE1A);
} }
// Initializes the trapezoid generator from the current block. Called whenever a new // Initializes the trapezoid generator from the current block. Called whenever a new
@ -154,9 +160,7 @@ SIGNAL(TIMER1_COMPA_vect)
counter_z = counter_x; counter_z = counter_x;
step_events_completed = 0; step_events_completed = 0;
} else { } else {
// set enable pin st_go_idle();
STEPPERS_ENABLE_PORT &= ~(1<<STEPPERS_ENABLE_BIT);
DISABLE_STEPPER_DRIVER_INTERRUPT();
} }
} }
@ -214,7 +218,7 @@ void st_init()
// Configure directions of interface pins // Configure directions of interface pins
STEPPING_DDR |= STEPPING_MASK; STEPPING_DDR |= STEPPING_MASK;
STEPPING_PORT = (STEPPING_PORT & ~STEPPING_MASK) | settings.invert_mask; STEPPING_PORT = (STEPPING_PORT & ~STEPPING_MASK) | settings.invert_mask;
STEPPERS_ENABLE_DDR |= 1<<STEPPERS_ENABLE_BIT; STEPPERS_DISABLE_DDR |= 1<<STEPPERS_DISABLE_BIT;
// waveform generation = 0100 = CTC // waveform generation = 0100 = CTC
TCCR1B &= ~(1<<WGM13); TCCR1B &= ~(1<<WGM13);
@ -234,10 +238,8 @@ void st_init()
set_step_events_per_minute(6000); set_step_events_per_minute(6000);
trapezoid_tick_cycle_counter = 0; trapezoid_tick_cycle_counter = 0;
STEPPERS_ENABLE_PORT &= ~(1<<STEPPERS_ENABLE_BIT); // Start in the idle state
DISABLE_STEPPER_DRIVER_INTERRUPT(); st_go_idle();
sei();
} }
// Block until all buffered steps are executed // Block until all buffered steps are executed