further integration of gen3 logic
This commit is contained in:
parent
25b8f9ebfb
commit
38cf934594
4
Makefile
4
Makefile
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
PROGRAM = mendel
|
||||
|
||||
SOURCES = $(PROGRAM).c serial.c dda.c gcode_parse.c gcode_process.c timer.c temp.c sermsg.c dda_queue.c watchdog.c debug.c sersendf.c heater.c analog.c delay.c intercom.c
|
||||
SOURCES = $(PROGRAM).c serial.c dda.c gcode_parse.c gcode_process.c timer.c temp.c sermsg.c dda_queue.c watchdog.c debug.c sersendf.c heater.c analog.c delay.c intercom.c pinio.c
|
||||
|
||||
##############################################################################
|
||||
# #
|
||||
|
|
@ -117,7 +117,7 @@ clean:
|
|||
|
||||
size: $(PROGRAM).elf
|
||||
@echo " SIZE Atmega168 Atmega328p Atmega644"
|
||||
@$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(text)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " FLASH : %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, ceil($$a * 100 / (14 * 1024)), 14, ceil($$a * 100 / (30 * 1024)), 30, ceil($$a * 100 / (63 * 1024)), 63 }'
|
||||
@$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(text)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " FLASH : %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, ceil($$a * 100 / (15 * 1024)), 15, ceil($$a * 100 / (31 * 1024)), 31, ceil($$a * 100 / (63 * 1024)), 63 }'
|
||||
@$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(data|bss)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " RAM : %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, ceil($$a * 100 / (1 * 1024)), 1, ceil($$a * 100 / (2 * 1024)), 2, ceil($$a * 100 / (4 * 1024)), 4 }'
|
||||
@$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(eeprom)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " EEPROM: %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, ceil($$a * 100 / (1 * 1024)), 1, ceil($$a * 100 / (2 * 1024)), 2, ceil($$a * 100 / (2 * 1024)), 2 }'
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@
|
|||
#define OC5B DIO45
|
||||
#define OC5C DIO44
|
||||
|
||||
// #define ICP1 NULL /* not brought out on the Arduino Mega, remove line as not used ?? */
|
||||
// change for your board
|
||||
#define DEBUG_LED DIO21
|
||||
|
||||
/*
|
||||
pins
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#define OC2A DIO11
|
||||
#define OC2B DIO3
|
||||
|
||||
#define ICP1 DIO8
|
||||
#define DEBUG_LED AIO5
|
||||
|
||||
/*
|
||||
pins
|
||||
|
|
|
|||
|
|
@ -1,27 +1,31 @@
|
|||
// UART
|
||||
#define RXD DIO0
|
||||
#define TXD DIO1
|
||||
#define RXD DIO8
|
||||
#define TXD DIO9
|
||||
#define RXD0 DIO8
|
||||
#define TXD0 DIO9
|
||||
|
||||
#define RXD1 DIO10
|
||||
#define TXD1 DIO11
|
||||
|
||||
// SPI
|
||||
#define SCK DIO13
|
||||
#define MISO DIO12
|
||||
#define MOSI DIO11
|
||||
#define SS DIO10
|
||||
#define SCK DIO7
|
||||
#define MISO DIO6
|
||||
#define MOSI DIO5
|
||||
#define SS DIO4
|
||||
|
||||
// TWI (I2C)
|
||||
#define SCL AIO5
|
||||
#define SDA AIO4
|
||||
#define SCL DIO16
|
||||
#define SDA DIO17
|
||||
|
||||
// timers and PWM
|
||||
#define OC0A DIO6
|
||||
#define OC0B DIO5
|
||||
#define OC1A DIO9
|
||||
#define OC1B DIO10
|
||||
#define OC2A DIO11
|
||||
#define OC2B DIO3
|
||||
|
||||
#define ICP1 DIO8
|
||||
#define OC0A DIO3
|
||||
#define OC0B DIO4
|
||||
#define OC1A DIO13
|
||||
#define OC1B DIO12
|
||||
#define OC2A DIO15
|
||||
#define OC2B DIO14
|
||||
|
||||
#define DEBUG_LED DIO0
|
||||
/*
|
||||
pins
|
||||
*/
|
||||
|
|
|
|||
140
config.h.dist
140
config.h.dist
|
|
@ -118,14 +118,14 @@ struct {
|
|||
volatile uint8_t *heater_port;
|
||||
uint8_t heater_pin;
|
||||
volatile uint8_t *heater_pwm;
|
||||
} heaters[NUM_HEATERS] =
|
||||
} heaters[NUM_HEATERS]/* =
|
||||
{
|
||||
{
|
||||
&PORTD,
|
||||
PIND6,
|
||||
&OCR0A
|
||||
}
|
||||
};
|
||||
}*/;
|
||||
#endif
|
||||
|
||||
// temperature history count. higher values make PID derivative term more stable at the expense of reaction time
|
||||
|
|
@ -194,57 +194,57 @@ struct {
|
|||
|
||||
#include "arduino.h"
|
||||
|
||||
/*
|
||||
RESERVED pins
|
||||
we NEED these for communication
|
||||
*/
|
||||
|
||||
#define RESERVED_RXD DIO0
|
||||
#define RESERVED_TXD DIO1
|
||||
|
||||
/*
|
||||
these pins are used for the MAX6675
|
||||
Arduino Mega has SPI on different pins
|
||||
*/
|
||||
#if defined (__AVR_ATmega1280__)
|
||||
#define RESERVED_SCK DIO52
|
||||
#define RESERVED_MISO DIO50
|
||||
#define RESERVED_MOSI DIO51
|
||||
#define RESERVED_SS DIO53
|
||||
#else
|
||||
#define RESERVED_SCK DIO13
|
||||
#define RESERVED_MISO DIO12
|
||||
#define RESERVED_MOSI DIO11
|
||||
#define RESERVED_SS DIO10
|
||||
#endif
|
||||
|
||||
/*
|
||||
user defined pins
|
||||
adjust to suit your electronics,
|
||||
or adjust your electronics to suit this
|
||||
*/
|
||||
|
||||
#define X_STEP_PIN AIO0
|
||||
#define X_DIR_PIN AIO1
|
||||
#define X_MIN_PIN AIO2
|
||||
|
||||
#define Y_STEP_PIN AIO3
|
||||
#define Y_DIR_PIN AIO4
|
||||
#define Y_MIN_PIN AIO5
|
||||
|
||||
#define Z_STEP_PIN DIO2
|
||||
#define Z_DIR_PIN DIO3
|
||||
#define Z_MIN_PIN DIO4
|
||||
|
||||
#define E_STEP_PIN DIO7
|
||||
#define E_DIR_PIN DIO8
|
||||
|
||||
#define STEPPER_ENABLE_PIN DIO9
|
||||
|
||||
#ifdef GEN3
|
||||
#define TX_ENABLE_PIN AIO2
|
||||
#define RX_ENABLE_PIN DIO4
|
||||
#define DEBUG_LED DIO13
|
||||
// this is official reprap motherboard pinout
|
||||
#define TX_ENABLE_PIN DIO12
|
||||
#define RX_ENABLE_PIN DIO13
|
||||
|
||||
#define X_STEP_PIN DIO15
|
||||
#define X_DIR_PIN DIO18
|
||||
#define X_MIN_PIN DIO20
|
||||
#define X_MAX_PIN DIO21
|
||||
#define X_ENABLE_PIN DIO19
|
||||
|
||||
#define Y_STEP_PIN DIO23
|
||||
#define Y_DIR_PIN DIO22
|
||||
#define Y_MIN_PIN AIO6
|
||||
#define Y_MAX_PIN AIO5
|
||||
#define Y_ENABLE_PIN DIO7
|
||||
|
||||
#define Z_STEP_PIN AIO4
|
||||
#define Z_DIR_PIN AIO3
|
||||
#define Z_MIN_PIN AIO1
|
||||
#define Z_MAX_PIN AIO0
|
||||
#define Z_ENABLE_PIN AIO2
|
||||
|
||||
#define E_STEP_PIN DIO16
|
||||
#define E_DIR_PIN DIO17
|
||||
|
||||
#define SD_CARD_DETECT DIO2
|
||||
#define SD_WRITE_PROTECT DIO3
|
||||
#else
|
||||
/*
|
||||
user defined pins
|
||||
adjust to suit your electronics,
|
||||
or adjust your electronics to suit this
|
||||
*/
|
||||
|
||||
#define X_STEP_PIN AIO0
|
||||
#define X_DIR_PIN AIO1
|
||||
#define X_MIN_PIN AIO2
|
||||
|
||||
#define Y_STEP_PIN AIO3
|
||||
#define Y_DIR_PIN AIO4
|
||||
#define Y_MIN_PIN AIO5
|
||||
|
||||
#define Z_STEP_PIN DIO2
|
||||
#define Z_DIR_PIN DIO3
|
||||
#define Z_MIN_PIN DIO4
|
||||
|
||||
#define E_STEP_PIN DIO7
|
||||
#define E_DIR_PIN DIO8
|
||||
|
||||
#define PS_ON_PIN DIO9
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
@ -285,40 +285,4 @@ struct {
|
|||
// this is the scaling of internally stored PID values. 1024L is a good value
|
||||
#define PID_SCALE 1024L
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// you shouldn't need to edit anything below this line
|
||||
|
||||
/*
|
||||
fan
|
||||
*/
|
||||
|
||||
#ifdef FAN_PIN
|
||||
#ifdef FAN_PWM
|
||||
#define enable_fan() do { TCCR0A |= MASK(COM0B1); } while (0)
|
||||
#define disable_fan() do { TCCR0A &= ~MASK(COM0B1); } while (0)
|
||||
#else
|
||||
#define enable_fan() WRITE(FAN_PIN, 1)
|
||||
#define disable_fan() WRITE(FAN_PIN, 0);
|
||||
#endif
|
||||
#else
|
||||
#define enable_fan() if (0) {}
|
||||
#define disable_fan() if (0) {}
|
||||
#endif
|
||||
|
||||
/*
|
||||
Stepper Enable (ATX PSU pwr_good signal?)
|
||||
*/
|
||||
|
||||
#ifdef STEPPER_ENABLE_PIN
|
||||
// for connection to stepper driver ENABLE pins (negative asserted)
|
||||
// #define power_on() WRITE(STEPPER_ENABLE_PIN, 0)
|
||||
// #define power_off() WRITE(STEPPER_ENABLE_PIN, 1)
|
||||
// for connection to ATX PSU PWR_ON signal
|
||||
#define power_on() do { WRITE(STEPPER_ENABLE_PIN, 0); SET_OUTPUT(STEPPER_ENABLE_PIN); } while (0)
|
||||
#define power_off() SET_INPUT(STEPPER_ENABLE_PIN)
|
||||
#else
|
||||
#define power_on() if (0) {}
|
||||
#define power_off() if (0) {}
|
||||
#endif
|
||||
|
||||
#endif /* _CONFIG_H */
|
||||
|
|
|
|||
5
dda.c
5
dda.c
|
|
@ -9,6 +9,7 @@
|
|||
#include "dda_queue.h"
|
||||
#include "debug.h"
|
||||
#include "sersendf.h"
|
||||
#include "pinio.h"
|
||||
|
||||
/*
|
||||
X Stepper
|
||||
|
|
@ -232,6 +233,10 @@ void dda_create(DDA *dda, TARGET *target) {
|
|||
// get steppers ready to go
|
||||
steptimeout = 0;
|
||||
power_on();
|
||||
x_enable();
|
||||
y_enable();
|
||||
if (dda->z_delta)
|
||||
z_enable();
|
||||
|
||||
dda->x_counter = dda->y_counter = dda->z_counter = dda->e_counter =
|
||||
-(dda->total_steps >> 1);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "heater.h"
|
||||
#include "timer.h"
|
||||
#include "sersendf.h"
|
||||
#include "pinio.h"
|
||||
|
||||
/****************************************************************************
|
||||
* *
|
||||
|
|
@ -230,8 +231,8 @@ void process_gcode_command() {
|
|||
case 109:
|
||||
temp_set(next_target.P, next_target.S);
|
||||
if (next_target.S) {
|
||||
enable_heater();
|
||||
power_on();
|
||||
enable_heater();
|
||||
}
|
||||
else {
|
||||
disable_heater();
|
||||
|
|
|
|||
24
mendel.c
24
mendel.c
|
|
@ -16,6 +16,7 @@
|
|||
#include "sersendf.h"
|
||||
#include "heater.h"
|
||||
#include "analog.h"
|
||||
#include "pinio.h"
|
||||
|
||||
void io_init(void) {
|
||||
// disable modules we don't use
|
||||
|
|
@ -71,7 +72,6 @@ void io_init(void) {
|
|||
}
|
||||
|
||||
void init(void) {
|
||||
|
||||
// set up watchdog
|
||||
wd_init();
|
||||
|
||||
|
|
@ -107,13 +107,6 @@ void init(void) {
|
|||
|
||||
}
|
||||
|
||||
void clock_10ms(void) {
|
||||
// reset watchdog
|
||||
wd_reset();
|
||||
|
||||
temp_tick();
|
||||
}
|
||||
|
||||
void clock_250ms(void) {
|
||||
if (steptimeout > (30 * 4)) {
|
||||
power_off();
|
||||
|
|
@ -138,6 +131,17 @@ void clock_250ms(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void clock_10ms(void) {
|
||||
// reset watchdog
|
||||
wd_reset();
|
||||
|
||||
temp_tick();
|
||||
|
||||
ifclock(CLOCK_FLAG_250MS) {
|
||||
clock_250ms();
|
||||
}
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
init();
|
||||
|
|
@ -154,9 +158,5 @@ int main (void)
|
|||
ifclock(CLOCK_FLAG_10MS) {
|
||||
clock_10ms();
|
||||
}
|
||||
|
||||
ifclock(CLOCK_FLAG_250MS) {
|
||||
clock_250ms();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
#include "pinio.h"
|
||||
|
||||
void power_off() {
|
||||
#ifdef X_ENABLE_PIN
|
||||
x_disable();
|
||||
#endif
|
||||
#ifdef Y_ENABLE_PIN
|
||||
y_disable();
|
||||
#endif
|
||||
#ifdef Z_ENABLE_PIN
|
||||
z_disable();
|
||||
#endif
|
||||
|
||||
#ifdef STEPPER_ENABLE_PIN
|
||||
SET_INPUT(STEPPER_ENABLE_PIN);
|
||||
#endif
|
||||
#ifdef PS_ON_PIN
|
||||
SET_INPUT(PS_ON_PIN);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef _PINIO_H
|
||||
#define _PINIO_H
|
||||
|
||||
/*
|
||||
Power
|
||||
*/
|
||||
|
||||
#ifdef STEPPER_ENABLE_PIN
|
||||
#define power_on() do { WRITE(STEPPER_ENABLE_PIN, 0); SET_OUTPUT(STEPPER_ENABLE_PIN); } while (0)
|
||||
#elif defined PS_ON_PIN
|
||||
#define power_on() do { WRITE(PS_ON_PIN, 0); SET_OUTPUT(PS_ON_PIN); } while (0)
|
||||
#else
|
||||
#define power_on() do { } while (0)
|
||||
#endif
|
||||
|
||||
void power_off(void);
|
||||
|
||||
/*
|
||||
Stepper Enable Pins
|
||||
*/
|
||||
|
||||
#ifdef X_ENABLE_PIN
|
||||
#define x_enable() do { WRITE(X_ENABLE_PIN, 0); SET_OUTPUT(X_ENABLE_PIN); } while (0)
|
||||
#define x_disable() do { WRITE(X_ENABLE_PIN, 1); SET_OUTPUT(X_ENABLE_PIN); } while (0)
|
||||
#else
|
||||
#define x_enable() do { } while (0)
|
||||
#define x_disable() do { } while (0)
|
||||
#endif
|
||||
|
||||
#ifdef Y_ENABLE_PIN
|
||||
#define y_enable() do { WRITE(Y_ENABLE_PIN, 0); SET_OUTPUT(Y_ENABLE_PIN); } while (0)
|
||||
#define y_disable() do { WRITE(Y_ENABLE_PIN, 1); SET_OUTPUT(Y_ENABLE_PIN); } while (0)
|
||||
#else
|
||||
#define y_enable() do { } while (0)
|
||||
#define y_disable() do { } while (0)
|
||||
#endif
|
||||
|
||||
#ifdef Z_ENABLE_PIN
|
||||
#define z_enable() do { WRITE(Z_ENABLE_PIN, 0); SET_OUTPUT(Z_ENABLE_PIN); } while (0)
|
||||
#define z_disable() do { WRITE(Z_ENABLE_PIN, 1); SET_OUTPUT(Z_ENABLE_PIN); } while (0)
|
||||
#else
|
||||
#define z_enable() do { } while (0)
|
||||
#define z_disable() do { } while (0)
|
||||
#endif
|
||||
|
||||
#endif /* _PINIO_H */
|
||||
Loading…
Reference in New Issue