#include "temperature.h"\r
#include "ultralcd.h"\r
\r
-//public variables\r
+//===========================================================================\r
+//=============================public variables ============================\r
+//===========================================================================\r
+\r
unsigned long minsegmenttime;\r
float max_feedrate[4]; // set the max speeds\r
float axis_steps_per_unit[4];\r
float max_z_jerk;\r
float mintravelfeedrate;\r
unsigned long axis_steps_per_sqr_second[NUM_AXIS];\r
+\r
+// The current position of the tool in absolute steps\r
long position[4]; //rescaled from extern when axis_steps_per_unit are changed by gcode\r
\r
\r
-//private variables\r
+//===========================================================================\r
+//=============================private variables ============================\r
+//===========================================================================\r
static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions\r
static volatile unsigned char block_buffer_head; // Index of the next block to be pushed\r
static volatile unsigned char block_buffer_tail; // Index of the block to process now\r
\r
-// The current position of the tool in absolute steps\r
\r
\r
+//===========================================================================\r
+//=============================functions ============================\r
+//===========================================================================\r
#define ONE_MINUTE_OF_MICROSECONDS 60000000.0\r
\r
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the \r
\r
#include "speed_lookuptable.h"\r
\r
+\r
+//===========================================================================\r
+//=============================public variables ============================\r
+//===========================================================================\r
+block_t *current_block; // A pointer to the block currently being traced\r
+\r
+\r
+//===========================================================================\r
+//=============================private variables ============================\r
+//===========================================================================\r
+//static makes it inpossible to be called from outside of this file by extern.!\r
+\r
+// Variables used by The Stepper Driver Interrupt\r
+static unsigned char out_bits; // The next stepping-bits to be output\r
+static long counter_x, // Counter variables for the bresenham line tracer\r
+ counter_y, \r
+ counter_z, \r
+ counter_e;\r
+static unsigned long step_events_completed; // The number of step events executed in the current block\r
+#ifdef ADVANCE\r
+ static long advance_rate, advance, final_advance = 0;\r
+ static short old_advance = 0;\r
+ static short e_steps;\r
+#endif\r
+static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.\r
+static long acceleration_time, deceleration_time;\r
+//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;\r
+static unsigned short acc_step_rate; // needed for deccelaration start point\r
+static char step_loops;\r
+\r
+\r
+\r
// if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer.\r
// for debugging purposes only, should be disabled by default\r
#ifdef DEBUG_STEPS\r
volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1};\r
#endif\r
\r
+//===========================================================================\r
+//=============================functions ============================\r
+//===========================================================================\r
+ \r
\r
// intRes = intIn1 * intIn2 >> 16\r
// uses:\r
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)\r
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)\r
\r
-block_t *current_block; // A pointer to the block currently being traced\r
\r
-//static makes it inpossible to be called from outside of this file by extern.!\r
\r
-// Variables used by The Stepper Driver Interrupt\r
-static unsigned char out_bits; // The next stepping-bits to be output\r
-static long counter_x, // Counter variables for the bresenham line tracer\r
- counter_y, \r
- counter_z, \r
- counter_e;\r
-static unsigned long step_events_completed; // The number of step events executed in the current block\r
-#ifdef ADVANCE\r
- static long advance_rate, advance, final_advance = 0;\r
- static short old_advance = 0;\r
- static short e_steps;\r
-#endif\r
-static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.\r
-static long acceleration_time, deceleration_time;\r
-//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;\r
-static unsigned short acc_step_rate; // needed for deccelaration start point\r
-static char step_loops;\r
+\r
\r
\r
// __________________________\r
#include "temperature.h"\r
#include "watchdog.h"\r
\r
-\r
+//===========================================================================\r
+//=============================public variables============================\r
+//===========================================================================\r
int target_raw[3] = {0, 0, 0};\r
int current_raw[3] = {0, 0, 0};\r
\r
+#ifdef PIDTEMP\r
+ \r
+ // probably used external\r
+ float HeaterPower;\r
+ float pid_setpoint = 0.0;\r
+\r
+ \r
+ float Kp=DEFAULT_Kp;\r
+ float Ki=DEFAULT_Ki;\r
+ float Kd=DEFAULT_Kd;\r
+ float Kc=DEFAULT_Kc;\r
+#endif //PIDTEMP\r
+ \r
+ \r
+//===========================================================================\r
+//=============================private variables============================\r
+//===========================================================================\r
static bool temp_meas_ready = false;\r
\r
static unsigned long previous_millis_heater, previous_millis_bed_heater;\r
static float pTerm;\r
static float iTerm;\r
static float dTerm;\r
- //int output;\r
+ //int output;\r
static float pid_error;\r
static float temp_iState_min;\r
static float temp_iState_max;\r
static float pid_input;\r
static float pid_output;\r
static bool pid_reset;\r
- \r
- // probably used external\r
- float HeaterPower;\r
- float pid_setpoint = 0.0;\r
-\r
- \r
- float Kp=DEFAULT_Kp;\r
- float Ki=DEFAULT_Ki;\r
- float Kd=DEFAULT_Kd;\r
- float Kc=DEFAULT_Kc;\r
+ \r
#endif //PIDTEMP\r
\r
#ifdef WATCHPERIOD\r
static int bed_maxttemp = temp2analog(BED_MAXTEMP);\r
#endif //BED_MAXTEMP\r
\r
+//===========================================================================\r
+//=============================functions ============================\r
+//===========================================================================\r
+ \r
void manage_heater()\r
{\r
#ifdef USE_WATCHDOG\r
#endif\r
}\r
}\r
-\r\r
+\r
+\r
#include "ultralcd.h"\r
#ifdef ULTRA_LCD\r
\r
+//===========================================================================\r
+//=============================imported variables============================\r
+//===========================================================================\r
\r
extern volatile int feedmultiply;\r
extern volatile bool feedmultiplychanged;\r
extern long position[4]; \r
extern CardReader card;\r
\r
+//===========================================================================\r
+//=============================public variables============================\r
+//===========================================================================\r
+volatile char buttons=0; //the last checked buttons in a bit array.\r
+int encoderpos=0;\r
+short lastenc=0;\r
+\r
+\r
+//===========================================================================\r
+//=============================private variables============================\r
+//===========================================================================\r
static char messagetext[LCD_WIDTH]="";\r
\r
+//return for string conversion routines\r
+static char conv[8];\r
+\r
#include <LiquidCrystal.h>\r
LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 \r
\r
static unsigned long previous_millis_lcd=0;\r
static long previous_millis_buttons=0;\r
\r
-inline int intround(const float &x){return int(0.5+x);}\r
\r
-volatile char buttons=0; //the last checked buttons in a bit array.\r
-int encoderpos=0;\r
-short lastenc=0;\r
#ifdef NEWPANEL\r
static long blocking=0;\r
#else\r
static long blocking[8]={0,0,0,0,0,0,0,0};\r
#endif\r
-MainMenu menu;\r
+ \r
+static MainMenu menu;\r
+\r
+\r
+//===========================================================================\r
+//=============================functions ============================\r
+//===========================================================================\r
+\r
+inline int intround(const float &x){return int(0.5+x);}\r
\r
void lcd_status(const char* message)\r
{\r
} \r
}\r
\r
-#include "SdFat.h"\r
+\r
\r
\r
\r
\r
\r
\r
-//return for string conversion routines\r
-static char conv[8];\r
+\r
\r
// convert float to string with +123.4 format\r
char *ftostr3(const float &x)\r
#include <avr/wdt.h>
#include <avr/interrupt.h>
+//===========================================================================
+//=============================private variables ============================
+//===========================================================================
+
static volatile uint8_t timeout_seconds=0;
void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
+//===========================================================================
+//=============================functinos ============================
+//===========================================================================
+
+
+/// intialise watch dog with a 1 sec interrupt time
+void wd_init()
+{
+ WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes
+ WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
+}
+
+/// reset watchdog. MUST be called every 1s after init or avr will reset.
+void wd_reset()
+{
+ wdt_reset();
+ timeout_seconds=0; //reset counter for resets
+}
+
+//===========================================================================
+//=============================ISR ============================
+//===========================================================================
+
//Watchdog timer interrupt, called if main program blocks >1sec
ISR(WDT_vect)
{
}
}
-/// intialise watch dog with a 1 sec interrupt time
-void wd_init()
-{
- WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes
- WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
-}
-
-/// reset watchdog. MUST be called every 1s after init or avr will reset.
-void wd_reset()
-{
- wdt_reset();
- timeout_seconds=0; //reset counter for resets
-}
-
#endif /* USE_WATCHDOG */