Compare commits

...

30 Commits

Author SHA1 Message Date
jeanmarc c33ed4dcb8 branch brought up to date 2012-07-06 20:49:09 +01:00
jeanmarc b000747fe5 Z max height updated 2012-07-06 20:33:12 +01:00
jeanmarc c4028c6502 revert planner.cpp change which broke retracts 2012-06-25 09:58:17 +01:00
jeanmarc d5eb0622ee configuration changes 2012-06-25 08:30:48 +01:00
reprappro c8e953bdf9 Algebraic temperature code added. Melzi pins defined. Huxley/Mendel selection added. 2012-06-03 22:37:38 +01:00
jeanmarc 42423d53fa need to test FULL_PID_BAND 2012-06-02 21:28:49 +01:00
jeanmarc 34d72198e6 more thermistor tables added 2012-05-22 10:05:39 +01:00
jeanmarc 0580997a99 M206 persistent. 2012-05-07 19:42:55 +01:00
jeanmarc a3915a5351 some #ifs added to cope with SL 1.1! 2012-04-03 16:58:20 +01:00
jeanmarc eba50c1d0e probing actually working now 2012-03-28 15:02:42 +01:00
jeanmarc 79b404064e probe routine working 2012-03-28 12:19:42 +01:00
jeanmarc 7a3845527d fixed bug in accel code 2012-03-26 09:47:17 +01:00
jeanmarc a89e833b50 minor changes 2012-03-22 16:29:02 +00:00
jeanmarc 6db3d3b90d made m206 work 2012-03-21 17:09:51 +00:00
jeanmarc 62b5f458d4 bed levelled 2012-03-21 14:05:12 +00:00
jeanmarc 21a2cf0a9e scropp's levelling added for testing. 2012-03-19 00:09:22 +00:00
jeanmarc 34dfe7a6b4 Set correct thermistor tables. 2012-03-18 21:53:18 +00:00
jeanmarc e70f1e5871 removed temp file 2012-03-18 21:48:13 +00:00
jeanmarc fc4eaabe60 brought up to date with Erik Zalm Marlin. Included Melzi LED pin. 2012-03-18 21:47:29 +00:00
jeanmarc da2f5db1af Merge branch 'dev' into Marlin_v1 2012-03-17 22:53:13 +00:00
jeanmarc e44ab05e0f removed temp files 2012-03-17 22:52:58 +00:00
jeanmarc 9ea7de270b added E jerk. Initial test with fast SD xfer. 2012-03-17 22:47:44 +00:00
jeanmarc 4eb543e4ca temp files no longer tracked 2012-02-29 16:45:47 +00:00
jeanmarc 5ca66537dc temp files removed 2012-02-29 16:32:31 +00:00
jeanmarc 340876889b hux2 running 2012-02-29 16:31:12 +00:00
jeanmarc ebc1b54c75 typo 2012-02-23 11:17:17 +00:00
jeanmarc 8f5cec3e95 thermistor tables updated 2012-02-23 11:14:43 +00:00
jeanmarc 018e04f3f8 added fast home, windup setting 2012-02-23 10:41:52 +00:00
ErikZalm c9005865ed Update README 2011-11-20 19:21:51 +01:00
ErikZalm 1022a5eaa7 Update README 2011-11-20 19:21:19 +01:00
36 changed files with 4235 additions and 926 deletions
+1
View File
@@ -0,0 +1 @@
*~
+3
View File
@@ -0,0 +1,3 @@
*.o
*.~
applet/
+172 -49
View File
@@ -1,5 +1,22 @@
#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
// Uncomment ONE of the next three lines - the one for your RepRap machine
#define REPRAPPRO_HUXLEY
//#define REPRAPPRO_MENDEL
//#define REPRAPPRO_WALLACE
#ifndef REPRAPPRO_HUXLEY
#ifndef REPRAPPRO_MENDEL
#ifndef REPRAPPRO_WALLACE
#error Uncomment one of #define REPRAPPRO_HUXLEY, REPRAPPRO_MENDEL or REPRAPPRO_WALLACE at the start of the file Configuration.h
#endif
#endif
#endif
// Uncomment this if you are experimenting, know what you are doing, and want to switch off some safety
// features, e.g. allow extrude at low temperature etc.
//#define DEVELOPING
// This configurtion file contains the basic settings.
// Advanced settings can be found in Configuration_adv.h
@@ -8,97 +25,164 @@
//User specified version info of THIS file to display in [Pronterface, etc] terminal window during startup.
//Implementation of an idea by Prof Braino to inform user that any changes made
//to THIS file by the user have been successfully uploaded into firmware.
#define STRING_VERSION_CONFIG_H "2012-02-08j" //Personal revision number for changes to THIS file.
#define STRING_CONFIG_H_AUTHOR "username" //Who made the changes.
#define STRING_VERSION_CONFIG_H "2012-06-25-1" //Personal revision number for changes to THIS file.
#define STRING_CONFIG_H_AUTHOR "RepRapPro" //Who made the changes.
// This determines the communication speed of the printer
#define BAUDRATE 250000
//#define BAUDRATE 115200
//// The following define selects which electronics board you have. Please choose the one that matches your setup
// MEGA/RAMPS up to 1.2 = 3,
// RAMPS 1.3 = 33
// Gen6 = 5,
// Gen7 custom (Alfons3 Version) = 10 "https://github.com/Alfons3/Generation_7_Electronics"
// Gen7 v1.1, v1.2 = 11
// Gen7 v1.3 = 12
// Gen7 v1.4 = 13
// MEGA/RAMPS up to 1.2 = 3
// RAMPS 1.3 = 33 (Power outputs: Extruder, Bed, Fan)
// RAMPS 1.3 = 34 (Power outputs: Extruder0, Extruder1, Bed)
// Gen6 = 5
// Gen6 deluxe = 51
// Sanguinololu 1.2 and above = 62
// Ultimaker = 7,
// Teensylu = 8,
// Melzi 63
// Ultimaker = 7
// Teensylu = 8
// Gen3+ =9
#define MOTHERBOARD 7
#define MOTHERBOARD 62
//===========================================================================
//=============================Thermal Settings ============================
//===========================================================================
// Set this if you want to define the constants in the thermistor circuit
// and work out temperatures algebraically - added by AB.
//#define COMPUTE_THERMISTORS
#ifdef COMPUTE_THERMISTORS
// See http://en.wikipedia.org/wiki/Thermistor#B_or_.CE.B2_parameter_equation
// BETA is the B value
// RS is the value of the series resistor in ohms
// R_INF is R0.exp(-BETA/T0), where R0 is the thermistor resistance at T0 (T0 is in kelvin)
// Normally T0 is 298.15K (25 C). If you write that expression in brackets in the #define the compiler
// should compute it for you (i.e. it won't need to be calculated at run time).
// If the A->D converter has a range of 0..1023 and the measured voltage is V (between 0 and 1023)
// then the thermistor resistance, R = V.RS/(1023 - V)
// and the temperature, T = BETA/ln(R/R_INF)
// To get degrees celsius (instead of kelvin) add -273.15 to T
// This DOES assume that all extruders use the same thermistor type.
#define ABS_ZERO -273.15
#define AD_RANGE 16383
// RS 198-961
#define E_BETA 3960.0
#define E_RS 4700.0
#define E_R_INF ( 100000.0*exp(-E_BETA/298.15) )
// RS 484-0149; EPCOS B57550G103J
#define BED_BETA 3480.0
#define BED_RS 4700.0
#define BED_R_INF ( 10000.0*exp(-BED_BETA/298.15) )
#define BED_USES_THERMISTOR
#define HEATER_0_USES_THERMISTOR
//#define HEATER_1_USES_THERMISTOR
//#define HEATER_2_USES_THERMISTOR
#endif
//// Temperature sensor settings:
// -2 is thermocouple with MAX6675 (only for sensor 0)
// -1 is thermocouple with AD595
// 0 is not used
// 1 is 100k thermistor
// 2 is 200k thermistor
// 3 is mendel-parts thermistor
// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
// 3 is mendel-parts thermistor (4.7k pullup)
// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
// 5 is ParCan supplied 104GT-2 100K
// 6 is EPCOS 100k
// 7 is 100k Honeywell thermistor 135-104LAG-J01
// 100 is 100k GE Sensing AL03006-58.2K-97-G1 with r2=4k7
// 101 is 100k 0603 SMD Vishay NTCS0603E3104FXT with r2=4k7
// 102 is 100k EPCOS G57540 Nozzle with r2=4k7
// 103 is 100k EPCOS G57540 Bed with r2=4k7
// 104 is 10k G57540 Bed with r2=4k7
// 105 is 10k G57540 Bed with r2=10k
// 110 is 100k RS thermistor 198-961 hot end with 10K resistor
#define TEMP_SENSOR_0 -1
#define TEMP_SENSOR_0 102
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_BED 0
#define TEMP_SENSOR_BED 101
// Actual temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 30 // (seconds)
#define TEMP_HYSTERESIS 3 // (C°) range of +/- temperatures considered "close" to the target one
#define TEMP_RESIDENCY_TIME 10 // (seconds)
#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
#define TEMP_WINDOW 2 // (degC) Window around target to start the recidency timer x degC early.
// The minimal temperature defines the temperature below which the heater will not be enabled It is used
// to check that the wiring to the thermistor is not broken.
// Otherwise this would lead to the heater being powered on all the time.
#define HEATER_0_MINTEMP 5
#define HEATER_1_MINTEMP 5
#define HEATER_2_MINTEMP 5
#define BED_MINTEMP 5
#define HEATER_0_MINTEMP 1
//#define HEATER_1_MINTEMP 5
//#define HEATER_2_MINTEMP 5
#define BED_MINTEMP 1
// When temperature exceeds max temp, your heater will be switched off.
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
// You should use MINTEMP for thermistor short/failure protection.
#define HEATER_0_MAXTEMP 275
#define HEATER_1_MAXTEMP 275
#define HEATER_2_MAXTEMP 275
#define HEATER_0_MAXTEMP 399
//#define HEATER_1_MAXTEMP 275
//#define HEATER_2_MAXTEMP 275
#define BED_MAXTEMP 150
// PID settings:
// Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP
#define PID_MAX 255 // limits current to nozzle; 255=full current
#define FULL_PID_BAND 150 // Full power is applied when pid_error[e] > FULL_PID_BAND
#ifdef PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term
#define PID_INTEGRAL_DRIVE_MAX 125 //limit for the integral term
#define K1 0.95 //smoothing factor withing the PID
#define PID_dT 0.128 //sampling period of the PID
#define PID_dT 0.122 //sampling period of the PID
// If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
// Ultimaker
#define DEFAULT_Kp 22.2
#define DEFAULT_Ki (1.25*PID_dT)
#define DEFAULT_Kd (99/PID_dT)
// #define DEFAULT_Kp 22.2
// #define DEFAULT_Ki (1.25*PID_dT)
// #define DEFAULT_Kd (99/PID_dT)
// Makergear
// #define DEFAULT_Kp 7.0
// #define DEFAULT_Ki 0.1
// #define DEFAULT_Kd 12
// RepRapPro Huxley + Mendel
#define DEFAULT_Kp 12.0
#define DEFAULT_Ki (2.2*PID_dT)
#define DEFAULT_Kd (80/PID_dT)
// Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0
// #define DEFAULT_Ki (2.25*PID_dT)
// #define DEFAULT_Kd (440/PID_dT)
#endif // PIDTEMP
#ifndef DEVELOPING
//this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
//can be software-disabled for whatever purposes by
#define PREVENT_DANGEROUS_EXTRUDE
#define EXTRUDE_MINTEMP 170
#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
#endif
//===========================================================================
//=============================Mechanical Settings===========================
@@ -108,9 +192,9 @@
#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.
const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool X_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool Y_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
#define X_ENABLE_ON 0
@@ -121,15 +205,15 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// Disables axis when it's not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z false
#define DISABLE_Z true
#define DISABLE_E false // For all extruders
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN
@@ -139,26 +223,52 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
#define min_software_endstops true //If true, axis won't move to coordinates less than zero.
#define max_software_endstops true //If true, axis won't move to coordinates greater than the defined lengths below.
#define X_MAX_LENGTH 205
#define Y_MAX_LENGTH 205
#define Z_MAX_LENGTH 200
// The position of the homing switches. Use MAX_LENGTH * -0.5 if the center should be 0, 0, 0
#define X_HOME_POS 0
#define Y_HOME_POS 0
#define Z_HOME_POS 0
//// MOVEMENT SETTINGS
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)
#ifdef REPRAPPRO_MENDEL
#define X_MAX_LENGTH 210
#define Y_MAX_LENGTH 210
#define Z_MAX_LENGTH 140
#define HOMING_FEEDRATE {10*60, 10*60, 1*60, 0} // set the homing speeds (mm/min)
#define FAST_HOME_FEEDRATE {50*60, 50*60, 1*60, 0} // set the homing speeds (mm/min)
#define DEFAULT_MAX_FEEDRATE {500, 500, 3, 45}
#define DEFAULT_MAX_FEEDRATE {300, 300, 3, 45} // (mm/sec)
#define DEFAULT_MAX_ACCELERATION {800,800,30,250} // X, Y, Z, E maximum start speed for accelerated moves. E default values
#else
#define X_MAX_LENGTH 155
#define Y_MAX_LENGTH 150
#define Z_MAX_LENGTH 90
#define HOMING_FEEDRATE {10*60, 10*60, 1*60, 0} // set the homing speeds (mm/min)
#define FAST_HOME_FEEDRATE {80*60, 80*60, 4*60, 0} // set the homing speeds (mm/min)
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
#define DEFAULT_MAX_ACCELERATION {1000,1000,50,250} // X, Y, Z, E maximum start speed for accelerated moves. E default values
#endif
// default settings
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
#define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
#define DEFAULT_AXIS_STEPS_PER_UNIT {91.4286, 91.4286,4000,875} // default steps per unit for ultimaker
#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
//
#define DEFAULT_XYJERK 20.0 // (mm/sec)
#define DEFAULT_XYJERK 15.0 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK 15.0 // (mm/sec)
//===========================================================================
//=============================Additional Features===========================
@@ -170,10 +280,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
//define this to enable eeprom support
//#define EEPROM_SETTINGS
#define EEPROM_SETTINGS
//to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
// please keep turned on if you can.
//#define EEPROM_CHITCHAT
#define EEPROM_CHITCHAT
//LCD and SD support
//#define ULTRA_LCD //general lcd support, also 16x2
@@ -186,6 +296,16 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
#define ULTRA_LCD
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
// Preheat Constants
#define PLA_PREHEAT_HOTEND_TEMP 180
#define PLA_PREHEAT_HPB_TEMP 70
#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
#define ABS_PREHEAT_HOTEND_TEMP 240
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
#else //no panel but just lcd
#ifdef ULTRA_LCD
#define LCD_WIDTH 16
@@ -193,6 +313,9 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
#endif
#endif
// Enable uM-FPU support:
#define UMFPUSUPPORT 1
// M240 Triggers a camera by emulating a Canon RC-1 Remote
// Data from: http://www.doc-diy.net/photo/rc-1_hacked/
// #define PHOTOGRAPH_PIN 23
+31 -15
View File
@@ -1,5 +1,5 @@
#ifndef __CONFIGURATION_ADV_H
#define __CONFIGURATION_ADV_H
#ifndef CONFIGURATION_ADV_H
#define CONFIGURATION_ADV_H
//===========================================================================
//=============================Thermal Settings ============================
@@ -25,13 +25,10 @@
// if CooldownNoWait is defined M109 will not wait for the cooldown to finish
#define CooldownNoWait true
//Do not wait for M109 to finish when printing from SD card
//#define STOP_HEATING_WAIT_WHEN_SD_PRINTING
#ifdef PIDTEMP
// this adds an experimental additional term to the heatingpower, proportional to the extrusion speed.
// if Kc is choosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
//#define PID_ADD_EXTRUSION_RATE
#ifdef PID_ADD_EXTRUSION_RATE
#define DEFAULT_Kc (1) //heatingpower=Kc*(e_speed)
#endif
@@ -53,12 +50,23 @@
// extruder run-out prevention.
//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
//#define EXTRUDER_RUNOUT_PREVENT
#define EXTRUDER_RUNOUT_MINTEMP 190
#define EXTRUDER_RUNOUT_MINTEMP 175
#define EXTRUDER_RUNOUT_SECONDS 30.
#define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament
#define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed
#define EXTRUDER_RUNOUT_EXTRUDE 100
//These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
//The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
#define TEMP_SENSOR_AD595_OFFSET 0.0
#define TEMP_SENSOR_AD595_GAIN 1.0
//This is for controlling a fan to cool down the stepper drivers
//it will turn on when any driver is enabled
//and turn off after the set amount of seconds from last driver being disabled again
//#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function
#define CONTROLLERFAN_SEC 60 //How many seconds, after all motors were disabled, the fan should run
//===========================================================================
//=============================Mechanical Settings===========================
//===========================================================================
@@ -66,19 +74,22 @@
// This defines the number of extruders
#define EXTRUDERS 1
#define Z_INCREMENT .0040 //Probe Movement Increment - 1 Full step on Huxley = 1/250
#define PROBE_N 3
#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
//#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats.
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
#define X_HOME_RETRACT_MM 5
#define Y_HOME_RETRACT_MM 5
#define Z_HOME_RETRACT_MM 1
#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
#define X_HOME_RETRACT_MM 4
#define Y_HOME_RETRACT_MM 4
#define Z_HOME_RETRACT_MM 2
//#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
#define AXIS_RELATIVE_MODES {false, false, false, false}
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
#define MAX_STEP_FREQUENCY 50000 // Max step frequency for Ultimaker (5000 pps / half step)
//default stepper release if idle
#define DEFAULT_STEPPER_DEACTIVE_TIME 60
@@ -139,15 +150,18 @@
#endif // ADVANCE
// A debugging feature to compare calculated vs performed steps, to see if steps are lost by the software.
//#define DEBUG_STEPS
// Arc interpretation settings:
#define MM_PER_ARC_SEGMENT 1
#define N_ARC_CORRECTION 25
const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
// If you are using a RAMPS board or cheap E-bay purchased boards that do not detect when an SD card is inserted
// You can get round this by connecting a push button or single throw switch to the pin defined as SDCARDCARDDETECT
// in the pins.h file. When using a push button pulling the pin to ground this will need inverted. This setting should
// be commented out otherwise
//#define SDCARDDETECTINVERTED
//===========================================================================
//=============================Buffers ============================
//===========================================================================
@@ -156,6 +170,8 @@ const int dropsegments=5; //everything with less than this number of steps will
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
#if defined SDSUPPORT
#define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
// Chuck size for fast sd transfer
#define SD_FAST_XFER_CHUNK_SIZE 1024
#else
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
#endif
+29 -3
View File
@@ -1,9 +1,10 @@
#ifndef __EEPROMH
#define __EEPROMH
#ifndef EEPROM_H
#define EEPROM_H
#include "Marlin.h"
#include "planner.h"
#include "temperature.h"
#include "FPUTransform.h"
//#include <EEPROM.h>
@@ -38,7 +39,7 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
// the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V04"
#define EEPROM_VERSION "V05"
inline void EEPROM_StoreSettings()
{
@@ -56,15 +57,21 @@ inline void EEPROM_StoreSettings()
EEPROM_writeAnything(i,minsegmenttime);
EEPROM_writeAnything(i,max_xy_jerk);
EEPROM_writeAnything(i,max_z_jerk);
EEPROM_writeAnything(i,max_e_jerk);
EEPROM_writeAnything(i,add_homeing);
#ifdef PIDTEMP
EEPROM_writeAnything(i,Kp);
EEPROM_writeAnything(i,Ki);
EEPROM_writeAnything(i,Kd);
EEPROM_writeAnything(i,Ki_Max);
#else
EEPROM_writeAnything(i,3000);
EEPROM_writeAnything(i,0);
EEPROM_writeAnything(i,0);
#endif
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
EEPROM_writeAnything(i,FPUEnabled);
#endif
char ver2[4]=EEPROM_VERSION;
i=EEPROM_OFFSET;
EEPROM_writeAnything(i,ver2); // validate data
@@ -116,7 +123,13 @@ inline void EEPROM_printSettings()
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
SERIAL_ECHOPAIR(" E" ,max_e_jerk);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M206 X",add_homeing[0]);
SERIAL_ECHOPAIR(" Y",add_homeing[1] );
SERIAL_ECHOPAIR(" Z", add_homeing[2] );
SERIAL_ECHOLN("");
#ifdef PIDTEMP
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("PID settings:");
@@ -124,6 +137,11 @@ inline void EEPROM_printSettings()
SERIAL_ECHOPAIR(" M301 P",Kp);
SERIAL_ECHOPAIR(" I" ,Ki/PID_dT);
SERIAL_ECHOPAIR(" D" ,Kd*PID_dT);
SERIAL_ECHOPAIR(" W" ,Ki_Max);
SERIAL_ECHOLN("");
#endif
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
SERIAL_ECHOPAIR(" FPU Enabled" , FPUEnabled?" yes":" no");
SERIAL_ECHOLN("");
#endif
#endif
@@ -150,12 +168,19 @@ inline void EEPROM_RetrieveSettings(bool def=false)
EEPROM_readAnything(i,minsegmenttime);
EEPROM_readAnything(i,max_xy_jerk);
EEPROM_readAnything(i,max_z_jerk);
EEPROM_readAnything(i,max_e_jerk);
EEPROM_readAnything(i,add_homeing);
#ifndef PIDTEMP
float Kp,Ki,Kd;
int Ki_Max;
#endif
EEPROM_readAnything(i,Kp);
EEPROM_readAnything(i,Ki);
EEPROM_readAnything(i,Kd);
EEPROM_readAnything(i,Ki_Max);
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
EEPROM_readAnything(i,FPUEnabled);
#endif
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retreived:");
@@ -179,6 +204,7 @@ inline void EEPROM_RetrieveSettings(bool def=false)
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
max_xy_jerk=DEFAULT_XYJERK;
max_z_jerk=DEFAULT_ZJERK;
max_e_jerk=DEFAULT_EJERK;
SERIAL_ECHO_START;
SERIAL_ECHOLN("Using Default settings:");
}
+190
View File
@@ -0,0 +1,190 @@
#include "FPUTransform.h"
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
#include "MatrixMath.h"
float MasterTransform[4][4]; // this is the transform that describes how to move from
// ideal coordinates to real world coords
// private functions
void loadMatrix(float X4, float Y3, float Z1, float X2, float Y2, float Z2, float X3, float Z3, float Z4);
void transformDestination(float &X, float &Y, float &Z);
bool FPUEnabled; // this is a bypass switch so that with one command the FPU can be
// turned off
void loadMatrix(float X4, float Y1, float Z1, float X2, float Y2, float Z2, float X3, float Z3, float Z4)
{
float Xdiff = X4 - X3;
serialPrintFloat(Xdiff);
SERIAL_ECHOLN("");
float Ydiff = Y2 - Y1;
serialPrintFloat(Ydiff);
SERIAL_ECHOLN("");
//clockwise
float ZdiffX = Z4 - Z3;
serialPrintFloat(ZdiffX);
SERIAL_ECHOLN("");
//anti clockwise
float ZdiffY = Z1 - Z2;
serialPrintFloat(ZdiffY);
SERIAL_ECHOLN("");
//modified to take advantage of small angle trig.
float Xtheta = ZdiffX / Xdiff;
// serialPrintFloat(Xtheta);
// SERIAL_ECHOLN("");
float Ytheta = ZdiffY / Ydiff;
// serialPrintFloat(Ytheta);
// SERIAL_ECHOLN("");
float cosxtheta = 1-(Xtheta*Xtheta)/2;
// serialPrintFloat(cosxtheta);
// SERIAL_ECHOLN("");
float sinxtheta = Xtheta;
// serialPrintFloat(sinxtheta);
// SERIAL_ECHOLN("");
float cosytheta = 1-(Ytheta*Ytheta)/2;
// serialPrintFloat(cosytheta);
// SERIAL_ECHOLN("");
float sinytheta = Ytheta;
// serialPrintFloat(sinytheta);
// SERIAL_ECHOLN("");
//these transforms are to set the origin for each rotation
float TranslateX0[4][4] = {{1.0, 0.0, 0.0, -X3},
{0.0, 1.0, 0.0, -Y1},
{0.0, 0.0, 1.0, -Z3},
{0.0, 0.0, 0.0, 1.0}};
float TranslateY0[4][4] = {{1.0, 0.0, 0.0, -X2},
{0.0, 1.0, 0.0, -Y1},
{0.0, 0.0, 1.0, -Z1},
{0.0, 0.0, 0.0, 1.0}};
//rotate in Y using XZ
float TransformY[4][4] = {{cosxtheta, 0.0, sinxtheta, 0.0},
{ 0.0, 1.0, 0.0, 0.0},
{-sinxtheta, 0.0, cosxtheta, 0.0},
{ 0.0, 0.0, 0.0, 1.0}};
//rotate in X using YZ
float TransformX[4][4] = {{ 1.0, 0.0, 0.0, 0.0},
{ 0.0, cosytheta, sinytheta, 0.0},
{ 0.0,sinytheta, cosytheta, 0.0},
{ 0.0, 0.0, 0.0, 1.0}};
// first translate point1 to 0 then rotate in Y then translate back
float MatrixStage1[4][4];
float MatrixStage2[4][4];
//matrixMaths.MatrixMult((float*)TranslateY0, (float*)TransformX, 4, 4, 4, (float*)MatrixStage1);
//matrixMaths.MatrixPrint((float*)MatrixStage1, 4, 4, "MatrixStage1");
//TranslateY0[0][3] = -TranslateY0[0][3];
//TranslateY0[1][3] = -TranslateY0[1][3];
//TranslateY0[2][3] = -TranslateY0[2][3];
//matrixMaths.MatrixPrint((float*)TranslateY0, 4, 4, "TranslateY0");
//matrixMaths.MatrixMult((float*)MatrixStage1, (float*)TranslateY0, 4, 4, 4, (float*)MatrixStage2);
//matrixMaths.MatrixPrint((float*)MatrixStage2, 4, 4, "MatrixStage2");
//Now translate point3 to 0 and rotate in x before translating back
float MatrixStage3[4][4];
float MatrixStage4[4][4];
//matrixMaths.MatrixMult((float*)MatrixStage2, (float*)TranslateX0, 4, 4, 4, (float*)MatrixStage3);
//matrixMaths.MatrixPrint((float*)MatrixStage3, 4, 4, "MatrixStage3");
//matrixMaths.MatrixMult((float*)MatrixStage3, (float*)TransformY, 4, 4, 4, (float*)MatrixStage4);
matrixMaths.MatrixMult((float*)TransformX, (float*)TransformY, 4, 4, 4, (float*)MasterTransform);
matrixMaths.MatrixPrint((float*)MatrixStage4, 4, 4, "MatrixStage4");
//TranslateX0[0][3] = -TranslateX0[0][3];
//TranslateX0[1][3] = -TranslateX0[1][3];
//TranslateX0[2][3] = -TranslateX0[2][3];
//matrixMaths.MatrixPrint((float*)TranslateX0, 4, 4, "TranslateX0");
//matrixMaths.MatrixMult((float*)MatrixStage4, (float*)TranslateX0, 4, 4, 4, (float*)MasterTransform);
//matrixMaths.MatrixPrint((float*)MasterTransform, 4, 4, "MasterTransform (pre-invert)");
// We now have a way to translate from real-world coordinates to idealised coortdinates,
// but what we actually want is a way to transform from the idealised g-code coordinates
// to real world coordinates.
// This is simply the inverse.
matrixMaths.MatrixInvert((float*)MasterTransform, 4);
matrixMaths.MatrixPrint((float*)MasterTransform, 4, 4, "MasterTransform");
}
void transformDestination(float &X, float &Y, float &Z)
{
float oldPoint[4][1]={{X}, {Y}, {Z}, {1.0}};
float newPoint[1][4]={{0.0,0.0,0.0,0.0}};
matrixMaths.MatrixMult((float*)MasterTransform, (float*)oldPoint, 4, 4, 1, (float*)newPoint);
X=newPoint[0][0];
Y=newPoint[0][1];
Z=newPoint[0][2];
}
void FPUTransform_init()
{
if (FPUEnabled == true)
{
// It is important to ensure that if the bed levelling routine has not been called the
// printer behaves as if the real world and idealised world are one and the same
matrixMaths.MatrixIdentity((float*)MasterTransform,4,4);
SERIAL_ECHO("transform configured to identity");
}
else
{
SERIAL_ECHO("transform correction not enabled");
}
}
void FPUEnable()
{
FPUEnabled = true;
FPUTransform_init();
}
void FPUReset()
{
FPUTransform_init();
}
void FPUDisable()
{
FPUEnabled = false;
}
void FPUTransform_determineBedOrientation()
{
int X3 = 15;
float X4 = X_MAX_LENGTH - 20;
float X2 = (X4 + X3) / 2;
int Y1 = 15;
float Y2 = Y_MAX_LENGTH - 5;
float Z1;
float Z2;
float Z3;
float Z4;
//get Z for X15 Y15, X15 Y(Y_MAX_LENGTH - 15) and X(X_MAX_LENGTH - 15) Y15
Z3 = Probe_Bed(X3,Y1,PROBE_N);
Z4 = Probe_Bed(X4,Y1,PROBE_N);
Z1 = (Z3 + Z4) / 2;
Z2 = Probe_Bed(X2,Y2,PROBE_N);
if(FPUEnabled)
{
loadMatrix(X4, Y1, Z1, X2, Y2, Z2, X3, Z3, Z4);
}
}
void FPUTransform_transformDestination()
{
float XPoint = destination[X_AXIS]; // float variable
float YPoint = destination[Y_AXIS]; // float variable
float ZPoint = destination[Z_AXIS]; // float variable
if(FPUEnabled)
{
transformDestination(XPoint, YPoint, ZPoint);
}
modified_destination[X_AXIS] = XPoint; // float variable
modified_destination[Y_AXIS] = YPoint; // float variable
modified_destination[Z_AXIS] = ZPoint; // float variable
}
#endif //UMFPUSUPPORT
+21
View File
@@ -0,0 +1,21 @@
#ifndef __FPUTRANSFORM
#define __FPUTRANSFORM
#include "Marlin.h"
#include "z_probe.h"
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
extern bool FPUEnabled;
void FPUTransform_init();
void FPUEnable();
void FPUReset();
void FPUDisable();
void FPUTransform_determineBedOrientation();
void FPUTransform_transformDestination();
#else //no UMFPU SUPPORT
FORCE_INLINE void FPUTransform_init() {};
#endif //UMFPUSUPPORT
#endif //__FPUTRANSFORM
+13 -7
View File
@@ -23,7 +23,9 @@
# 3. Set the line containing "MCU" to match your board's processor.
# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
# change F_CPU to 8000000.
# change F_CPU to 8000000. If you are using Gen7 electronics, you
# probably need to use 20000000. Either way, you must regenerate
# the speed lookup table with create_speed_lookuptable.py.
#
# 4. Type "make" and press enter to compile/verify your program.
#
@@ -42,6 +44,8 @@ MCU = atmega1280
#Arduino install directory
INSTALL_DIR = ../../arduino-0022/
# Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
# if you are setting this to something other than 16MHz
F_CPU = 16000000
UPLOAD_RATE = 115200
@@ -61,7 +65,7 @@ SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
$(ARDUINO)/wiring_pulse.c \
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
$(ARDUINO)/Print.cpp Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
$(ARDUINO)/Print.cpp applet/Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
FORMAT = ihex
@@ -138,6 +142,8 @@ all: build sizeafter
build: elf hex
applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
applet/%.cpp: %.pde
# Here is the "preprocessing".
# It creates a .cpp file based with the same name as the .pde file.
# On top of the new .cpp file comes the WProgram.h header.
@@ -145,11 +151,11 @@ applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
# Then the .cpp file will be compiled. Errors during compile will
# refer to this new, automatically generated, file.
# Not the original .pde file you actually edit...
@echo " WR applet/$(TARGET).cpp"
@test -d applet || mkdir applet
@echo '#include "WProgram.h"' > applet/$(TARGET).cpp
@cat $(TARGET).pde >> applet/$(TARGET).cpp
@cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
@echo " WR $@"
@test -d $(dir $@) || mkdir $(dir $@)
@echo '#include "WProgram.h"' > $@
@cat $< >> $@
@cat $(ARDUINO)/main.cpp >> $@
elf: applet/$(TARGET).elf
hex: applet/$(TARGET).hex
+24 -4
View File
@@ -1,8 +1,8 @@
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
// Licence: GPL
#ifndef __MARLINH
#define __MARLINH
#ifndef MARLIN_H
#define MARLIN_H
#define HardwareSerial_h // trick to disable the standard HWserial
@@ -26,7 +26,7 @@
#include "pins.h"
#if ARDUINO >= 100
#if defined(__AVR_ATmega644P__)
#if defined(__AVR_ATmega644P__) || defined (__AVR_ATmega1284P__)
#include "WProgram.h"
#else
#include "Arduino.h"
@@ -64,6 +64,7 @@
#define SERIAL_PROTOCOL(x) MYSERIAL.print(x);
#define SERIAL_PROTOCOL_F(x,y) MYSERIAL.print(x,y);
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
#define SERIAL_PROTOCOLLN(x) {MYSERIAL.print(x);MYSERIAL.write('\n');}
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MYSERIAL.write('\n');}
@@ -98,6 +99,13 @@ FORCE_INLINE void serialprintPGM(const char *str)
}
}
// printing floats to 3DP
FORCE_INLINE void serialPrintFloat( float f){
SERIAL_ECHO((int)f);
SERIAL_ECHOPGM(".");
int mantissa = (f - (int)f) * 1000;
SERIAL_ECHO( abs(mantissa) );
}
void get_command();
void process_commands();
@@ -162,6 +170,9 @@ void ClearToSend();
void get_coordinates();
void prepare_move();
void kill();
void Stop();
bool IsStopped();
void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
void prepare_arc_move(char isclockwise);
@@ -172,10 +183,19 @@ void prepare_arc_move(char isclockwise);
#endif //CRITICAL_SECTION_START
extern float homing_feedrate[];
extern float fast_home_feedrate[];
extern bool axis_relative_modes[];
extern volatile int feedmultiply;
extern int saved_feedmultiply;
extern float current_position[NUM_AXIS] ;
extern float add_homeing[3];
extern bool stop_heating_wait;
extern unsigned char FanSpeed;
extern float destination[NUM_AXIS];
extern float modified_destination[NUM_AXIS];
extern float offset[3];
extern float feedrate, next_feedrate, saved_feedrate;
// Handling multiple extruders pins
extern uint8_t active_extruder;
+445 -142
View File
File diff suppressed because it is too large Load Diff
+206
View File
@@ -0,0 +1,206 @@
/*
* MatrixMath.cpp Library for MatrixMath
*
* Created by Charlie Matlack on 12/18/10.
* Modified from code by RobH45345 on Arduino Forums, taken from unknown source.
* MatrixMath.cpp
*/
#include "Marlin.h"
#include "MatrixMath.h"
#define NR_END 1
MatrixMath::MatrixMath()
{
}
// Matrix Printing Routine
// Uses tabs to separate numbers under assumption printed float width won't cause problems
void MatrixMath::MatrixPrint(float* A, int m, int n, String label){
// A = input matrix (m x n)
int i,j;
SERIAL_ECHOLN(' ');
SERIAL_ECHOLN(label);
for (i=0; i<m; i++){
for (j=0;j<n;j++){
serialPrintFloat(A[n*i+j]);
SERIAL_ECHO("\t");
}
SERIAL_ECHOLN(' ');
}
}
void MatrixMath::MatrixCopy(float* A, int n, int m, float* B)
{
int i, j, k;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
{
B[n*i+j] = A[n*i+j];
}
}
//Matrix Multiplication Routine
// C = A*B
void MatrixMath::MatrixMult(float* A, float* B, int m, int p, int n, float* C)
{
// A = input matrix (m x p)
// B = input matrix (p x n)
// m = number of rows in A
// p = number of columns in A = number of rows in B
// n = number of columns in B
// C = output matrix = A*B (m x n)
int i, j, k;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
{
C[n*i+j]=0;
for (k=0;k<p;k++)
C[n*i+j]= C[n*i+j]+A[p*i+k]*B[n*k+j];
}
}
//Matrix Addition Routine
void MatrixMath::MatrixAdd(float* A, float* B, int m, int n, float* C)
{
// A = input matrix (m x n)
// B = input matrix (m x n)
// m = number of rows in A = number of rows in B
// n = number of columns in A = number of columns in B
// C = output matrix = A+B (m x n)
int i, j;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
C[n*i+j]=A[n*i+j]+B[n*i+j];
}
//Matrix Subtraction Routine
void MatrixMath::MatrixSubtract(float* A, float* B, int m, int n, float* C)
{
// A = input matrix (m x n)
// B = input matrix (m x n)
// m = number of rows in A = number of rows in B
// n = number of columns in A = number of columns in B
// C = output matrix = A-B (m x n)
int i, j;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
C[n*i+j]=A[n*i+j]-B[n*i+j];
}
//Matrix Transpose Routine
void MatrixMath::MatrixTranspose(float* A, int m, int n, float* C)
{
// A = input matrix (m x n)
// m = number of rows in A
// n = number of columns in A
// C = output matrix = the transpose of A (n x m)
int i, j;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
C[m*j+i]=A[n*i+j];
}
//Matrix Inversion Routine
// * This function inverts a matrix based on the Gauss Jordan method.
// * Specifically, it uses partial pivoting to improve numeric stability.
// * The algorithm is drawn from those presented in
// NUMERICAL RECIPES: The Art of Scientific Computing.
// * The function returns 1 on success, 0 on failure.
// * NOTE: The argument is ALSO the result matrix, meaning the input matrix is REPLACED
int MatrixMath::MatrixInvert(float* A, int n)
{
// A = input matrix AND result matrix
// n = number of rows = number of columns in A (n x n)
int pivrow; // keeps track of current pivot row
int k,i,j; // k: overall index along diagonal; i: row index; j: col index
int pivrows[n]; // keeps track of rows swaps to undo at end
float tmp; // used for finding max value and making column swaps
for (k = 0; k < n; k++)
{
// find pivot row, the row with biggest entry in current column
tmp = 0;
for (i = k; i < n; i++)
{
if (abs(A[i*n+k]) >= tmp) // 'Avoid using other functions inside abs()?'
{
tmp = abs(A[i*n+k]);
pivrow = i;
}
}
// check for singular matrix
if (A[pivrow*n+k] == 0.0f)
{
SERIAL_ECHOLNPGM("Inversion failed due to singular matrix");
return 0;
}
// Execute pivot (row swap) if needed
if (pivrow != k)
{
// swap row k with pivrow
for (j = 0; j < n; j++)
{
tmp = A[k*n+j];
A[k*n+j] = A[pivrow*n+j];
A[pivrow*n+j] = tmp;
}
}
pivrows[k] = pivrow; // record row swap (even if no swap happened)
tmp = 1.0f/A[k*n+k]; // invert pivot element
A[k*n+k] = 1.0f; // This element of input matrix becomes result matrix
// Perform row reduction (divide every element by pivot)
for (j = 0; j < n; j++)
{
A[k*n+j] = A[k*n+j]*tmp;
}
// Now eliminate all other entries in this column
for (i = 0; i < n; i++)
{
if (i != k)
{
tmp = A[i*n+k];
A[i*n+k] = 0.0f; // The other place where in matrix becomes result mat
for (j = 0; j < n; j++)
{
A[i*n+j] = A[i*n+j] - A[k*n+j]*tmp;
}
}
}
}
// Done, now need to undo pivot row swaps by doing column swaps in reverse order
for (k = n-1; k >= 0; k--)
{
if (pivrows[k] != k)
{
for (i = 0; i < n; i++)
{
tmp = A[i*n+k];
A[i*n+k] = A[i*n+pivrows[k]];
A[i*n+pivrows[k]] = tmp;
}
}
}
return 1;
}
void MatrixMath::MatrixIdentity(float* A, int m, int n)
{
int i, j;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
A[n*i+j]=i==j?1:0;
}
MatrixMath matrixMaths; //instance
+29
View File
@@ -0,0 +1,29 @@
/*
* MatrixMath.h Library for Matrix Math
*
* Created by Charlie Matlack on 12/18/10.
* Modified from code by RobH45345 on Arduino Forums, taken from unknown source.
*/
#ifndef MatrixMath_h
#define MatrixMath_h
#include "Marlin.h"
class MatrixMath
{
public:
MatrixMath();
void MatrixPrint(float* A, int m, int n, String label);
void MatrixCopy(float* A, int n, int m, float* B);
void MatrixMult(float* A, float* B, int m, int p, int n, float* C);
void MatrixAdd(float* A, float* B, int m, int n, float* C);
void MatrixSubtract(float* A, float* B, int m, int n, float* C);
void MatrixTranspose(float* A, int m, int n, float* C);
int MatrixInvert(float* A, int n);
void MatrixIdentity(float* A, int m, int n);
};
extern MatrixMath matrixMaths;
#endif
+199 -25
View File
@@ -3,6 +3,8 @@
#include "ultralcd.h"
#include "stepper.h"
#include "temperature.h"
#include "language.h"
#ifdef SDSUPPORT
@@ -51,7 +53,7 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
while (parent.readDir(p) > 0)
{
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename)
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
{
char path[13*2];
@@ -75,7 +77,7 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
if(lsAction==LS_SerialPrint)
{
SERIAL_ECHO_START;
SERIAL_ECHOLN("Cannot open subdir");
SERIAL_ECHOLN(MSG_SD_CANT_OPEN_SUBDIR);
SERIAL_ECHOLN(lfilename);
}
}
@@ -93,9 +95,11 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
if ( p.name[1] != '.')
continue;
}
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
filenameIsDir=DIR_IS_SUBDIR(&p);
if(!filenameIsDir)
{
if(p.name[8]!='G') continue;
@@ -143,38 +147,44 @@ void CardReader::initsd()
{
//if (!card.init(SPI_HALF_SPEED,SDSS))
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("SD init fail");
SERIAL_ECHOLNPGM(MSG_SD_INIT_FAIL);
}
else if (!volume.init(&card))
{
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("volume.init failed");
SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL);
}
else if (!root.openRoot(&volume))
{
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("openRoot failed");
SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL);
}
else
{
cardOK = true;
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("SD card ok");
SERIAL_ECHOLNPGM(MSG_SD_CARD_OK);
}
workDir=root;
curDir=&root;
/*
if(!workDir.openRoot(&volume))
{
SERIAL_ECHOLNPGM("workDir open failed");
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
}
*/
}
void CardReader::setroot()
{
curDir=&root;
if(!workDir.openRoot(&volume))
/*if(!workDir.openRoot(&volume))
{
SERIAL_ECHOLNPGM("workDir open failed");
}
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
}*/
workDir=root;
curDir=&workDir;
}
void CardReader::release()
{
@@ -230,7 +240,7 @@ void CardReader::openFile(char* name,bool read)
SERIAL_ECHOLN(subdirname);
if(!myDir.open(curDir,subdirname,O_READ))
{
SERIAL_PROTOCOLPGM("open failed, File: ");
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
@@ -260,18 +270,18 @@ void CardReader::openFile(char* name,bool read)
if (file.open(curDir, fname, O_READ))
{
filesize = file.fileSize();
SERIAL_PROTOCOLPGM("File opened:");
SERIAL_PROTOCOLPGM(MSG_SD_FILE_OPENED);
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLPGM(" Size:");
SERIAL_PROTOCOLPGM(MSG_SD_SIZE);
SERIAL_PROTOCOLLN(filesize);
sdpos = 0;
SERIAL_PROTOCOLLNPGM("File selected");
SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
LCD_MESSAGE(fname);
}
else
{
SERIAL_PROTOCOLPGM("open failed, File: ");
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLLNPGM(".");
}
@@ -280,14 +290,14 @@ void CardReader::openFile(char* name,bool read)
{ //write
if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
{
SERIAL_PROTOCOLPGM("open failed, File: ");
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLLNPGM(".");
}
else
{
saving = true;
SERIAL_PROTOCOLPGM("Writing to file: ");
SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
SERIAL_PROTOCOLLN(name);
LCD_MESSAGE(fname);
}
@@ -295,16 +305,85 @@ void CardReader::openFile(char* name,bool read)
}
void CardReader::removeFile(char* name)
{
if(!cardOK)
return;
file.close();
sdprinting = false;
SdFile myDir;
curDir=&root;
char *fname=name;
char *dirname_start,*dirname_end;
if(name[0]=='/')
{
dirname_start=strchr(name,'/')+1;
while(dirname_start>0)
{
dirname_end=strchr(dirname_start,'/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if(dirname_end>0 && dirname_end>dirname_start)
{
char subdirname[13];
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
subdirname[dirname_end-dirname_start]=0;
SERIAL_ECHOLN(subdirname);
if(!myDir.open(curDir,subdirname,O_READ))
{
SERIAL_PROTOCOLPGM("open failed, File: ");
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
;//SERIAL_ECHOLN("dive ok");
curDir=&myDir;
dirname_start=dirname_end+1;
}
else // the reminder after all /fsa/fdsa/ is the filename
{
fname=dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
}
}
else //relative path
{
curDir=&workDir;
}
if (file.remove(curDir, fname))
{
SERIAL_PROTOCOLPGM("File deleted:");
SERIAL_PROTOCOL(fname);
sdpos = 0;
}
else
{
SERIAL_PROTOCOLPGM("Deletion failed, File: ");
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLLNPGM(".");
}
}
void CardReader::getStatus()
{
if(cardOK){
SERIAL_PROTOCOLPGM("SD printing byte ");
SERIAL_PROTOCOLPGM(MSG_SD_PRINTING_BYTE);
SERIAL_PROTOCOL(sdpos);
SERIAL_PROTOCOLPGM("/");
SERIAL_PROTOCOLLN(filesize);
}
else{
SERIAL_PROTOCOLLNPGM("Not SD printing");
SERIAL_PROTOCOLLNPGM(MSG_SD_NOT_PRINTING);
}
}
void CardReader::write_command(char *buf)
@@ -326,7 +405,7 @@ void CardReader::write_command(char *buf)
if (file.writeError)
{
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("error writing to file");
SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
}
}
@@ -420,7 +499,7 @@ void CardReader::chdir(const char * relpath)
if(!newfile.open(*parent,relpath, O_READ))
{
SERIAL_ECHO_START;
SERIAL_ECHOPGM("Cannot enter subdir:");
SERIAL_ECHOPGM(MSG_SD_CANT_ENTER_SUBDIR);
SERIAL_ECHOLN(relpath);
}
else
@@ -447,9 +526,6 @@ void CardReader::printingHasFinished()
st_synchronize();
quickStop();
sdprinting = false;
#ifdef STOP_HEATING_WAIT_FOR_SD_PRINTING
stop_heating_wait=true;
#endif
if(SD_FINISHED_STEPPERRELEASE)
{
//finishAndDisableSteppers();
@@ -457,4 +533,102 @@ void CardReader::printingHasFinished()
}
autotempShutdown();
}
void CardReader::fast_xfer(char* strchr_pointer)
{
char *pstr;
boolean done = false;
//force heater pins low
if(HEATER_0_PIN > -1) WRITE(HEATER_0_PIN,LOW);
if(HEATER_BED_PIN > -1) WRITE(HEATER_BED_PIN,LOW);
lastxferchar = 1;
xferbytes = 0;
pstr = strstr(strchr_pointer, " ");
//pstr = strchr_pointer;
if(pstr == NULL)
{
SERIAL_ECHOLN("invalid command");
return;
}
*pstr = '\0';
//check mode (currently only RAW is supported
if(strcmp(strchr_pointer, "RAW") != 0)
{
SERIAL_ECHOLN("Invalid transfer codec");
return;
}else{
SERIAL_ECHOPGM("Selected codec: ");
SERIAL_ECHOLN(strchr_pointer+4);
}
if (!file.open(&root, pstr+1, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
{
SERIAL_ECHOPGM("open failed, File: ");
SERIAL_ECHOLN(pstr+1);
SERIAL_ECHOPGM(".");
}else{
SERIAL_ECHOPGM("Writing to file: ");
SERIAL_ECHOLN(pstr+1);
}
SERIAL_ECHOLN("ok");
//RAW transfer codec
//Host sends \0 then up to SD_FAST_XFER_CHUNK_SIZE then \0
//when host is done, it sends \0\0.
//if a non \0 character is recieved at the beginning, host has failed somehow, kill the transfer.
//read SD_FAST_XFER_CHUNK_SIZE bytes (or until \0 is recieved)
while(!done)
{
while(!MYSERIAL.available())
{
}
if(MYSERIAL.peek() != 0)
{
//host has failed, this isn't a RAW chunk, it's an actual command
file.sync();
file.close();
SERIAL_ECHOLN("Not RAW data");
return;
}
//clear the initial 0
MYSERIAL.read();
for(int i=0;i<SD_FAST_XFER_CHUNK_SIZE+1;i++)
{
while(!MYSERIAL.available())
{
}
lastxferchar = MYSERIAL.read();
//buffer the data...
fastxferbuffer[i] = lastxferchar;
xferbytes++;
if(lastxferchar == 0)
break;
}
if(fastxferbuffer[0] != 0)
{
fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE] = 0;
file.write(fastxferbuffer);
SERIAL_ECHOLN("ok");
}else{
SERIAL_ECHOPGM("Wrote ");
SERIAL_ECHO(xferbytes);
SERIAL_ECHOLN(" bytes.");
done = true;
}
}
file.sync();
file.close();
}
#endif //SDSUPPORT
+12 -34
View File
@@ -1,5 +1,5 @@
#ifndef __CARDREADERH
#define __CARDREADERH
#ifndef CARDREADER_H
#define CARDREADER_H
#ifdef SDSUPPORT
@@ -17,6 +17,7 @@ public:
void checkautostart(bool x);
void openFile(char* name,bool read);
void removeFile(char* name);
void closefile();
void release();
void startFileprint();
@@ -32,6 +33,8 @@ public:
void chdir(const char * relpath);
void updir();
void setroot();
void fast_xfer(char* strchr_pointer);
FORCE_INLINE bool eof() { return sdpos>=filesize ;};
@@ -44,9 +47,10 @@ public:
bool saving;
bool sdprinting ;
bool cardOK ;
char filename[11];
char filename[12];
bool filenameIsDir;
int lastnr; //last number of the autostart;
char fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE + 1];
private:
SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
Sd2Card card;
@@ -63,40 +67,14 @@ private:
int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
char* diveDirName;
void lsDive(const char *prepend,SdFile parent);
int lastxferchar;
long xferbytes;
};
#define IS_SD_PRINTING (card.sdprinting)
#else
#define dir_t bool
class CardReader
{
public:
FORCE_INLINE CardReader(){};
FORCE_INLINE static void initsd(){};
FORCE_INLINE static void write_command(char *buf){};
FORCE_INLINE static void checkautostart(bool x) {};
FORCE_INLINE static void openFile(char* name,bool read){};
FORCE_INLINE static void closefile() {};
FORCE_INLINE static void release(){};
FORCE_INLINE static void startFileprint(){};
FORCE_INLINE static void startFilewrite(char *name){};
FORCE_INLINE static void pauseSDPrint(){};
FORCE_INLINE static void getStatus(){};
FORCE_INLINE static void selectFile(char* name){};
FORCE_INLINE static void getfilename(const uint8_t nr){};
FORCE_INLINE static uint8_t getnrfilenames(){return 0;};
#define IS_SD_PRINTING (false)
FORCE_INLINE static void ls() {};
FORCE_INLINE static bool eof() {return true;};
FORCE_INLINE static char get() {return 0;};
FORCE_INLINE static void setIndex(){};
FORCE_INLINE uint8_t percentDone(){return 0;};
};
#endif //SDSUPPORT
#endif
#endif
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env python
""" Generate the stepper delay lookup table for Marlin firmware. """
import argparse
__author__ = "Ben Gamari <bgamari@gmail.com>"
__copyright__ = "Copyright 2012, Ben Gamari"
__license__ = "GPL"
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-f', '--cpu-freq', type=int, default=16, help='CPU clockrate in MHz (default=16)')
parser.add_argument('-d', '--divider', type=int, default=8, help='Timer/counter pre-scale divider (default=8)')
args = parser.parse_args()
cpu_freq = args.cpu_freq * 1000000
timer_freq = cpu_freq / args.divider
print "#ifndef SPEED_LOOKUPTABLE_H"
print "#define SPEED_LOOKUPTABLE_H"
print
print '#include "Marlin.h"'
print
print "const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {"
a = [ timer_freq / ((i*256)+(args.cpu_freq*2)) for i in range(256) ]
b = [ a[i] - a[i+1] for i in range(255) ]
b.append(b[-1])
for i in range(32):
print " ",
for j in range(8):
print "{%d, %d}," % (a[8*i+j], b[8*i+j]),
print
print "};"
print
print "const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {"
a = [ timer_freq / ((i*8)+(args.cpu_freq*2)) for i in range(256) ]
b = [ a[i] - a[i+1] for i in range(255) ]
b.append(b[-1])
for i in range(32):
print " ",
for j in range(8):
print "{%d, %d}," % (a[8*i+j], b[8*i+j]),
print
print "};"
print
print "#endif"
+1 -1
View File
@@ -424,7 +424,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_ATmega1284__) || defined (__AVR_ATmega1284P__)
// UART
#define RXD DIO8
#define TXD DIO9
+299
View File
@@ -0,0 +1,299 @@
#ifndef LANGUAGE_H
#define LANGUAGE_H
// Languages
// 1 Custom (For you to add your own messages)
// 2 English
// 3 French (Waiting translation)
// 4 German (Waiting translation)
// 5 Etc
#define LANGUAGE_CHOICE 1 // Pick your language from the list above
#if LANGUAGE_CHOICE == 1
// LCD Menu Messages
#define WELCOME_MSG "Printer Ready."
#define MSG_SD_INSERTED "Card inserted"
#define MSG_SD_REMOVED "Card removed"
#define MSG_MAIN " Main \003"
#define MSG_AUTOSTART " Autostart"
#define MSG_DISABLE_STEPPERS " Disable Steppers"
#define MSG_AUTO_HOME " Auto Home"
#define MSG_SET_ORIGIN " Set Origin"
#define MSG_COOLDOWN " Cooldown"
#define MSG_EXTRUDE " Extrude"
#define MSG_PREHEAT_PLA " Preheat PLA"
#define MSG_PREHEAT_ABS " Preheat ABS"
#define MSG_MOVE_AXIS " Move Axis \x7E"
#define MSG_SPEED " Speed:"
#define MSG_NOZZLE " \002Nozzle:"
#define MSG_BED " \002Bed:"
#define MSG_FAN_SPEED " Fan speed:"
#define MSG_FLOW " Flow:"
#define MSG_CONTROL " Control \003"
#define MSG_MIN " \002 Min:"
#define MSG_MAX " \002 Max:"
#define MSG_FACTOR " \002 Fact:"
#define MSG_AUTOTEMP " Autotemp:"
#define MSG_ON "On "
#define MSG_OFF "Off"
#define MSG_PID_P " PID-P: "
#define MSG_PID_I " PID-I: "
#define MSG_PID_D " PID-D: "
#define MSG_PID_C " PID-C: "
#define MSG_ACC " Acc:"
#define MSG_VXY_JERK " Vxy-jerk: "
#define MSG_VMAX " Vmax "
#define MSG_X "x:"
#define MSG_Y "y:"
#define MSG_Z "z:"
#define MSG_E "e:"
#define MSG_VMIN " Vmin:"
#define MSG_VTRAV_MIN " VTrav min:"
#define MSG_AMAX " Amax "
#define MSG_A_RETRACT " A-retract:"
#define MSG_XSTEPS " Xsteps/mm:"
#define MSG_YSTEPS " Ysteps/mm:"
#define MSG_ZSTEPS " Zsteps/mm:"
#define MSG_ESTEPS " Esteps/mm:"
#define MSG_MAIN_WIDE " Main \003"
#define MSG_TEMPERATURE_WIDE " Temperature \x7E"
#define MSG_MOTION_WIDE " Motion \x7E"
#define MSG_STORE_EPROM " Store memory"
#define MSG_LOAD_EPROM " Load memory"
#define MSG_RESTORE_FAILSAFE " Restore Failsafe"
#define MSG_REFRESH "\004Refresh"
#define MSG_WATCH " Watch \003"
#define MSG_PREPARE " Prepare \x7E"
#define MSG_PREPARE_ALT " Prepare \003"
#define MSG_CONTROL_ARROW " Control \x7E"
#define MSG_TUNE " Tune \x7E"
#define MSG_STOP_PRINT " Stop Print \x7E"
#define MSG_CARD_MENU " Card Menu \x7E"
#define MSG_NO_CARD " No Card"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Something is wrong in the MenuStructure."
#define MSG_DWELL "Sleep..."
#define MSG_USERWAIT "Wait for user..."
#define MSG_NO_MOVE "No move."
#define MSG_PART_RELEASE "Partial Release"
#define MSG_KILLED "KILLED. "
#define MSG_STOPPED "STOPPED. "
#define MSG_PREHEAT_PLA " Preheat PLA"
#define MSG_PREHEAT_ABS " Preheat ABS"
#define MSG_STEPPER_RELEASED "Released."
// Serial Console Messages
#define MSG_Enqueing "enqueing \""
#define MSG_POWERUP "PowerUp"
#define MSG_EXTERNAL_RESET " External Reset"
#define MSG_BROWNOUT_RESET " Brown out Reset"
#define MSG_WATCHDOG_RESET " Watchdog Reset"
#define MSG_SOFTWARE_RESET " Software Reset"
#define MSG_MARLIN "Marlin "
#define MSG_AUTHOR " | Author: "
#define MSG_CONFIGURATION_VER " Last Updated: "
#define MSG_FREE_MEMORY " Free Memory: "
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
#define MSG_OK "ok"
#define MSG_FILE_SAVED "Done saving file."
#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line:"
#define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line:"
#define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line:"
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line:"
#define MSG_FILE_PRINTED "Done printing file"
#define MSG_BEGIN_FILE_LIST "Begin file list"
#define MSG_END_FILE_LIST "End file list"
#define MSG_M104_INVALID_EXTRUDER "M104 Invalid extruder "
#define MSG_M105_INVALID_EXTRUDER "M105 Invalid extruder "
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temp"
#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder "
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
#define MSG_COUNT_X " Count X:"
#define MSG_ERR_KILLED "Printer halted. kill() called !!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!. (Temperature is reset. Set it before restarting)"
#define MSG_RESEND "Resend:"
#define MSG_UNKNOWN_COMMAND "Unknown command:\""
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
#define MSG_INVALID_EXTRUDER "Invalid extruder"
#define MSG_X_MIN "x_min:"
#define MSG_X_MAX "x_max:"
#define MSG_Y_MIN "y_min:"
#define MSG_Y_MAX "y_max:"
#define MSG_Z_MIN "z_min:"
#define MSG_Z_MAX "z_max:"
#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
#define MSG_SD_INIT_FAIL "SD init fail"
#define MSG_SD_VOL_INIT_FAIL "volume.init failed"
#define MSG_SD_OPENROOT_FAIL "openRoot failed"
#define MSG_SD_CARD_OK "SD card ok"
#define MSG_SD_WORKDIR_FAIL "workDir open failed"
#define MSG_SD_OPEN_FILE_FAIL "open failed, File: "
#define MSG_SD_FILE_OPENED "File opened:"
#define MSG_SD_SIZE " Size:"
#define MSG_SD_FILE_SELECTED "File selected"
#define MSG_SD_WRITE_TO_FILE "Writing to file: "
#define MSG_SD_PRINTING_BYTE "SD printing byte "
#define MSG_SD_NOT_PRINTING "Not SD printing"
#define MSG_SD_ERR_WRITE_TO_FILE "error writing to file"
#define MSG_SD_CANT_ENTER_SUBDIR "Cannot enter subdir:"
#define MSG_STEPPER_TO_HIGH "Steprate to high : "
#define MSG_ENDSTOPS_HIT "endstops hit: "
#define MSG_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented"
#define MSG_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented"
#endif
#if LANGUAGE_CHOICE == 4
// LCD Menu Messages
#define WELCOME_MSG "MARLIN Ready."
#define MSG_SD_INSERTED "Card inserted"
#define MSG_SD_REMOVED "Card removed"
#define MSG_MAIN " Main \003"
#define MSG_AUTOSTART " Autostart"
#define MSG_DISABLE_STEPPERS " Stepper abschalten"
#define MSG_AUTO_HOME " Auto Heim"
#define MSG_SET_ORIGIN " Position setzen"
#define MSG_PREHEAT_PLA " Aufheizen PLA"
#define MSG_PREHEAT_ABS " Aufheizen ABS"
#define MSG_COOLDOWN " Abkuehlen"
#define MSG_EXTRUDE " Extrude"
#define MSG_PREHEAT_PLA " Preheat PLA"
#define MSG_PREHEAT_ABS " Preheat ABS"
#define MSG_MOVE_AXIS " Move Axis \x7E"
#define MSG_MOVE_AXIS " Achsen verfahren \x7E"
#define MSG_SPEED " Geschw:"
#define MSG_NOZZLE " \002Duese:"
#define MSG_BED " \002Bett:"
#define MSG_FAN_SPEED " Luefter geschw.:"
#define MSG_FLOW " Fluss:"
#define MSG_CONTROL " Kontrolle \003"
#define MSG_MIN " \002 Min:"
#define MSG_MAX " \002 Max:"
#define MSG_FACTOR " \002 Faktor:"
#define MSG_AUTOTEMP " AutoTemp:"
#define MSG_ON "Ein "
#define MSG_OFF "Aus "
#define MSG_PID_P " PID-P: "
#define MSG_PID_I " PID-I: "
#define MSG_PID_D " PID-D: "
#define MSG_PID_C " PID-C: "
#define MSG_ACC " Acc:"
#define MSG_VXY_JERK " Vxy-jerk: "
#define MSG_VMAX " Vmax "
#define MSG_X "x:"
#define MSG_Y "y:"
#define MSG_Z "z:"
#define MSG_E "e:"
#define MSG_VMIN " Vmin:"
#define MSG_VTRAV_MIN " VTrav min:"
#define MSG_AMAX " Amax "
#define MSG_A_RETRACT " A-retract:"
#define MSG_XSTEPS " Xsteps/mm:"
#define MSG_YSTEPS " Ysteps/mm:"
#define MSG_ZSTEPS " Zsteps/mm:"
#define MSG_ESTEPS " Esteps/mm:"
#define MSG_MAIN_WIDE " Main \003"
#define MSG_TEMPERATURE_WIDE " Temperatur \x7E"
#define MSG_MOTION_WIDE " Motion \x7E"
#define MSG_STORE_EPROM " EPROM speichern"
#define MSG_LOAD_EPROM " EPROM laden"
#define MSG_RESTORE_FAILSAFE " Standard Konfig."
#define MSG_REFRESH "\004Refresh"
#define MSG_WATCH " Beobachten \003"
#define MSG_PREPARE " Prepare \x7E"
#define MSG_PREPARE_ALT " Prepare \003"
#define MSG_CONTROL_ARROW " Control \x7E"
#define MSG_TUNE " Tune \x7E"
#define MSG_STOP_PRINT " Druck stoppen \x7E"
#define MSG_CARD_MENU " SDKarten Menue \x7E"
#define MSG_NO_CARD " Keine SDKarte"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Fehler in der Menuestruktur."
#define MSG_DWELL "DWELL..."
#define MSG_NO_MOVE "No move."
#define MSG_PART_RELEASE "Partial Release"
#define MSG_KILLED "KILLED. "
#define MSG_PREHEAT_PLA " Preheat PLA"
#define MSG_PREHEAT_ABS " Preheat ABS"
#define MSG_STEPPER_RELEASED "Released."
// Serial Console Messages
#define MSG_Enqueing "enqueing \""
#define MSG_POWERUP "PowerUp"
#define MSG_EXTERNAL_RESET " External Reset"
#define MSG_BROWNOUT_RESET " Brown out Reset"
#define MSG_WATCHDOG_RESET " Watchdog Reset"
#define MSG_SOFTWARE_RESET " Software Reset"
#define MSG_MARLIN "Marlin: "
#define MSG_AUTHOR " | Author: "
#define MSG_CONFIGURATION_VER " Last Updated: "
#define MSG_FREE_MEMORY " Free Memory: "
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
#define MSG_OK "ok"
#define MSG_FILE_SAVED "Done saving file."
#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line:"
#define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line:"
#define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line:"
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line:"
#define MSG_FILE_PRINTED "Done printing file"
#define MSG_BEGIN_FILE_LIST "Begin file list"
#define MSG_END_FILE_LIST "End file list"
#define MSG_M104_INVALID_EXTRUDER "M104 Invalid extruder "
#define MSG_M105_INVALID_EXTRUDER "M105 Invalid extruder "
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temp"
#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder "
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
#define MSG_COUNT_X " Count X:"
#define MSG_ERR_KILLED "Printer halted. kill() called !!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!"
#define MSG_RESEND "Resend:"
#define MSG_UNKNOWN_COMMAND "Unknown command:\""
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
#define MSG_INVALID_EXTRUDER "Invalid extruder"
#define MSG_X_MIN "x_min:"
#define MSG_X_MAX "x_max:"
#define MSG_Y_MIN "y_min:"
#define MSG_Y_MAX "y_max:"
#define MSG_Z_MIN "z_min:"
#define MSG_Z_MAX "z_max:"
#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
#define MSG_SD_INIT_FAIL "SD init fail"
#define MSG_SD_VOL_INIT_FAIL "volume.init failed"
#define MSG_SD_OPENROOT_FAIL "openRoot failed"
#define MSG_SD_CARD_OK "SD card ok"
#define MSG_SD_WORKDIR_FAIL "workDir open failed"
#define MSG_SD_OPEN_FILE_FAIL "open failed, File: "
#define MSG_SD_FILE_OPENED "File opened:"
#define MSG_SD_SIZE " Size:"
#define MSG_SD_FILE_SELECTED "File selected"
#define MSG_SD_WRITE_TO_FILE "Writing to file: "
#define MSG_SD_PRINTING_BYTE "SD printing byte "
#define MSG_SD_NOT_PRINTING "Not SD printing"
#define MSG_SD_ERR_WRITE_TO_FILE "error writing to file"
#define MSG_SD_CANT_ENTER_SUBDIR "Cannot enter subdir:"
#define MSG_STEPPER_TO_HIGH "Steprate to high : "
#define MSG_ENDSTOPS_HIT "endstops hit: "
#define MSG_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented"
#define MSG_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented"
#endif
#endif // ifndef LANGUAGE_H
+35
View File
@@ -0,0 +1,35 @@
#include "led.h"
#if (LED_PIN > -1)
#include "Marlin.h"
#include "temperature.h"
static unsigned long previous_millis_led=0;
static unsigned long previous_millis_toggle=0;
void led_init()
{
SET_OUTPUT(LED_PIN);
}
void led_status()
{
if (((millis() - previous_millis_led) < LED_UPDATE_INTERVAL))
return;
previous_millis_led=millis();
if (degTargetHotend(active_extruder) > HEATER_0_MINTEMP)
{
if (((millis() - previous_millis_toggle) < LED_HOTEND_ACTIVE_FLASH))
return;
previous_millis_toggle=millis();
TOGGLE(LED_PIN);
}
else
{
WRITE(LED_PIN, HIGH);
}
}
#endif //LED_PIN > -1
+20
View File
@@ -0,0 +1,20 @@
#ifndef __LEDH
#define __LEDH
#include "Marlin.h"
#if (LED_PIN > -1)
void led_status();
void led_init();
#define LED_UPDATE_INTERVAL 100
#define LED_HOTEND_ACTIVE_FLASH 800
#define LED_ERROR_FLASH 200
#define LED_STATUS led_status()
#else //no led
#define LED_STATUS
FORCE_INLINE void led_status() {};
#endif //LED_PIN > -1
#endif
+14
View File
@@ -47,6 +47,8 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel));
if (millimeters_of_travel < 0.001) { return; }
uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT);
if(segments == 0) segments = 1;
/*
// Multiply inverse feed_rate to compensate for the fact that this movement is approximated
// by a number of discrete segments. The inverse feed_rate should be correct for the sum of
@@ -122,6 +124,18 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
arc_target[axis_1] = center_axis1 + r_axis1;
arc_target[axis_linear] += linear_per_segment;
arc_target[E_AXIS] += extruder_per_segment;
if (min_software_endstops) {
if (arc_target[X_AXIS] < X_HOME_POS) arc_target[X_AXIS] = X_HOME_POS;
if (arc_target[Y_AXIS] < Y_HOME_POS) arc_target[Y_AXIS] = Y_HOME_POS;
if (arc_target[Z_AXIS] < Z_HOME_POS) arc_target[Z_AXIS] = Z_HOME_POS;
}
if (max_software_endstops) {
if (arc_target[X_AXIS] > X_MAX_LENGTH) arc_target[X_AXIS] = X_MAX_LENGTH;
if (arc_target[Y_AXIS] > Y_MAX_LENGTH) arc_target[Y_AXIS] = Y_MAX_LENGTH;
if (arc_target[Z_AXIS] > Z_MAX_LENGTH) arc_target[Z_AXIS] = Z_MAX_LENGTH;
}
plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder);
}
+340 -218
View File
@@ -45,225 +45,195 @@
#endif /* 99 */
/****************************************************************************************
* Arduino pin assignment
*
* ATMega168
* +-\/-+
* PC6 1| |28 PC5 (AI 5 / D19)
* (D 0) PD0 2| |27 PC4 (AI 4 / D18)
* (D 1) PD1 3| |26 PC3 (AI 3 / D17)
* (D 2) PD2 4| |25 PC2 (AI 2 / D16)
* PWM+ (D 3) PD3 5| |24 PC1 (AI 1 / D15)
* (D 4) PD4 6| |23 PC0 (AI 0 / D14)
* VCC 7| |22 GND
* GND 8| |21 AREF
* PB6 9| |20 AVCC
* PB7 10| |19 PB5 (D 13)
* PWM+ (D 5) PD5 11| |18 PB4 (D 12)
* PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
* (D 7) PD7 13| |16 PB2 (D 10) PWM
* (D 8) PB0 14| |15 PB1 (D 9) PWM
* +----+
****************************************************************************************/
#if MOTHERBOARD == 0
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega168__
#error Oops! Make sure you have 'Arduino Diecimila' selected from the boards menu.
#endif
#define X_STEP_PIN 2
#define X_DIR_PIN 3
#define X_ENABLE_PIN -1
#define X_MIN_PIN 4
#define X_MAX_PIN 9
#define Y_STEP_PIN 10
#define Y_DIR_PIN 7
#define Y_ENABLE_PIN -1
#define Y_MIN_PIN 8
#define Y_MAX_PIN 13
#define Z_STEP_PIN 19
#define Z_DIR_PIN 18
#define Z_ENABLE_PIN 5
#define Z_MIN_PIN 17
#define Z_MAX_PIN 16
#define E0_STEP_PIN 11
#define E0_DIR_PIN 12
#define E0_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS -1
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN 15
#define KILL_PIN -1
#define HEATER_0_PIN 6
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_2_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#endif
/****************************************************************************************
* Sanguino/RepRap Motherboard with direct-drive extruders
*
* ATMega644P
*
* +---\/---+
* (D 0) PB0 1| |40 PA0 (AI 0 / D31)
* (D 1) PB1 2| |39 PA1 (AI 1 / D30)
* INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
* PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
* PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
* MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
* MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
* SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
* RST 9| |32 AREF
* VCC 10| |31 GND
* GND 11| |30 AVCC
* XTAL2 12| |29 PC7 (D 23)
* XTAL1 13| |28 PC6 (D 22)
* RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
* TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
* INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
* INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
* PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
* PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
* PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
* +--------+
* Gen7 v1.1, v1.2, v1.3, v1.4 pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 1
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#if MOTHERBOARD == 13
#define MOTHERBOARD 11
#define GEN7_VERSION 14 // v1.4
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN 21
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 19
#define Y_MIN_PIN 25
#define Y_MAX_PIN 26
#define Z_STEP_PIN 29
#define Z_DIR_PIN 30
#define Z_ENABLE_PIN 31
#define Z_MIN_PIN 2
#define Z_MAX_PIN 1
#define E0_STEP_PIN 12
#define E0_DIR_PIN 16
#define E0_ENABLE_PIN 3
#define SDPOWER -1
#define SDSS -1
#define LED_PIN 0
#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 14
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 4 //D27 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
/* Unused (1) (2) (3) 4 5 6 7 8 9 10 11 12 13 (14) (15) (16) 17 (18) (19) (20) (21) (22) (23) 24 (25) (26) (27) 28 (29) (30) (31) */
#if MOTHERBOARD == 12
#define MOTHERBOARD 11
#define GEN7_VERSION 13 // v1.3
#endif
#if MOTHERBOARD == 11
#define KNOWN_BOARD
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__)
#error Oops! Make sure you have 'Gen7' selected from the 'Tools -> Boards' menu.
#endif
/****************************************************************************************
* RepRap Motherboard ****---NOOOOOO RS485/EXTRUDER CONTROLLER!!!!!!!!!!!!!!!!!---*******
*
****************************************************************************************/
#if MOTHERBOARD == 2
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#ifndef GEN7_VERSION
#define GEN7_VERSION 12 // v1.x
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN 21
//x axis pins
#define X_STEP_PIN 19
#define X_DIR_PIN 18
#define X_ENABLE_PIN 24
#define X_MIN_PIN 7
#define X_MAX_PIN -1
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 24
#define Y_MIN_PIN 25
#define Y_MAX_PIN 26
//y axis pins
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 24
#define Y_MIN_PIN 5
#define Y_MAX_PIN -1
#define Z_STEP_PINN 27
#define Z_DIR_PINN 28
#define Z_ENABLE_PIN 29
#define Z_MIN_PIN 30
#define Z_MAX_PIN 31
//z axis pins
#define Z_STEP_PIN 26
#define Z_DIR_PIN 25
#define Z_ENABLE_PIN 24
#define Z_MIN_PIN 1
#define Z_MAX_PIN 0
#define E0_STEP_PIN 17
#define E0_DIR_PIN 16
#define E0_ENABLE_PIN -1
//extruder pins
#define E0_STEP_PIN 28
#define E0_DIR_PIN 27
#define E0_ENABLE_PIN 24
#define SDPOWER -1
#define SDSS 4
#define LED_PIN 0
#define TEMP_0_PIN 1
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 2
#define SD_CARD_WRITE 2
#define SD_CARD_DETECT 3
#define SD_CARD_SELECT 4
#define HEATER_0_PIN 4
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN 3
#define SDPOWER -1
#define SDSS -1 // SCL pin of I2C header
#define LED_PIN -1
#if (GEN7_VERSION >= 13)
// Gen7 v1.3 removed the fan pin
#define FAN_PIN -1
#else
#define FAN_PIN 31
#endif
#define PS_ON_PIN 15
#if (GEN7_VERSION < 14)
// Gen 1.3 and earlier supplied thermistor power via PS_ON
// Need to ignore the bad thermistor readings on those units
#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
#endif
//our pin for debugging.
#define DEBUG_PIN 0
//our RS485 pins
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
//pin for controlling the PSU.
#define PS_ON_PIN 14
#endif
#define FAN_PIN -1
#define KILL_PIN -1
/*******************************************************************************
*********
* Gen7 Alfons3 pin assignment
*
********************************************************************************
********/
/* These Pins are assigned for the modified GEN7 Board from Alfons3 Please review the pins and adjust it for your needs*/
#define HEATER_0_PIN -1
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#if MOTHERBOARD == 10
#define KNOWN_BOARD
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__)
#error Oops! Make sure you have 'Gen7' selected from the 'Tools -> Boards' menu.
#endif
//x axis pins
#define X_STEP_PIN 21 //different from stanard GEN7
#define X_DIR_PIN 20 //different from stanard GEN7
#define X_ENABLE_PIN 24
#define X_MIN_PIN 0
#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 1
#define Y_MAX_PIN -1
//z axis pins
#define Z_STEP_PIN 26
#define Z_DIR_PIN 25
#define Z_ENABLE_PIN 24
#define Z_MIN_PIN 2
#define Z_MAX_PIN -1
//extruder pins
#define E0_STEP_PIN 28
#define E0_DIR_PIN 27
#define E0_ENABLE_PIN 24
#define TEMP_0_PIN 2
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed)
#define HEATER_0_PIN 4
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN 3 // (bed)
#define SDPOWER -1
#define SDSS 31 // SCL pin of I2C header || CS Pin for SD Card support
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN 19
//our pin for debugging.
#define DEBUG_PIN -1
//our RS485 pins
//#define TX_ENABLE_PIN 12
//#define RX_ENABLE_PIN 13
#define BEEPER -1
#define SDCARDDETECT -1
#define SUICIDE_PIN -1 //has to be defined; otherwise Power_off doesn't work
//Pins for 4bit LCD Support
#define LCD_PINS_RS 18
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 16
#define LCD_PINS_D5 15
#define LCD_PINS_D6 13
#define LCD_PINS_D7 14
//buttons are directly attached
#define BTN_EN1 11
#define BTN_EN2 10
#define BTN_ENC 12 //the click
#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
#endif
/****************************************************************************************
* Arduino Mega pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 33
#define MOTHERBOARD 3
#define RAMPS_V_1_3
#endif
#if MOTHERBOARD == 3
#if MOTHERBOARD == 3 || MOTHERBOARD == 33 || MOTHERBOARD == 34
#define KNOWN_BOARD 1
//////////////////FIX THIS//////////////
@@ -277,7 +247,7 @@
// #define RAMPS_V_1_3
// #define RAMPS_V_1_0
#ifdef RAMPS_V_1_3
#if MOTHERBOARD == 33 || MOTHERBOARD == 34
#define X_STEP_PIN 54
#define X_DIR_PIN 55
@@ -295,7 +265,7 @@
#define Z_DIR_PIN 48
#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19 //19
#define Z_MAX_PIN 19
#define E0_STEP_PIN 26
#define E0_DIR_PIN 28
@@ -308,19 +278,96 @@
#define SDPOWER -1
#define SDSS 53
#define LED_PIN 13
#define FAN_PIN 4
#if MOTHERBOARD == 33
#define FAN_PIN 9 // (Sprinter config)
#else
#define FAN_PIN 4 // IO pin. Buffer needed
#endif
#define PS_ON_PIN 12
#define KILL_PIN -1
#define HEATER_0_PIN 10 // EXTRUDER 1
#define HEATER_1_PIN 9 // EXTRUDER 2
#define HEATER_2_PIN -1 // EXTRUDER 2
#if MOTHERBOARD == 33
#define HEATER_1_PIN -1
#else
#define HEATER_1_PIN 9 // EXTRUDER 2 (FAN On Sprinter)
#endif
#define HEATER_2_PIN -1
#define TEMP_0_PIN 13 // ANALOG NUMBERING
#define TEMP_1_PIN 15 // ANALOG NUMBERING
#define TEMP_2_PIN -1 // ANALOG NUMBERING
#define HEATER_BED_PIN 8 // BED
#define TEMP_BED_PIN 14 // ANALOG NUMBERING
#ifdef ULTRA_LCD
#ifdef NEWPANEL
//arduino pin which triggers an piezzo beeper
#define BEEPER 33 // Beeper on AUX-4
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
//buttons are directly attached using AUX-2
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31 //the click
#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define SDCARDDETECT -1 // Ramps does not use this port
//encoder rotation values
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
#else //old style panel with shift register
//arduino pin witch triggers an piezzo beeper
#define BEEPER 33 No Beeper added
//buttons are attached to a shift register
// Not wired this yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
//encoder rotation values
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
//bits in the shift register that carry the buttons for:
// left up center down right red
#define BL_LE 7
#define BL_UP 6
#define BL_MI 5
#define BL_DW 4
#define BL_RI 3
#define BL_ST 2
#define BLEN_B 1
#define BLEN_A 0
#endif
#endif //ULTRA_LCD
#else // RAMPS_V_1_1 or RAMPS_V_1_2 as default
@@ -352,8 +399,6 @@
#define PS_ON_PIN -1
#define KILL_PIN -1
#ifdef RAMPS_V_1_0 // RAMPS_V_1_0
#define HEATER_0_PIN 12 // RAMPS 1.0
#define HEATER_BED_PIN -1 // RAMPS 1.0
@@ -440,11 +485,13 @@
* Gen6 pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 5
#if MOTHERBOARD == 5 || MOTHERBOARD == 51
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#ifndef __AVR_ATmega1284P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#endif
//x axis pins
@@ -474,13 +521,19 @@
#define E0_ENABLE_PIN 3 //Added @ EJE Electronics 20100715
#define TEMP_0_PIN 5 //changed @ rkoeppl 20110410
#define TEMP_1_PIN -1 //changed @ rkoeppl 20110410
#define TEMP_2_PIN -1 //changed @ rkoeppl 20110410
#define HEATER_0_PIN 14 //changed @ rkoeppl 20110410
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#if MOTHERBOARD == 5
#define HEATER_BED_PIN -1 //changed @ rkoeppl 20110410
#define TEMP_BED_PIN -1 //changed @ rkoeppl 20110410
#else
#define HEATER_BED_PIN 1 //changed @ rkoeppl 20110410
#define TEMP_BED_PIN 0 //changed @ rkoeppl 20110410
#endif
#define SDPOWER -1
#define SDSS 17
#define LED_PIN -1 //changed @ rkoeppl 20110410
@@ -502,14 +555,17 @@
*
****************************************************************************************/
#if MOTHERBOARD == 62
#undef MOTHERBOARD
#define MOTHERBOARD 6
#define SANGUINOLOLU_V_1_2
#endif
#if MOTHERBOARD == 6
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#ifndef __AVR_ATmega1284P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 21
@@ -529,9 +585,10 @@
#define E0_STEP_PIN 1
#define E0_DIR_PIN 0
#define LED_PIN -1
#define PROBE_PIN 20
#define FAN_PIN -1
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
@@ -542,7 +599,7 @@
#ifdef SANGUINOLOLU_V_1_2
#define HEATER_BED_PIN 12 // (bed)
#define HEATER_BED_PIN 10 // (bed) - 10 for spare DIO pin and bed MOSFET, 12 for SL MOSFET
#define X_ENABLE_PIN 14
#define Y_ENABLE_PIN 14
#define Z_ENABLE_PIN 26
@@ -567,6 +624,65 @@
#endif
/****************************************************************************************
* Melzi pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 63
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#ifndef __AVR_ATmega1284P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 21
#define X_MIN_PIN 18
#define X_MAX_PIN -2
#define Y_STEP_PIN 22
#define Y_DIR_PIN 23
#define Y_MIN_PIN 19
#define Y_MAX_PIN -1
#define Z_STEP_PIN 3
#define Z_DIR_PIN 2
#define Z_MIN_PIN 20
#define Z_MAX_PIN -1
#define E0_STEP_PIN 1
#define E0_DIR_PIN 0
#define PROBE_PIN -1 //29 on Melzi1284p A2
#define LED_PIN 27
#define FAN_PIN 4
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 13 // (extruder)
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN 12 // bed (change to 10 for gate pin of MOSFET on heated bed)
#define X_ENABLE_PIN 14
#define Y_ENABLE_PIN 14
#define Z_ENABLE_PIN 26
#define E0_ENABLE_PIN 14
#define TEMP_0_PIN 7 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 33 extruder)
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 6 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed)
#define SDPOWER -1
#define SDSS 31
#endif
#if MOTHERBOARD == 7
#define KNOWN_BOARD
@@ -616,7 +732,7 @@
#define E1_STEP_PIN 49
#define E1_DIR_PIN 47
#define E1_ENABLE_PIN 51
#define E1_ENABLE_PIN 48
#define SDPOWER -1
#define SDSS 53
@@ -678,7 +794,7 @@
#define encrot2 3
#define encrot3 1
#define SDCARDDETECT -1
//bits in the shift register that carry the buttons for:
// left up center down right red
#define BL_LE 7
@@ -829,8 +945,10 @@
#define MOTHERBOARD 6
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#ifndef __AVR_ATmega1284P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 18
@@ -882,22 +1000,26 @@
#endif
//List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN
#if EXTRUDERS == 3
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN
#define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN
#elif EXTRUDERS == 2
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN
#define _E2_PINS -1
#elif EXTRUDERS == 1
#define _E1_PINS -1
#define _E2_PINS -1
#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, HEATER_0_PIN,
#if EXTRUDERS > 1
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, HEATER_1_PIN,
#else
#error Unsupported number of extruders
#define _E1_PINS
#endif
#if EXTRUDERS > 2
#define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, HEATER_2_PIN,
#else
#define _E2_PINS
#endif
#ifdef DISABLE_MAX_ENDSTOPS
#define X_MAX_PIN -1
#define Y_MAX_PIN -1
#define Z_MAX_PIN -1
#endif
#define SENSITIVE_PINS {0, 1, X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, LED_PIN, PS_ON_PIN, \
HEATER_0_PIN, HEATER_1_PIN, HEATER_2_PIN, \
HEATER_BED_PIN, FAN_PIN, \
_E0_PINS, _E1_PINS, _E2_PINS, \
_E0_PINS _E1_PINS _E2_PINS \
TEMP_0_PIN, TEMP_1_PIN, TEMP_2_PIN, TEMP_BED_PIN }
#endif
+94 -82
View File
@@ -51,14 +51,13 @@
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
*/
#include "Marlin.h"
#include "planner.h"
#include "stepper.h"
#include "temperature.h"
#include "ultralcd.h"
#include "language.h"
#include "led.h"
//===========================================================================
//=============================public variables ============================
@@ -73,6 +72,7 @@ float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT A
float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
float max_z_jerk;
float max_e_jerk;
float mintravelfeedrate;
unsigned long axis_steps_per_sqr_second[NUM_AXIS];
@@ -81,6 +81,8 @@ long position[4]; //rescaled from extern when axis_steps_per_unit are changed
static float previous_speed[4]; // Speed of previous path line segment
static float previous_nominal_speed; // Nominal speed of previous path line segment
extern volatile int extrudemultiply; // Sets extrude multiply factor (in percent)
#ifdef AUTOTEMP
float autotemp_max=250;
float autotemp_min=210;
@@ -373,20 +375,26 @@ void plan_init() {
void getHighESpeed()
{
static float oldt=0;
if(!autotemp_enabled)
if(!autotemp_enabled){
return;
if(degTargetHotend0()+2<autotemp_min) //probably temperature set to zero.
}
if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
return; //do nothing
}
float high=0;
float high=0.0;
uint8_t block_index = block_buffer_tail;
while(block_index != block_buffer_head) {
float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
//se; units steps/sec;
if(se>high)
{
high=se;
if((block_buffer[block_index].steps_x != 0) ||
(block_buffer[block_index].steps_y != 0) ||
(block_buffer[block_index].steps_z != 0)) {
float se=(float(block_buffer[block_index].steps_e)/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed;
//se; mm/sec;
if(se>high)
{
high=se;
}
}
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
}
@@ -403,10 +411,6 @@ void getHighESpeed()
}
oldt=t;
setTargetHotend0(t);
// SERIAL_ECHO_START;
// SERIAL_ECHOPAIR("highe",high);
// SERIAL_ECHOPAIR(" t",t);
// SERIAL_ECHOLN("");
}
#endif
@@ -415,23 +419,38 @@ void check_axes_activity() {
unsigned char y_active = 0;
unsigned char z_active = 0;
unsigned char e_active = 0;
unsigned char fan_speed = 0;
unsigned char tail_fan_speed = 0;
block_t *block;
if(block_buffer_tail != block_buffer_head) {
uint8_t block_index = block_buffer_tail;
tail_fan_speed = block_buffer[block_index].fan_speed;
while(block_index != block_buffer_head) {
block = &block_buffer[block_index];
if(block->steps_x != 0) x_active++;
if(block->steps_y != 0) y_active++;
if(block->steps_z != 0) z_active++;
if(block->steps_e != 0) e_active++;
if(block->fan_speed != 0) fan_speed++;
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
}
}
else {
#if FAN_PIN > -1
if (FanSpeed != 0) analogWrite(FAN_PIN,FanSpeed); // If buffer is empty use current fan speed
#endif
}
if((DISABLE_X) && (x_active == 0)) disable_x();
if((DISABLE_Y) && (y_active == 0)) disable_y();
if((DISABLE_Z) && (z_active == 0)) disable_z();
if((DISABLE_E) && (e_active == 0)) { disable_e0();disable_e1();disable_e2(); }
#if FAN_PIN > -1
if((FanSpeed == 0) && (fan_speed ==0)) analogWrite(FAN_PIN, 0);
#endif
if (FanSpeed != 0 && tail_fan_speed !=0) {
analogWrite(FAN_PIN,tail_fan_speed);
}
}
@@ -439,7 +458,7 @@ float junction_deviation = 0.1;
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters.
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder)
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder)
{
// Calculate the buffer head after we push this byte
int next_buffer_head = next_block_index(block_buffer_head);
@@ -450,8 +469,9 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
manage_heater();
manage_inactivity(1);
LCD_STATUS;
LED_STATUS;
}
// The target position of the tool in absolute steps
// Calculate target position in absolute steps
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
@@ -467,13 +487,13 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
{
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(" cold extrusion prevented");
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
}
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
{
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(" too long extrusion prevented");
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
}
#endif
@@ -488,11 +508,15 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
block->steps_y = labs(target[Y_AXIS]-position[Y_AXIS]);
block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
block->steps_e = labs(target[E_AXIS]-position[E_AXIS]);
block->steps_e *= extrudemultiply;
block->steps_e /= 100;
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
// Bail if this is a zero-length block
if (block->step_event_count <=dropsegments) { return; };
if (block->step_event_count <= dropsegments) { return; };
block->fan_speed = FanSpeed;
// Compute direction bits for this block
block->direction_bits = 0;
if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<<X_AXIS); }
@@ -512,63 +536,61 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// Enable all
if(block->steps_e != 0) { enable_e0();enable_e1();enable_e2(); }
float delta_mm[4];
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
if ( block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0 ) {
block->millimeters = abs(delta_mm[E_AXIS]);
} else {
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
}
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
float inverse_second = feed_rate * inverse_millimeters;
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
if (block->steps_e == 0) {
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
}
else {
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
}
float delta_mm[4];
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0;
// if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) {
// block->millimeters = abs(delta_mm[E_AXIS]);
// } else {
// block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
// }
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
// TODO - JMG - SORT OUT RETRACTS WHEN e IS NOT ALONE
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
square(delta_mm[Z_AXIS]) + square(delta_mm[E_AXIS]));
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
float inverse_second = feed_rate * inverse_millimeters;
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
#ifdef SLOWDOWN
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
#endif
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
#ifdef OLD_SLOWDOWN
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
#endif
/*
#ifdef SLOWDOWN
// segment time im micro seconds
long segment_time = lround(1000000.0/inverse_second);
if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
if (segment_time<minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
unsigned long segment_time = lround(1000000.0/inverse_second);
if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
if (segment_time < minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
}
}
else {
if (segment_time<minsegmenttime) segment_time=minsegmenttime;
}
#endif
// END OF SLOW DOWN SECTION
*/
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
// Calculate speed in mm/sec for each axis
// Calculate and limit speed in mm/sec for each axis
float current_speed[4];
for(int i=0; i < 4; i++) {
current_speed[i] = delta_mm[i] * inverse_second;
}
// Limit speed per axis
float speed_factor = 1.0; //factor <=1 do decrease speed
for(int i=0; i < 4; i++) {
if(abs(current_speed[i]) > max_feedrate[i])
speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
current_speed[i] = delta_mm[i] * inverse_second;
if(fabs(current_speed[i]) > max_feedrate[i])
speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
}
// Max segement time in us.
@@ -603,17 +625,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// Correct the speed
if( speed_factor < 1.0) {
// Serial.print("speed factor : "); Serial.println(speed_factor);
for(int i=0; i < 4; i++) {
if(abs(current_speed[i]) > max_feedrate[i])
speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
/*
if(speed_factor < 0.1) {
Serial.print("speed factor : "); Serial.println(speed_factor);
Serial.print("current_speed"); Serial.print(i); Serial.print(" : "); Serial.println(current_speed[i]);
}
*/
}
for(unsigned char i=0; i < 4; i++) {
current_speed[i] *= speed_factor;
}
@@ -683,20 +694,25 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
#endif
// Start with a safe speed
float vmax_junction = max_xy_jerk/2;
if(abs(current_speed[Z_AXIS]) > max_z_jerk/2)
if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2)
vmax_junction = max_z_jerk/2;
vmax_junction = min(vmax_junction, block->nominal_speed);
if ((moves_queued > 1) && (previous_nominal_speed > 0.0)) {
if(fabs(current_speed[E_AXIS]) > max_e_jerk/2)
vmax_junction = min(vmax_junction, max_e_jerk/2);
if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) {
float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));
if((previous_speed[X_AXIS] != 0.0) || (previous_speed[Y_AXIS] != 0.0)) {
if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) {
vmax_junction = block->nominal_speed;
}
if (jerk > max_xy_jerk) {
vmax_junction *= (max_xy_jerk/jerk);
}
if(abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
vmax_junction *= (max_z_jerk/abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
vmax_junction *= (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
}
if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
vmax_junction *= (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]));
}
}
block->max_entry_speed = vmax_junction;
@@ -720,6 +736,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// Update previous path unit_vector and nominal speed
memcpy(previous_speed, current_speed, sizeof(previous_speed)); // previous_speed[] = current_speed[]
previous_nominal_speed = block->nominal_speed;
#ifdef ADVANCE
// Calculate advance rate
@@ -748,9 +765,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
*/
#endif // ADVANCE
calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
MINIMUM_PLANNER_SPEED/block->nominal_speed);
@@ -761,9 +775,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
memcpy(position, target, sizeof(target)); // position[] = target[]
planner_recalculate();
#ifdef AUTOTEMP
getHighESpeed();
#endif
st_wake_up();
}
+6 -4
View File
@@ -45,10 +45,10 @@ typedef struct {
#endif
// Fields used by the motion planner to manage acceleration
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis
float nominal_speed; // The nominal speed for this block in mm/min
float entry_speed; // Entry speed at previous-current junction in mm/min
float max_entry_speed; // Maximum allowable junction entry speed in mm/min
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis
float nominal_speed; // The nominal speed for this block in mm/sec
float entry_speed; // Entry speed at previous-current junction in mm/sec
float max_entry_speed; // Maximum allowable junction entry speed in mm/sec
float millimeters; // The total travel of this block in mm
float acceleration; // acceleration mm/sec^2
unsigned char recalculate_flag; // Planner flag to recalculate trapezoids on entry junction
@@ -59,6 +59,7 @@ typedef struct {
unsigned long initial_rate; // The jerk-adjusted step rate at start of block
unsigned long final_rate; // The minimal rate at exit
unsigned long acceleration_st; // acceleration steps/sec^2
unsigned long fan_speed;
volatile char busy;
} block_t;
@@ -87,6 +88,7 @@ extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DE
extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
extern float max_z_jerk;
extern float max_e_jerk;
extern float mintravelfeedrate;
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
+76
View File
@@ -3,6 +3,8 @@
#include "Marlin.h"
#if F_CPU == 16000000
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
@@ -73,4 +75,78 @@ const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
{ 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
};
#else
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {
{62500, 54055}, {8445, 3917}, {4528, 1434}, {3094, 745}, {2349, 456}, {1893, 307}, {1586, 222}, {1364, 167},
{1197, 131}, {1066, 105}, {961, 86}, {875, 72}, {803, 61}, {742, 53}, {689, 45}, {644, 40},
{604, 35}, {569, 32}, {537, 28}, {509, 25}, {484, 23}, {461, 21}, {440, 19}, {421, 17},
{404, 16}, {388, 15}, {373, 14}, {359, 13}, {346, 12}, {334, 11}, {323, 10}, {313, 10},
{303, 9}, {294, 9}, {285, 8}, {277, 7}, {270, 8}, {262, 7}, {255, 6}, {249, 6},
{243, 6}, {237, 6}, {231, 5}, {226, 5}, {221, 5}, {216, 5}, {211, 4}, {207, 5},
{202, 4}, {198, 4}, {194, 4}, {190, 3}, {187, 4}, {183, 3}, {180, 3}, {177, 4},
{173, 3}, {170, 3}, {167, 2}, {165, 3}, {162, 3}, {159, 2}, {157, 3}, {154, 2},
{152, 3}, {149, 2}, {147, 2}, {145, 2}, {143, 2}, {141, 2}, {139, 2}, {137, 2},
{135, 2}, {133, 2}, {131, 2}, {129, 1}, {128, 2}, {126, 2}, {124, 1}, {123, 2},
{121, 1}, {120, 2}, {118, 1}, {117, 1}, {116, 2}, {114, 1}, {113, 1}, {112, 2},
{110, 1}, {109, 1}, {108, 1}, {107, 2}, {105, 1}, {104, 1}, {103, 1}, {102, 1},
{101, 1}, {100, 1}, {99, 1}, {98, 1}, {97, 1}, {96, 1}, {95, 1}, {94, 1},
{93, 1}, {92, 1}, {91, 0}, {91, 1}, {90, 1}, {89, 1}, {88, 1}, {87, 0},
{87, 1}, {86, 1}, {85, 1}, {84, 0}, {84, 1}, {83, 1}, {82, 1}, {81, 0},
{81, 1}, {80, 1}, {79, 0}, {79, 1}, {78, 0}, {78, 1}, {77, 1}, {76, 0},
{76, 1}, {75, 0}, {75, 1}, {74, 1}, {73, 0}, {73, 1}, {72, 0}, {72, 1},
{71, 0}, {71, 1}, {70, 0}, {70, 1}, {69, 0}, {69, 1}, {68, 0}, {68, 1},
{67, 0}, {67, 1}, {66, 0}, {66, 1}, {65, 0}, {65, 0}, {65, 1}, {64, 0},
{64, 1}, {63, 0}, {63, 1}, {62, 0}, {62, 0}, {62, 1}, {61, 0}, {61, 1},
{60, 0}, {60, 0}, {60, 1}, {59, 0}, {59, 0}, {59, 1}, {58, 0}, {58, 0},
{58, 1}, {57, 0}, {57, 0}, {57, 1}, {56, 0}, {56, 0}, {56, 1}, {55, 0},
{55, 0}, {55, 1}, {54, 0}, {54, 0}, {54, 1}, {53, 0}, {53, 0}, {53, 0},
{53, 1}, {52, 0}, {52, 0}, {52, 1}, {51, 0}, {51, 0}, {51, 0}, {51, 1},
{50, 0}, {50, 0}, {50, 0}, {50, 1}, {49, 0}, {49, 0}, {49, 0}, {49, 1},
{48, 0}, {48, 0}, {48, 0}, {48, 1}, {47, 0}, {47, 0}, {47, 0}, {47, 1},
{46, 0}, {46, 0}, {46, 0}, {46, 0}, {46, 1}, {45, 0}, {45, 0}, {45, 0},
{45, 1}, {44, 0}, {44, 0}, {44, 0}, {44, 0}, {44, 1}, {43, 0}, {43, 0},
{43, 0}, {43, 0}, {43, 1}, {42, 0}, {42, 0}, {42, 0}, {42, 0}, {42, 0},
{42, 1}, {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 1}, {40, 0},
{40, 0}, {40, 0}, {40, 0}, {40, 1}, {39, 0}, {39, 0}, {39, 0}, {39, 0},
{39, 0}, {39, 0}, {39, 1}, {38, 0}, {38, 0}, {38, 0}, {38, 0}, {38, 0},
};
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {
{62500, 10417}, {52083, 7441}, {44642, 5580}, {39062, 4340}, {34722, 3472}, {31250, 2841}, {28409, 2368}, {26041, 2003},
{24038, 1717}, {22321, 1488}, {20833, 1302}, {19531, 1149}, {18382, 1021}, {17361, 914}, {16447, 822}, {15625, 745},
{14880, 676}, {14204, 618}, {13586, 566}, {13020, 520}, {12500, 481}, {12019, 445}, {11574, 414}, {11160, 385},
{10775, 359}, {10416, 336}, {10080, 315}, {9765, 296}, {9469, 278}, {9191, 263}, {8928, 248}, {8680, 235},
{8445, 222}, {8223, 211}, {8012, 200}, {7812, 191}, {7621, 181}, {7440, 173}, {7267, 165}, {7102, 158},
{6944, 151}, {6793, 145}, {6648, 138}, {6510, 133}, {6377, 127}, {6250, 123}, {6127, 118}, {6009, 113},
{5896, 109}, {5787, 106}, {5681, 101}, {5580, 98}, {5482, 95}, {5387, 91}, {5296, 88}, {5208, 86},
{5122, 82}, {5040, 80}, {4960, 78}, {4882, 75}, {4807, 73}, {4734, 70}, {4664, 69}, {4595, 67},
{4528, 64}, {4464, 63}, {4401, 61}, {4340, 60}, {4280, 58}, {4222, 56}, {4166, 55}, {4111, 53},
{4058, 52}, {4006, 51}, {3955, 49}, {3906, 48}, {3858, 48}, {3810, 45}, {3765, 45}, {3720, 44},
{3676, 43}, {3633, 42}, {3591, 40}, {3551, 40}, {3511, 39}, {3472, 38}, {3434, 38}, {3396, 36},
{3360, 36}, {3324, 35}, {3289, 34}, {3255, 34}, {3221, 33}, {3188, 32}, {3156, 31}, {3125, 31},
{3094, 31}, {3063, 30}, {3033, 29}, {3004, 28}, {2976, 28}, {2948, 28}, {2920, 27}, {2893, 27},
{2866, 26}, {2840, 25}, {2815, 25}, {2790, 25}, {2765, 24}, {2741, 24}, {2717, 24}, {2693, 23},
{2670, 22}, {2648, 22}, {2626, 22}, {2604, 22}, {2582, 21}, {2561, 21}, {2540, 20}, {2520, 20},
{2500, 20}, {2480, 20}, {2460, 19}, {2441, 19}, {2422, 19}, {2403, 18}, {2385, 18}, {2367, 18},
{2349, 17}, {2332, 18}, {2314, 17}, {2297, 16}, {2281, 17}, {2264, 16}, {2248, 16}, {2232, 16},
{2216, 16}, {2200, 15}, {2185, 15}, {2170, 15}, {2155, 15}, {2140, 15}, {2125, 14}, {2111, 14},
{2097, 14}, {2083, 14}, {2069, 14}, {2055, 13}, {2042, 13}, {2029, 13}, {2016, 13}, {2003, 13},
{1990, 13}, {1977, 12}, {1965, 12}, {1953, 13}, {1940, 11}, {1929, 12}, {1917, 12}, {1905, 12},
{1893, 11}, {1882, 11}, {1871, 11}, {1860, 11}, {1849, 11}, {1838, 11}, {1827, 11}, {1816, 10},
{1806, 11}, {1795, 10}, {1785, 10}, {1775, 10}, {1765, 10}, {1755, 10}, {1745, 9}, {1736, 10},
{1726, 9}, {1717, 10}, {1707, 9}, {1698, 9}, {1689, 9}, {1680, 9}, {1671, 9}, {1662, 9},
{1653, 9}, {1644, 8}, {1636, 9}, {1627, 8}, {1619, 9}, {1610, 8}, {1602, 8}, {1594, 8},
{1586, 8}, {1578, 8}, {1570, 8}, {1562, 8}, {1554, 7}, {1547, 8}, {1539, 8}, {1531, 7},
{1524, 8}, {1516, 7}, {1509, 7}, {1502, 7}, {1495, 7}, {1488, 7}, {1481, 7}, {1474, 7},
{1467, 7}, {1460, 7}, {1453, 7}, {1446, 6}, {1440, 7}, {1433, 7}, {1426, 6}, {1420, 6},
{1414, 7}, {1407, 6}, {1401, 6}, {1395, 7}, {1388, 6}, {1382, 6}, {1376, 6}, {1370, 6},
{1364, 6}, {1358, 6}, {1352, 6}, {1346, 5}, {1341, 6}, {1335, 6}, {1329, 5}, {1324, 6},
{1318, 5}, {1313, 6}, {1307, 5}, {1302, 6}, {1296, 5}, {1291, 5}, {1286, 6}, {1280, 5},
{1275, 5}, {1270, 5}, {1265, 5}, {1260, 5}, {1255, 5}, {1250, 5}, {1245, 5}, {1240, 5},
{1235, 5}, {1230, 5}, {1225, 5}, {1220, 5}, {1215, 4}, {1211, 5}, {1206, 5}, {1201, 5},
};
#endif
#endif
+44 -21
View File
@@ -21,15 +21,13 @@
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
and Philipp Tiefenbacher. */
#include "Marlin.h"
#include "stepper.h"
#include "planner.h"
#include "temperature.h"
#include "ultralcd.h"
#include "language.h"
#include "led.h"
#include "speed_lookuptable.h"
@@ -38,6 +36,8 @@
//=============================public variables ============================
//===========================================================================
block_t *current_block; // A pointer to the block currently being traced
volatile bool endstop_z_hit=false;
bool old_z_min_endstop=false;
//===========================================================================
@@ -57,7 +57,6 @@ volatile static unsigned long step_events_completed; // The number of step event
static long old_advance = 0;
#endif
static long e_steps[3];
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
static unsigned short acc_step_rate; // needed for deccelaration start point
@@ -68,13 +67,11 @@ volatile long endstops_trigsteps[3]={0,0,0};
volatile long endstops_stepsTotal,endstops_stepsDone;
static volatile bool endstop_x_hit=false;
static volatile bool endstop_y_hit=false;
static volatile bool endstop_z_hit=false;
static bool old_x_min_endstop=false;
static bool old_x_max_endstop=false;
static bool old_y_min_endstop=false;
static bool old_y_max_endstop=false;
static bool old_z_min_endstop=false;
static bool old_z_max_endstop=false;
static bool check_endstops = true;
@@ -86,11 +83,7 @@ volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
//=============================functions ============================
//===========================================================================
#ifdef ENDSTOPS_ONLY_FOR_HOMING
#define CHECK_ENDSTOPS if(check_endstops)
#else
#define CHECK_ENDSTOPS
#endif
#define CHECK_ENDSTOPS if(check_endstops)
// intRes = intIn1 * intIn2 >> 16
// uses:
@@ -172,7 +165,7 @@ void checkHitEndstops()
{
if( endstop_x_hit || endstop_y_hit || endstop_z_hit) {
SERIAL_ECHO_START;
SERIAL_ECHOPGM("endstops hit: ");
SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
if(endstop_x_hit) {
SERIAL_ECHOPAIR(" X:",(float)endstops_trigsteps[X_AXIS]/axis_steps_per_unit[X_AXIS]);
}
@@ -219,7 +212,6 @@ void enable_endstops(bool check)
void st_wake_up() {
// TCNT1 = 0;
if(busy == false)
ENABLE_STEPPER_DRIVER_INTERRUPT();
}
@@ -239,8 +231,8 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
step_loops = 1;
}
if(step_rate < 32) step_rate = 32;
step_rate -= 32; // Correct for minimal speed
if(step_rate < (F_CPU/500000)) step_rate = (F_CPU/500000);
step_rate -= (F_CPU/500000); // Correct for minimal speed
if(step_rate >= (8*256)){ // higher step rate
unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
unsigned char tmp_step_rate = (step_rate & 0x00ff);
@@ -254,7 +246,7 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
timer = (unsigned short)pgm_read_word_near(table_address);
timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
}
if(timer < 100) { timer = 100; MYSERIAL.print("Steprate to high : "); MYSERIAL.println(step_rate); }//(20kHz this should never happen)
if(timer < 100) { timer = 100; MYSERIAL.print(MSG_STEPPER_TO_HIGH); MYSERIAL.println(step_rate); }//(20kHz this should never happen)
return timer;
}
@@ -298,12 +290,14 @@ ISR(TIMER1_COMPA_vect)
// Anything in the buffer?
current_block = plan_get_current_block();
if (current_block != NULL) {
current_block->busy = true;
trapezoid_generator_reset();
counter_x = -(current_block->step_event_count >> 1);
counter_y = counter_x;
counter_z = counter_x;
counter_e = counter_x;
step_events_completed = 0;
step_events_completed = 0;
#ifdef Z_LATE_ENABLE
if(current_block->steps_z > 0) {
enable_z();
@@ -432,7 +426,7 @@ ISR(TIMER1_COMPA_vect)
}
else { // +direction
NORM_E_DIR();
count_direction[E_AXIS]=-1;
count_direction[E_AXIS]=1;
}
#endif //!ADVANCE
@@ -716,23 +710,45 @@ void st_init()
//Initialize Step Pins
#if (X_STEP_PIN > -1)
SET_OUTPUT(X_STEP_PIN);
#if X_ENABLE_PIN > -1
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
#endif
#endif
#if (Y_STEP_PIN > -1)
SET_OUTPUT(Y_STEP_PIN);
#if Y_ENABLE_PIN > -1
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
#endif
#endif
#if (Z_STEP_PIN > -1)
SET_OUTPUT(Z_STEP_PIN);
#if Z_ENABLE_PIN > -1
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
#endif
#endif
#if (E0_STEP_PIN > -1)
SET_OUTPUT(E0_STEP_PIN);
#if E0_ENABLE_PIN > -1
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
#endif
#endif
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
SET_OUTPUT(E1_STEP_PIN);
#if E1_ENABLE_PIN > -1
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
#endif
#endif
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
SET_OUTPUT(E2_STEP_PIN);
#if E2_ENABLE_PIN > -1
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
#endif
#endif
#ifdef CONTROLLERFAN_PIN
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
#endif
// waveform generation = 0100 = CTC
TCCR1B &= ~(1<<WGM13);
TCCR1B |= (1<<WGM12);
@@ -742,7 +758,13 @@ void st_init()
// output mode = 00 (disconnected)
TCCR1A &= ~(3<<COM1A0);
TCCR1A &= ~(3<<COM1B0);
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10); // 2MHz timer
// Set the timer pre-scaler
// Generally we use a divider of 8, resulting in a 2MHz timer
// frequency on a 16MHz MCU. If you are going to change this, be
// sure to regenerate speed_lookuptable.h with
// create_speed_lookuptable.py
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10);
OCR1A = 0x4000;
TCNT1 = 0;
@@ -808,7 +830,7 @@ long st_get_position(uint8_t axis)
void finishAndDisableSteppers()
{
st_synchronize();
LCD_MESSAGEPGM("Released.");
LCD_MESSAGEPGM(MSG_STEPPER_RELEASED);
disable_x();
disable_y();
disable_z();
@@ -822,6 +844,7 @@ void quickStop()
DISABLE_STEPPER_DRIVER_INTERRUPT();
while(blocks_queued())
plan_discard_current_block();
current_block = NULL;
ENABLE_STEPPER_DRIVER_INTERRUPT();
}
+3
View File
@@ -66,6 +66,9 @@ void checkStepperErrors(); //Print errors detected by the stepper
void finishAndDisableSteppers();
extern block_t *current_block; // A pointer to the block currently being traced
extern volatile long endstops_trigsteps[];
extern volatile bool endstop_z_hit;
extern bool old_z_min_endstop;
void quickStop();
#endif
+193 -48
View File
@@ -52,6 +52,7 @@ int current_raw_bed = 0;
float Kp=DEFAULT_Kp;
float Ki=DEFAULT_Ki;
int Ki_Max=PID_INTEGRAL_DRIVE_MAX;
float Kd=DEFAULT_Kd;
#ifdef PID_ADD_EXTRUSION_RATE
float Kc=DEFAULT_Kc;
@@ -62,7 +63,7 @@ int current_raw_bed = 0;
//===========================================================================
//=============================private variables============================
//===========================================================================
static bool temp_meas_ready = false;
static volatile bool temp_meas_ready = false;
static unsigned long previous_millis_bed_heater;
//static unsigned long previous_millis_heater;
@@ -95,17 +96,6 @@ static unsigned long previous_millis_bed_heater;
static int maxttemp[EXTRUDERS] = { 16383 }; // the first value used for all
static int bed_minttemp = 0;
static int bed_maxttemp = 16383;
static int heater_pin_map[EXTRUDERS] = { HEATER_0_PIN
#if EXTRUDERS > 1
, HEATER_1_PIN
#endif
#if EXTRUDERS > 2
, HEATER_2_PIN
#endif
#if EXTRUDERS > 3
#error Unsupported number of extruders
#endif
};
static void *heater_ttbl_map[EXTRUDERS] = { (void *)heater_0_temptable
#if EXTRUDERS > 1
, (void *)heater_1_temptable
@@ -132,12 +122,129 @@ static unsigned long previous_millis_bed_heater;
//===========================================================================
//============================= functions ============================
//===========================================================================
void PID_autotune(float temp)
{
float input;
int cycles=0;
bool heating = true;
unsigned long temp_millis = millis();
unsigned long t1=temp_millis;
unsigned long t2=temp_millis;
long t_high;
long t_low;
long bias=PID_MAX/2;
long d = PID_MAX/2;
float Ku, Tu;
float Kp, Ki, Kd;
float max, min;
SERIAL_ECHOLN("PID Autotune start");
disable_heater(); // switch off all heaters.
soft_pwm[0] = PID_MAX/2;
for(;;) {
if(temp_meas_ready == true) { // temp sample ready
CRITICAL_SECTION_START;
temp_meas_ready = false;
CRITICAL_SECTION_END;
input = analog2temp(current_raw[0], 0);
max=max(max,input);
min=min(min,input);
if(heating == true && input > temp) {
if(millis() - t2 > 5000) {
heating=false;
soft_pwm[0] = (bias - d) >> 1;
t1=millis();
t_high=t1 - t2;
max=temp;
}
}
if(heating == false && input < temp) {
if(millis() - t1 > 5000) {
heating=true;
t2=millis();
t_low=t2 - t1;
if(cycles > 0) {
bias += (d*(t_high - t_low))/(t_low + t_high);
bias = constrain(bias, 20 ,PID_MAX-FULL_PID_BAND);
if(bias > PID_MAX/2) d = PID_MAX - 1 - bias;
else d = bias;
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
SERIAL_PROTOCOLPGM(" d: "); SERIAL_PROTOCOL(d);
SERIAL_PROTOCOLPGM(" min: "); SERIAL_PROTOCOL(min);
SERIAL_PROTOCOLPGM(" max: "); SERIAL_PROTOCOLLN(max);
if(cycles > 2) {
Ku = (4.0*d)/(3.14159*(max-min)/2.0);
Tu = ((float)(t_low + t_high)/1000.0);
SERIAL_PROTOCOLPGM(" Ku: "); SERIAL_PROTOCOL(Ku);
SERIAL_PROTOCOLPGM(" Tu: "); SERIAL_PROTOCOLLN(Tu);
Kp = 0.6*Ku;
Ki = 2*Kp/Tu;
Kd = Kp*Tu/8;
SERIAL_PROTOCOLLNPGM(" Clasic PID ")
SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
/*
Kp = 0.33*Ku;
Ki = Kp/Tu;
Kd = Kp*Tu/3;
SERIAL_PROTOCOLLNPGM(" Some overshoot ")
SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
Kp = 0.2*Ku;
Ki = 2*Kp/Tu;
Kd = Kp*Tu/3;
SERIAL_PROTOCOLLNPGM(" No overshoot ")
SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
*/
}
}
soft_pwm[0] = (bias + d) >> 1;
cycles++;
min=temp;
}
}
}
if(input > (temp + 20)) {
SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature to high");
return;
}
if(millis() - temp_millis > 2000) {
temp_millis = millis();
SERIAL_PROTOCOLPGM("ok T:");
SERIAL_PROTOCOL(degHotend(0));
SERIAL_PROTOCOLPGM(" @:");
SERIAL_PROTOCOLLN(getHeaterPower(0));
}
if(((millis() - t1) + (millis() - t2)) > (10L*60L*1000L*2L)) {
SERIAL_PROTOCOLLNPGM("PID Autotune failed! timeout");
return;
}
if(cycles > 5) {
SERIAL_PROTOCOLLNPGM("PID Autotune finished ! Place the Kp, Ki and Kd constants in the configuration.h");
return;
}
LCD_STATUS;
}
}
void updatePID()
{
#ifdef PIDTEMP
for(int e = 0; e < EXTRUDERS; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki;
temp_iState_max[e] = Ki_Max / Ki;
}
#endif
}
@@ -170,11 +277,11 @@ void manage_heater()
#ifndef PID_OPENLOOP
pid_error[e] = pid_setpoint[e] - pid_input;
if(pid_error[e] > 10) {
if(pid_error[e] > FULL_PID_BAND) {
pid_output = PID_MAX;
pid_reset[e] = true;
}
else if(pid_error[e] < -10) {
else if(pid_error[e] < -FULL_PID_BAND) {
pid_output = 0;
pid_reset[e] = true;
}
@@ -207,11 +314,9 @@ void manage_heater()
// Check if temperature is within the correct range
if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e]))
{
//analogWrite(heater_pin_map[e], pid_output);
soft_pwm[e] = (int)pid_output >> 1;
}
else {
//analogWrite(heater_pin_map[e], 0);
soft_pwm[e] = 0;
}
} // End extruder for loop
@@ -271,6 +376,30 @@ void manage_heater()
}
#define PGM_RD_W(x) (short)pgm_read_word(&x)
#ifdef COMPUTE_THERMISTORS
// Use algebra to work out temperatures, not tables
// NB - this assumes all extruders use the same thermistor type.
int temp2analogi(int celsius, const float& beta, const float& rs, const float& r_inf)
{
float r = r_inf*exp(beta/(celsius - ABS_ZERO));
return AD_RANGE - (int)(0.5 + AD_RANGE*r/(r + rs));
}
float analog2tempi(int raw, const float& beta, const float& rs, const float& r_inf)
{
float rawf = (float)(AD_RANGE - raw);
return ABS_ZERO + beta/log( (rawf*rs/(AD_RANGE - rawf))/r_inf );
}
int temp2analog(int celsius, uint8_t e) { return temp2analogi(celsius, E_BETA, E_RS, E_R_INF); }
int temp2analogBed(int celsius) { return temp2analogi(celsius, BED_BETA, BED_RS, BED_R_INF); }
float analog2temp(int raw, uint8_t e) { return analog2tempi(raw, E_BETA, E_RS, E_R_INF); }
float analog2tempBed(int raw) { return analog2tempi(raw, BED_BETA, BED_RS, BED_R_INF); }
#else
// Takes hot end temperature value as input and returns corresponding raw value.
// For a thermistor, it uses the RepRap thermistor temp table.
// This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
@@ -312,7 +441,7 @@ int temp2analog(int celsius, uint8_t e) {
return (1023 * OVERSAMPLENR) - raw;
}
return celsius * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
return ((celsius-TEMP_SENSOR_AD595_OFFSET)/TEMP_SENSOR_AD595_GAIN) * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
}
// Takes bed temperature value as input and returns corresponding raw value.
@@ -342,7 +471,7 @@ int temp2analogBed(int celsius) {
return (1023 * OVERSAMPLENR) - raw;
#elif defined BED_USES_AD595
return lround(celsius * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
return lround(((celsius-TEMP_SENSOR_AD595_OFFSET)/TEMP_SENSOR_AD595_GAIN) * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
#else
#warning No heater-type defined for the bed.
return 0;
@@ -390,14 +519,14 @@ float analog2temp(int raw, uint8_t e) {
return celsius;
}
return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
}
// Derived from RepRap FiveD extruder::getTemperature()
// For bed temperature measurement.
float analog2tempBed(int raw) {
#ifdef BED_USES_THERMISTOR
int celsius = 0;
float celsius = 0;
byte i;
raw = (1023 * OVERSAMPLENR) - raw;
@@ -408,9 +537,8 @@ float analog2tempBed(int raw) {
{
celsius = PGM_RD_W(bedtemptable[i-1][1]) +
(raw - PGM_RD_W(bedtemptable[i-1][0])) *
(PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
(PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
(float)(PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
(float)(PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
break;
}
}
@@ -419,15 +547,16 @@ float analog2tempBed(int raw) {
if (i == bedtemptable_len) celsius = PGM_RD_W(bedtemptable[i-1][1]);
return celsius;
#elif defined BED_USES_AD595
return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
#else
#warning No heater-type defined for the bed.
return 0;
#endif
return 0;
}
#endif
void tp_init()
{
// Finish init of mult extruder arrays
@@ -439,7 +568,7 @@ void tp_init()
maxttemp[e] = maxttemp[0];
#ifdef PIDTEMP
temp_iState_min[e] = 0.0;
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki;
temp_iState_max[e] = Ki_Max / Ki;
#endif //PIDTEMP
}
@@ -576,7 +705,7 @@ void disable_heater()
target_raw[0]=0;
soft_pwm[0]=0;
#if HEATER_0_PIN > -1
digitalWrite(HEATER_0_PIN,LOW);
WRITE(HEATER_0_PIN,LOW);
#endif
#endif
@@ -584,7 +713,7 @@ void disable_heater()
target_raw[1]=0;
soft_pwm[1]=0;
#if HEATER_1_PIN > -1
digitalWrite(HEATER_1_PIN,LOW);
WRITE(HEATER_1_PIN,LOW);
#endif
#endif
@@ -592,36 +721,44 @@ void disable_heater()
target_raw[2]=0;
soft_pwm[2]=0;
#if HEATER_2_PIN > -1
digitalWrite(HEATER_2_PIN,LOW);
WRITE(HEATER_2_PIN,LOW);
#endif
#endif
#if TEMP_BED_PIN > -1
target_raw_bed=0;
#if HEATER_BED_PIN > -1
digitalWrite(HEATER_BED_PIN,LOW);
WRITE(HEATER_BED_PIN,LOW);
#endif
#endif
}
void max_temp_error(uint8_t e) {
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN(e);
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
disable_heater();
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLN((int)e);
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
}
}
void min_temp_error(uint8_t e) {
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN(e);
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
disable_heater();
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLN((int)e);
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
}
}
void bed_max_temp_error(void) {
digitalWrite(HEATER_BED_PIN, 0);
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
#if HEATER_BED_PIN > -1
WRITE(HEATER_BED_PIN, 0);
#endif
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
}
}
#define HEAT_INTERVAL 250
@@ -813,14 +950,14 @@ ISR(TIMER0_COMPB_vect)
if(temp_count >= 16) // 8 ms * 16 = 128ms.
{
#ifdef HEATER_0_USES_AD595
#if defined(HEATER_0_USES_AD595) || defined(HEATER_0_USES_MAX6675)
current_raw[0] = raw_temp_0_value;
#else
current_raw[0] = 16383 - raw_temp_0_value;
#endif
#if EXTRUDERS > 1
#ifdef HEATER_1_USES_AD595 || defined HEATER_0_USES_MAX6675
#ifdef HEATER_1_USES_AD595
current_raw[1] = raw_temp_1_value;
#else
current_raw[1] = 16383 - raw_temp_1_value;
@@ -852,12 +989,20 @@ ISR(TIMER0_COMPB_vect)
if(current_raw[e] >= maxttemp[e]) {
target_raw[e] = 0;
max_temp_error(e);
kill();;
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
{
Stop();;
}
#endif
}
if(current_raw[e] <= minttemp[e]) {
target_raw[e] = 0;
min_temp_error(e);
kill();
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
{
Stop();
}
#endif
}
}
@@ -865,7 +1010,7 @@ ISR(TIMER0_COMPB_vect)
if(current_raw_bed >= bed_maxttemp) {
target_raw_bed = 0;
bed_max_temp_error();
kill();
Stop();
}
#endif
}
+10 -2
View File
@@ -47,6 +47,7 @@ extern int current_raw_bed;
extern int target_bed_high_temp ;
#endif
extern float Kp,Ki,Kd,Kc;
extern int Ki_Max;
#ifdef PIDTEMP
extern float pid_setpoint[EXTRUDERS];
@@ -129,6 +130,8 @@ FORCE_INLINE bool isCoolingBed() {
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
#define isHeatingHotend1() isHeatingHotend(1)
#define isCoolingHotend1() isCoolingHotend(1)
#else
#define setTargetHotend1(_celsius) do{}while(0)
#endif
#if EXTRUDERS > 2
#define degHotend2() degHotend(2)
@@ -136,6 +139,8 @@ FORCE_INLINE bool isCoolingBed() {
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
#define isHeatingHotend2() isHeatingHotend(2)
#define isCoolingHotend2() isCoolingHotend(2)
#else
#define setTargetHotend2(_celsius) do{}while(0)
#endif
#if EXTRUDERS > 3
#error Invalid number of extruders
@@ -153,10 +158,13 @@ FORCE_INLINE void autotempShutdown(){
if(autotemp_enabled)
{
autotemp_enabled=false;
if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
setTargetHotend(0,ACTIVE_EXTRUDER);
if(degTargetHotend(active_extruder)>autotemp_min)
setTargetHotend(0,active_extruder);
}
#endif
}
void PID_autotune(float temp);
#endif
+338 -85
View File
@@ -73,27 +73,41 @@ const short temptable_1[][2] PROGMEM = {
#endif
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor
const short temptable_2[][2] PROGMEM = {
//200k ATC Semitec 204GT-2
//Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
{1*OVERSAMPLENR, 848},
{54*OVERSAMPLENR, 275},
{107*OVERSAMPLENR, 228},
{160*OVERSAMPLENR, 202},
{213*OVERSAMPLENR, 185},
{266*OVERSAMPLENR, 171},
{319*OVERSAMPLENR, 160},
{372*OVERSAMPLENR, 150},
{425*OVERSAMPLENR, 141},
{478*OVERSAMPLENR, 133},
{531*OVERSAMPLENR, 125},
{584*OVERSAMPLENR, 118},
{637*OVERSAMPLENR, 110},
{690*OVERSAMPLENR, 103},
{743*OVERSAMPLENR, 95},
{796*OVERSAMPLENR, 86},
{849*OVERSAMPLENR, 77},
{902*OVERSAMPLENR, 65},
{955*OVERSAMPLENR, 49},
{1008*OVERSAMPLENR, 17},
{1020*OVERSAMPLENR, 0} //safety
{30*OVERSAMPLENR, 300}, //top rating 300C
{34*OVERSAMPLENR, 290},
{39*OVERSAMPLENR, 280},
{46*OVERSAMPLENR, 270},
{53*OVERSAMPLENR, 260},
{63*OVERSAMPLENR, 250},
{74*OVERSAMPLENR, 240},
{87*OVERSAMPLENR, 230},
{104*OVERSAMPLENR, 220},
{124*OVERSAMPLENR, 210},
{148*OVERSAMPLENR, 200},
{176*OVERSAMPLENR, 190},
{211*OVERSAMPLENR, 180},
{252*OVERSAMPLENR, 170},
{301*OVERSAMPLENR, 160},
{357*OVERSAMPLENR, 150},
{420*OVERSAMPLENR, 140},
{489*OVERSAMPLENR, 130},
{562*OVERSAMPLENR, 120},
{636*OVERSAMPLENR, 110},
{708*OVERSAMPLENR, 100},
{775*OVERSAMPLENR, 90},
{835*OVERSAMPLENR, 80},
{884*OVERSAMPLENR, 70},
{924*OVERSAMPLENR, 60},
{955*OVERSAMPLENR, 50},
{977*OVERSAMPLENR, 40},
{993*OVERSAMPLENR, 30},
{1004*OVERSAMPLENR, 20},
{1012*OVERSAMPLENR, 10},
{1016*OVERSAMPLENR, 0},
};
#endif
@@ -157,73 +171,48 @@ const short temptable_4[][2] PROGMEM = {
#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
const short temptable_5[][2] PROGMEM = {
{1*OVERSAMPLENR, 713},
{18*OVERSAMPLENR, 316},
{35*OVERSAMPLENR, 266},
{52*OVERSAMPLENR, 239},
{69*OVERSAMPLENR, 221},
{86*OVERSAMPLENR, 208},
{103*OVERSAMPLENR, 197},
{120*OVERSAMPLENR, 188},
{137*OVERSAMPLENR, 181},
{154*OVERSAMPLENR, 174},
{171*OVERSAMPLENR, 169},
{188*OVERSAMPLENR, 163},
{205*OVERSAMPLENR, 159},
{222*OVERSAMPLENR, 154},
{239*OVERSAMPLENR, 150},
{256*OVERSAMPLENR, 147},
{273*OVERSAMPLENR, 143},
{290*OVERSAMPLENR, 140},
{307*OVERSAMPLENR, 136},
{324*OVERSAMPLENR, 133},
{341*OVERSAMPLENR, 130},
{358*OVERSAMPLENR, 128},
{375*OVERSAMPLENR, 125},
{392*OVERSAMPLENR, 122},
{409*OVERSAMPLENR, 120},
{426*OVERSAMPLENR, 117},
{443*OVERSAMPLENR, 115},
{460*OVERSAMPLENR, 112},
{477*OVERSAMPLENR, 110},
{494*OVERSAMPLENR, 108},
{511*OVERSAMPLENR, 106},
{528*OVERSAMPLENR, 103},
{545*OVERSAMPLENR, 101},
{562*OVERSAMPLENR, 99},
{579*OVERSAMPLENR, 97},
{596*OVERSAMPLENR, 95},
{613*OVERSAMPLENR, 92},
{630*OVERSAMPLENR, 90},
{647*OVERSAMPLENR, 88},
{664*OVERSAMPLENR, 86},
{681*OVERSAMPLENR, 84},
{698*OVERSAMPLENR, 81},
{715*OVERSAMPLENR, 79},
{732*OVERSAMPLENR, 77},
{749*OVERSAMPLENR, 75},
{766*OVERSAMPLENR, 72},
{783*OVERSAMPLENR, 70},
{800*OVERSAMPLENR, 67},
{817*OVERSAMPLENR, 64},
{834*OVERSAMPLENR, 61},
{851*OVERSAMPLENR, 58},
{868*OVERSAMPLENR, 55},
{885*OVERSAMPLENR, 52},
{902*OVERSAMPLENR, 48},
{919*OVERSAMPLENR, 44},
{936*OVERSAMPLENR, 40},
{953*OVERSAMPLENR, 34},
{970*OVERSAMPLENR, 28},
{987*OVERSAMPLENR, 20},
{1004*OVERSAMPLENR, 8},
{1021*OVERSAMPLENR, 0}
// ATC Semitec 104GT-2 (Used in ParCan)
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
{1*OVERSAMPLENR, 713},
{17*OVERSAMPLENR, 300}, //top rating 300C
{20*OVERSAMPLENR, 290},
{23*OVERSAMPLENR, 280},
{27*OVERSAMPLENR, 270},
{31*OVERSAMPLENR, 260},
{37*OVERSAMPLENR, 250},
{43*OVERSAMPLENR, 240},
{51*OVERSAMPLENR, 230},
{61*OVERSAMPLENR, 220},
{73*OVERSAMPLENR, 210},
{87*OVERSAMPLENR, 200},
{106*OVERSAMPLENR, 190},
{128*OVERSAMPLENR, 180},
{155*OVERSAMPLENR, 170},
{189*OVERSAMPLENR, 160},
{230*OVERSAMPLENR, 150},
{278*OVERSAMPLENR, 140},
{336*OVERSAMPLENR, 130},
{402*OVERSAMPLENR, 120},
{476*OVERSAMPLENR, 110},
{554*OVERSAMPLENR, 100},
{635*OVERSAMPLENR, 90},
{713*OVERSAMPLENR, 80},
{784*OVERSAMPLENR, 70},
{846*OVERSAMPLENR, 60},
{897*OVERSAMPLENR, 50},
{937*OVERSAMPLENR, 40},
{966*OVERSAMPLENR, 30},
{986*OVERSAMPLENR, 20},
{1000*OVERSAMPLENR, 10},
{1010*OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
const short temptable_6[][2] PROGMEM = {
{28*OVERSAMPLENR, 250},
{1*OVERSAMPLENR, 350},
{28*OVERSAMPLENR, 250}, //top rating 250C
{31*OVERSAMPLENR, 245},
{35*OVERSAMPLENR, 240},
{39*OVERSAMPLENR, 235},
@@ -232,8 +221,8 @@ const short temptable_6[][2] PROGMEM = {
{49*OVERSAMPLENR, 220},
{53*OVERSAMPLENR, 215},
{62*OVERSAMPLENR, 210},
{73*OVERSAMPLENR, 205},
{72*OVERSAMPLENR, 200},
{71*OVERSAMPLENR, 205}, //fitted graphically
{78*OVERSAMPLENR, 200}, //fitted graphically
{94*OVERSAMPLENR, 190},
{102*OVERSAMPLENR, 185},
{116*OVERSAMPLENR, 170},
@@ -264,7 +253,8 @@ const short temptable_6[][2] PROGMEM = {
#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
const short temptable_7[][2] PROGMEM = {
{46*OVERSAMPLENR, 270},
{1*OVERSAMPLENR, 500},
{46*OVERSAMPLENR, 270}, //top rating 300C
{50*OVERSAMPLENR, 265},
{54*OVERSAMPLENR, 260},
{58*OVERSAMPLENR, 255},
@@ -320,6 +310,269 @@ const short temptable_7[][2] PROGMEM = {
{1005*OVERSAMPLENR, 5}
};
#endif
//
#if (THERMISTORHEATER_0 == 100) || (THERMISTORHEATER_1 == 100) || (THERMISTORHEATER_2 == 100) || (THERMISTORBED == 100) // 100k DO-35 NTC
const short temptable_100[][2] PROGMEM = {
{1*OVERSAMPLENR, 929},
{36*OVERSAMPLENR, 299},
{71*OVERSAMPLENR, 246},
{106*OVERSAMPLENR, 217},
{141*OVERSAMPLENR, 198},
{176*OVERSAMPLENR, 184},
{211*OVERSAMPLENR, 173},
{246*OVERSAMPLENR, 163},
{281*OVERSAMPLENR, 154},
{316*OVERSAMPLENR, 147},
{351*OVERSAMPLENR, 140},
{386*OVERSAMPLENR, 134},
{421*OVERSAMPLENR, 128},
{456*OVERSAMPLENR, 122},
{491*OVERSAMPLENR, 117},
{526*OVERSAMPLENR, 112},
{561*OVERSAMPLENR, 107},
{596*OVERSAMPLENR, 102},
{631*OVERSAMPLENR, 97},
{666*OVERSAMPLENR, 91},
{701*OVERSAMPLENR, 86},
{736*OVERSAMPLENR, 81},
{771*OVERSAMPLENR, 76},
{806*OVERSAMPLENR, 70},
{841*OVERSAMPLENR, 63},
{876*OVERSAMPLENR, 56},
{911*OVERSAMPLENR, 48},
{946*OVERSAMPLENR, 38},
{981*OVERSAMPLENR, 23},
{1005*OVERSAMPLENR, 5},
{1016*OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 101) || (THERMISTORHEATER_1 == 101) || (THERMISTORHEATER_2 == 101) || (THERMISTORBED == 101) // 100k Honeywell 135-104LAG-J01
const short temptable_101[][2] PROGMEM = {
{1*OVERSAMPLENR, 704},
{54*OVERSAMPLENR, 216},
{107*OVERSAMPLENR, 175},
{160*OVERSAMPLENR, 152},
{213*OVERSAMPLENR, 137},
{266*OVERSAMPLENR, 125},
{319*OVERSAMPLENR, 115},
{372*OVERSAMPLENR, 106},
{425*OVERSAMPLENR, 99},
{478*OVERSAMPLENR, 91},
{531*OVERSAMPLENR, 85},
{584*OVERSAMPLENR, 78},
{637*OVERSAMPLENR, 71},
{690*OVERSAMPLENR, 65},
{743*OVERSAMPLENR, 58},
{796*OVERSAMPLENR, 50},
{849*OVERSAMPLENR, 42},
{902*OVERSAMPLENR, 31},
{955*OVERSAMPLENR, 17},
{1008*OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 102) || (THERMISTORHEATER_1 == 102) || (THERMISTORHEATER_2 == 102) || (THERMISTORBED == 102) // EPCOS G57540
const short temptable_102[][2] PROGMEM = {
{15*OVERSAMPLENR,286},
{16*OVERSAMPLENR,282},
{17*OVERSAMPLENR,278},
{18*OVERSAMPLENR,274},
{19*OVERSAMPLENR,270},
{20*OVERSAMPLENR,266},
{21*OVERSAMPLENR,262},
{22*OVERSAMPLENR,258},
{23*OVERSAMPLENR,254},
{25*OVERSAMPLENR,250},
{27*OVERSAMPLENR,246},
{28*OVERSAMPLENR,242},
{31*OVERSAMPLENR,238},
{33*OVERSAMPLENR,234},
{35*OVERSAMPLENR,230},
{38*OVERSAMPLENR,226},
{41*OVERSAMPLENR,222},
{44*OVERSAMPLENR,218},
{48*OVERSAMPLENR,214},
{52*OVERSAMPLENR,210},
{56*OVERSAMPLENR,206},
{61*OVERSAMPLENR,202},
{66*OVERSAMPLENR,198},
{71*OVERSAMPLENR,194},
{78*OVERSAMPLENR,190},
{84*OVERSAMPLENR,186},
{92*OVERSAMPLENR,182},
{100*OVERSAMPLENR,178},
{109*OVERSAMPLENR,174},
{120*OVERSAMPLENR,170},
{131*OVERSAMPLENR,166},
{143*OVERSAMPLENR,162},
{156*OVERSAMPLENR,158},
{171*OVERSAMPLENR,154},
{187*OVERSAMPLENR,150},
{205*OVERSAMPLENR,146},
{224*OVERSAMPLENR,142},
{224*OVERSAMPLENR,160},
{245*OVERSAMPLENR,155},
{268*OVERSAMPLENR,150},
{293*OVERSAMPLENR,145},
{320*OVERSAMPLENR,140},
{348*OVERSAMPLENR,135},
{379*OVERSAMPLENR,130},
{411*OVERSAMPLENR,125},
{480*OVERSAMPLENR,115},
{553*OVERSAMPLENR,105},
{628*OVERSAMPLENR,95},
{702*OVERSAMPLENR,85},
{770*OVERSAMPLENR,75},
{830*OVERSAMPLENR,65},
{881*OVERSAMPLENR,55},
{922*OVERSAMPLENR,45},
{954*OVERSAMPLENR,35},
{977*OVERSAMPLENR,25},
{993*OVERSAMPLENR,15},
{999*OVERSAMPLENR,10},
{1008*OVERSAMPLENR,0},
};
#endif
#if (THERMISTORHEATER_0 == 103) || (THERMISTORHEATER_1 == 103) || (THERMISTORHEATER_2 == 103) || (THERMISTORBED == 103) // EPCOS G57540
const short temptable_103[][2] PROGMEM = {
{1*OVERSAMPLENR, 628},
{187*OVERSAMPLENR, 156},
{218*OVERSAMPLENR, 148},
{249*OVERSAMPLENR, 141},
{280*OVERSAMPLENR, 135},
{311*OVERSAMPLENR, 129},
{342*OVERSAMPLENR, 124},
{373*OVERSAMPLENR, 120},
{404*OVERSAMPLENR, 115},
{435*OVERSAMPLENR, 111},
{466*OVERSAMPLENR, 107},
{497*OVERSAMPLENR, 103},
{528*OVERSAMPLENR, 99},
{559*OVERSAMPLENR, 96},
{590*OVERSAMPLENR, 92},
{621*OVERSAMPLENR, 88},
{652*OVERSAMPLENR, 84},
{683*OVERSAMPLENR, 81},
{714*OVERSAMPLENR, 77},
{745*OVERSAMPLENR, 73},
{776*OVERSAMPLENR, 68},
{807*OVERSAMPLENR, 64},
{838*OVERSAMPLENR, 59},
{869*OVERSAMPLENR, 54},
{900*OVERSAMPLENR, 48},
{931*OVERSAMPLENR, 40},
{962*OVERSAMPLENR, 31},
{993*OVERSAMPLENR, 17},
{1008*OVERSAMPLENR,0}
};
#endif
#if (THERMISTORHEATER_0 == 104) || (THERMISTORHEATER_1 == 104) || (THERMISTORHEATER_2 == 104) || (THERMISTORBED == 104) // EPCOS G57540G103F - r2=4k7
const short temptable_104[][2] PROGMEM = {
{1*OVERSAMPLENR, 599},
{54*OVERSAMPLENR, 160},
{107*OVERSAMPLENR, 123},
{160*OVERSAMPLENR, 103},
{213*OVERSAMPLENR, 90},
{266*OVERSAMPLENR, 79},
{319*OVERSAMPLENR, 70},
{372*OVERSAMPLENR, 62},
{425*OVERSAMPLENR, 55},
{478*OVERSAMPLENR, 49},
{531*OVERSAMPLENR, 43},
{584*OVERSAMPLENR, 37},
{637*OVERSAMPLENR, 31},
{690*OVERSAMPLENR, 25},
{743*OVERSAMPLENR, 19},
{796*OVERSAMPLENR, 12},
{849*OVERSAMPLENR, 5},
{902*OVERSAMPLENR, -3},
{955*OVERSAMPLENR, -16},
{1008*OVERSAMPLENR, -42}
};
#endif
#if (THERMISTORHEATER_0 == 105) || (THERMISTORHEATER_1 == 105) || (THERMISTORHEATER_2 == 105) || (THERMISTORBED == 105) // EPCOS G57540G103F - r2=10k
const short temptable_105[][2] PROGMEM = {
{1*OVERSAMPLENR, 460},
{54*OVERSAMPLENR, 123},
{107*OVERSAMPLENR, 92},
{160*OVERSAMPLENR, 75},
{213*OVERSAMPLENR, 63},
{266*OVERSAMPLENR, 54},
{319*OVERSAMPLENR, 46},
{372*OVERSAMPLENR, 40},
{425*OVERSAMPLENR, 34},
{478*OVERSAMPLENR, 28},
{531*OVERSAMPLENR, 23},
{584*OVERSAMPLENR, 17},
{637*OVERSAMPLENR, 12},
{690*OVERSAMPLENR, 7},
{743*OVERSAMPLENR, 2},
{796*OVERSAMPLENR, -3},
{849*OVERSAMPLENR, -10},
{902*OVERSAMPLENR, -18},
{955*OVERSAMPLENR, -29},
{1008*OVERSAMPLENR, -53}
};
#endif
#if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // RS thermistor 198-961
const short temptable_110[][2] PROGMEM = {
{1*OVERSAMPLENR, 704},
{15*OVERSAMPLENR, 280},
{21*OVERSAMPLENR, 266},
{41*OVERSAMPLENR, 234},
{61*OVERSAMPLENR, 208},
{81*OVERSAMPLENR, 191},
{101*OVERSAMPLENR, 178},
{121*OVERSAMPLENR, 168},
{141*OVERSAMPLENR, 159},
{161*OVERSAMPLENR, 152},
{181*OVERSAMPLENR, 146},
{221*OVERSAMPLENR, 135},
{261*OVERSAMPLENR, 126},
{301*OVERSAMPLENR, 118},
{341*OVERSAMPLENR, 111},
{381*OVERSAMPLENR, 105},
{421*OVERSAMPLENR, 99},
{461*OVERSAMPLENR, 94},
{501*OVERSAMPLENR, 88},
{541*OVERSAMPLENR, 83},
{581*OVERSAMPLENR, 78},
{621*OVERSAMPLENR, 73},
{661*OVERSAMPLENR, 68},
{741*OVERSAMPLENR, 58},
{781*OVERSAMPLENR, 52},
{821*OVERSAMPLENR, 46},
{861*OVERSAMPLENR, 40},
{901*OVERSAMPLENR, 32},
{981*OVERSAMPLENR, 7},
{1008*OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 111) || (THERMISTORHEATER_1 == 111) || (THERMISTORHEATER_2 == 111) || (THERMISTORBED == 111) //100k EPCOS
const short temptable_111[][2] PROGMEM = {
{1*OVERSAMPLENR, 704},
{54*OVERSAMPLENR, 216},
{107*OVERSAMPLENR, 175},
{160*OVERSAMPLENR, 152},
{213*OVERSAMPLENR, 137},
{266*OVERSAMPLENR, 125},
{319*OVERSAMPLENR, 115},
{372*OVERSAMPLENR, 106},
{425*OVERSAMPLENR, 99},
{478*OVERSAMPLENR, 91},
{531*OVERSAMPLENR, 85},
{584*OVERSAMPLENR, 78},
{637*OVERSAMPLENR, 71},
{690*OVERSAMPLENR, 65},
{743*OVERSAMPLENR, 58},
{796*OVERSAMPLENR, 50},
{849*OVERSAMPLENR, 42},
{902*OVERSAMPLENR, 31},
{955*OVERSAMPLENR, 17},
{1008*OVERSAMPLENR, 0}
};
#endif
#define _TT_NAME(_N) temptable_ ## _N
#define TT_NAME(_N) _TT_NAME(_N)
+24 -22
View File
@@ -1,5 +1,5 @@
#ifndef __ULTRALCDH
#define __ULTRALCDH
#ifndef ULTRALCD_H
#define ULTRALCD_H
#include "Marlin.h"
#ifdef ULTRA_LCD
#include <LiquidCrystal.h>
@@ -7,28 +7,29 @@
void lcd_init();
void lcd_status(const char* message);
void beep();
void buttons_init();
void buttons_check();
#define LCD_UPDATE_INTERVAL 100
#define STATUSTIMEOUT 15000
extern LiquidCrystal lcd;
extern volatile char buttons; //the last checked buttons in a bit array.
#ifdef NEWPANEL
#define EN_C (1<<BLEN_C)
#define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A)
#define CLICKED (buttons&EN_C)
#define BLOCK {blocking=millis()+blocktime;}
#define CARDINSERTED (READ(SDCARDDETECT)==0)
#if (SDCARDDETECT > -1)
#ifdef SDCARDDETECTINVERTED
#define CARDINSERTED (READ(SDCARDDETECT)!=0)
#else
#define CARDINSERTED (READ(SDCARDDETECT)==0)
#endif
#endif //SDCARDTETECTINVERTED
#else
//atomatic, do not change
@@ -50,7 +51,7 @@
#define blocktime 500
#define lcdslow 5
enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl};
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl};
class MainMenu{
public:
@@ -67,9 +68,11 @@
void showControl();
void showControlMotion();
void showControlTemp();
void showControlRetract();
void showAxisMove();
void showSD();
bool force_lcd_update;
int lastencoderpos;
long lastencoderpos;
int8_t lineoffset;
int8_t lastlineoffset;
@@ -78,11 +81,11 @@
bool tune;
private:
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
{
if(linechanging) return; // an item is changint its value, do not switch lines hence
lastlineoffset=lineoffset;
int curencoderpos=encoderpos;
long curencoderpos=encoderpos;
force_lcd_update=false;
if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
{
@@ -129,23 +132,23 @@
//conversion routines, could need some overworking
char *ftostr51(const float &x);
char *ftostr52(const float &x);
char *ftostr31(const float &x);
char *ftostr3(const float &x);
#define LCD_INIT lcd_init();
#define LCD_MESSAGE(x) lcd_status(x);
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
#define LCD_STATUS lcd_status()
#else //no lcd
#define LCD_INIT
#define LCD_STATUS
#define LCD_MESSAGE(x)
#define LCD_MESSAGEPGM(x)
FORCE_INLINE void lcd_status() {};
#endif
#ifndef ULTIPANEL
#define CLICKED false
#define CLICKED false
#define BLOCK ;
#endif
@@ -160,4 +163,3 @@ char *itostr3(const int &xx);
char *itostr4(const int &xx);
char *ftostr51(const float &x);
#endif //ULTRALCD
+873 -162
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef __WATCHDOGH
#define __WATCHDOGH
#ifndef WATCHDOG_H
#define WATCHDOG_H
#include "Marlin.h"
#ifdef USE_WATCHDOG
+173
View File
@@ -0,0 +1,173 @@
#include "z_probe.h"
#if defined(PROBE_PIN) && (PROBE_PIN > -1)
#include "Marlin.h"
#include "stepper.h"
#include "temperature.h"
float Probe_Bed(float x_pos, float y_pos, int n)
{
//returns Probed Z average height
float ProbeDepth[n];
float ProbeDepthAvg=0;
//force bed heater off for probing
int save_bed_targ = target_raw_bed;
target_raw_bed = 0;
WRITE(HEATER_BED_PIN,LOW);
if (Z_HOME_DIR==-1)
{
//int probe_flag =1;
float meas = 0;
int fails = 0;
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
feedmultiply = 100;
//previous_millis_cmd = millis();
//Move to probe position
if (x_pos >= 0) destination[X_AXIS]=x_pos;
if (y_pos >= 0) destination[Y_AXIS]=y_pos;
//destination[Z_AXIS]=current_position[Z_AXIS];
destination[Z_AXIS]=Z_HOME_RETRACT_MM;
feedrate = 9000;
prepare_move();
enable_endstops(true);
SERIAL_ECHO("PRE-PROBE current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]);
SERIAL_ECHOLN("Ready to probe...");
//Probe bed n times
//*******************************************************************************************Bed Loop*************************************
for(int8_t i=0; i < n ; i++)
{
//int z = 0;
//fast probe
//plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[Z_AXIS] = 1.1 * Z_MAX_LENGTH * Z_HOME_DIR;
feedrate = homing_feedrate[Z_AXIS];
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize();
//feedrate = 0.0;
SERIAL_ECHO("current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]);
if(endstop_z_hit == true)
{
SERIAL_ECHO("endstops_trigsteps[Z_AXIS]=");SERIAL_ECHOLN(endstops_trigsteps[Z_AXIS]);
ProbeDepth[i]= endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS];
meas = ProbeDepth[i];
SERIAL_ECHO("ProbeDepth[");SERIAL_ECHO(i);SERIAL_ECHO("]=");SERIAL_ECHOLN(ProbeDepth[i]);
//*************************************************************************************************************
if (i > 0 ) //Second probe has happened so compare results
{
if (abs(ProbeDepth[i] - ProbeDepth[i - 1]) > .05)
{ //keep going until readings match to avoid sticky bed
SERIAL_ECHO("Probing again: ");
SERIAL_ECHO(ProbeDepth[i]); SERIAL_ECHO(" - "); SERIAL_ECHO(ProbeDepth[i - 1]);SERIAL_ECHO(" = "); SERIAL_ECHOLN(abs(ProbeDepth[i] - ProbeDepth[i - 1]));
meas = ProbeDepth[i];
i--; i--; //Throw out both that don't match because we don't know which one is accurate
if(fails++ > 4) break;
}
}
}else{
SERIAL_ECHOLN("Probe not triggered.");
i=n-1;
}
//**************************************************************************************************************************************************
//fast move clear
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], meas, current_position[E_AXIS]);
destination[Z_AXIS] = Z_HOME_RETRACT_MM;
feedrate = fast_home_feedrate[Z_AXIS];
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize();
//check z stop isn't still triggered
if ( READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING )
{
SERIAL_ECHOLN("Poking Stuck Bed:");
destination[Z_AXIS] = -1; prepare_move();
destination[Z_AXIS] = Z_HOME_RETRACT_MM; prepare_move();
st_synchronize();
i--; //Throw out this meaningless measurement
}
feedrate = 0;
} //end probe loop
#ifdef ENDSTOPS_ONLY_FOR_HOMING
enable_endstops(false);
#endif
feedrate = saved_feedrate;
feedmultiply = saved_feedmultiply;
//previous_millis_cmd = millis();
endstops_hit_on_purpose();
}
for(int8_t i=0;i<n;i++)
{
ProbeDepthAvg += ProbeDepth[i];
}
ProbeDepthAvg /= n;
SERIAL_ECHO("Probed Z="); SERIAL_ECHOLN(ProbeDepthAvg);
SERIAL_ECHO("RAW current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]);
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], Z_HOME_RETRACT_MM, current_position[E_AXIS]);
current_position[Z_AXIS] = Z_HOME_RETRACT_MM;
target_raw_bed = save_bed_targ;
return ProbeDepthAvg;
}
void probe_init()
{
SET_INPUT(PROBE_PIN);
WRITE(PROBE_PIN,HIGH);
}
/*Crash1 - G29 to Probe and stop on Bed
G29 will probe bed at least twice at 3 points and take an average. G30 will probe bed at it's current location.
Z stop should be set slightly below bed height. Solder stub wire to each hole in huxley bed and attach a ring terminal under spring.
Wire bed probe to A2 on Melzi and duplicate cap/resistor circuit in schematic.
Use something like this in the start.gcode file:
G29 ;Probe bed for Z height
G92 Z0 ;Set Z to Probed Depth
G1 Z5 F200 ;Lift Z out of way
*/
void probe_3points()
{
float Probe_Avg, Point1, Point2, Point3;
Point1 = Probe_Bed(15,15,PROBE_N);
Point2 = Probe_Bed(X_MAX_LENGTH - 20,15,PROBE_N) ;
Point3 = Probe_Bed(X_MAX_LENGTH/2,Y_MAX_LENGTH - 5,PROBE_N);
Probe_Avg = (Point1 + Point2 + Point3) / 3;
//destination[2] = Probe_Avg;
//feedrate = homing_feedrate[Z_AXIS];
//prepare_move();
SERIAL_ECHOLN("**************************************");
SERIAL_ECHO("Point1 ="); SERIAL_ECHOLN(Point1);
SERIAL_ECHO("Point2 ="); SERIAL_ECHOLN(Point2);
SERIAL_ECHO("Point3 ="); SERIAL_ECHOLN(Point3);
SERIAL_ECHO("Probed Average="); SERIAL_ECHOLN(Probe_Avg);
SERIAL_ECHOLN("**************************************");
}
void probe_1point()
{
float Point;
Point = Probe_Bed(-1,-1,PROBE_N);
//destination[2] = Point +1;
//feedrate = homing_feedrate[Z_AXIS];
//prepare_move();
SERIAL_ECHOLN("**************************************");
SERIAL_ECHO("Probed Z="); SERIAL_ECHOLN(Point);
}
void probe_status()
{
SERIAL_ECHO("Probe Status = "); SERIAL_ECHOLN(READ(PROBE_PIN));
}
#endif //defined(PROBE_PIN) > -1
+21
View File
@@ -0,0 +1,21 @@
#ifndef __Z_PROBEH
#define __Z_PROBEH
#include "Marlin.h"
#if defined(PROBE_PIN) && (PROBE_PIN > -1)
void probe_init();
void probe_3points();
void probe_1point();
void probe_status();
float Probe_Bed(float x_pos, float y_pos,int n);
#else //no probe pin
FORCE_INLINE void probe_init() {};
FORCE_INLINE void probe_3points() {};
FORCE_INLINE void probe_1point() {};
FORCE_INLINE void probe_status() {};
FORCE_INLINE float Probe_Bed(float x_pos, float y_pos,int n) {return 0;}
#endif //PROBE_PIN
#endif
+90
View File
@@ -1,3 +1,92 @@
<<<<<<< HEAD
A new beta version is avaiable.
Look under the Marlin_v1 branch. We also made a tag that you can download.
This firmware is a mashup between Sprinter, grbl and many original parts.
(https://github.com/kliment/Sprinter)
(https://github.com/simen/grbl/tree)
Features:
- Interrupt based movement with real linear acceleration
- High steprate
- Look ahead (Keep the speed high when possible. High cornering speed)
- Interrupt based temperature protection
- preliminary support for Matthew Roberts advance algorithm
For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
This firmware is optimized for gen6 electronics.
The default baudrate is 250000.
This gives less communication errors then regular baudrates.
========================================================================================
Configuring and compilation
Install the arduino software version 0018
http://www.arduino.cc/en/Main/Software
Install the sanguino software, version 0018
http://sanguino.cc/useit
Install pronterface
https://github.com/kliment/Printrun
Copy the Marlin firmware
https:/github.com/ErikZalm/Marlin
(Use the download button)
Start the arduino IDE.
Select Tools -> Board -> Sanguino
Select the correct serial port in Tools ->Serial Port
Open Marlin.pde
Change the printer specific setting in Configuration.h to the correct values.
The following values are the most important:
- float axis_steps_per_unit[].... // Set the correct steps / mm in the corresponding field
- const bool ENDSTOPS_INVERTING = false; // Change if only positive moves are executed
- #define INVERT_x_DIR true // Change if the motor direction is wrong
Click the Upload button
If all goes well the firmware is uploading
Start pronterface
Select the correct Serial Port. Type 250000 in the baudrate field.
Press the Connect button
===============================================================================================
Known issues
On some systems we get compilation errors.
This is caused by the "wiring_serial.c" and "wiring.c".
The simple fix is to delete these files but this may have a performance impact.
The best workaround is to move these files to sanguino directory.
(".../arduino-0018/hardware/Sanguino/cores/arduino/" on windows systems)
=======
This RepRap firmware is a mashup between Sprinter, grbl and many original parts.
(https://github.com/kliment/Sprinter)
(https://github.com/simen/grbl/tree)
@@ -62,3 +151,4 @@ KNOWN ISSUES: RepG will display: Unknown: marlin x.y.z
That's ok. Enjoy Silky Smooth Printing.
>>>>>>> Mendel
+154
View File
@@ -0,0 +1,154 @@
<<<<<<< HEAD
A new beta version is avaiable.
Look under the Marlin_v1 branch. We also made a tag that you can download.
This firmware is a mashup between Sprinter, grbl and many original parts.
(https://github.com/kliment/Sprinter)
(https://github.com/simen/grbl/tree)
Features:
- Interrupt based movement with real linear acceleration
- High steprate
- Look ahead (Keep the speed high when possible. High cornering speed)
- Interrupt based temperature protection
- preliminary support for Matthew Roberts advance algorithm
For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
This firmware is optimized for gen6 electronics.
The default baudrate is 250000.
This gives less communication errors then regular baudrates.
========================================================================================
Configuring and compilation
Install the arduino software version 0018
http://www.arduino.cc/en/Main/Software
Install the sanguino software, version 0018
http://sanguino.cc/useit
Install pronterface
https://github.com/kliment/Printrun
Copy the Marlin firmware
https:/github.com/ErikZalm/Marlin
(Use the download button)
Start the arduino IDE.
Select Tools -> Board -> Sanguino
Select the correct serial port in Tools ->Serial Port
Open Marlin.pde
Change the printer specific setting in Configuration.h to the correct values.
The following values are the most important:
- float axis_steps_per_unit[].... // Set the correct steps / mm in the corresponding field
- const bool ENDSTOPS_INVERTING = false; // Change if only positive moves are executed
- #define INVERT_x_DIR true // Change if the motor direction is wrong
Click the Upload button
If all goes well the firmware is uploading
Start pronterface
Select the correct Serial Port. Type 250000 in the baudrate field.
Press the Connect button
===============================================================================================
Known issues
On some systems we get compilation errors.
This is caused by the "wiring_serial.c" and "wiring.c".
The simple fix is to delete these files but this may have a performance impact.
The best workaround is to move these files to sanguino directory.
(".../arduino-0018/hardware/Sanguino/cores/arduino/" on windows systems)
=======
This RepRap firmware is a mashup between Sprinter, grbl and many original parts.
(https://github.com/kliment/Sprinter)
(https://github.com/simen/grbl/tree)
Derived from Sprinter and Grbl by Erik van der Zalm.
Sprinters lead developers are Kliment and caru.
Grbls lead developer is Simen Svale Skogsrud.
It has been adapted to the Ultimaker Printer by:
Bernhard Kubicek, Matthijs Keuper, Bradley Feldman, and others...
Features:
- Interrupt based movement with real linear acceleration
- High steprate
- Look ahead (Keep the speed high when possible. High cornering speed)
- Interrupt based temperature protection
- preliminary support for Matthew Roberts advance algorithm
For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
- Full endstop support
- Simple LCD support (16x2)
- SD Card support
- Provisions for Bernhard Kubicek's new hardware control console and 20x4 lcd
This firmware is optimized for Ultimaker's gen6 electronics (including the Ultimaker 1.5.x daughterboard and Arduino Mega 2560).
The default baudrate is 115200.
========================================================================================
Configuring and compilation
Install the latest arduino software IDE/toolset (currently 0022)
http://www.arduino.cc/en/Main/Software
Install Ultimaker's RepG 25 build
http://software.ultimaker.com
(or alternatively install Kliment's printrun/pronterface https://github.com/kliment/Printrun_)
Copy the Ultimaker Marlin firmware
https:/github.com/bkubicek/Marlin
(Use the download button)
Start the arduino IDE.
Select Tools -> Board -> Arduino Mega 2560
Select the correct serial port in Tools ->Serial Port
Open Marlin.pde
Click the Verify/Compile button
Click the Upload button
If all goes well the firmware is uploading
Start Ultimaker's Custom RepG 25
Make sure Show Experimental Profiles is enabled in Preferences
Select Sprinter as the Driver
Press the Connect button.
KNOWN ISSUES: RepG will display: Unknown: marlin x.y.z
That's ok. Enjoy Silky Smooth Printing.
>>>>>>> Mendel