Grbl can now take advantage of the extra memory in the 328
This commit is contained in:
parent
e409f10047
commit
937c70cb50
2
Makefile
2
Makefile
@ -27,7 +27,7 @@
|
|||||||
# is connected.
|
# is connected.
|
||||||
# FUSES ........ Parameters for avrdude to flash the fuses appropriately.
|
# FUSES ........ Parameters for avrdude to flash the fuses appropriately.
|
||||||
|
|
||||||
DEVICE = atmega168
|
DEVICE = atmega328p
|
||||||
CLOCK = 16000000
|
CLOCK = 16000000
|
||||||
PROGRAMMER = -c avrisp2 -P usb
|
PROGRAMMER = -c avrisp2 -P usb
|
||||||
OBJECTS = main.o motion_control.o gcode.o spindle_control.o wiring_serial.o serial_protocol.o stepper.o \
|
OBJECTS = main.o motion_control.o gcode.o spindle_control.o wiring_serial.o serial_protocol.o stepper.o \
|
||||||
|
@ -26,16 +26,15 @@ end
|
|||||||
|
|
||||||
SerialPort.open('/dev/tty.FireFly-A964-SPP-1', 115200) do |sp|
|
SerialPort.open('/dev/tty.FireFly-A964-SPP-1', 115200) do |sp|
|
||||||
sp.write("\r\n\r\n");
|
sp.write("\r\n\r\n");
|
||||||
sleep 5
|
sleep 1
|
||||||
ARGV.each do |file|
|
ARGV.each do |file|
|
||||||
puts "Processing file #{file}"
|
puts "Processing file #{file}"
|
||||||
prebuffer = $prebuffer ? 12 : 0
|
prebuffer = $prebuffer ? 20 : 0
|
||||||
File.readlines(file).each do |line|
|
File.readlines(file).each do |line|
|
||||||
next if line.strip == ''
|
next if line.strip == ''
|
||||||
puts line.strip
|
puts line.strip
|
||||||
sp.write("#{line.strip}\r\n");
|
sp.write("#{line.strip}\r\n");
|
||||||
if prebuffer == 0
|
if prebuffer == 0
|
||||||
sleep 0.1
|
|
||||||
begin
|
begin
|
||||||
result = sp.gets.strip
|
result = sp.gets.strip
|
||||||
puts "Grbl >> #{result}" unless result == '' or result == 'ok'
|
puts "Grbl >> #{result}" unless result == '' or result == 'ok'
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "nuts_bolts.h"
|
#include "nuts_bolts.h"
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#define LINE_BUFFER_SIZE 30
|
#define LINE_BUFFER_SIZE 50
|
||||||
|
|
||||||
char line[LINE_BUFFER_SIZE];
|
char line[LINE_BUFFER_SIZE];
|
||||||
uint8_t char_counter;
|
uint8_t char_counter;
|
||||||
@ -52,6 +52,7 @@ void sp_process()
|
|||||||
{
|
{
|
||||||
if((c == '\n')) { // Line is complete. Then execute!
|
if((c == '\n')) { // Line is complete. Then execute!
|
||||||
line[char_counter] = 0;
|
line[char_counter] = 0;
|
||||||
|
printString(line); printPgmString(PSTR("\r\n"));
|
||||||
gc_execute_line(line);
|
gc_execute_line(line);
|
||||||
char_counter = 0;
|
char_counter = 0;
|
||||||
prompt();
|
prompt();
|
||||||
|
15
stepper.c
15
stepper.c
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
|
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
|
||||||
and Philipp Tiefenbacher. The circle buffer implementation gleaned from the wiring_serial library
|
and Philipp Tiefenbacher. The ring buffer implementation gleaned from the wiring_serial library
|
||||||
by David A. Mellis */
|
by David A. Mellis */
|
||||||
|
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
@ -32,7 +32,12 @@
|
|||||||
|
|
||||||
#include "wiring_serial.h"
|
#include "wiring_serial.h"
|
||||||
|
|
||||||
|
// Pick a suitable line-buffer size
|
||||||
|
#ifdef __AVR_ATmega328P__
|
||||||
|
#define LINE_BUFFER_SIZE 40 // Atmega 328 has one full kilobyte of extra RAM!
|
||||||
|
#else
|
||||||
#define LINE_BUFFER_SIZE 10
|
#define LINE_BUFFER_SIZE 10
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Line {
|
struct Line {
|
||||||
uint32_t steps_x, steps_y, steps_z;
|
uint32_t steps_x, steps_y, steps_z;
|
||||||
@ -86,7 +91,11 @@ void st_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_t
|
|||||||
// This timer interrupt is executed at the rate set with config_step_timer. 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
|
// the line_buffer, executes it. Then it starts timer2 in order to reset the motor port after
|
||||||
// five microseconds.
|
// five microseconds.
|
||||||
|
#ifdef TIMER1_COMPA_vect
|
||||||
|
SIGNAL(TIMER1_COMPA_vect)
|
||||||
|
#else
|
||||||
SIGNAL(SIG_OUTPUT_COMPARE1A)
|
SIGNAL(SIG_OUTPUT_COMPARE1A)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if(busy){ return; } // The busy-flag is used to avoid reentering this interrupt
|
if(busy){ return; } // The busy-flag is used to avoid reentering this interrupt
|
||||||
|
|
||||||
@ -158,7 +167,11 @@ SIGNAL(SIG_OUTPUT_COMPARE1A)
|
|||||||
|
|
||||||
// This interrupt is set up by SIG_OUTPUT_COMPARE1A when it sets the motor port bits. It resets
|
// This interrupt is set up by SIG_OUTPUT_COMPARE1A when it sets the motor port bits. It resets
|
||||||
// the motor port after a short period (settings.pulse_microseconds) completing one step cycle.
|
// the motor port after a short period (settings.pulse_microseconds) completing one step cycle.
|
||||||
|
#ifdef TIMER2_OVF_vect
|
||||||
|
SIGNAL(TIMER2_OVF_vect)
|
||||||
|
#else
|
||||||
SIGNAL(SIG_OVERFLOW2)
|
SIGNAL(SIG_OVERFLOW2)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// reset stepping pins (leave the direction pins)
|
// reset stepping pins (leave the direction pins)
|
||||||
STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | (settings.invert_mask & STEP_MASK);
|
STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | (settings.invert_mask & STEP_MASK);
|
||||||
|
@ -39,7 +39,6 @@ int rx_buffer_tail = 0;
|
|||||||
|
|
||||||
void beginSerial(long baud)
|
void beginSerial(long baud)
|
||||||
{
|
{
|
||||||
#if defined(__AVR_ATmega168__)
|
|
||||||
UBRR0H = ((F_CPU / 16 + baud / 2) / baud - 1) >> 8;
|
UBRR0H = ((F_CPU / 16 + baud / 2) / baud - 1) >> 8;
|
||||||
UBRR0L = ((F_CPU / 16 + baud / 2) / baud - 1);
|
UBRR0L = ((F_CPU / 16 + baud / 2) / baud - 1);
|
||||||
|
|
||||||
@ -49,34 +48,16 @@ void beginSerial(long baud)
|
|||||||
|
|
||||||
// enable interrupt on complete reception of a byte
|
// enable interrupt on complete reception of a byte
|
||||||
sbi(UCSR0B, RXCIE0);
|
sbi(UCSR0B, RXCIE0);
|
||||||
#else
|
|
||||||
UBRRH = ((F_CPU / 16 + baud / 2) / baud - 1) >> 8;
|
|
||||||
UBRRL = ((F_CPU / 16 + baud / 2) / baud - 1);
|
|
||||||
|
|
||||||
// enable rx and tx
|
|
||||||
sbi(UCSRB, RXEN);
|
|
||||||
sbi(UCSRB, TXEN);
|
|
||||||
|
|
||||||
// enable interrupt on complete reception of a byte
|
|
||||||
sbi(UCSRB, RXCIE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// defaults to 8-bit, no parity, 1 stop bit
|
// defaults to 8-bit, no parity, 1 stop bit
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialWrite(unsigned char c)
|
void serialWrite(unsigned char c)
|
||||||
{
|
{
|
||||||
#if defined(__AVR_ATmega168__)
|
|
||||||
while (!(UCSR0A & (1 << UDRE0)))
|
while (!(UCSR0A & (1 << UDRE0)))
|
||||||
;
|
;
|
||||||
|
|
||||||
UDR0 = c;
|
UDR0 = c;
|
||||||
#else
|
|
||||||
while (!(UCSRA & (1 << UDRE)))
|
|
||||||
;
|
|
||||||
|
|
||||||
UDR = c;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int serialAvailable()
|
int serialAvailable()
|
||||||
@ -106,18 +87,13 @@ void serialFlush()
|
|||||||
rx_buffer_head = rx_buffer_tail;
|
rx_buffer_head = rx_buffer_tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__AVR_ATmega168__)
|
#ifdef USART_RX_vect
|
||||||
SIGNAL(SIG_USART_RECV)
|
SIGNAL(USART_RX_vect)
|
||||||
#else
|
#else
|
||||||
SIGNAL(SIG_UART_RECV)
|
SIGNAL(SIG_USART_RECV)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined(__AVR_ATmega168__)
|
|
||||||
unsigned char c = UDR0;
|
unsigned char c = UDR0;
|
||||||
#else
|
|
||||||
unsigned char c = UDR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int i = (rx_buffer_head + 1) % RX_BUFFER_SIZE;
|
int i = (rx_buffer_head + 1) % RX_BUFFER_SIZE;
|
||||||
|
|
||||||
// if we should be storing the received character into the location
|
// if we should be storing the received character into the location
|
||||||
|
Loading…
Reference in New Issue
Block a user