Initial v0.8 ALPHA commit. Features multi-tasking run-time command execution (feed hold, cycle start, reset, status query). Extensive re-structuring of code for future features.
- ALPHA status. - Multitasking ability with run-time command executions for real-time control and feedback. - Decelerating feed hold and resume during operation. - System abort/reset, which immediately kills all movement and re-initializes grbl. - Re-structured grbl to easily allow for new features: Status reporting, jogging, backlash compensation. (To be completed in the following releases.) - Resized TX/RX serial buffers (32/128 bytes) - Increased planner buffer size to 20 blocks. - Updated documentation.
This commit is contained in:
64
main.c
64
main.c
@ -3,7 +3,9 @@
|
||||
Part of Grbl
|
||||
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
Copyright (c) 2011 Sungeun K. Jeon
|
||||
Copyright (c) 2011 Jens Geisler
|
||||
|
||||
Grbl is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
@ -21,9 +23,11 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <util/delay.h>
|
||||
#include "config.h"
|
||||
#include "planner.h"
|
||||
#include "nuts_bolts.h"
|
||||
#include "stepper.h"
|
||||
#include "spindle_control.h"
|
||||
#include "motion_control.h"
|
||||
@ -34,22 +38,56 @@
|
||||
#include "settings.h"
|
||||
#include "serial.h"
|
||||
|
||||
#include "print.h"
|
||||
|
||||
// Declare system global variables
|
||||
uint8_t sys_abort; // Global system abort flag
|
||||
volatile uint8_t sys_state; // Global system state variable
|
||||
|
||||
int main(void)
|
||||
{
|
||||
sei();
|
||||
|
||||
serial_init(BAUD_RATE);
|
||||
protocol_init();
|
||||
settings_init();
|
||||
plan_init();
|
||||
st_init();
|
||||
spindle_init();
|
||||
gc_init();
|
||||
limits_init();
|
||||
// Initialize system
|
||||
sei(); // Enable interrupts
|
||||
serial_init(BAUD_RATE); // Setup serial baud rate and interrupts
|
||||
st_init(); // Setup stepper pins and interrupt timers
|
||||
sys_abort = true; // Set abort to complete initialization
|
||||
|
||||
for(;;){
|
||||
sleep_mode(); // Wait for it ...
|
||||
while(1) {
|
||||
|
||||
// Upon a system abort, the main program will return to this loop. Once here, it is safe to
|
||||
// re-initialize the system. Upon startup, the system will automatically reset to finish the
|
||||
// initialization process.
|
||||
if (sys_abort) {
|
||||
// Execute system reset
|
||||
sys_state = 0; // Reset system state
|
||||
sys_abort = false; // Release system abort
|
||||
|
||||
// Reset system.
|
||||
serial_reset_read_buffer(); // Clear serial read buffer
|
||||
settings_init(); // Load grbl settings from EEPROM
|
||||
protocol_init(); // Clear incoming line data
|
||||
plan_init(); // Clear block buffer and planner variables
|
||||
gc_init(); // Set g-code parser to default state
|
||||
spindle_init();
|
||||
limits_init();
|
||||
|
||||
// TODO: For now, the stepper subsystem tracks the absolute stepper position from the point
|
||||
// of power up or hard reset. This reset is a soft reset, where the information of the current
|
||||
// position is not lost after a system abort. This is not guaranteed to be correct, since
|
||||
// during an abort, the steppers can lose steps in the immediate stop. However, if a feed
|
||||
// hold is performed before a system abort, this position should be correct. In the next few
|
||||
// updates, this soft reset feature will be fleshed out along with the status reporting and
|
||||
// jogging features.
|
||||
st_reset(); // Clear stepper subsystem variables. Machine position variable is not reset.
|
||||
|
||||
// Print grbl initialization message
|
||||
printPgmString(PSTR("\r\nGrbl " GRBL_VERSION));
|
||||
printPgmString(PSTR("\r\n'$' to dump current settings\r\n"));
|
||||
}
|
||||
|
||||
protocol_execute_runtime();
|
||||
protocol_process(); // ... process the serial protocol
|
||||
|
||||
}
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
Reference in New Issue
Block a user