diff options
Diffstat (limited to 'Sprinter')
-rw-r--r-- | Sprinter/Configuration.h | 14 | ||||
-rw-r--r-- | Sprinter/Sd2PinMap.h | 2 | ||||
-rw-r--r-- | Sprinter/Sprinter.h | 1 | ||||
-rw-r--r-- | Sprinter/Sprinter.pde | 99 | ||||
-rw-r--r-- | Sprinter/fastio.h | 4 | ||||
-rw-r--r-- | Sprinter/pins.h | 136 | ||||
-rw-r--r-- | Sprinter/thermistortables.h | 122 |
7 files changed, 302 insertions, 76 deletions
diff --git a/Sprinter/Configuration.h b/Sprinter/Configuration.h index 2594593..6e643ff 100644 --- a/Sprinter/Configuration.h +++ b/Sprinter/Configuration.h @@ -9,6 +9,8 @@ // Gen6 = 5, // Sanguinololu up to 1.1 = 6 // Sanguinololu 1.2 and above = 62 +// Gen 3 Plus = 21 +// gen 3 Monolithic Electronics = 22 #define MOTHERBOARD 3 //// Thermistor settings: @@ -16,6 +18,8 @@ // 2 is 200k thermistor // 3 is mendel-parts thermistor // 4 is 10k thermistor +// 5 is ParCan supplied 104GT-2 100K +// 6 is EPCOS 100k #define THERMISTORHEATER 1 #define THERMISTORBED 1 @@ -29,7 +33,7 @@ float axis_steps_per_unit[] = {80, 80, 3200/1.25,700}; //float axis_steps_per_unit[] = {104.987, 104.987, 4545.4544, 1487}; //// Endstop Settings -#define ENDSTOPPULLUPS 1 // Comment this out (using // at the start of the line) to disable the endstop pullup resistors +#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins. //If your axes are only moving in one direction, make sure the endstops are connected properly. //If your axes move in one direction ONLY when the endstops are triggered, set [XYZ]_ENDSTOP_INVERT to true here: @@ -41,7 +45,7 @@ const bool Z_ENDSTOP_INVERT = false; #define BAUDRATE 115200 // Comment out (using // at the start of the line) to disable SD support: -#define SDSUPPORT 1 +#define SDSUPPORT //// ADVANCED SETTINGS - to tweak parameters @@ -93,7 +97,7 @@ bool axis_relative_modes[] = {false, false, false, false}; //#define STEP_DELAY_RATIO 0.25 // Comment this to disable ramp acceleration -#define RAMP_ACCELERATION 1 +#define RAMP_ACCELERATION //// Acceleration settings #ifdef RAMP_ACCELERATION @@ -113,7 +117,7 @@ char uuid[] = "00000000-0000-0000-0000-000000000000"; //// PID settings: // Uncomment the following line to enable PID support. This is untested and could be disastrous. Be careful. -//#define PIDTEMP 1 +//#define PIDTEMP #ifdef PIDTEMP #define PID_INTEGRAL_DRIVE_MAX 220 #define PID_PGAIN 180 //100 is 1.0 @@ -139,7 +143,7 @@ char uuid[] = "00000000-0000-0000-0000-000000000000"; #define DISABLE_CHECK_DURING_TRAVEL 1000 //// Temperature smoothing - only uncomment this if your temp readings are noisy (Gen6 without EvdZ's 5V hack) -//#define SMOOTHING 1 +//#define SMOOTHING //#define SMOOTHFACTOR 16 //best to use a power of two here - determines how many values are averaged together by the smoothing algorithm //// Experimental watchdog and minimal temp diff --git a/Sprinter/Sd2PinMap.h b/Sprinter/Sd2PinMap.h index 4bd75a3..55518ed 100644 --- a/Sprinter/Sd2PinMap.h +++ b/Sprinter/Sd2PinMap.h @@ -117,7 +117,7 @@ static const pin_map_t digitalPinMap[] = { {&DDRK, &PINK, &PORTK, 7} // K7 69
};
//------------------------------------------------------------------------------
-#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
+#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284P__)
// Sanguino
// Two Wire (aka I2C) ports
diff --git a/Sprinter/Sprinter.h b/Sprinter/Sprinter.h index d612b5d..a7c7a8f 100644 --- a/Sprinter/Sprinter.h +++ b/Sprinter/Sprinter.h @@ -8,6 +8,7 @@ void get_command(); void process_commands(); void manage_inactivity(byte debug); +void setup_acceleration(); void manage_heater(); int temp2analogu(int celsius, const short table[][2], int numtemps, int source); diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 3243d78..95fcd47 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -311,11 +311,7 @@ void setup() SET_OUTPUT(E_STEP_PIN); #endif #ifdef RAMP_ACCELERATION - for(int i=0; i < NUM_AXIS; i++){ - axis_max_interval[i] = 100000000.0 / (max_start_speed_units_per_second[i] * axis_steps_per_unit[i]); - axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; - axis_travel_steps_per_sqr_second[i] = max_travel_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; - } + setup_acceleration(); #endif #ifdef HEATER_USES_MAX6675 @@ -787,7 +783,7 @@ inline void process_commands() #endif return; //break; - case 109: // M109 - Wait for extruder heater to reach target. + case 109: { // M109 - Wait for extruder heater to reach target. if (code_seen('S')) target_raw = temp2analogh(code_value()); #ifdef WATCHPERIOD if(target_raw>current_raw){ @@ -798,65 +794,39 @@ inline void process_commands() } #endif codenum = millis(); + /* See if we are heating up or cooling down */ - if( current_raw < target_raw ) - /* We are heating up */ - #ifdef TEMP_RESIDENCY_TIME - long residencyStart; - residencyStart = -1; - /* continue to loop until we have reached the target temp - _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */ - while( current_raw < target_raw - || (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) { - #else - while(current_raw < target_raw) { - #endif - if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up. - { - Serial.print("T:"); - Serial.println( analog2temp(current_raw) ); - codenum = millis(); - } - manage_heater(); - #ifdef TEMP_RESIDENCY_TIME - /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time - or when current temp falls outside the hysteresis after target temp was reached */ - if ( (residencyStart == -1 && current_raw >= target_raw) - || (residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) ) { - residencyStart = millis(); - } - #endif - } - else if( current_raw > target_raw ) - /* We are cooling down */ - #ifdef TEMP_RESIDENCY_TIME - long residencyStart; - residencyStart = -1; - /* continue to loop until we have reached the target temp - _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */ - while( current_raw > target_raw - || (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) { - #else - while(current_raw > target_raw) { - #endif - if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up. + bool target_direction = (current_raw < target_raw); // true if heating, false if cooling + + #ifdef TEMP_RESIDENCY_TIME + long residencyStart; + residencyStart = -1; + /* continue to loop until we have reached the target temp + _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */ + while( (target_direction ? (current_raw < target_raw) : (current_raw > target_raw)) + || (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) { + #else + while ( target_direction ? (current_raw < target_raw) : (current_raw > target_raw) ) { + #endif + if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up/cooling down { Serial.print("T:"); - Serial.println( analog2temp(current_raw) ); - codenum = millis(); + Serial.println( analog2temp(current_raw) ); + codenum = millis(); } manage_heater(); #ifdef TEMP_RESIDENCY_TIME /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time or when current temp falls outside the hysteresis after target temp was reached */ - if ( (residencyStart == -1 && current_raw <= target_raw) + if ( (residencyStart == -1 && target_direction && current_raw >= target_raw) + || (residencyStart == -1 && !target_direction && current_raw <= target_raw) || (residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) ) { residencyStart = millis(); } #endif - } - - break; + } + } + break; case 190: // M190 - Wait bed for heater to reach target. #if TEMP_1_PIN > -1 if (code_seen('S')) target_bed_raw = temp2analogh(code_value()); @@ -917,15 +887,10 @@ inline void process_commands() if(code_seen(axis_codes[i])) axis_steps_per_unit[i] = code_value(); } - //Update start speed intervals and axis order. TODO: refactor axis_max_interval[] calculation into a function, as it - // should also be used in setup() as well #ifdef RAMP_ACCELERATION - long temp_max_intervals[NUM_AXIS]; - for(int i=0; i < NUM_AXIS; i++) { - axis_max_interval[i] = 100000000.0 / (max_start_speed_units_per_second[i] * axis_steps_per_unit[i]);//TODO: do this for - // all steps_per_unit related variables - } + setup_acceleration(); #endif + break; case 115: // M115 Serial.print("FIRMWARE_NAME:Sprinter FIRMWARE_URL:http%%3A/github.com/kliment/Sprinter/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 UUID:"); @@ -1277,8 +1242,8 @@ inline void linear_move(unsigned long axis_steps_remaining[]) // make linear mov if (acceleration_enabled && steps_done == 0) { interval = max_interval; } else if (acceleration_enabled && steps_done <= plateau_steps) { - long current_speed = (long) ((((long) steps_per_sqr_second) / 10000) - * ((micros() - start_move_micros) / 100) + (long) min_speed_steps_per_second); + long current_speed = (long) ((((long) steps_per_sqr_second) / 100) + * ((micros() - start_move_micros) / 100)/100 + (long) min_speed_steps_per_second); interval = 100000000 / current_speed; if (interval < full_interval) { accelerating = false; @@ -1664,6 +1629,16 @@ if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) if( (millis()-previous_millis_cmd) > stepper_inactive_time ) if(stepper_inactive_time) { disable_x(); disable_y(); disable_z(); disable_e(); } } +#ifdef RAMP_ACCELERATION +void setup_acceleration() { + for (int i=0; i < NUM_AXIS; i++) { + axis_max_interval[i] = 100000000.0 / (max_start_speed_units_per_second[i] * axis_steps_per_unit[i]); + axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; + axis_travel_steps_per_sqr_second[i] = max_travel_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; + } +} +#endif + #ifdef DEBUG void log_message(char* message) { Serial.print("DEBUG"); Serial.println(message); diff --git a/Sprinter/fastio.h b/Sprinter/fastio.h index 1d28d05..73410cb 100644 --- a/Sprinter/fastio.h +++ b/Sprinter/fastio.h @@ -400,7 +400,7 @@ pins #define PD7_PWM NULL #endif /* _AVR_ATmega{168,328,328P}__ */ -#if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) +#if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__) // UART #define RXD DIO8 #define TXD DIO9 @@ -901,7 +901,7 @@ pins #define PD7_WPORT PORTD #define PD7_DDR DDRD #define PD7_PWM &OCR2A -#endif /* _AVR_ATmega{644,644P,644PA}__ */ +#endif /* _AVR_ATmega{644,644P,644PA,1284P}__ */ #if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__) // UART diff --git a/Sprinter/pins.h b/Sprinter/pins.h index 9c38bed..8571d20 100644 --- a/Sprinter/pins.h +++ b/Sprinter/pins.h @@ -98,7 +98,7 @@ #if MOTHERBOARD == 1 #define KNOWN_BOARD 1 -#ifndef __AVR_ATmega644P__ +#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. #endif @@ -148,7 +148,7 @@ #if MOTHERBOARD == 2 #define KNOWN_BOARD 1 -#ifndef __AVR_ATmega644P__ +#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. #endif @@ -201,6 +201,129 @@ #endif /**************************************************************************************** +* Gen3 PLUS +* +****************************************************************************************/ +#if MOTHERBOARD == 21 +#define KNOWN_BOARD 1 + +#ifndef __AVR_ATmega644P__ + #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. +#endif + + +//x axis pins +#define X_STEP_PIN 15 +#define X_DIR_PIN 18 +#define X_ENABLE_PIN 19 +#define X_MIN_PIN 20 +#define X_MAX_PIN -1 + +//y axis pins +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 +#define Y_MIN_PIN 25 +#define Y_MAX_PIN -1 + +//z axis pins +#define Z_STEP_PIN 27 +#define Z_DIR_PIN 28 +#define Z_ENABLE_PIN 29 +#define Z_MIN_PIN 30 +#define Z_MAX_PIN -1 + +#define E_DIR_PIN 21 +#define E_STEP_PIN 17 +#define E_ENABLE_PIN 13 + +//heaters + +//pin for hot end heater +#define HEATER_0_PIN 12 + +//Pin for heated bed heater +#define HEATER_1_PIN 5 + + +//pin for debugging. +#define DEBUG_PIN -1 + +//SD card pin + +#define SDSS 4 + +#define SDPOWER -1 +#define FAN_PIN -1 +#define TEMP_0_PIN 0 +#define TEMP_1_PIN 5 +#define LED_PIN -1 + +//pin for controlling the PSU. +#define PS_ON_PIN 14 + +#endif + +/**************************************************************************************** +* Gen3 Monolithic Electronics +* +****************************************************************************************/ +#if MOTHERBOARD == 22 +#define KNOWN_BOARD 1 + +#ifndef __AVR_ATmega644P__ + #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. +#endif + +#define DEBUG_PIN 0 + + +// x axis +#define X_STEP_PIN 15 +#define X_DIR_PIN 18 +#define X_MIN_PIN 20 +#define X_ENABLE_PIN 24 //actually uses Y_enable_pin +#define X_MAX_PIN -1 + +// y axes +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_MIN_PIN 25 +#define Y_ENABLE_PIN 24 //shared with X_enable_pin +#define Y_MAX_PIN -1 + +// z axes +#define Z_STEP_PIN 27 +#define Z_DIR_PIN 28 +#define Z_MIN_PIN 30 +#define Z_ENABLE_PIN 29 +#define Z_MAX_PIN -1 + +//extruder pins +#define E_STEP_PIN 12 +#define E_DIR_PIN 17 +#define E_ENABLE_PIN 3 +#define HEATER_0_PIN 16 +#define TEMP_0_PIN 0 + +#define FAN_PIN -1 + +//bed pins +#define HEATER_1_PIN -1 +#define TEMP_1_PIN -1 + + +#define SDSS -1 +#define SDPOWER -1 +#define LED_PIN -1 + +//pin for controlling the PSU. +#define PS_ON_PIN 14 + +#endif + + +/**************************************************************************************** * Arduino Mega pin assignment * ****************************************************************************************/ @@ -261,7 +384,7 @@ #define HEATER_1_PIN 8 #define TEMP_0_PIN 13 // ANALOG NUMBERING #define TEMP_1_PIN 14 // ANALOG NUMBERING - +#define TEMP_2_PIN 15 // ANALOG NUMBERING #else // RAMPS_V_1_1 or RAMPS_V_1_2 as default @@ -313,7 +436,8 @@ // SPI for Max6675 Thermocouple #ifndef SDSUPPORT -// these pins are defined in the SD library if building with SD support #define SCK_PIN 52 +// these pins are defined in the SD library if building with SD support + #define SCK_PIN 52 #define MISO_PIN 50 #define MOSI_PIN 51 #define MAX6675_SS 53 @@ -376,7 +500,7 @@ #if MOTHERBOARD == 5 #define KNOWN_BOARD 1 -#ifndef __AVR_ATmega644P__ +#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. #endif @@ -435,7 +559,7 @@ #endif #if MOTHERBOARD == 6 #define KNOWN_BOARD 1 -#ifndef __AVR_ATmega644P__ +#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. #endif diff --git a/Sprinter/thermistortables.h b/Sprinter/thermistortables.h index de9aee6..67fb666 100644 --- a/Sprinter/thermistortables.h +++ b/Sprinter/thermistortables.h @@ -157,6 +157,116 @@ short temptable_4[NUMTEMPS_4][2] = { }; #endif +#if (THERMISTORHEATER == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2) + +#define NUMTEMPS_5 61 +const short temptable_5[NUMTEMPS_5][2] = { +{1, 713}, +{18, 316}, +{35, 266}, +{52, 239}, +{69, 221}, +{86, 208}, +{103, 197}, +{120, 188}, +{137, 181}, +{154, 174}, +{171, 169}, +{188, 163}, +{205, 159}, +{222, 154}, +{239, 150}, +{256, 147}, +{273, 143}, +{290, 140}, +{307, 136}, +{324, 133}, +{341, 130}, +{358, 128}, +{375, 125}, +{392, 122}, +{409, 120}, +{426, 117}, +{443, 115}, +{460, 112}, +{477, 110}, +{494, 108}, +{511, 106}, +{528, 103}, +{545, 101}, +{562, 99}, +{579, 97}, +{596, 95}, +{613, 92}, +{630, 90}, +{647, 88}, +{664, 86}, +{681, 84}, +{698, 81}, +{715, 79}, +{732, 77}, +{749, 75}, +{766, 72}, +{783, 70}, +{800, 67}, +{817, 64}, +{834, 61}, +{851, 58}, +{868, 55}, +{885, 52}, +{902, 48}, +{919, 44}, +{936, 40}, +{953, 34}, +{970, 28}, +{987, 20}, +{1004, 8}, +{1021, 0} +}; +#endif + +#if (THERMISTORHEATER == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor +#define NUMTEMPS_6 36 +const short temptable_6[NUMTEMPS_6][2] = { + {28, 250}, + {31, 245}, + {35, 240}, + {39, 235}, + {42, 230}, + {44, 225}, + {49, 220}, + {53, 215}, + {62, 210}, + {73, 205}, + {72, 200}, + {94, 190}, + {102, 185}, + {116, 170}, + {143, 160}, + {183, 150}, + {223, 140}, + {270, 130}, + {318, 120}, + {383, 110}, + {413, 105}, + {439, 100}, + {484, 95}, + {513, 90}, + {607, 80}, + {664, 70}, + {781, 60}, + {810, 55}, + {849, 50}, + {914, 45}, + {914, 40}, + {935, 35}, + {954, 30}, + {970, 25}, + {978, 22}, + {1008, 3} +}; +#endif + #if THERMISTORHEATER == 1 #define NUMTEMPS NUMTEMPS_1 #define temptable temptable_1 @@ -169,6 +279,12 @@ short temptable_4[NUMTEMPS_4][2] = { #elif THERMISTORHEATER == 4 #define NUMTEMPS NUMTEMPS_4 #define temptable temptable_4 +#elif THERMISTORHEATER == 5 +#define NUMTEMPS NUMTEMPS_5 +#define temptable temptable_5 +#elif THERMISTORHEATER == 6 +#define NUMTEMPS NUMTEMPS_6 +#define temptable temptable_6 #elif defined HEATER_USES_THERMISTOR #error No heater thermistor table specified #endif @@ -184,6 +300,12 @@ short temptable_4[NUMTEMPS_4][2] = { #elif THERMISTORBED == 4 #define BNUMTEMPS NUMTEMPS_4 #define bedtemptable temptable_4 +#elif THERMISTORBED == 5 +#define BNUMTEMPS NUMTEMPS_5 +#define bedtemptable temptable_5 +#elif THERMISTORBED == 6 +#define BNUMTEMPS NUMTEMPS_6 +#define bedtemptable temptable_6 #elif defined BED_USES_THERMISTOR #error No bed thermistor table specified #endif |