diff --git a/Documentation/BedLeveling.md b/Documentation/BedLeveling.md deleted file mode 100644 index 35a38bb3a0..0000000000 --- a/Documentation/BedLeveling.md +++ /dev/null @@ -1,105 +0,0 @@ -=============================================== -Instructions for configuring Bed Auto Leveling -=============================================== -There are two options for this feature. You may choose to use a servo mounted on the X carriage or you may use a sled that mounts on the X axis and can be docked when not in use. -See the section for each option below for specifics about installation and configuration. Also included are instructions that apply to both options. - -Instructions for Both Options ------------------------------ - -Uncomment the "ENABLE_AUTO_BED_LEVELING" define (commented by default) - -The following options define the probing positions. These are good starting values. -I recommend to keep a better clearance from borders in the first run and then make the probes as close as possible to borders: - -* \#define LEFT_PROBE_BED_POSITION 30 -* \#define RIGHT_PROBE_BED_POSITION 140 -* \#define BACK_PROBE_BED_POSITION 140 -* \#define FRONT_PROBE_BED_POSITION 30 - -A few more options: - -* \#define XY_TRAVEL_SPEED 6000 - -X and Y axis travel speed between probes, in mm/min. -Bear in mind that really fast moves may render step skipping. 6000 mm/min (100mm/s) is a good value. - -* \#define Z_RAISE_BEFORE_PROBING 10 -* \#define Z_RAISE_BETWEEN_PROBINGS 10 - -The Z axis is lifted when traveling to the first probe point by Z_RAISE_BEFORE_PROBING value -and then lifted when traveling from first to second and second to third point by Z_RAISE_BETWEEN_PROBINGS. -All values are in mm as usual. - -Servo Option Notes ------------------- -You will probably need a swivel Z-MIN endstop in the extruder. A rc servo do a great job. -Check the system working here: http://www.youtube.com/watch?v=3IKMeOYz-1Q (Enable English subtitles) -Teasing ;-) video: http://www.youtube.com/watch?v=x8eqSQNAyro - -In order to get the servo working, you need to enable: - -* \#define NUM_SERVOS 1 // Servo index starts with 0 for M280 command - -* \#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 - -* \#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 165,60} // X,Y,Z Axis Extend and Retract angles - -The first define tells firmware how many servos you have. -The second tells what axis this servo will be attached to. In the example above, we have a servo in Z axis. -The third one tells the angle in 2 situations: Probing (165º) and resting (60º). Check this with command M280 P0 S{angle} (example: M280 P0 S60 moves the servo to 60º) - -Next you need to define the Z endstop (probe) offset from hotend. -My preferred method: - -* a) Make a small mark in the bed with a marker/felt-tip pen. -* b) Place the hotend tip as *exactly* as possible on the mark, touching the bed. Raise the hotend 0.1mm (a regular paper thickness) and zero all axis (G92 X0 Y0 Z0); -* d) Raise the hotend 10mm (or more) for probe clearance, lower the Z probe (Z-Endstop) with M401 and place it just on that mark by moving X, Y and Z; -* e) Lower the Z in 0.1mm steps, with the probe always touching the mark (it may be necessary to adjust X and Y as well) until you hear the "click" meaning the mechanical endstop was trigged. You can confirm with M119; -* f) Now you have the probe in the same place as your hotend tip was before. Perform a M114 and write down the values, for example: X:24.3 Y:-31.4 Z:5.1; -* g) You can raise the z probe with M402 command; -* h) Fill the defines bellow multiplying the values by "-1" (just change the signal) - -* X and Y-Offset must be Integers! -* \#define X_PROBE_OFFSET_FROM_EXTRUDER -24 -* \#define Y_PROBE_OFFSET_FROM_EXTRUDER 31 -* \#define Z_PROBE_OFFSET_FROM_EXTRUDER -5.1 - -Sled Option Notes ------------------ -The sled option uses an electromagnet to attach and detach to/from the X carriage. See http://www.thingiverse.com/thing:396692 for more details on how to print and install this feature. It uses the same connections as the servo option. - -To use the sled option, you must define two additional things in Configuration.h: - -* \#define Z_PROBE_SLED -* \#define SLED_DOCKING_OFFSET 5 - -Uncomment the Z_PROBE_SLED to define to enable the sled (commented out by default). - -Uncomment the SLED_DOCKING_OFFSET to set the extra distance the X axis must travel to dock the sled. This value can be found by moving the X axis to its maximum position then measure the distance to the right X end and subtract the width of the sled (23mm if you printed the sled from Thingiverse). - -Next you need to define the Z endstop (probe) offset from hotend. -My preferred method: - -* a) Home the X and Y axes. -* b) Move the X axis to about the center of the print bed. Make a mark on the print bed. -* c) Move the Y axis to the maximum position. Make another mark. -* d) Home the X axis and use a straight edge to make a line between the two points. -* e) Repeat (b)-(d) reversing the X and Y. When you are done you will have two lines on the print bed. We will use these to measure the offset for the Z probe endstop. -* f) Move the nozzle so that it is positioned on the center point of the two lines. You can use fine movement of 0.1mm to get it as close as possible. Note the position of X and Y. -* g) Zero the Z axis with the G92 Z0 command. -* h) Raise the Z axis about 20mmm. -* i) Use the G32 command to retrieve the sled. -* j) Now more the X and Y axis to the position recorded in (f). -* k) Lower the Z axis in 0.1mm steps until you hear the "click" meaning the mechanical endstop was trigged. You can confirm with the M119 command. Note the position of the Z axis. -* l) Make a mark on the print bed where the endstop lever has touched the print bed. Raise the Z-axis about 30mm to give yourself some room. -* m) Now measure the distance from the center point to the endstop impact site along the X and Y axis using the lines drawn previously. -* n) Fill in the values below. If the endstop mark is in front of the line running left-to-right, use positive values. If it is behind, use negative values. For the Z axis use the value from (k) and subtract 0.1mm. - -For example, suppose you measured the endstop position and it was 20mm to the right of the line running front-to-back, 10mm toward the front of the line running left-to-right, and the value from (k) was 2.85. The values for the defines would be: - -* \#define X_PROBE_OFFSET_FROM_EXTRUDER 20 -* \#define Y_PROBE_OFFSET_FROM_EXTRUDER 10 -* \#define Z_PROBE_OFFSET_FROM_EXTRUDER 2.75 - -That's it.. enjoy never having to calibrate your Z endstop neither leveling your bed by hand anymore ;-) diff --git a/Documentation/Compilation.md b/Documentation/Compilation.md deleted file mode 100644 index 93c23a627d..0000000000 --- a/Documentation/Compilation.md +++ /dev/null @@ -1,16 +0,0 @@ -# Configuring and compilation - - 1. Install the latest non-beta arduino software IDE/toolset: http://www.arduino.cc/en/Main/Software - 2. Download the Marlin firmware - - [Latest developement version](https://github.com/MarlinFirmware/Marlin/tree/Development) - - [Stable version]() - 3. In both cases use the "Download Zip" button on the right. - 4. Some boards require special files and/or libraries from the ArduinoAddons directory. Take a look at the dedicated [README](/ArduinoAddons/README.md) for details. - 5. Start the arduino IDE. - 6. Select Tools -> Board -> Arduino Mega 2560 or your microcontroller - 7. Select the correct serial port in Tools ->Serial Port - 8. Open Marlin.pde or .ino - 9. Click the Verify/Compile button - 10. Click the Upload button. If all goes well the firmware is uploading - -That's ok. Enjoy Silky Smooth Printing. diff --git a/Documentation/Contributing.md b/Documentation/Contributing.md deleted file mode 100644 index 2caa96442a..0000000000 --- a/Documentation/Contributing.md +++ /dev/null @@ -1,10 +0,0 @@ -Developer Notes -=================== - -- There are now 2 branches: The __development__ branch is where new features and code changes will be sorted out. This branch may have untested code in it, so please let us know if you find any bugs. When the __development__ branch has reached a state where it is stable, it will be moved to the __stable__ branch. - -- We are doing a kind of cleanup in the list of Issues and Pull Requests, the aim is to get to a state where we can certify the code as stable. To get the code tested as widely as possible we require several volunteers with a wide variety of hardware configurations willing to test the firmware and help us to certify it as stable. If you want to help out testing go to this issue and let us know: https://github.com/MarlinFirmware/Marlin/issues/1209 - -- Before you submit any pull request, we ask that you _PLEASE_ test your code before submission, even if the change seems innocuous. When creating the pull request, please include the hardware you used for testing and a short synopsis of your testing procedure. Untested pull requests are less likely to be merged, as even slight changes create the risk of breaking the main branch. - -- If you have a fix don't open an issue telling about it, but test the code and submit a pull request. Use the __development__ branch when you submit. \ No newline at end of file diff --git a/Documentation/Features.md b/Documentation/Features.md deleted file mode 100644 index b306741e8f..0000000000 --- a/Documentation/Features.md +++ /dev/null @@ -1,112 +0,0 @@ -# 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](http://reprap.org/pipermail/reprap-dev/2011-May/003323.html) -* Full endstop support -* SD Card support -* SD Card folders (works in pronterface) -* SD Card autostart support -* LCD support (ideally 20x4) -* LCD menu system for autonomous SD card printing, controlled by an click-encoder. -* EEPROM storage of e.g. max-velocity, max-acceleration, and similar variables -* many small but handy things originating from bkubicek's fork. -* Arc support -* Temperature oversampling -* Dynamic Temperature setpointing aka "AutoTemp" -* Support for [QTMarlin](https://github.com/bkubicek/QTMarlin), a very beta GUI for PID-tuning and velocity-acceleration testing. -* Endstop trigger reporting to the host software. -* Updated sdcardlib -* Heater power reporting. Useful for PID monitoring. -* PID tuning -* [CoreXY kinematics](www.corexy.com/theory.html) -* Delta kinematics -* SCARA kinematics -* Dual X-carriage support for multiple extruder systems -* Configurable serial port to support connection of wireless adaptors. -* Automatic operation of extruder/cold-end cooling fans based on nozzle temperature -* RC Servo Support, specify angle or duration for continuous rotation servos. -* Bed Auto Leveling. -* Support for a filament diameter sensor, which adjusts extrusion volume - -The default baudrate is 250000. This baudrate has less jitter and hence errors than the usual 115200 baud, but is less supported by drivers and host-environments. - -## Differences and additions to the already good Sprinter firmware - -### Look-ahead - -Marlin has look-ahead. While sprinter has to break and re-accelerate at each corner, -lookahead will only decelerate and accelerate to a velocity, -so that the change in vectorial velocity magnitude is less than the xy_jerk_velocity. -This is only possible, if some future moves are already processed, hence the name. -It leads to less over-deposition at corners, especially at flat angles. - -### Arc support - -Slic3r can find curves that, although broken into segments, were ment to describe an arc. -Marlin is able to print those arcs. The advantage is the firmware can choose the resolution, -and can perform the arc with nearly constant velocity, resulting in a nice finish. -Also, less serial communication is needed. - -### Temperature Oversampling - -To reduce noise and make the PID-differential term more useful, 16 ADC conversion results are averaged. - -### AutoTemp - -If your gcode contains a wide spread of extruder velocities, or you realtime change the building speed, the temperature should be changed accordingly. -Usually, higher speed requires higher temperature. -This can now be performed by the AutoTemp function -By calling M109 S B F you enter the autotemp mode. - -You can leave it by calling M109 without any F. -If active, the maximal extruder stepper rate of all buffered moves will be calculated, and named "maxerate" [steps/sec]. -The wanted temperature then will be set to t=tempmin+factor*maxerate, while being limited between tempmin and tempmax. -If the target temperature is set manually or by gcode to a value less then tempmin, it will be kept without change. -Ideally, your gcode can be completely free of temperature controls, apart from a M109 S T F in the start.gcode, and a M109 S0 in the end.gcode. - -### EEPROM - -If you know your PID values, the acceleration and max-velocities of your unique machine, you can set them, and finally store them in the EEPROM. -After each reboot, it will magically load them from EEPROM, independent what your Configuration.h says. - -### LCD Menu - -If your hardware supports it, you can build yourself a LCD-CardReader+Click+encoder combination. It will enable you to realtime tune temperatures, -accelerations, velocities, flow rates, select and print files from the SD card, preheat, disable the steppers, and do other fancy stuff. -One working hardware is documented here: http://www.thingiverse.com/thing:12663 -Also, with just a 20x4 or 16x2 display, useful data is shown. - -### SD card directories - -If you have an SD card reader attached to your controller, also folders work now. Listing the files in pronterface will show "/path/subpath/file.g". -You can write to file in a subfolder by specifying a similar text using small letters in the path. -Also, backup copies of various operating systems are hidden, as well as files not ending with ".g". - -### Autostart - -If you place a file auto[0-9].g into the root of the sd card, it will be automatically executed if you boot the printer. The same file will be executed by selecting "Autostart" from the menu. -First *0 will be performed, than *1 and so on. That way, you can heat up or even print automatically without user interaction. - -### Endstop trigger reporting - -If an endstop is hit while moving towards the endstop, the location at which the firmware thinks that the endstop was triggered is outputed on the serial port. -This is useful, because the user gets a warning message. -However, also tools like QTMarlin can use this for finding acceptable combinations of velocity+acceleration. - -### Coding paradigm - -Not relevant from a user side, but Marlin was split into thematic junks, and has tried to partially enforced private variables. -This is intended to make it clearer, what interacts which what, and leads to a higher level of modularization. -We think that this is a useful prestep for porting this firmware to e.g. an ARM platform in the future. -A lot of RAM (with enabled LCD ~2200 bytes) was saved by storing char []="some message" in Program memory. -In the serial communication, a #define based level of abstraction was enforced, so that it is clear that -some transfer is information (usually beginning with "echo:"), an error "error:", or just normal protocol, -necessary for backwards compatibility. - -### Interrupt based temperature measurements - -An interrupt is used to manage ADC conversions, and enforce checking for critical temperatures. -This leads to less blocking in the heater management routine. diff --git a/Documentation/FilamentSensor.md b/Documentation/FilamentSensor.md deleted file mode 100644 index 46e4251c1b..0000000000 --- a/Documentation/FilamentSensor.md +++ /dev/null @@ -1,9 +0,0 @@ -Filament Sensor ---------------- -Supports the use of a real time filament diameter sensor that measures the diameter of the filament going into the extruder and then adjusts the extrusion rate to compensate for filament that does not match what is defined in the g-code. The diameter can also be displayed on the LCD screen. This potentially eliminates the need to measure filament diameter when changing spools of filament. Gcode becomes independent of the filament diameter. Can also compensate for changing diameter. - -For examples of these sensors, see: http://www.thingiverse.com/thing:454584, https://www.youmagine.com/designs/filament-diameter-sensor, http://diy3dprinting.blogspot.com/2014/01/diy-filament-diameter-sensor.html. Any sensor which produces a voltage equivalent to the diameter in mm (i.e. 1v = 1mm) can be used. This provides a very simple interface and may encourage more innovation in this area. - -4 new Mcodes are defined to set relevant parameters: M404, M405, M406, M407 - see above. - - Implements a delay buffer to handle the transit delay between where the filament is measured and when it gets to the extruder. \ No newline at end of file diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md deleted file mode 100644 index c05be6198b..0000000000 --- a/Documentation/GCodes.md +++ /dev/null @@ -1,193 +0,0 @@ -## Implemented G Codes - -### Movement G and M Codes -``` -G0 -> G1 -G1 - Coordinated Movement X Y Z E -G2 - CW ARC -G3 - CCW ARC -G4 - Dwell S[seconds] or P[milliseconds] -G92 - Set the "current position" to coordinates: X Y Z E -M0 - Wait for user, with optional prompt message (requires LCD controller) - M0 Click When Ready ; show "Click When Ready" until the button is pressed. -M1 - Same as M0 -M400 - Finish all moves -M999 - Restart after being stopped by error -``` -### SD Card M Codes -``` -M20 - List SD card -M21 - Init SD card -M22 - Release SD card -M23 - Select SD file (M23 filename.g) -M24 - Start/resume SD print -M25 - Pause SD print -M26 - Set SD position in bytes (M26 S12345) -M27 - Report SD print status -M28 - Start SD write (M28 filename.g) -M29 - Stop SD write -M30 - Delete file from SD (M30 filename.g) -M31 - Output time since last M109 or SD card start to serial -M32 - Select file and start SD print (Can be used _while_ printing from SD card files): - syntax "M32 /path/filename#", or "M32 S !filename#" - Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include). - The '#' is necessary when calling from within sd files, as it stops buffer prereading -M540 - Enable/Disable "Stop SD Print on Endstop Hit" (req. ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) - M540 S<0|1> -M928 - Start SD logging (M928 filename.g) - ended by M29 -``` -### Hardware Control -``` -M42 - Change pin status via gcode: P S. If P is omitted the onboard LED pin will be used. - M42 P9 S1 ; set PIN 9 to 1. -M80 - Turn on Power Supply -M81 - Turn off Power Supply -M84 - Disable steppers until next move, - or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. -M85 - Set inactivity shutdown timer with parameter S. Disable with "M85" or "M85 S0". -M112 - Emergency stop. Requires hardware reset!! -M226 - Wait for a pin to be in some state: P S -``` -### Temperature M Codes -``` -M104 - Set extruder target temp -M105 - Read current temp -M106 - Fan on -M107 - Fan off -M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating - Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling - IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F -M140 - Set bed target temp -M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating - Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling -M301 - Set PID parameters P I and D -M302 - Allow cold extrudes, or set the minimum extrude S. -M303 - PID relay autotune S sets the target temperature. (default target temperature = 150C) -M304 - Set bed PID parameters P I and D -``` -### Message M Codes -``` -M114 - Output current position to serial port -M115 - Capabilities string -M117 - Display message text on the LCD -M119 - Output Endstop status to serial port -``` -### Endstops M Codes -``` -M120 - Enable endstop detection -M121 - Disable endstop detection -``` -### Special Features M Codes -``` -M126 - Solenoid Air Valve Open (BariCUDA support by jmil) -M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) -M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) -M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) -M150 - Set BlinkM Color: R U B via I2C. Range: 0-255 -M240 - Trigger a camera to take a photograph. (Add to your per-layer GCode.) -M250 - Set LCD contrast: C<0-63> -M280 - Set servo position absolute. P S -M300 - Play beep sound S P -M380 - Activate solenoid on active extruder -M381 - Disable all solenoids -M600 - Pause for filament change X Y Z E L -``` -### Units and Measures G and M Codes -``` -G90 - Use Absolute Coordinates -G91 - Use Relative Coordinates -M82 - Set E codes absolute (default) -M83 - Set E codes relative while in Absolute Coordinates (G90) mode -M92 - Set axis_steps_per_unit - same syntax as G92 -M200 - Set filament diameter and set E axis units to mm^3 (use S0 to set back to mm).: D -M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) -M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! -M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec -M204 - Set default acceleration: P for Printing moves, R for Retract only (no X, Y, Z) moves and T for Travel (non printing) moves (ex. M204 P800 T3000 R9000) in mm/sec^2 -M205 - Advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X=maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk -M206 - Set additional homing offset -M218 - Set hotend offset (in mm): T X Y -M220 - Set speed factor override percentage: S -M221 - Set extrude factor override percentage: S -``` -### Firmware Retraction G and M Codes -``` -G10 - Retract filament according to settings of M207 -G11 - Retract recover filament according to settings of M208 -M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting -M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/s] -M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction -``` -### Z Probe G and M Codes -``` -G28 - Home all Axis -G29 - Detailed Z-Probe, probes the bed at 3 or more points. The printer must be homed with G28 before G29. -G30 - Single Z Probe, probes bed at current XY location. -G31 - Dock Z Probe sled (if enabled) -G32 - Undock Z Probe sled (if enabled) -M48 - Measure Z_Probe repeatability: P X Y V E=engage L - As with G29, the E flag causes the probe to stow after each probe. -M401 - Lower Z-probe (if present) -M402 - Raise Z-probe (if present) -``` -### Filament Diameter M Codes -``` -M404 - Set (or display) Nominal Filament Diameter in mm: [N] (e.g., 3mm or 1.75mm) -M405 - Turn on Filament Sensor extrusion control: [D] to set distance (in cm) from sensor to extruder -M406 - Turn off Filament Sensor extrusion control -M407 - Display measured Filament Diameter -``` -### EEPROM Settings M Codes -``` -M500 - Store parameters in EEPROM -M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). -M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. -M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings. -``` -### Delta M Codes -``` -M665 - Set Delta configurations: L R S -M666 - Set Delta endstop adjustment: X Y Z -M605 - Set dual x-carriage movement mode: S [ X R ] -``` -### Stepper Driver M Codes -``` -M17 - Enable/Power all stepper motors -M18 - Disable all stepper motors. (same as M84) -M907 - Set digital trimpot motor current using axis codes. -M908 - Control digital trimpot directly. -M350 - Set microstepping mode. -M351 - Toggle MS1 MS2 pins directly. -``` -### SCARA M-Codes -__May change to suit future G-code standards__ -``` -M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) -M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) -M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) -M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) -M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) -M365 - SCARA calibration: Scaling factor, X, Y, Z axis -``` - -## Comments - -Comments start at a `;` (semicolon) and end with the end of the line: - - N3 T0*57 ; This is a comment - N4 G92 E0*67 - ; So is this - N5 G28*22 - -(example taken from the [RepRap wiki](http://reprap.org/wiki/Gcode#Comments)) - -If you need to use a literal `;` somewhere (for example within `M117`), you can escape semicolons with a `\` -(backslash): - - M117 Hello \;) - -`\` can also be used to escape `\` itself, if you need a literal `\` in front of a `;`: - - M117 backslash: \\;and a comment - -Please note that hosts should strip any comments before sending GCODE to the printer in order to save bandwidth. diff --git a/Documentation/LCD Menu Tree.pdf b/Documentation/LCD Menu Tree.pdf deleted file mode 100644 index 72b5911dd7..0000000000 Binary files a/Documentation/LCD Menu Tree.pdf and /dev/null differ diff --git a/Documentation/Menu Plans.xlsx b/Documentation/Menu Plans.xlsx deleted file mode 100644 index 8c7e2c17ba..0000000000 Binary files a/Documentation/Menu Plans.xlsx and /dev/null differ diff --git a/Documentation/MeshBedLeveling.md b/Documentation/MeshBedLeveling.md deleted file mode 100644 index 09c1ec9483..0000000000 --- a/Documentation/MeshBedLeveling.md +++ /dev/null @@ -1,82 +0,0 @@ -============================================== -Instructions for configuring Mesh Bed Leveling -============================================== - -Background ----------- - -This mesh based method of leveling/compensating can compensate for an non-flat bed. There are various opinions about doing this. It was primarily written to compensate a RigidBot BIG bed (40x30cm) that was somewhat bent. - -Currently there is no automatic way to probe the bed like the Auto Bed Leveling feature. So, you can not enable `ENABLE_AUTO_BED_LEVELING` at the same time. This might soon be implemented though, stay tuned. - -Theory ------- - -The bed is manually probed in a grid maner. During a print the Z axis compensation will be interpolated within each square using a bi-linear method. Because the grid squares can be tilting in different directions a printing move can be split on the borders of the grid squares. During fast travel moves one can sometimes notice a de-acceleration on these borders. - -Mesh point probing can either be carried out from the display, or by issuing `G29` commands. - -The Z-endstop should be set slightly above the bed. An opto endstop is preferable but a switch with a metal arm that allow some travel though should also work. - -Configuration -------------- - -In `Configuration.h` there are two options that can be enabled. - -`MESH_BED_LEVELING` will enable mesh bed leveling.
-`MANUAL_BED_LEVELING` will add the menu option for bed leveling. - -There are also some values that can be set. - -The following will set the step distance used when manually turning the display encoder. Default is 0.025 - -`MBL_Z_STEP` - -Following four define the area to cover. Default 10mm from max bed size - -`MESH_MIN_X`
-`MESH_MAX_X`
-`MESH_MIN_Y`
-`MESH_MAX_Y` - -Following two define the number of points to probe, total number will be these two multiplied. Default is 3x3 points. Don't probe more than 7x7 points (software limited) - -`MESH_NUM_X_POINTS`
-`MESH_NUM_Y_POINTS`
- -The following will set the Z-endstop height during probing. When initiating a bed leveling probing, a homing will take place and the Z-endstop will be set to this height so lowering through the endstop can take place and the bed should be within this distance. Default is 4mm - -`MESH_HOME_SEARCH_Z` - -The probed points will also be saved in the EEPROM if it has been enables. Otherwise a new probe sequence needs to be made next time the printer has been turned on. - -Probing the bed with the display --------------------------------- - -If `MANUAL_BED_LEVELING` has been enabled then will a `Level bed` menu option be available in the `Prepare` menu. - -When selecting this option the printer will first do a homing, and then travel to the first probe point. There it will wait. By turning the encoder on the display the hotend can now be lowered until it touches the bed. Using a paper to feel the distance when it gets close. Pressing the encoder/button will store this point and then travel to the next point. Repeating this until all points have been probed. - -If the EEPROM has been enable it can be good to issue a `M500` to get these points saved. - -Issuing a `G29` will return the state of the mesh leveling and report the probed points. - -Probing the bed with G-codes ----------------------------- - -Probing the bed by G-codes follows the sequence much like doing it with the display. - -`G29` or `G29 S0` will return the state of the bed leveling and report the probed points. Where X=1 Y=1 is the top-left value and X=MESH_NUM_X_POINTS Y=MESH_NUM_Y_POINTS is bottom-right value. X per column and Y per row. - -`G29 S1` will initiate the bed leveling, homing and traveling to the first point to probe. - -Then use your preferred Printer controller program, i.e. Printrun, to lower the hotend until it touches the bed. Using a paper to feel the distance when it gets close. - -`G29 S2` will store the point and travel to the next point until last point has been probed. - -`G29 S3 Xn Yn Zn.nn` will modify a single probed point. This can be used to tweak a badly probed point. Specify probe point where `Xn` and `Yn`, where `n` in `Xn` is between 1 and `MESH_NUM_X_POINTS`. Likewise for `Yn`. `Zn.nn` is the new Z value in that probed point. - -Note ----- - -Depending how firm feel you aim for on the paper you can use the `Z offset` option in Slic3r to compensate a slight height diff. (I like the paper loose so I needed to put `-0.05` in Slic3r) \ No newline at end of file diff --git a/Documentation/RampsServoPower.md b/Documentation/RampsServoPower.md deleted file mode 100644 index 2f715cfd73..0000000000 --- a/Documentation/RampsServoPower.md +++ /dev/null @@ -1,9 +0,0 @@ - - -__Note for RAMPS users:__ ----------------------- - --By default, RAMPS have no power on servo bus (if you happen to have a multimeter, check the voltage on servo power pins). --In order to get the servo working, you need to supply 5V to 5V pin.. You can do it using your power supply (if it has a 5V output) or jumping the "Vcc" from Arduino to the 5V RAMPS rail. --These 2 pins are located just between the Reset Button and the yellow fuses... There are marks in the board showing 5V and VCC.. just connect them.. --If jumping the arduino Vcc do RAMPS 5V rail, take care to not use a power hungry servo, otherwise you will cause a blackout in the arduino board ;-) diff --git a/Documentation/changelog.md b/Documentation/changelog.md deleted file mode 100644 index 393b404df2..0000000000 --- a/Documentation/changelog.md +++ /dev/null @@ -1,30 +0,0 @@ -### Version 1.0.3 -* Reduced code size, maybe a lot depending on your configuration. -* Improved support for Delta, SCARA, and COREXY kinematics. -* Move parts of Configuration files to `Conditionals.h` and `SanityCheck.h`. -* Clean up of temperature code. -* Enhanced `G29` with improved grid bed leveling based on Roxy code. See documentation. -* Various bugs fixed from 1.0.2. -* EEPROM layout updated to `V17`. -* Added `M204` travel acceleration options. -* `M204` "`P`" parameter replaces "`S`." "`S`" retained for backward compatibility. -* Support for more RAMPS-based boards. -* Configurator utility under development. -* `M404` "`N`" parameter replaced with "`W`." ("`N`" is for line numbers only). -* Much cleanup of the code. -* Improved support for Cyrillic and accented languages. -* LCD controller knob acceleration. -* Improved compatibility with various sensors, MAX6675 thermocouple. -* Filament runout sensor support. -* Filament width measurement support. -* Support for TMC and L6470 stepper drivers. -* Better support of G-Code `;` comments, `\`, `N` line numbers, and `*` checksums. -* Moved GCode handling code into individual functions per-code. - -### Version 1.0.2 -* Progress bar for character-based LCD displays. - -### Version 1.0.1 - -### Version 1.0.0 -* Initial release diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index fa574083d8..f09a8a2fe8 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -276,6 +276,13 @@ #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER)) #endif + /** + * Sled Options + */ + #ifdef Z_PROBE_SLED + #define Z_SAFE_HOMING + #endif + /** * MAX_STEP_FREQUENCY differs for TOSHIBA */ diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 63dcee5354..6c54f9891c 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -270,44 +270,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius - -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -377,7 +357,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false -#define INVERT_Y_DIR false +#define INVERT_Y_DIR true #define INVERT_Z_DIR false // @section extruder @@ -411,17 +391,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define Z_MAX_POS 200 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif //=========================================================================== -//============================ Mesh Bed Leveling ============================ +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -442,7 +425,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== // @section bedlevel @@ -622,10 +605,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #ifdef EEPROM_SETTINGS // To disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out: - #define EEPROM_CHITCHAT // please keep turned on if you can. + #define EEPROM_CHITCHAT // Please keep turned on if you can. #endif - // @section temperature // Preheat Constants diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b79035ab69..fd41e9d0dc 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -14,13 +14,27 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. @@ -31,14 +45,16 @@ #endif #endif - -//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode. -//The maximum buffered steps/sec of the extruder motor are called "se". -//You enter the autotemp mode by a M109 S B F -// the target temperature is set to mintemp+factor*se[steps/sec] and limited by mintemp and maxtemp -// you exit the value by any M109 without F* -// Also, if the temperature is set to a value B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #define AUTOTEMP #ifdef AUTOTEMP #define AUTOTEMP_OLDWEIGHT 0.98 @@ -376,6 +392,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/Makefile b/Marlin/Makefile index e23c2a19b4..34ad1340da 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -266,8 +266,8 @@ VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy endif CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \ MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \ - SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \ - stepper.cpp temperature.cpp cardreader.cpp configuration_store.cpp \ + SdFile.cpp SdVolume.cpp planner.cpp stepper.cpp \ + temperature.cpp cardreader.cpp configuration_store.cpp \ watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \ vector_3.cpp qr_solve.cpp ifeq ($(LIQUID_TWI2), 0) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 97978c45f7..592b4027a8 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -21,6 +21,10 @@ #include "fastio.h" #include "Configuration.h" +#ifndef SANITYCHECK_H + #error Your Configuration.h and Configuration_adv.h files are outdated! +#endif + #if (ARDUINO >= 100) #include "Arduino.h" #else @@ -109,7 +113,6 @@ FORCE_INLINE void serialprintPGM(const char *str) { } void get_command(); -void process_commands(); void manage_inactivity(bool ignore_stepper_queue=false); @@ -195,13 +198,14 @@ void manage_inactivity(bool ignore_stepper_queue=false); */ enum AxisEnum {X_AXIS=0, Y_AXIS=1, A_AXIS=0, B_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5}; +enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=6}; + void enable_all_steppers(); void disable_all_steppers(); void FlushSerialRequestResend(); -void ClearToSend(); +void ok_to_send(); -void get_coordinates(); #ifdef DELTA void calculate_delta(float cartesian[3]); #ifdef ENABLE_AUTO_BED_LEVELING diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 996bd60b91..efc14ea426 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1,30 +1,30 @@ -/* -*- c++ -*- */ - -/* - Reprap firmware based on Sprinter and grbl. - Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - */ - -/* - This firmware is a mashup between Sprinter and grbl. - (https://github.com/kliment/Sprinter) - (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm - http://reprap.org/pipermail/reprap-dev/2011-May/003323.html +/** + * Marlin Firmware + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * About Marlin + * + * This firmware is a mashup between Sprinter and grbl. + * - https://github.com/kliment/Sprinter + * - https://github.com/simen/grbl/tree + * + * It has preliminary support for Matthew Roberts advance algorithm + * - http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ #include "Marlin.h" @@ -36,6 +36,7 @@ #endif #endif // ENABLE_AUTO_BED_LEVELING +#define HAS_LCD_BUZZ (defined(ULTRALCD) || (defined(BEEPER) && BEEPER >= 0) || defined(LCD_USE_I2C_BUZZER)) #define SERVO_LEVELING (defined(ENABLE_AUTO_BED_LEVELING) && PROBE_SERVO_DEACTIVATION_DELAY > 0) #ifdef MESH_BED_LEVELING @@ -46,7 +47,6 @@ #include "planner.h" #include "stepper.h" #include "temperature.h" -#include "motion_control.h" #include "cardreader.h" #include "watchdog.h" #include "configuration_store.h" @@ -60,7 +60,7 @@ #endif #if NUM_SERVOS > 0 - #include "Servo.h" + #include "servo.h" #endif #if HAS_DIGIPOTSS @@ -73,13 +73,12 @@ * - http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes * * Help us document these G-codes online: + * - http://www.marlinfirmware.org/index.php/G-Code * - http://reprap.org/wiki/G-code - * - https://github.com/MarlinFirmware/Marlin/wiki/Marlin-G-Code - */ - -/** + * + * ----------------- * Implemented Codes - * ------------------- + * ----------------- * * "G" Codes * @@ -163,7 +162,7 @@ * M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk * M206 - Set additional homing offset * M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting - * M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] + * M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/min] * M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction. * M218 - Set hotend offset (in mm): T X Y * M220 - Set speed factor override percentage: S @@ -189,6 +188,7 @@ * M410 - Quickstop. Abort all the planned moves * M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable * M421 - Set a single Z coordinate in the Mesh Leveling grid. X Y Z + * M428 - Set the home_offset logically based on the current_position * M500 - Store parameters in EEPROM * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -214,6 +214,11 @@ * * M928 - Start SD logging (M928 filename.g) - ended by M29 * M999 - Restart after being stopped by error + * + * "T" Codes + * + * T0-T3 - Select a tool by index (usually an extruder) [ F ] + * */ #ifdef SDSUPPORT @@ -224,7 +229,7 @@ bool Running = true; uint8_t marlin_debug_flags = DEBUG_INFO|DEBUG_ERRORS; -static float feedrate = 1500.0, next_feedrate, saved_feedrate; +static float feedrate = 1500.0, saved_feedrate; float current_position[NUM_AXIS] = { 0.0 }; static float destination[NUM_AXIS] = { 0.0 }; bool axis_known_position[3] = { false }; @@ -256,7 +261,6 @@ const char errormagic[] PROGMEM = "Error:"; const char echomagic[] PROGMEM = "echo:"; const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; -static float offset[3] = { 0 }; static bool relative_mode = false; //Determines Absolute or Relative Coordinates static char serial_char; static int serial_count = 0; @@ -361,6 +365,7 @@ bool target_direction; #endif #ifdef SCARA + float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND; static float delta[3] = { 0 }; float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1 #endif @@ -398,7 +403,8 @@ bool target_direction; //================================ Functions ================================ //=========================================================================== -void get_arc_coordinates(); +void process_next_command(); + bool setTargetedHotend(int code); void serial_echopair_P(const char *s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } @@ -500,7 +506,7 @@ void setup_filrunoutpin() { #if HAS_FILRUNOUT pinMode(FILRUNOUT_PIN, INPUT); #ifdef ENDSTOPPULLUP_FIL_RUNOUT - WRITE(FILLRUNOUT_PIN, HIGH); + WRITE(FILRUNOUT_PIN, HIGH); #endif #endif } @@ -555,9 +561,9 @@ void servo_init() { // Set position of Servo Endstops that are defined #ifdef SERVO_ENDSTOPS - for (int i = 0; i < 3; i++) - if (servo_endstops[i] >= 0) - servo[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]); + for (int i = 0; i < 3; i++) + if (servo_endstops[i] >= 0) + servo[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]); #endif #if SERVO_LEVELING @@ -648,8 +654,8 @@ void setup() { #endif #ifdef Z_PROBE_SLED - pinMode(SERVO0_PIN, OUTPUT); - digitalWrite(SERVO0_PIN, LOW); // turn it off + pinMode(SLED_PIN, OUTPUT); + digitalWrite(SLED_PIN, LOW); // turn it off #endif // Z_PROBE_SLED setup_homepin(); @@ -697,17 +703,17 @@ void loop() { // Write the string from the read buffer to SD card.write_command(command); if (card.logging) - process_commands(); // The card is saving because it's logging + process_next_command(); // The card is saving because it's logging else SERIAL_PROTOCOLLNPGM(MSG_OK); } } else - process_commands(); + process_next_command(); #else - process_commands(); + process_next_command(); #endif // SDSUPPORT @@ -721,6 +727,15 @@ void loop() { lcd_update(); } +void gcode_line_error(const char *err, bool doFlush=true) { + SERIAL_ERROR_START; + serialprintPGM(err); + SERIAL_ERRORLN(gcode_LastN); + //Serial.println(gcode_N); + if (doFlush) FlushSerialRequestResend(); + serial_count = 0; +} + /** * Add to the circular command queue the next command from: * - The command-injection queue (queued_commands_P) @@ -731,21 +746,41 @@ void get_command() { if (drain_queued_commands_P()) return; // priority is given to non-serial commands - while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { + #ifdef NO_TIMEOUTS + static millis_t last_command_time = 0; + millis_t ms = millis(); + + if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > NO_TIMEOUTS) { + SERIAL_ECHOLNPGM(MSG_WAIT); + last_command_time = ms; + } + #endif + + // + // Loop while serial characters are incoming and the queue is not full + // + while (commands_in_queue < BUFSIZE && MYSERIAL.available() > 0) { + + #ifdef NO_TIMEOUTS + last_command_time = ms; + #endif serial_char = MYSERIAL.read(); - if (serial_char == '\n' || serial_char == '\r' || - serial_count >= (MAX_CMD_SIZE - 1) - ) { + // + // If the character ends the line, or the line is full... + // + if (serial_char == '\n' || serial_char == '\r' || serial_count >= MAX_CMD_SIZE-1) { + // end of line == end of comment comment_mode = false; - if (!serial_count) return; // shortcut for empty lines + if (!serial_count) return; // empty lines just exit char *command = command_queue[cmd_queue_index_w]; command[serial_count] = 0; // terminate string + // this item in the queue is not from sd #ifdef SDSUPPORT fromsd[cmd_queue_index_w] = false; #endif @@ -754,13 +789,7 @@ void get_command() { strchr_pointer = strchr(command, 'N'); gcode_N = (strtol(strchr_pointer + 1, NULL, 10)); if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) { - SERIAL_ERROR_START; - SERIAL_ERRORPGM(MSG_ERR_LINE_NO1); - SERIAL_ERROR(gcode_LastN + 1); - SERIAL_ERRORPGM(MSG_ERR_LINE_NO2); - SERIAL_ERRORLN(gcode_N); - FlushSerialRequestResend(); - serial_count = 0; + gcode_line_error(PSTR(MSG_ERR_LINE_NO)); return; } @@ -771,33 +800,22 @@ void get_command() { strchr_pointer = strchr(command, '*'); if (strtol(strchr_pointer + 1, NULL, 10) != checksum) { - SERIAL_ERROR_START; - SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH); - SERIAL_ERRORLN(gcode_LastN); - FlushSerialRequestResend(); - serial_count = 0; + gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH)); return; } - //if no errors, continue parsing + // if no errors, continue parsing } else { - SERIAL_ERROR_START; - SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM); - SERIAL_ERRORLN(gcode_LastN); - FlushSerialRequestResend(); - serial_count = 0; + gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM)); return; } gcode_LastN = gcode_N; - //if no errors, continue parsing + // if no errors, continue parsing } else { // if we don't receive 'N' but still see '*' if ((strchr(command, '*') != NULL)) { - SERIAL_ERROR_START; - SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM); - SERIAL_ERRORLN(gcode_LastN); - serial_count = 0; + gcode_line_error(PSTR(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false); return; } } @@ -828,7 +846,7 @@ void get_command() { serial_count = 0; //clear buffer } else if (serial_char == '\\') { // Handle escapes - if (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { + if (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { // if we have one more character, copy it over serial_char = MYSERIAL.read(); command_queue[cmd_queue_index_w][serial_count++] = serial_char; @@ -979,7 +997,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); #endif //DUAL_X_CARRIAGE -static void axis_is_at_home(int axis) { +static void axis_is_at_home(AxisEnum axis) { #ifdef DUAL_X_CARRIAGE if (axis == X_AXIS) { @@ -1083,6 +1101,14 @@ inline void sync_plan_position() { inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); } inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); } +static void setup_for_endstop_move() { + saved_feedrate = feedrate; + saved_feedrate_multiplier = feedrate_multiplier; + feedrate_multiplier = 100; + refresh_cmd_timeout(); + enable_endstops(true); +} + #ifdef ENABLE_AUTO_BED_LEVELING #ifdef DELTA @@ -1176,12 +1202,12 @@ inline void set_destination_to_current() { memcpy(destination, current_position, plan_bed_level_matrix.set_to_identity(); feedrate = homing_feedrate[Z_AXIS]; - // move down until you find the bed + // Move down until the probe (or endstop?) is triggered float zPosition = -10; line_to_z(zPosition); st_synchronize(); - // we have to let the planner know where we are right now as it is not where we said to go. + // Tell the planner where we ended up - Get this from the stepper handler zPosition = st_get_position_mm(Z_AXIS); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS]); @@ -1243,14 +1269,6 @@ inline void set_destination_to_current() { memcpy(destination, current_position, feedrate = oldFeedRate; } - static void setup_for_endstop_move() { - saved_feedrate = feedrate; - saved_feedrate_multiplier = feedrate_multiplier; - feedrate_multiplier = 100; - refresh_cmd_timeout(); - enable_endstops(true); - } - static void clean_up_after_endstop_move() { #ifdef ENDSTOPS_ONLY_FOR_HOMING enable_endstops(false); @@ -1266,13 +1284,14 @@ inline void set_destination_to_current() { memcpy(destination, current_position, // Engage Z Servo endstop if enabled if (servo_endstops[Z_AXIS] >= 0) { + Servo *srv = &servo[servo_endstops[Z_AXIS]]; #if SERVO_LEVELING - servo[servo_endstops[Z_AXIS]].attach(0); + srv->attach(0); #endif - servo[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2]); + srv->write(servo_endstop_angles[Z_AXIS * 2]); #if SERVO_LEVELING delay(PROBE_SERVO_DEACTIVATION_DELAY); - servo[servo_endstops[Z_AXIS]].detach(); + srv->detach(); #endif } @@ -1298,27 +1317,27 @@ inline void set_destination_to_current() { memcpy(destination, current_position, st_synchronize(); - #ifdef Z_PROBE_ENDSTOP - bool z_probe_endstop = (READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING); - if (z_probe_endstop) - #else - bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); - if (z_min_endstop) - #endif - { - if (IsRunning()) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Z-Probe failed to engage!"); - LCD_ALERTMESSAGEPGM("Err: ZPROBE"); + #ifdef Z_PROBE_ENDSTOP + bool z_probe_endstop = (READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING); + if (z_probe_endstop) + #else + bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); + if (z_min_endstop) + #endif + { + if (IsRunning()) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Z-Probe failed to engage!"); + LCD_ALERTMESSAGEPGM("Err: ZPROBE"); + } + Stop(); } - Stop(); - } #endif // Z_PROBE_ALLEN_KEY } - static void stow_z_probe() { + static void stow_z_probe(bool doRaise=true) { #ifdef SERVO_ENDSTOPS @@ -1326,19 +1345,21 @@ inline void set_destination_to_current() { memcpy(destination, current_position, if (servo_endstops[Z_AXIS] >= 0) { #if Z_RAISE_AFTER_PROBING > 0 - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // this also updates current_position - st_synchronize(); + if (doRaise) { + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // this also updates current_position + st_synchronize(); + } #endif + // Change the Z servo angle + Servo *srv = &servo[servo_endstops[Z_AXIS]]; #if SERVO_LEVELING - servo[servo_endstops[Z_AXIS]].attach(0); + srv->attach(0); #endif - - servo[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2 + 1]); - + srv->write(servo_endstop_angles[Z_AXIS * 2 + 1]); #if SERVO_LEVELING delay(PROBE_SERVO_DEACTIVATION_DELAY); - servo[servo_endstops[Z_AXIS]].detach(); + srv->detach(); #endif } @@ -1373,23 +1394,23 @@ inline void set_destination_to_current() { memcpy(destination, current_position, st_synchronize(); - #ifdef Z_PROBE_ENDSTOP - bool z_probe_endstop = (READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING); - if (!z_probe_endstop) - #else - bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); - if (!z_min_endstop) - #endif - { - if (IsRunning()) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Z-Probe failed to retract!"); - LCD_ALERTMESSAGEPGM("Err: ZPROBE"); + #ifdef Z_PROBE_ENDSTOP + bool z_probe_endstop = (READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING); + if (!z_probe_endstop) + #else + bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); + if (!z_min_endstop) + #endif + { + if (IsRunning()) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Z-Probe failed to retract!"); + LCD_ALERTMESSAGEPGM("Err: ZPROBE"); + } + Stop(); } - Stop(); - } - #endif + #endif // Z_PROBE_ALLEN_KEY } @@ -1401,32 +1422,31 @@ inline void set_destination_to_current() { memcpy(destination, current_position, }; // Probe bed height at position (x,y), returns the measured z value - static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeDeployAndStow, int verbose_level=1) { + static float probe_pt(float x, float y, float z_before, ProbeAction probe_action=ProbeDeployAndStow, int verbose_level=1) { // move to right place do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); // this also updates current_position do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); // this also updates current_position #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY) - if (retract_action & ProbeDeploy) deploy_z_probe(); + if (probe_action & ProbeDeploy) deploy_z_probe(); #endif run_z_probe(); float measured_z = current_position[Z_AXIS]; #if Z_RAISE_BETWEEN_PROBINGS > 0 - if (retract_action == ProbeStay) { + if (probe_action == ProbeStay) { do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); // this also updates current_position st_synchronize(); } #endif #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY) - if (retract_action & ProbeStow) stow_z_probe(); + if (probe_action & ProbeStow) stow_z_probe(); #endif if (verbose_level > 2) { - SERIAL_PROTOCOLPGM("Bed"); - SERIAL_PROTOCOLPGM(" X: "); + SERIAL_PROTOCOLPGM("Bed X: "); SERIAL_PROTOCOL_F(x, 3); SERIAL_PROTOCOLPGM(" Y: "); SERIAL_PROTOCOL_F(y, 3); @@ -1500,6 +1520,47 @@ inline void set_destination_to_current() { memcpy(destination, current_position, #endif // ENABLE_AUTO_BED_LEVELING + +#ifdef Z_PROBE_SLED + + #ifndef SLED_DOCKING_OFFSET + #define SLED_DOCKING_OFFSET 0 + #endif + + /** + * Method to dock/undock a sled designed by Charles Bell. + * + * dock[in] If true, move to MAX_X and engage the electromagnet + * offset[in] The additional distance to move to adjust docking location + */ + static void dock_sled(bool dock, int offset=0) { + if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) { + LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); + return; + } + + if (dock) { + float oldXpos = current_position[X_AXIS]; // save x position + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // rise Z + do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1, current_position[Y_AXIS], current_position[Z_AXIS]); // Dock sled a bit closer to ensure proper capturing + digitalWrite(SLED_PIN, LOW); // turn off magnet + do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking + } else { + float oldXpos = current_position[X_AXIS]; // save x position + float z_loc = current_position[Z_AXIS]; + if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING; + do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position + digitalWrite(SLED_PIN, HIGH); // turn on magnet + do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking + } + } + +#endif // Z_PROBE_SLED + + + /** * Home an individual axis */ @@ -1522,19 +1583,31 @@ static void homeaxis(AxisEnum axis) { current_position[axis] = 0; sync_plan_position(); - // Engage Servo endstop if enabled - #if defined(SERVO_ENDSTOPS) && !defined(Z_PROBE_SLED) + #ifdef Z_PROBE_SLED + // Get Probe + if (axis == Z_AXIS) { + if (axis_home_dir < 0) dock_sled(false); + } + #endif + + #if SERVO_LEVELING && !defined(Z_PROBE_SLED) - #if SERVO_LEVELING - if (axis == Z_AXIS) deploy_z_probe(); else - #endif - { - if (servo_endstops[axis] > -1) - servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]); - } + // Deploy a probe if there is one, and homing towards the bed + if (axis == Z_AXIS) { + if (axis_home_dir < 0) deploy_z_probe(); + } - #endif // SERVO_ENDSTOPS && !Z_PROBE_SLED + #endif + + #ifdef SERVO_ENDSTOPS + if (axis != Z_AXIS) { + // Engage Servo endstop if enabled + if (servo_endstops[axis] > -1) + servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]); + } + #endif + // Set a flag for Z motor locking #ifdef Z_DUAL_ENDSTOPS if (axis == Z_AXIS) In_Homing_Process(true); #endif @@ -1612,14 +1685,29 @@ static void homeaxis(AxisEnum axis) { endstops_hit_on_purpose(); // clear endstop hit flags axis_known_position[axis] = true; - // Retract Servo endstop if enabled - #ifdef SERVO_ENDSTOPS - if (servo_endstops[axis] > -1) - servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2 + 1]); + #ifdef Z_PROBE_SLED + // bring probe back + if (axis == Z_AXIS) { + if (axis_home_dir < 0) dock_sled(true); + } #endif #if SERVO_LEVELING && !defined(Z_PROBE_SLED) - if (axis == Z_AXIS) stow_z_probe(); + + // Deploy a probe if there is one, and homing towards the bed + if (axis == Z_AXIS) { + if (axis_home_dir < 0) stow_z_probe(); + } + else + + #endif + + #ifdef SERVO_ENDSTOPS + { + // Retract Servo endstop if enabled + if (servo_endstops[axis] > -1) + servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2 + 1]); + } #endif } @@ -1627,7 +1715,7 @@ static void homeaxis(AxisEnum axis) { #ifdef FWRETRACT - void retract(bool retracting, bool swapretract = false) { + void retract(bool retracting, bool swapping=false) { if (retracting == retracted[active_extruder]) return; @@ -1638,7 +1726,7 @@ static void homeaxis(AxisEnum axis) { if (retracting) { feedrate = retract_feedrate * 60; - current_position[E_AXIS] += (swapretract ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder]; + current_position[E_AXIS] += (swapping ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder]; plan_set_e_position(current_position[E_AXIS]); prepare_move(); @@ -1665,7 +1753,7 @@ static void homeaxis(AxisEnum axis) { } feedrate = retract_recover_feedrate * 60; - float move_e = swapretract ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length; + float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length; current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder]; plan_set_e_position(current_position[E_AXIS]); prepare_move(); @@ -1678,51 +1766,38 @@ static void homeaxis(AxisEnum axis) { #endif // FWRETRACT -#ifdef Z_PROBE_SLED - - #ifndef SLED_DOCKING_OFFSET - #define SLED_DOCKING_OFFSET 0 - #endif - - /** - * Method to dock/undock a sled designed by Charles Bell. - * - * dock[in] If true, move to MAX_X and engage the electromagnet - * offset[in] The additional distance to move to adjust docking location - */ - static void dock_sled(bool dock, int offset=0) { - if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) { - LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); - return; - } - - if (dock) { - do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], current_position[Z_AXIS]); // this also updates current_position - digitalWrite(SERVO0_PIN, LOW); // turn off magnet - } else { - float z_loc = current_position[Z_AXIS]; - if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING; - do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc); // this also updates current_position - digitalWrite(SERVO0_PIN, HIGH); // turn on magnet - } - } - -#endif // Z_PROBE_SLED - /** * * G-Code Handler functions * */ +/** + * Set XYZE destination and feedrate from the current GCode command + * + * - Set destination from included axis codes + * - Set to current for missing axis codes + * - Set the feedrate, if included + */ +void gcode_get_destination() { + for (int i = 0; i < NUM_AXIS; i++) { + if (code_seen(axis_codes[i])) + destination[i] = code_value() + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0); + else + destination[i] = current_position[i]; + } + if (code_seen('F')) { + float next_feedrate = code_value(); + if (next_feedrate > 0.0) feedrate = next_feedrate; + } +} + /** * G0, G1: Coordinated movement of X Y Z E axes */ inline void gcode_G0_G1() { if (IsRunning()) { - get_coordinates(); // For X Y Z E F + gcode_get_destination(); // For X Y Z E F #ifdef FWRETRACT @@ -1740,18 +1815,161 @@ inline void gcode_G0_G1() { #endif //FWRETRACT prepare_move(); - //ClearToSend(); } } +/** + * Plan an arc in 2 dimensions + * + * The arc is approximated by generating many small linear segments. + * The length of each segment is configured in MM_PER_ARC_SEGMENT (Default 1mm) + * Arcs should only be made relatively large (over 5mm), as larger arcs with + * larger segments will tend to be more efficient. Your slicer should have + * options for G2/G3 arc generation. In future these options may be GCode tunable. + */ +void plan_arc( + float *target, // Destination position + float *offset, // Center of rotation relative to current_position + uint8_t clockwise // Clockwise? +) { + + float radius = hypot(offset[X_AXIS], offset[Y_AXIS]), + center_axis0 = current_position[X_AXIS] + offset[X_AXIS], + center_axis1 = current_position[Y_AXIS] + offset[Y_AXIS], + linear_travel = target[Z_AXIS] - current_position[Z_AXIS], + extruder_travel = target[E_AXIS] - current_position[E_AXIS], + r_axis0 = -offset[X_AXIS], // Radius vector from center to current location + r_axis1 = -offset[Y_AXIS], + rt_axis0 = target[X_AXIS] - center_axis0, + rt_axis1 = target[Y_AXIS] - center_axis1; + + // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required. + float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); + if (angular_travel < 0) { angular_travel += RADIANS(360); } + if (clockwise) { angular_travel -= RADIANS(360); } + + // Make a circle if the angular rotation is 0 + if (current_position[X_AXIS] == target[X_AXIS] && current_position[Y_AXIS] == target[Y_AXIS] && angular_travel == 0) + angular_travel += RADIANS(360); + + float mm_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); + if (mm_of_travel < 0.001) { return; } + uint16_t segments = floor(mm_of_travel / MM_PER_ARC_SEGMENT); + if (segments == 0) segments = 1; + + float theta_per_segment = angular_travel/segments; + float linear_per_segment = linear_travel/segments; + float extruder_per_segment = extruder_travel/segments; + + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, + and phi is the angle of rotation. Based on the solution approach by Jens Geisler. + r_T = [cos(phi) -sin(phi); + sin(phi) cos(phi] * r ; + + For arc generation, the center of the circle is the axis of rotation and the radius vector is + defined from the circle center to the initial position. Each line segment is formed by successive + vector rotations. This requires only two cos() and sin() computations to form the rotation + matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since + all double numbers are single precision on the Arduino. (True double precision will not have + round off issues for CNC applications.) Single precision error can accumulate to be greater than + tool precision in some cases. Therefore, arc path correction is implemented. + + Small angle approximation may be used to reduce computation overhead further. This approximation + holds for everything, but very small circles and large MM_PER_ARC_SEGMENT values. In other words, + theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an + issue for CNC machines with the single precision Arduino calculations. + + This approximation also allows plan_arc to immediately insert a line segment into the planner + without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied + a correction, the planner should have caught up to the lag caused by the initial plan_arc overhead. + This is important when there are successive arc motions. + */ + // Vector rotation matrix values + float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation + float sin_T = theta_per_segment; + + float arc_target[4]; + float sin_Ti; + float cos_Ti; + float r_axisi; + uint16_t i; + int8_t count = 0; + + // Initialize the linear axis + arc_target[Z_AXIS] = current_position[Z_AXIS]; + + // Initialize the extruder axis + arc_target[E_AXIS] = current_position[E_AXIS]; + + float feed_rate = feedrate*feedrate_multiplier/60/100.0; + + for (i = 1; i < segments; i++) { // Increment (segments-1) + + if (count < N_ARC_CORRECTION) { + // Apply vector rotation matrix to previous r_axis0 / 1 + r_axisi = r_axis0*sin_T + r_axis1*cos_T; + r_axis0 = r_axis0*cos_T - r_axis1*sin_T; + r_axis1 = r_axisi; + count++; + } + else { + // Arc correction to radius vector. Computed only every N_ARC_CORRECTION increments. + // Compute exact location by applying transformation matrix from initial radius vector(=-offset). + cos_Ti = cos(i*theta_per_segment); + sin_Ti = sin(i*theta_per_segment); + r_axis0 = -offset[X_AXIS]*cos_Ti + offset[Y_AXIS]*sin_Ti; + r_axis1 = -offset[X_AXIS]*sin_Ti - offset[Y_AXIS]*cos_Ti; + count = 0; + } + + // Update arc_target location + arc_target[X_AXIS] = center_axis0 + r_axis0; + arc_target[Y_AXIS] = center_axis1 + r_axis1; + arc_target[Z_AXIS] += linear_per_segment; + arc_target[E_AXIS] += extruder_per_segment; + + clamp_to_software_endstops(arc_target); + plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, active_extruder); + } + // Ensure last segment arrives at target location. + plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, active_extruder); + + // As far as the parser is concerned, the position is now == target. In reality the + // motion control system might still be processing the action and the real tool position + // in any intermediate location. + set_current_to_destination(); +} + /** * G2: Clockwise Arc * G3: Counterclockwise Arc */ inline void gcode_G2_G3(bool clockwise) { if (IsRunning()) { - get_arc_coordinates(); - prepare_arc_move(clockwise); + + #ifdef SF_ARC_FIX + bool relative_mode_backup = relative_mode; + relative_mode = true; + #endif + + gcode_get_destination(); + + #ifdef SF_ARC_FIX + relative_mode = relative_mode_backup; + #endif + + // Center of arc as offset from current_position + float arc_offset[2] = { + code_seen('I') ? code_value() : 0, + code_seen('J') ? code_value() : 0 + }; + + // Send an arc to the planner + plan_arc(destination, arc_offset, clockwise); + + refresh_cmd_timeout(); } } @@ -1762,7 +1980,7 @@ inline void gcode_G4() { millis_t codenum = 0; if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait - if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait + if (code_seen('S')) codenum = code_value() * 1000; // seconds to wait st_synchronize(); refresh_cmd_timeout(); @@ -1815,6 +2033,9 @@ inline void gcode_G4() { */ inline void gcode_G28() { + // Wait for planner moves to finish! + st_synchronize(); + // For auto bed leveling, clear the level matrix #ifdef ENABLE_AUTO_BED_LEVELING plan_bed_level_matrix.set_to_identity(); @@ -1829,12 +2050,7 @@ inline void gcode_G28() { mbl.active = 0; #endif - saved_feedrate = feedrate; - saved_feedrate_multiplier = feedrate_multiplier; - feedrate_multiplier = 100; - refresh_cmd_timeout(); - - enable_endstops(true); + setup_for_endstop_move(); set_destination_to_current(); @@ -2549,14 +2765,14 @@ inline void gcode_G28() { z_tmp = current_position[Z_AXIS], real_z = (float)st_get_position(Z_AXIS) / axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane) - apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset - current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner. + apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); // Apply the correction sending the probe offset + current_position[Z_AXIS] += z_tmp - real_z; // The difference is added to current position and sent to planner. sync_plan_position(); } #endif // !DELTA #ifdef Z_PROBE_SLED - dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel + dock_sled(true); // dock the probe #elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING) stow_z_probe(); #endif @@ -2578,8 +2794,7 @@ inline void gcode_G28() { feedrate = homing_feedrate[Z_AXIS]; run_z_probe(); - SERIAL_PROTOCOLPGM("Bed"); - SERIAL_PROTOCOLPGM(" X: "); + SERIAL_PROTOCOLPGM("Bed X: "); SERIAL_PROTOCOL(current_position[X_AXIS] + 0.0001); SERIAL_PROTOCOLPGM(" Y: "); SERIAL_PROTOCOL(current_position[Y_AXIS] + 0.0001); @@ -2612,7 +2827,13 @@ inline void gcode_G92() { didXYZ = true; } } - if (didXYZ) sync_plan_position(); + if (didXYZ) { + #if defined(DELTA) || defined(SCARA) + sync_plan_position_delta(); + #else + sync_plan_position(); + #endif + } } #ifdef ULTIPANEL @@ -2631,7 +2852,7 @@ inline void gcode_G92() { hasP = codenum > 0; } if (code_seen('S')) { - codenum = code_value_short() * 1000UL; // seconds to wait + codenum = code_value() * 1000; // seconds to wait hasS = codenum > 0; } char* starpos = strchr(src, '*'); @@ -2996,7 +3217,7 @@ inline void gcode_M42() { current_position[E_AXIS] = E_current = st_get_position_mm(E_AXIS); // - // OK, do the inital probe to get us close to the bed. + // OK, do the initial probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // @@ -3105,12 +3326,14 @@ inline void gcode_M42() { plan_buffer_line(X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); + // Stow between if (deploy_probe_for_each_reading) { stow_z_probe(); delay(1000); } } + // Stow after if (!deploy_probe_for_each_reading) { stow_z_probe(); delay(1000); @@ -3118,8 +3341,6 @@ inline void gcode_M42() { clean_up_after_endstop_move(); - // enable_endstops(true); - if (verbose_level > 0) { SERIAL_PROTOCOLPGM("Mean: "); SERIAL_PROTOCOL_F(mean, 6); @@ -3146,7 +3367,10 @@ inline void gcode_M104() { if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0) setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset); #endif - setWatch(); + + #ifdef THERMAL_PROTECTION_HOTENDS + start_watching_heater(target_extruder); + #endif } } @@ -3157,7 +3381,7 @@ inline void gcode_M105() { if (setTargetedHotend(105)) return; #if HAS_TEMP_0 || HAS_TEMP_BED || defined(HEATER_0_USES_MAX6675) - SERIAL_PROTOCOLPGM("ok"); + SERIAL_PROTOCOLPGM(MSG_OK); #if HAS_TEMP_0 SERIAL_PROTOCOLPGM(" T:"); SERIAL_PROTOCOL_F(degHotend(target_extruder), 1); @@ -3258,7 +3482,9 @@ inline void gcode_M109() { if (code_seen('B')) autotemp_max = code_value(); #endif - setWatch(); + #ifdef THERMAL_PROTECTION_HOTENDS + start_watching_heater(target_extruder); + #endif millis_t temp_ms = millis(); @@ -3638,15 +3864,16 @@ inline void gcode_M115() { SERIAL_PROTOCOLPGM(MSG_M115_REPORT); } -/** - * M117: Set LCD Status Message - */ -inline void gcode_M117() { - char* codepos = strchr_pointer + 5; - char* starpos = strchr(codepos, '*'); - if (starpos) *starpos = '\0'; - lcd_setstatus(codepos); -} +#ifdef ULTIPANEL + + /** + * M117: Set LCD Status Message + */ + inline void gcode_M117() { + lcd_setstatus(strchr_pointer + 5); + } + +#endif /** * M119: Output endstop states to serial output @@ -4054,21 +4281,22 @@ inline void gcode_M226() { #if NUM_SERVOS > 0 /** - * M280: Set servo position absolute. P: servo index, S: angle or microseconds + * M280: Get or set servo position. P S */ inline void gcode_M280() { - int servo_index = code_seen('P') ? code_value() : -1; + int servo_index = code_seen('P') ? code_value_short() : -1; int servo_position = 0; if (code_seen('S')) { - servo_position = code_value(); - if ((servo_index >= 0) && (servo_index < NUM_SERVOS)) { + servo_position = code_value_short(); + if (servo_index >= 0 && servo_index < NUM_SERVOS) { + Servo *srv = &servo[servo_index]; #if SERVO_LEVELING - servo[servo_index].attach(0); + srv->attach(0); #endif - servo[servo_index].write(servo_position); + srv->write(servo_position); #if SERVO_LEVELING delay(PROBE_SERVO_DEACTIVATION_DELAY); - servo[servo_index].detach(); + srv->detach(); #endif } else { @@ -4090,7 +4318,7 @@ inline void gcode_M226() { #endif // NUM_SERVOS > 0 -#if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER) +#if HAS_LCD_BUZZ /** * M300: Play beep sound S P @@ -4102,7 +4330,7 @@ inline void gcode_M226() { lcd_buzz(beepP, beepS); } -#endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER +#endif // HAS_LCD_BUZZ #ifdef PIDTEMP @@ -4251,14 +4479,14 @@ inline void gcode_M303() { //SoftEndsEnabled = false; // Ignore soft endstops during calibration //SERIAL_ECHOLN(" Soft endstops disabled "); if (IsRunning()) { - //get_coordinates(); // For X Y Z E F + //gcode_get_destination(); // For X Y Z E F delta[X_AXIS] = delta_x; delta[Y_AXIS] = delta_y; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; prepare_move(); - //ClearToSend(); + //ok_to_send(); return true; } return false; @@ -4372,12 +4600,12 @@ inline void gcode_M303() { */ inline void gcode_M400() { st_synchronize(); } -#if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && not defined(Z_PROBE_SLED) +#if defined(ENABLE_AUTO_BED_LEVELING) && !defined(Z_PROBE_SLED) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) #ifdef SERVO_ENDSTOPS void raise_z_for_servo() { float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_HOMING; - if (!axis_known_position[Z_AXIS]) z_dest += zpos; + z_dest += axis_known_position[Z_AXIS] ? -zprobe_zoffset : zpos; if (zpos < z_dest) do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_dest); // also updates current_position } @@ -4400,10 +4628,10 @@ inline void gcode_M400() { st_synchronize(); } #ifdef SERVO_ENDSTOPS raise_z_for_servo(); #endif - stow_z_probe(); + stow_z_probe(false); } -#endif +#endif // ENABLE_AUTO_BED_LEVELING && (SERVO_ENDSTOPS || Z_PROBE_ALLEN_KEY) && !Z_PROBE_SLED #ifdef FILAMENT_SENSOR @@ -4499,11 +4727,59 @@ inline void gcode_M410() { quickStop(); } err = true; } - if (!err) mbl.set_z(select_x_index(x), select_y_index(y), z); + if (!err) mbl.set_z(mbl.select_x_index(x), mbl.select_y_index(y), z); } #endif +/** + * M428: Set home_offset based on the distance between the + * current_position and the nearest "reference point." + * If an axis is past center its endstop position + * is the reference-point. Otherwise it uses 0. This allows + * the Z offset to be set near the bed when using a max endstop. + * + * M428 can't be used more than 2cm away from 0 or an endstop. + * + * Use M206 to set these values directly. + */ +inline void gcode_M428() { + bool err = false; + float new_offs[3], new_pos[3]; + memcpy(new_pos, current_position, sizeof(new_pos)); + memcpy(new_offs, home_offset, sizeof(new_offs)); + for (int8_t i = X_AXIS; i <= Z_AXIS; i++) { + if (axis_known_position[i]) { + float base = (new_pos[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0, + diff = new_pos[i] - base; + if (diff > -20 && diff < 20) { + new_offs[i] -= diff; + new_pos[i] = base; + } + else { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR); + LCD_ALERTMESSAGEPGM("Err: Too far!"); + #if HAS_LCD_BUZZ + enqueuecommands_P(PSTR("M300 S40 P200")); + #endif + err = true; + break; + } + } + } + + if (!err) { + memcpy(current_position, new_pos, sizeof(new_pos)); + memcpy(home_offset, new_offs, sizeof(new_offs)); + sync_plan_position(); + LCD_ALERTMESSAGEPGM("Offset applied."); + #if HAS_LCD_BUZZ + enqueuecommands_P(PSTR("M300 S659 P200\nM300 S698 P200")); + #endif + } +} + /** * M500: Store settings in EEPROM */ @@ -4550,7 +4826,7 @@ inline void gcode_M503() { if (code_seen('Z')) { value = code_value(); if (Z_PROBE_OFFSET_RANGE_MIN <= value && value <= Z_PROBE_OFFSET_RANGE_MAX) { - zprobe_zoffset = -value; // compare w/ line 278 of configuration_store.cpp + zprobe_zoffset = -value; SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK); SERIAL_EOL; @@ -4805,9 +5081,11 @@ inline void gcode_M999() { /** * T0-T3: Switch tool, usually switching extruders + * + * F[mm/min] Set the movement feedrate */ inline void gcode_T() { - int tmp_extruder = code_value(); + uint16_t tmp_extruder = code_value_short(); if (tmp_extruder >= EXTRUDERS) { SERIAL_ECHO_START; SERIAL_CHAR('T'); @@ -4827,7 +5105,7 @@ inline void gcode_T() { make_move = true; #endif - next_feedrate = code_value(); + float next_feedrate = code_value(); if (next_feedrate > 0.0) feedrate = next_feedrate; } #if EXTRUDERS > 1 @@ -4913,7 +5191,7 @@ inline void gcode_T() { * Process Commands and dispatch them to handlers * This is called from the main loop() */ -void process_commands() { +void process_next_command() { if ((marlin_debug_flags & DEBUG_ECHO)) { SERIAL_ECHO_START; @@ -4922,9 +5200,9 @@ void process_commands() { if (code_seen('G')) { - int gCode = code_value_short(); + int codenum = code_value_short(); - switch(gCode) { + switch (codenum) { // G0, G1 case 0: @@ -4936,7 +5214,7 @@ void process_commands() { #ifndef SCARA case 2: // G2 - CW ARC case 3: // G3 - CCW ARC - gcode_G2_G3(gCode == 2); + gcode_G2_G3(codenum == 2); break; #endif @@ -4949,7 +5227,7 @@ void process_commands() { case 10: // G10: retract case 11: // G11: retract_recover - gcode_G10_G11(gCode == 10); + gcode_G10_G11(codenum == 10); break; #endif //FWRETRACT @@ -4976,7 +5254,7 @@ void process_commands() { case 31: // G31: dock the sled case 32: // G32: undock the sled - dock_sled(gCode == 31); + dock_sled(codenum == 31); break; #endif // Z_PROBE_SLED @@ -5147,9 +5425,13 @@ void process_commands() { case 115: // M115: Report capabilities gcode_M115(); break; - case 117: // M117: Set LCD message text - gcode_M117(); - break; + + #ifdef ULTIPANEL + case 117: // M117: Set LCD message text + gcode_M117(); + break; + #endif + case 114: // M114: Report current position gcode_M114(); break; @@ -5251,11 +5533,11 @@ void process_commands() { break; #endif // NUM_SERVOS > 0 - #if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER) + #if HAS_LCD_BUZZ case 300: // M300 - Play beep tone gcode_M300(); break; - #endif // BEEPER > 0 || ULTRALCD || LCD_USE_I2C_BUZZER + #endif // HAS_LCD_BUZZ #ifdef PIDTEMP case 301: // M301 @@ -5316,14 +5598,14 @@ void process_commands() { gcode_M400(); break; - #if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && not defined(Z_PROBE_SLED) + #if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && !defined(Z_PROBE_SLED) case 401: gcode_M401(); break; case 402: gcode_M402(); break; - #endif + #endif // ENABLE_AUTO_BED_LEVELING && (SERVO_ENDSTOPS || Z_PROBE_ALLEN_KEY) && !Z_PROBE_SLED #ifdef FILAMENT_SENSOR case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width @@ -5353,6 +5635,10 @@ void process_commands() { break; #endif + case 428: // M428 Apply current_position to home_offset + gcode_M428(); + break; + case 500: // M500 Store settings in EEPROM gcode_M500(); break; @@ -5429,7 +5715,7 @@ void process_commands() { SERIAL_ECHOLNPGM("\""); } - ClearToSend(); + ok_to_send(); } void FlushSerialRequestResend() { @@ -5437,42 +5723,21 @@ void FlushSerialRequestResend() { MYSERIAL.flush(); SERIAL_PROTOCOLPGM(MSG_RESEND); SERIAL_PROTOCOLLN(gcode_LastN + 1); - ClearToSend(); + ok_to_send(); } -void ClearToSend() { +void ok_to_send() { refresh_cmd_timeout(); #ifdef SDSUPPORT if (fromsd[cmd_queue_index_r]) return; #endif - SERIAL_PROTOCOLLNPGM(MSG_OK); -} - -void get_coordinates() { - for (int i = 0; i < NUM_AXIS; i++) { - if (code_seen(axis_codes[i])) - destination[i] = code_value() + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0); - else - destination[i] = current_position[i]; - } - if (code_seen('F')) { - next_feedrate = code_value(); - if (next_feedrate > 0.0) feedrate = next_feedrate; - } -} - -void get_arc_coordinates() { - #ifdef SF_ARC_FIX - bool relative_mode_backup = relative_mode; - relative_mode = true; - #endif - get_coordinates(); - #ifdef SF_ARC_FIX - relative_mode = relative_mode_backup; + SERIAL_PROTOCOLPGM(MSG_OK); + #ifdef ADVANCED_OK + SERIAL_PROTOCOLPGM(" N"); SERIAL_PROTOCOL(gcode_LastN); + SERIAL_PROTOCOLPGM(" P"); SERIAL_PROTOCOL(int(BLOCK_BUFFER_SIZE - movesplanned() - 1)); + SERIAL_PROTOCOLPGM(" B"); SERIAL_PROTOCOL(BUFSIZE - commands_in_queue); #endif - - offset[0] = code_seen('I') ? code_value() : 0; - offset[1] = code_seen('J') ? code_value() : 0; + SERIAL_EOL; } void clamp_to_software_endstops(float target[3]) { @@ -5577,10 +5842,6 @@ void clamp_to_software_endstops(float target[3]) { #ifdef MESH_BED_LEVELING - #if !defined(MIN) - #define MIN(_v1, _v2) (((_v1) < (_v2)) ? (_v1) : (_v2)) - #endif // ! MIN - // This function is used to split lines on mesh borders so each segment is only part of one mesh area void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_rate, const uint8_t &extruder, uint8_t x_splits=0xff, uint8_t y_splits=0xff) { @@ -5593,10 +5854,10 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_ int piy = mbl.select_y_index(current_position[Y_AXIS]); int ix = mbl.select_x_index(x); int iy = mbl.select_y_index(y); - pix = MIN(pix, MESH_NUM_X_POINTS-2); - piy = MIN(piy, MESH_NUM_Y_POINTS-2); - ix = MIN(ix, MESH_NUM_X_POINTS-2); - iy = MIN(iy, MESH_NUM_Y_POINTS-2); + pix = min(pix, MESH_NUM_X_POINTS - 2); + piy = min(piy, MESH_NUM_Y_POINTS - 2); + ix = min(ix, MESH_NUM_X_POINTS - 2); + iy = min(iy, MESH_NUM_Y_POINTS - 2); if (pix == ix && piy == iy) { // Start and end on same mesh square plan_buffer_line(x, y, z, e, feed_rate, extruder); @@ -5648,77 +5909,35 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_ #ifdef PREVENT_DANGEROUS_EXTRUDE - inline float prevent_dangerous_extrude(float &curr_e, float &dest_e) { + inline void prevent_dangerous_extrude(float &curr_e, float &dest_e) { float de = dest_e - curr_e; if (de) { if (degHotend(active_extruder) < extrude_min_temp) { curr_e = dest_e; // Behave as if the move really took place, but ignore E part SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); - return 0; } #ifdef PREVENT_LENGTHY_EXTRUDE if (labs(de) > EXTRUDE_MAXLENGTH) { curr_e = dest_e; // Behave as if the move really took place, but ignore E part SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP); - return 0; } #endif } - return de; } #endif // PREVENT_DANGEROUS_EXTRUDE -void prepare_move() { - clamp_to_software_endstops(destination); - refresh_cmd_timeout(); - - #ifdef PREVENT_DANGEROUS_EXTRUDE - (void)prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]); - #endif - - #ifdef SCARA //for now same as delta-code - - float difference[NUM_AXIS]; - for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i]; - - float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS])); - if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); } - if (cartesian_mm < 0.000001) { return; } - float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier; - int steps = max(1, int(scara_segments_per_second * seconds)); - - //SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm); - //SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds); - //SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps); - - for (int s = 1; s <= steps; s++) { - float fraction = float(s) / float(steps); - for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction; - - calculate_delta(destination); - //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); - //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); - //SERIAL_ECHOPGM("destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]); - //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); - //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); - //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder); - } - - #endif // SCARA - - #ifdef DELTA +#if defined(DELTA) || defined(SCARA) + inline bool prepare_move_delta() { float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i]; float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS])); if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]); - if (cartesian_mm < 0.000001) return; + if (cartesian_mm < 0.000001) return false; float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier; int steps = max(1, int(delta_segments_per_second * seconds)); @@ -5727,18 +5946,39 @@ void prepare_move() { // SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps); for (int s = 1; s <= steps; s++) { + float fraction = float(s) / float(steps); - for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction; + + for (int8_t i = 0; i < NUM_AXIS; i++) + destination[i] = current_position[i] + difference[i] * fraction; + calculate_delta(destination); + #ifdef ENABLE_AUTO_BED_LEVELING adjust_delta(destination); #endif + + //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); + //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); + //SERIAL_ECHOPGM("destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]); + //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); + //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); + //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder); } + return true; + } - #endif // DELTA +#endif // DELTA || SCARA - #ifdef DUAL_X_CARRIAGE +#ifdef SCARA + inline bool prepare_move_scara() { return prepare_move_delta(); } +#endif + +#ifdef DUAL_X_CARRIAGE + + inline bool prepare_move_dual_x_carriage() { if (active_extruder_parked) { if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) { // move duplicate extruder into correct duplication position. @@ -5759,7 +5999,7 @@ void prepare_move() { set_current_to_destination(); NOLESS(raised_parked_position[Z_AXIS], destination[Z_AXIS]); delayed_move_time = millis(); - return; + return false; } } delayed_move_time = 0; @@ -5770,9 +6010,14 @@ void prepare_move() { active_extruder_parked = false; } } - #endif // DUAL_X_CARRIAGE + return true; + } - #if !defined(DELTA) && !defined(SCARA) +#endif // DUAL_X_CARRIAGE + +#if !defined(DELTA) && !defined(SCARA) + + inline bool prepare_move_cartesian() { // Do not use feedrate_multiplier for E or Z only moves if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS]) { line_to_destination(); @@ -5780,140 +6025,156 @@ void prepare_move() { else { #ifdef MESH_BED_LEVELING mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedrate_multiplier/100.0), active_extruder); - return; + return false; #else line_to_destination(feedrate * feedrate_multiplier / 100.0); - #endif // MESH_BED_LEVELING + #endif } - #endif // !(DELTA || SCARA) + return true; + } - set_current_to_destination(); -} +#endif // !DELTA && !SCARA -void prepare_arc_move(char isclockwise) { - float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc +/** + * Prepare a single move and get ready for the next one + */ +void prepare_move() { + clamp_to_software_endstops(destination); + refresh_cmd_timeout(); - // Trace the arc - mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedrate_multiplier/60/100.0, r, isclockwise, active_extruder); + #ifdef PREVENT_DANGEROUS_EXTRUDE + prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]); + #endif + + #ifdef SCARA + if (!prepare_move_scara()) return; + #elif defined(DELTA) + if (!prepare_move_delta()) return; + #endif + + #ifdef DUAL_X_CARRIAGE + if (!prepare_move_dual_x_carriage()) return; + #endif + + #if !defined(DELTA) && !defined(SCARA) + if (!prepare_move_cartesian()) return; + #endif - // As far as the parser is concerned, the position is now == target. In reality the - // motion control system might still be processing the action and the real tool position - // in any intermediate location. set_current_to_destination(); - refresh_cmd_timeout(); } #if HAS_CONTROLLERFAN -millis_t lastMotor = 0; // Last time a motor was turned on -millis_t lastMotorCheck = 0; // Last time the state was checked - -void controllerFan() { - millis_t ms = millis(); - if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms - lastMotorCheck = ms; - if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0 - || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled... - #if EXTRUDERS > 1 - || E1_ENABLE_READ == E_ENABLE_ON - #if HAS_X2_ENABLE - || X2_ENABLE_READ == X_ENABLE_ON - #endif - #if EXTRUDERS > 2 - || E2_ENABLE_READ == E_ENABLE_ON - #if EXTRUDERS > 3 - || E3_ENABLE_READ == E_ENABLE_ON + void controllerFan() { + static millis_t lastMotor = 0; // Last time a motor was turned on + static millis_t lastMotorCheck = 0; // Last time the state was checked + millis_t ms = millis(); + if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms + lastMotorCheck = ms; + if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0 + || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled... + #if EXTRUDERS > 1 + || E1_ENABLE_READ == E_ENABLE_ON + #if HAS_X2_ENABLE + || X2_ENABLE_READ == X_ENABLE_ON + #endif + #if EXTRUDERS > 2 + || E2_ENABLE_READ == E_ENABLE_ON + #if EXTRUDERS > 3 + || E3_ENABLE_READ == E_ENABLE_ON + #endif #endif #endif - #endif - ) { - lastMotor = ms; //... set time to NOW so the fan will turn on + ) { + lastMotor = ms; //... set time to NOW so the fan will turn on + } + uint8_t speed = (lastMotor == 0 || ms >= lastMotor + (CONTROLLERFAN_SECS * 1000UL)) ? 0 : CONTROLLERFAN_SPEED; + // allows digital or PWM fan output to be used (see M42 handling) + digitalWrite(CONTROLLERFAN_PIN, speed); + analogWrite(CONTROLLERFAN_PIN, speed); } - uint8_t speed = (lastMotor == 0 || ms >= lastMotor + (CONTROLLERFAN_SECS * 1000UL)) ? 0 : CONTROLLERFAN_SPEED; - // allows digital or PWM fan output to be used (see M42 handling) - digitalWrite(CONTROLLERFAN_PIN, speed); - analogWrite(CONTROLLERFAN_PIN, speed); } -} -#endif + +#endif // HAS_CONTROLLERFAN #ifdef SCARA -void calculate_SCARA_forward_Transform(float f_scara[3]) -{ - // Perform forward kinematics, and place results in delta[3] - // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - - float x_sin, x_cos, y_sin, y_cos; - + + void calculate_SCARA_forward_Transform(float f_scara[3]) { + // Perform forward kinematics, and place results in delta[3] + // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 + + float x_sin, x_cos, y_sin, y_cos; + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - - // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); - // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); - // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); - // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + + //SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); + //SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); + //SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); + //SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} + } -void calculate_delta(float cartesian[3]){ - //reverse kinematics. - // Perform reversed kinematics, and place results in delta[3] - // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - - float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - - SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y - SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - - #if (Linkage_1 == Linkage_2) - SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; - #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; - #endif - - SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - - SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; - SCARA_K2 = Linkage_2 * SCARA_S2; - - SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; - SCARA_psi = atan2(SCARA_S2,SCARA_C2); - - delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle - delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) - delta[Z_AXIS] = cartesian[Z_AXIS]; - - /* - SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); - SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); - SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - - SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); - SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - - SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); - SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); - SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - - SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); - SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); - SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); - SERIAL_ECHOPGM(" Psi="); SERIAL_ECHOLN(SCARA_psi); - SERIAL_ECHOLN(" ");*/ -} + void calculate_delta(float cartesian[3]){ + //reverse kinematics. + // Perform reversed kinematics, and place results in delta[3] + // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 + + float SCARA_pos[2]; + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y + SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. + + #if (Linkage_1 == Linkage_2) + SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; + #else + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + #endif + + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); + + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; + SCARA_K2 = Linkage_2 * SCARA_S2; + + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; + SCARA_psi = atan2(SCARA_S2,SCARA_C2); + + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle + delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) + delta[Z_AXIS] = cartesian[Z_AXIS]; + + /* + SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); + SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); + SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); + + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); + SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); + + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); + SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); + SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); + + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); + SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); + SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); + SERIAL_ECHOPGM(" Psi="); SERIAL_ECHOLN(SCARA_psi); + SERIAL_EOL; + */ + } -#endif +#endif // SCARA #ifdef TEMP_STAT_LEDS @@ -5975,7 +6236,7 @@ void disable_all_steppers() { void manage_inactivity(bool ignore_stepper_queue/*=false*/) { #if HAS_FILRUNOUT - if (card.sdprinting && !(READ(FILRUNOUT_PIN) ^ FIL_RUNOUT_INVERTING)) + if (IS_SD_PRINTING && !(READ(FILRUNOUT_PIN) ^ FIL_RUNOUT_INVERTING)) filrunout(); #endif @@ -6022,7 +6283,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { if (!READ(HOME_PIN)) { if (!homeDebounceCount) { enqueuecommands_P(PSTR("G28")); - LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME); + LCD_MESSAGEPGM(MSG_AUTO_HOME); } if (homeDebounceCount < HOME_DEBOUNCE_DELAY) homeDebounceCount++; @@ -6140,92 +6401,93 @@ void kill() void filrunout() { if (!filrunoutEnqueued) { filrunoutEnqueued = true; - enqueuecommand("M600"); + enqueuecommands_P(PSTR(FILAMENT_RUNOUT_SCRIPT)); + st_synchronize(); } } -#endif - -void Stop() { - disable_all_heaters(); - if (IsRunning()) { - Running = false; - Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM(MSG_ERR_STOPPED); - LCD_MESSAGEPGM(MSG_STOPPED); - } -} +#endif // FILAMENT_RUNOUT_SENSOR #ifdef FAST_PWM_FAN -void setPwmFrequency(uint8_t pin, int val) -{ - val &= 0x07; - switch(digitalPinToTimer(pin)) - { - #if defined(TCCR0A) - case TIMER0A: - case TIMER0B: -// TCCR0B &= ~(_BV(CS00) | _BV(CS01) | _BV(CS02)); -// TCCR0B |= val; - break; - #endif + void setPwmFrequency(uint8_t pin, int val) { + val &= 0x07; + switch (digitalPinToTimer(pin)) { - #if defined(TCCR1A) - case TIMER1A: - case TIMER1B: -// TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12)); -// TCCR1B |= val; - break; - #endif + #if defined(TCCR0A) + case TIMER0A: + case TIMER0B: + // TCCR0B &= ~(_BV(CS00) | _BV(CS01) | _BV(CS02)); + // TCCR0B |= val; + break; + #endif - #if defined(TCCR2) - case TIMER2: - case TIMER2: - TCCR2 &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12)); - TCCR2 |= val; - break; - #endif + #if defined(TCCR1A) + case TIMER1A: + case TIMER1B: + // TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12)); + // TCCR1B |= val; + break; + #endif - #if defined(TCCR2A) - case TIMER2A: - case TIMER2B: - TCCR2B &= ~(_BV(CS20) | _BV(CS21) | _BV(CS22)); - TCCR2B |= val; - break; - #endif + #if defined(TCCR2) + case TIMER2: + case TIMER2: + TCCR2 &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12)); + TCCR2 |= val; + break; + #endif - #if defined(TCCR3A) - case TIMER3A: - case TIMER3B: - case TIMER3C: - TCCR3B &= ~(_BV(CS30) | _BV(CS31) | _BV(CS32)); - TCCR3B |= val; - break; - #endif + #if defined(TCCR2A) + case TIMER2A: + case TIMER2B: + TCCR2B &= ~(_BV(CS20) | _BV(CS21) | _BV(CS22)); + TCCR2B |= val; + break; + #endif - #if defined(TCCR4A) - case TIMER4A: - case TIMER4B: - case TIMER4C: - TCCR4B &= ~(_BV(CS40) | _BV(CS41) | _BV(CS42)); - TCCR4B |= val; - break; - #endif - - #if defined(TCCR5A) - case TIMER5A: - case TIMER5B: - case TIMER5C: - TCCR5B &= ~(_BV(CS50) | _BV(CS51) | _BV(CS52)); - TCCR5B |= val; - break; - #endif + #if defined(TCCR3A) + case TIMER3A: + case TIMER3B: + case TIMER3C: + TCCR3B &= ~(_BV(CS30) | _BV(CS31) | _BV(CS32)); + TCCR3B |= val; + break; + #endif + + #if defined(TCCR4A) + case TIMER4A: + case TIMER4B: + case TIMER4C: + TCCR4B &= ~(_BV(CS40) | _BV(CS41) | _BV(CS42)); + TCCR4B |= val; + break; + #endif + #if defined(TCCR5A) + case TIMER5A: + case TIMER5B: + case TIMER5C: + TCCR5B &= ~(_BV(CS50) | _BV(CS51) | _BV(CS52)); + TCCR5B |= val; + break; + #endif + + } + } + +#endif // FAST_PWM_FAN + +void Stop() { + disable_all_heaters(); + if (IsRunning()) { + Running = false; + Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM(MSG_ERR_STOPPED); + LCD_MESSAGEPGM(MSG_STOPPED); } } -#endif //FAST_PWM_FAN bool setTargetedHotend(int code){ target_extruder = active_extruder; diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 3bba4584cd..9aaff4a951 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -313,4 +313,16 @@ #error [XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM #endif + #if WATCH_TEMP_PERIOD > 500 + #error WATCH_TEMP_PERIOD now uses seconds instead of milliseconds + #endif + + #if !defined(THERMAL_PROTECTION_HOTENDS) && (defined(WATCH_TEMP_PERIOD) || defined(THERMAL_PROTECTION_PERIOD)) + #error Thermal Runaway Protection for hotends must now be enabled with THERMAL_PROTECTION_HOTENDS + #endif + + #if !defined(THERMAL_PROTECTION_BED) && defined(THERMAL_PROTECTION_BED_PERIOD) + #error Thermal Runaway Protection for the bed must now be enabled with THERMAL_PROTECTION_BED + #endif + #endif //SANITYCHECK_H diff --git a/Marlin/SdBaseFile.cpp b/Marlin/SdBaseFile.cpp index c72eced73c..f92f48e148 100644 --- a/Marlin/SdBaseFile.cpp +++ b/Marlin/SdBaseFile.cpp @@ -1097,8 +1097,9 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) { fail: return -1; } -//------------------------------------------------------------------------------ -/** Read the next directory entry from a directory file. + +/** + * Read the next entry in a directory. * * \param[out] dir The dir_t struct that will receive the data. * @@ -1114,50 +1115,38 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { if (!isDir() || (0X1F & curPosition_)) return -1; //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. - if (longFilename != NULL) - { - longFilename[0] = '\0'; - } + if (longFilename != NULL) longFilename[0] = '\0'; while (1) { + n = read(dir, sizeof(dir_t)); if (n != sizeof(dir_t)) return n == 0 ? 0 : -1; + // last entry if DIR_NAME_FREE if (dir->name[0] == DIR_NAME_FREE) return 0; + // skip empty entries and entry for . and .. if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') continue; - //Fill the long filename if we have a long filename entry, - // long filename entries are stored before the actual filename. - if (DIR_IS_LONG_NAME(dir) && longFilename != NULL) - { - vfat_t *VFAT = (vfat_t*)dir; - //Sanity check the VFAT entry. The first cluster is always set to zero. And th esequence number should be higher then 0 - if (VFAT->firstClusterLow == 0 && (VFAT->sequenceNumber & 0x1F) > 0 && (VFAT->sequenceNumber & 0x1F) <= MAX_VFAT_ENTRIES) - { - //TODO: Store the filename checksum to verify if a none-long filename aware system modified the file table. - n = ((VFAT->sequenceNumber & 0x1F) - 1) * FILENAME_LENGTH; - longFilename[n+0] = VFAT->name1[0]; - longFilename[n+1] = VFAT->name1[1]; - longFilename[n+2] = VFAT->name1[2]; - longFilename[n+3] = VFAT->name1[3]; - longFilename[n+4] = VFAT->name1[4]; - longFilename[n+5] = VFAT->name2[0]; - longFilename[n+6] = VFAT->name2[1]; - longFilename[n+7] = VFAT->name2[2]; - longFilename[n+8] = VFAT->name2[3]; - longFilename[n+9] = VFAT->name2[4]; - longFilename[n+10] = VFAT->name2[5]; - longFilename[n+11] = VFAT->name3[0]; - longFilename[n+12] = VFAT->name3[1]; - //If this VFAT entry is the last one, add a NUL terminator at the end of the string - if (VFAT->sequenceNumber & 0x40) - longFilename[n+FILENAME_LENGTH] = '\0'; - } + + // Fill the long filename if we have a long filename entry. + // Long filename entries are stored before the short filename. + if (longFilename != NULL && DIR_IS_LONG_NAME(dir)) { + vfat_t *VFAT = (vfat_t*)dir; + // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 + if (VFAT->firstClusterLow == 0 && (VFAT->sequenceNumber & 0x1F) > 0 && (VFAT->sequenceNumber & 0x1F) <= MAX_VFAT_ENTRIES) { + // TODO: Store the filename checksum to verify if a none-long filename aware system modified the file table. + n = ((VFAT->sequenceNumber & 0x1F) - 1) * FILENAME_LENGTH; + for (uint8_t i=0; iname1[i] : (i < 11) ? VFAT->name2[i-5] : VFAT->name3[i-11]; + // If this VFAT entry is the last one, add a NUL terminator at the end of the string + if (VFAT->sequenceNumber & 0x40) longFilename[n+FILENAME_LENGTH] = '\0'; + } } - // return if normal file or subdirectory + // Return if normal file or subdirectory if (DIR_IS_FILE_OR_SUBDIR(dir)) return n; } } + //------------------------------------------------------------------------------ // Read next directory entry into the cache // Assumes file is correctly positioned diff --git a/Marlin/boards.h b/Marlin/boards.h index 8a60f011d5..cc9d1f2897 100644 --- a/Marlin/boards.h +++ b/Marlin/boards.h @@ -14,6 +14,7 @@ #define BOARD_RAMPS_13_EEB 34 // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed) #define BOARD_RAMPS_13_EFF 35 // RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Fan) #define BOARD_RAMPS_13_EEF 36 // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Fan) +#define BOARD_RAMPS_13_SF 38 // RAMPS 1.3 / 1.4 (Power outputs: Spindle, Controller Fan) #define BOARD_FELIX2 37 // Felix 2.0+ Electronics Board (RAMPS like) #define BOARD_DUEMILANOVE_328P 4 // Duemilanove w/ ATMega328P pin assignments #define BOARD_GEN6 5 // Gen6 @@ -50,6 +51,7 @@ #define BOARD_ELEFU_3 21 // Elefu Ra Board (v3) #define BOARD_5DPRINT 88 // 5DPrint D8 Driver Board #define BOARD_LEAPFROG 999 // Leapfrog +#define BOARD_MKS_BASE 40 // MKS BASE 1.0 #define BOARD_WITBOX 41 // bq WITBOX #define BOARD_HEPHESTOS 42 // bq Prusa i3 Hephestos #define BOARD_BAM_DICE 401 // 2PrintBeta BAM&DICE with STK drivers diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 639b4f244a..a2a6d8eb51 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -20,6 +20,7 @@ CardReader::CardReader() { autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software. autostart_index = 0; + //power to SD reader #if SDPOWER > -1 OUT_WRITE(SDPOWER, HIGH); @@ -39,24 +40,43 @@ char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters return buffer; } +/** + * Dive into a folder and recurse depth-first to perform a pre-set operation lsAction: + * LS_Count - Add +1 to nrFiles for every file within the parent + * LS_GetFilename - Get the filename of the file indexed by nrFiles + * LS_SerialPrint - Print the full path of each file to serial output + */ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/) { dir_t p; uint8_t cnt = 0; + // Read the next entry from a directory while (parent.readDir(p, longFilename) > 0) { - if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) { // hence LS_SerialPrint - char path[FILENAME_LENGTH*2]; + + // If the entry is a directory and the action is LS_SerialPrint + if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) { + + // Allocate enough stack space for the full path to a folder + int len = strlen(prepend) + FILENAME_LENGTH + 1; + char path[len]; + + // Get the short name for the item, which we know is a folder char lfilename[FILENAME_LENGTH]; createFilename(lfilename, p); - path[0] = 0; - if (prepend[0] == 0) strcat(path, "/"); //avoid leading / if already in prepend + // Append the FOLDERNAME12/ to the passed string. + // It contains the full path to the "parent" argument. + // We now have the full path to the item in this folder. + path[0] = '\0'; + if (prepend[0] == '\0') strcat(path, "/"); // a root slash if prepend is empty strcat(path, prepend); strcat(path, lfilename); strcat(path, "/"); - //Serial.print(path); + // Serial.print(path); + // Get a new directory object using the full path + // and dive recursively into it. SdFile dir; if (!dir.open(parent, lfilename, O_READ)) { if (lsAction == LS_SerialPrint) { @@ -66,14 +86,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } } lsDive(path, dir); - //close done automatically by destructor of SdFile + // close() is done automatically by destructor of SdFile } else { char pn0 = p.name[0]; if (pn0 == DIR_NAME_FREE) break; if (pn0 == DIR_NAME_DELETED || pn0 == '.') continue; - char lf0 = longFilename[0]; - if (lf0 == '.') continue; + if (longFilename[0] == '.') continue; if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; @@ -81,24 +100,27 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue; - //if (cnt++ != nr) continue; - createFilename(filename, p); - if (lsAction == LS_SerialPrint) { - SERIAL_PROTOCOL(prepend); - SERIAL_PROTOCOLLN(filename); - } - else if (lsAction == LS_Count) { - nrFiles++; - } - else if (lsAction == LS_GetFilename) { - if (match != NULL) { - if (strcasecmp(match, filename) == 0) return; - } - else if (cnt == nrFiles) return; - cnt++; + switch (lsAction) { + case LS_Count: + nrFiles++; + break; + case LS_SerialPrint: + createFilename(filename, p); + SERIAL_PROTOCOL(prepend); + SERIAL_PROTOCOLLN(filename); + break; + case LS_GetFilename: + createFilename(filename, p); + if (match != NULL) { + if (strcasecmp(match, filename) == 0) return; + } + else if (cnt == nrFiles) return; + cnt++; + break; } + } - } + } // while readDir } void CardReader::ls() { @@ -237,7 +259,7 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/) char *dirname_start, *dirname_end; if (name[0] == '/') { dirname_start = &name[1]; - while(dirname_start > 0) { + 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)); @@ -287,14 +309,14 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/) else { SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL); SERIAL_PROTOCOL(fname); - SERIAL_PROTOCOLCHAR('.'); + SERIAL_PROTOCOLPGM(".\n"); } } else { //write if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL); SERIAL_PROTOCOL(fname); - SERIAL_PROTOCOLCHAR('.'); + SERIAL_PROTOCOLPGM(".\n"); } else { saving = true; diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 782b5d320a..b950b88cd2 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -676,9 +676,9 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOLNPGM("Mesh bed leveling:"); CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M420 S", (int32_t)mbl.active); - SERIAL_ECHOPAIR(" X", MESH_NUM_X_POINTS); - SERIAL_ECHOPAIR(" Y", MESH_NUM_Y_POINTS); + SERIAL_ECHOPAIR(" M420 S", (unsigned long)mbl.active); + SERIAL_ECHOPAIR(" X", (unsigned long)MESH_NUM_X_POINTS); + SERIAL_ECHOPAIR(" Y", (unsigned long)MESH_NUM_Y_POINTS); SERIAL_EOL; for (int y=0; y B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -376,6 +400,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h index d8ceafb1a5..40d8dbe663 100644 --- a/Marlin/configurator/config/language.h +++ b/Marlin/configurator/config/language.h @@ -30,6 +30,7 @@ // eu Basque-Euskera // kana Japanese // kana_utf Japanese +// cn Chinese #ifndef LANGUAGE_INCLUDE // pick your language from the list above @@ -122,21 +123,22 @@ #define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: " #define MSG_OK "ok" #define MSG_FILE_SAVED "Done saving file." -#define MSG_ERR_LINE_NO1 "Line Number out of sequence. Expected: " -#define MSG_ERR_LINE_NO2 " Got: " +#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_M200_INVALID_EXTRUDER "M200 Invalid extruder " -#define MSG_M218_INVALID_EXTRUDER "M218 Invalid extruder " -#define MSG_M221_INVALID_EXTRUDER "M221 Invalid extruder " +#define MSG_INVALID_EXTRUDER "Invalid extruder" +#define MSG_INVALID_SOLENOID "Invalid solenoid" +#define MSG_M104_INVALID_EXTRUDER "M104 " MSG_INVALID_EXTRUDER " " +#define MSG_M105_INVALID_EXTRUDER "M105 " MSG_INVALID_EXTRUDER " " +#define MSG_M109_INVALID_EXTRUDER "M109 " MSG_INVALID_EXTRUDER " " +#define MSG_M200_INVALID_EXTRUDER "M200 " MSG_INVALID_EXTRUDER " " +#define MSG_M218_INVALID_EXTRUDER "M218 " MSG_INVALID_EXTRUDER " " +#define MSG_M221_INVALID_EXTRUDER "M221 " MSG_INVALID_EXTRUDER " " #define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature" -#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder " #define MSG_HEATING "Heating..." #define MSG_HEATING_COMPLETE "Heating done." #define MSG_BED_HEATING "Bed Heating." @@ -148,8 +150,6 @@ #define MSG_RESEND "Resend: " #define MSG_UNKNOWN_COMMAND "Unknown command: \"" #define MSG_ACTIVE_EXTRUDER "Active Extruder: " -#define MSG_INVALID_EXTRUDER "Invalid extruder" -#define MSG_INVALID_SOLENOID "Invalid solenoid" #define MSG_X_MIN "x_min: " #define MSG_X_MAX "x_max: " #define MSG_Y_MIN "y_min: " @@ -161,6 +161,7 @@ #define MSG_ERR_MATERIAL_INDEX "M145 S out of range (0-1)" #define MSG_ERR_M421_REQUIRES_XYZ "M421 requires XYZ parameters" #define MSG_ERR_MESH_INDEX_OOB "Mesh XY index is out of bounds" +#define MSG_ERR_M428_TOO_FAR "Too far from reference point" #define MSG_M119_REPORT "Reporting endstop status" #define MSG_ENDSTOP_HIT "TRIGGERED" #define MSG_ENDSTOP_OPEN "open" diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index ff7cc99906..47e4a9244d 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -273,7 +273,6 @@ static void lcd_implementation_status_screen() { u8g.drawFrame(42, 49 - TALL_FONT_CORRECTION, 10, 4); u8g.drawPixel(50, 43 - TALL_FONT_CORRECTION); - // Progress bar frame u8g.drawFrame(54, 49, 73, 4 - TALL_FONT_CORRECTION); @@ -333,19 +332,28 @@ static void lcd_implementation_status_screen() { u8g.drawPixel(8,XYZ_BASELINE - 5); u8g.drawPixel(8,XYZ_BASELINE - 3); u8g.setPrintPos(10,XYZ_BASELINE); - lcd_print(ftostr31ns(current_position[X_AXIS])); + if (axis_known_position[X_AXIS]) + lcd_print(ftostr31ns(current_position[X_AXIS])); + else + lcd_printPGM(PSTR("---")); u8g.setPrintPos(43,XYZ_BASELINE); lcd_print('Y'); u8g.drawPixel(49,XYZ_BASELINE - 5); u8g.drawPixel(49,XYZ_BASELINE - 3); u8g.setPrintPos(51,XYZ_BASELINE); - lcd_print(ftostr31ns(current_position[Y_AXIS])); + if (axis_known_position[Y_AXIS]) + lcd_print(ftostr31ns(current_position[Y_AXIS])); + else + lcd_printPGM(PSTR("---")); u8g.setPrintPos(83,XYZ_BASELINE); lcd_print('Z'); u8g.drawPixel(89,XYZ_BASELINE - 5); u8g.drawPixel(89,XYZ_BASELINE - 3); u8g.setPrintPos(91,XYZ_BASELINE); - lcd_print(ftostr31(current_position[Z_AXIS])); + if (axis_known_position[Z_AXIS]) + lcd_print(ftostr32sp(current_position[Z_AXIS])); + else + lcd_printPGM(PSTR("---.--")); u8g.setColorIndex(1); // black on white // Feedrate diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 41e0955a44..caceb6b72e 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -236,44 +236,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius - -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -350,17 +330,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define Z_MAX_POS 235 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -381,7 +364,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index 3d485c89bc..681c954c35 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -236,44 +236,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius - -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -350,17 +330,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define Z_MAX_POS 235 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -377,7 +360,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 672b3ff028..678ebbe083 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -376,6 +400,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index f53dc9d934..f59c86cea7 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -257,44 +257,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius - -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -371,17 +351,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define Z_MAX_POS 180 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -402,7 +385,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 5713373d16..e1ec3fa6a7 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -374,7 +398,16 @@ const unsigned int dropsegments=5; //everything with less than this number of st //The ASCII buffer for receiving from the serial: #define MAX_CMD_SIZE 96 -#define BUFSIZE 5 +#define BUFSIZE 4 + +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK // @section fwretract diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index ac5ff0c71f..2ea8f7ff31 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -286,44 +286,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius - -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -427,17 +407,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define Z_MAX_POS 200 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif //=========================================================================== -//============================ Mesh Bed Leveling ============================ +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -458,7 +441,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== // @section bedlevel diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 672b3ff028..678ebbe083 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -376,6 +400,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h new file mode 100644 index 0000000000..27a2582900 --- /dev/null +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -0,0 +1,799 @@ +#ifndef CONFIGURATION_H +#define CONFIGURATION_H + +#include "boards.h" + +//=========================================================================== +//============================= Getting Started ============================= +//=========================================================================== +/* +Here are some standard links for getting your machine calibrated: + * http://reprap.org/wiki/Calibration + * http://youtu.be/wAL9d7FgInk + * http://calculator.josefprusa.cz + * http://reprap.org/wiki/Triffid_Hunter%27s_Calibration_Guide + * http://www.thingiverse.com/thing:5573 + * https://sites.google.com/site/repraplogphase/calibration-of-your-reprap + * http://www.thingiverse.com/thing:298812 +*/ + +// This configuration file contains the basic settings. +// Advanced settings can be found in Configuration_adv.h +// BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration + +//=========================================================================== +//============================= DELTA Printer =============================== +//=========================================================================== +// For a Delta printer replace the configuration files with the files in the +// example_configurations/delta directory. +// + +//=========================================================================== +//============================= SCARA Printer =============================== +//=========================================================================== +// For a Scara printer replace the configuration files with the files in the +// example_configurations/SCARA directory. +// + +// @section info + +// User-specified version info of this build 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 +// build by the user have been successfully uploaded into firmware. +#define STRING_VERSION "1.0.3 dev" +#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time +#define STRING_CONFIG_H_AUTHOR "RepRapWorld.com" // Who made the changes. +#define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 +//#define STRING_SPLASH_LINE2 STRING_VERSION_CONFIG_H // will be shown during bootup in line2 + +// @section machine + +// SERIAL_PORT selects which serial port should be used for communication with the host. +// This allows the connection of wireless adapters (for instance) to non-default port pins. +// Serial port 0 is still used by the Arduino bootloader regardless of this setting. +// :[0,1,2,3,4,5,6,7] +#define SERIAL_PORT 0 + +// This determines the communication speed of the printer +// :[2400,9600,19200,38400,57600,115200,250000] +#define BAUDRATE 250000 + +// This enables the serial port associated to the Bluetooth interface +//#define BTENABLED // Enable BT interface on AT90USB devices + +// The following define selects which electronics board you have. +// Please choose the name from boards.h that matches your setup +#ifndef MOTHERBOARD + #define MOTHERBOARD BOARD_MEGATRONICS_3 +#endif + +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "3D Printer" + +// Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) +// You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) +// #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" + +// This defines the number of extruders +// :[1,2,3,4] +#define EXTRUDERS 1 + +// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). +// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). +// For the other hotends it is their distance from the extruder 0 hotend. +//#define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis +//#define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis + +//// The following define selects which power supply you have. Please choose the one that matches your setup +// 1 = ATX +// 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC) +// :{1:'ATX',2:'X-Box 360'} + +#define POWER_SUPPLY 1 + +// Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it. +// #define PS_DEFAULT_OFF + +// @section temperature + +//=========================================================================== +//============================= Thermal Settings ============================ +//=========================================================================== +// +//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table +// +//// 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 - 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 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup) +// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) +// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) +// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) +// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) +// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) +// 10 is 100k RS thermistor 198-961 (4.7k pullup) +// 11 is 100k beta 3950 1% thermistor (4.7k pullup) +// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 20 is the PT100 circuit found in the Ultimainboard V2.x +// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 +// +// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k +// (but gives greater accuracy and more stable PID) +// 51 is 100k thermistor - EPCOS (1k pullup) +// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup) +// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) +// +// 1047 is Pt1000 with 4k7 pullup +// 1010 is Pt1000 with 1k pullup (non standard) +// 147 is Pt100 with 4k7 pullup +// 110 is Pt100 with 1k pullup (non standard) +// 998 and 999 are Dummy Tables. They will ALWAYS read 25°C or the temperature defined below. +// Use it for Testing or Development purposes. NEVER for production machine. +// #define DUMMY_THERMISTOR_998_VALUE 25 +// #define DUMMY_THERMISTOR_999_VALUE 100 +// :{ '0': "Not used", '4': "10k !! do not use for a hotend. Bad resolution at high temp. !!", '1': "100k / 4.7k - EPCOS", '51': "100k / 1k - EPCOS", '6': "100k / 4.7k EPCOS - Not as accurate as Table 1", '5': "100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '7': "100k / 4.7k Honeywell 135-104LAG-J01", '71': "100k / 4.7k Honeywell 135-104LAF-J01", '8': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9': "100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10': "100k / 4.7k RS 198-961", '11': "100k / 4.7k beta 3950 1%", '12': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13': "100k Hisens 3950 1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '60': "100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '55': "100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '2': "200k / 4.7k - ATC Semitec 204GT-2", '52': "200k / 1k - ATC Semitec 204GT-2", '-2': "Thermocouple + MAX6675 (only for sensor 0)", '-1': "Thermocouple + AD595", '3': "Mendel-parts / 4.7k", '1047': "Pt1000 / 4.7k", '1010': "Pt1000 / 1k (non standard)", '20': "PT100 (Ultimainboard V2.x)", '147': "Pt100 / 4.7k", '110': "Pt100 / 1k (non-standard)", '998': "Dummy 1", '999': "Dummy 2" } +#define TEMP_SENSOR_0 1 +#define TEMP_SENSOR_1 0 +#define TEMP_SENSOR_2 0 +#define TEMP_SENSOR_3 0 +#define TEMP_SENSOR_BED 1 + +// This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted. +//#define TEMP_SENSOR_1_AS_REDUNDANT +#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 + +// Actual temperature must be close to target for this long before M109 returns success +#define TEMP_RESIDENCY_TIME 10 // (seconds) +#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one +#define TEMP_WINDOW 1 // (degC) Window around target to start the residency 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 HEATER_3_MINTEMP 5 +#define BED_MINTEMP 5 + +// 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_3_MAXTEMP 275 +#define BED_MAXTEMP 150 + +// If your bed has low resistance e.g. .6 ohm and throws the fuse you can duty cycle it to reduce the +// average current. The value should be an integer and the heat bed will be turned on for 1 interval of +// HEATER_BED_DUTY_CYCLE_DIVIDER intervals. +//#define HEATER_BED_DUTY_CYCLE_DIVIDER 4 + +// If you want the M105 heater power reported in watts, define the BED_WATTS, and (shared for all extruders) EXTRUDER_WATTS +//#define EXTRUDER_WATTS (12.0*12.0/6.7) // P=I^2/R +//#define BED_WATTS (12.0*12.0/1.1) // P=I^2/R + +//=========================================================================== +//============================= PID Settings ================================ +//=========================================================================== +// PID Tuning Guide here: http://reprap.org/wiki/PID_Tuning + +// Comment the following line to disable PID and enable bang-bang. +#define PIDTEMP +#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current +#define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current +#ifdef PIDTEMP + //#define PID_DEBUG // Sends debug data to the serial port. + //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX + //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay + //#define PID_PARAMS_PER_EXTRUDER // Uses separate PID parameters for each extruder (useful for mismatched extruders) + // Set/get with gcode: M301 E[extruder number, 0-2] + #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature + // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. + #define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term + #define K1 0.95 //smoothing factor within the PID + +// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it +// Ultimaker + #define DEFAULT_Kp 22.2 + #define DEFAULT_Ki 1.08 + #define DEFAULT_Kd 114 + +// MakerGear +// #define DEFAULT_Kp 7.0 +// #define DEFAULT_Ki 0.1 +// #define DEFAULT_Kd 12 + +// Mendel Parts V9 on 12V +// #define DEFAULT_Kp 63.0 +// #define DEFAULT_Ki 2.25 +// #define DEFAULT_Kd 440 +#endif // PIDTEMP + +//=========================================================================== +//============================= PID > Bed Temperature Control =============== +//=========================================================================== +// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis +// +// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. +// If your PID_dT is the default, and correct for your hardware/configuration, that means 7.689Hz, +// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating. +// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. +// If your configuration is significantly different than this and you don't understand the issues involved, you probably +// shouldn't use bed PID until someone else verifies your hardware works. +// If this is enabled, find your own PID constants below. +//#define PIDTEMPBED +// +//#define BED_LIMIT_SWITCHING + +// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option. +// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis) +// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did, +// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED) +#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current + +//#define PID_BED_DEBUG // Sends debug data to the serial port. + +#ifdef PIDTEMPBED +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) + #define DEFAULT_bedKp 10.00 + #define DEFAULT_bedKi .023 + #define DEFAULT_bedKd 305.4 + +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from pidautotune +// #define DEFAULT_bedKp 97.1 +// #define DEFAULT_bedKi 1.41 +// #define DEFAULT_bedKd 1675.16 + +// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. +#endif // PIDTEMPBED + +// @section extruder + +//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 +//if PREVENT_DANGEROUS_EXTRUDE is on, you can still disable (uncomment) very long bits of extrusion separately. +#define PREVENT_LENGTHY_EXTRUDE + +#define EXTRUDE_MINTEMP 170 +#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. + +//=========================================================================== +//======================== Thermal Runaway Protection ======================= +//=========================================================================== + +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ + +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed + +//=========================================================================== +//============================= Mechanical Settings ========================= +//=========================================================================== + +// @section machine + +// Uncomment this option to enable CoreXY kinematics +// #define COREXY + +// Enable this option for Toshiba steppers +// #define CONFIG_STEPPERS_TOSHIBA + +// @section homing + +// coarse Endstop Settings +#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors + +#ifndef ENDSTOPPULLUPS + // fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined + // #define ENDSTOPPULLUP_XMAX + // #define ENDSTOPPULLUP_YMAX + // #define ENDSTOPPULLUP_ZMAX + // #define ENDSTOPPULLUP_XMIN + // #define ENDSTOPPULLUP_YMIN + // #define ENDSTOPPULLUP_ZMIN + // #define ENDSTOPPULLUP_ZPROBE +#endif + +// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). +const bool X_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Y_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +//#define DISABLE_MAX_ENDSTOPS +//#define DISABLE_MIN_ENDSTOPS + +// @section machine +// If you want to enable the Z Probe pin, but disable its use, uncomment the line below. +// This only affects a Z Probe Endstop if you have separate Z min endstop as well and have +// activated Z_PROBE_ENDSTOP below. If you are using the Z Min endstop on your Z Probe, +// this has no effect. +//#define DISABLE_Z_PROBE_ENDSTOP + +// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 +// :{0:'Low',1:'High'} +#define X_ENABLE_ON 0 +#define Y_ENABLE_ON 0 +#define Z_ENABLE_ON 0 +#define E_ENABLE_ON 0 // For all extruders + +// Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! +#define DISABLE_X false +#define DISABLE_Y false +#define DISABLE_Z false + +// @section extruder + +#define DISABLE_E false // For all extruders +#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled + +// @section machine + +// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. +#define INVERT_X_DIR false +#define INVERT_Y_DIR true +#define INVERT_Z_DIR false + +// @section extruder + +// For direct drive extruder v9 set to true, for geared extruder set to false. +#define INVERT_E0_DIR false +#define INVERT_E1_DIR false +#define INVERT_E2_DIR false +#define INVERT_E3_DIR false + +// @section homing + +// ENDSTOP SETTINGS: +// Sets direction of endstops when homing; 1=MAX, -1=MIN +// :[-1,1] +#define X_HOME_DIR -1 +#define Y_HOME_DIR -1 +#define Z_HOME_DIR -1 + +#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS. +#define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below. + +// @section machine + +// Travel limits after homing (units are in mm) +#define X_MIN_POS 0 +#define Y_MIN_POS 0 +#define Z_MIN_POS 0 +#define X_MAX_POS 200 +#define Y_MAX_POS 200 +#define Z_MAX_POS 200 + +//=========================================================================== +//========================= Filament Runout Sensor ========================== +//=========================================================================== +//#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament + // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. + // It is assumed that when logic high = filament available + // when logic low = filament ran out +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + +//=========================================================================== +//=========================== Manual Bed Leveling =========================== +//=========================================================================== + +// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling +// #define MESH_BED_LEVELING // Enable mesh bed leveling + +#ifdef MANUAL_BED_LEVELING + #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis +#endif // MANUAL_BED_LEVELING + +#ifdef MESH_BED_LEVELING + #define MESH_MIN_X 10 + #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X) + #define MESH_MIN_Y 10 + #define MESH_MAX_Y (Y_MAX_POS - MESH_MIN_Y) + #define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited + #define MESH_NUM_Y_POINTS 3 + #define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0 +#endif // MESH_BED_LEVELING + +//=========================================================================== +//============================ Bed Auto Leveling ============================ +//=========================================================================== + +// @section bedlevel + +//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) +#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled. + +#ifdef ENABLE_AUTO_BED_LEVELING + + // There are 2 different ways to specify probing locations + // + // - "grid" mode + // Probe several points in a rectangular grid. + // You specify the rectangle and the density of sample points. + // This mode is preferred because there are more measurements. + // + // - "3-point" mode + // Probe 3 arbitrary points on the bed (that aren't colinear) + // You specify the XY coordinates of all 3 points. + + // Enable this to sample the bed in a grid (least squares solution) + // Note: this feature generates 10KB extra code size + #define AUTO_BED_LEVELING_GRID + + #ifdef AUTO_BED_LEVELING_GRID + + #define LEFT_PROBE_BED_POSITION 15 + #define RIGHT_PROBE_BED_POSITION 170 + #define FRONT_PROBE_BED_POSITION 20 + #define BACK_PROBE_BED_POSITION 170 + + #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this + + // Set the number of grid points per dimension + // You probably don't need more than 3 (squared=9) + #define AUTO_BED_LEVELING_GRID_POINTS 2 + + #else // !AUTO_BED_LEVELING_GRID + + // Arbitrary points to probe. A simple cross-product + // is used to estimate the plane of the bed. + #define ABL_PROBE_PT_1_X 15 + #define ABL_PROBE_PT_1_Y 180 + #define ABL_PROBE_PT_2_X 15 + #define ABL_PROBE_PT_2_Y 20 + #define ABL_PROBE_PT_3_X 170 + #define ABL_PROBE_PT_3_Y 20 + + #endif // AUTO_BED_LEVELING_GRID + + // Offsets to the probe relative to the extruder tip (Hotend - Probe) + // X and Y offsets must be integers + #define X_PROBE_OFFSET_FROM_EXTRUDER -25 // Probe on: -left +right + #define Y_PROBE_OFFSET_FROM_EXTRUDER -29 // Probe on: -front +behind + #define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35 // -below (always!) + + #define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z before homing (G28) for Probe Clearance. + // Be sure you have this distance over your Z_MAX_POS in case + + #define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min + + #define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point. + #define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when traveling from between next probing points + #define Z_RAISE_AFTER_PROBING 15 //How much the extruder will be raised after the last probing point. + +// #define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" //These commands will be executed in the end of G29 routine. + //Useful to retract a deployable probe. + + //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell + //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like. + + //If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk + //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it. + // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile. + +// #define PROBE_SERVO_DEACTIVATION_DELAY 300 + + +//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing, +//it is highly recommended you let this Z_SAFE_HOMING enabled!!! + + #define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area. + // When defined, it will: + // - Allow Z homing only after X and Y homing AND stepper drivers still enabled + // - If stepper drivers timeout, it will need X and Y homing again before Z homing + // - Position the probe in a defined XY point before Z Homing when homing all axis (G28) + // - Block Z homing only when the probe is outside bed area. + + #ifdef Z_SAFE_HOMING + + #define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28) + #define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28) + + #endif + + // Support for a dedicated Z PROBE endstop separate from the Z MIN endstop. + // If you would like to use both a Z PROBE and a Z MIN endstop together or just a Z PROBE with a custom pin, uncomment #define Z_PROBE_ENDSTOP and read the instructions below. + // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. + // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. + // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 + // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. + // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. + // D32 is currently selected in the RAMPS 1.3/1.4 pin file. All other boards will need changes to the respective pins_XXXXX.h file. + // WARNING: Setting the wrong pin may have unexpected and potentially disastrous outcomes. Use with caution and do your homework. + + //#define Z_PROBE_ENDSTOP + +#endif // ENABLE_AUTO_BED_LEVELING + + +// @section homing + +// The position of the homing switches +//#define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used +//#define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0) + +// Manual homing switch locations: +// For deltabots this means top and center of the Cartesian print volume. +#ifdef MANUAL_HOME_POSITIONS + #define MANUAL_X_HOME_POS 0 + #define MANUAL_Y_HOME_POS 0 + #define MANUAL_Z_HOME_POS 0 + //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing. +#endif + +// @section movement + +/** + * MOVEMENT SETTINGS + */ + +#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min) + +// default settings + +#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402*2,78.7402*2,5120.00,760*1*1.5} // default steps per unit for Ultimaker +#define DEFAULT_MAX_FEEDRATE {300, 300, 5, 25} // (mm/sec) +#define DEFAULT_MAX_ACCELERATION {3000,3000,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_ACCELERATION 3000 // X, Y, Z and E acceleration in mm/s^2 for printing moves +#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration in mm/s^2 for retracts +#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves + +// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) +#define DEFAULT_XYJERK 20.0 // (mm/sec) +#define DEFAULT_ZJERK 0.4 // (mm/sec) +#define DEFAULT_EJERK 5.0 // (mm/sec) + + +//============================================================================= +//============================= Additional Features =========================== +//============================================================================= + +// @section more + +// Custom M code points +#define CUSTOM_M_CODES +#ifdef CUSTOM_M_CODES + #ifdef ENABLE_AUTO_BED_LEVELING + #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851 + #define Z_PROBE_OFFSET_RANGE_MIN -20 + #define Z_PROBE_OFFSET_RANGE_MAX 20 + #endif +#endif + +// @section extras + +// EEPROM +// The microcontroller can store settings in the EEPROM, e.g. max velocity... +// M500 - stores parameters in EEPROM +// 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 + +#ifdef EEPROM_SETTINGS + // To disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out: + #define EEPROM_CHITCHAT // please keep turned on if you can. +#endif + + +// @section temperature + +// Preheat Constants +#define PLA_PREHEAT_HOTEND_TEMP 180 +#define PLA_PREHEAT_HPB_TEMP 70 +#define PLA_PREHEAT_FAN_SPEED 0 // Insert Value between 0 and 255 + +#define ABS_PREHEAT_HOTEND_TEMP 240 +#define ABS_PREHEAT_HPB_TEMP 110 +#define ABS_PREHEAT_FAN_SPEED 0 // Insert Value between 0 and 255 + +//==============================LCD and SD support============================= +// @section lcd + +// Define your display language below. Replace (en) with your language code and uncomment. +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test +// See also language.h +#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) + +// Choose ONE of these 3 charsets. This has to match your hardware. Ignored for full graphic display. +// To find out what type you have - compile with (test) - upload - click to get the menu. You'll see two typical lines from the upper half of the charset. +// See also documentation/LCDLanguageFont.md + #define DISPLAY_CHARSET_HD44780_JAPAN // this is the most common hardware + //#define DISPLAY_CHARSET_HD44780_WESTERN + //#define DISPLAY_CHARSET_HD44780_CYRILLIC + +#define ULTRA_LCD //general LCD support, also 16x2 +//#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family) +#define SDSUPPORT // Enable SD Card Support in Hardware Console +//#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error) +#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication +//#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder +//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. +//#define ULTIPANEL //the UltiPanel as on Thingiverse +//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P +// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) +// http://reprap.org/wiki/PanelOne +//#define PANEL_ONE + +// The MaKr3d Makr-Panel with graphic controller and SD support +// http://reprap.org/wiki/MaKr3d_MaKrPanel +//#define MAKRPANEL + +// The Panucatt Devices Viki 2.0 and mini Viki with Graphic LCD +// http://panucatt.com +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +//#define VIKI2 +//#define miniVIKI + +// The RepRapDiscount Smart Controller (white PCB) +// http://reprap.org/wiki/RepRapDiscount_Smart_Controller +//#define REPRAP_DISCOUNT_SMART_CONTROLLER + +// The GADGETS3D G3D LCD/SD Controller (blue PCB) +// http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel +//#define G3D_PANEL + +// The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB) +// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller +// +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER + +// The RepRapWorld REPRAPWORLD_KEYPAD v1.1 +// http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626 +#define REPRAPWORLD_KEYPAD +#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // how much should be moved when a key is pressed, eg 10.0 means 10mm per click + +// The Elefu RA Board Control Panel +// http://www.elefu.com/index.php?route=product/product&product_id=53 +// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C +//#define RA_CONTROL_PANEL + +/** + * I2C Panels + */ + +//#define LCD_I2C_SAINSMART_YWROBOT + +// PANELOLU2 LCD with status LEDs, separate encoder and click inputs +//#define LCD_I2C_PANELOLU2 + +// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs +//#define LCD_I2C_VIKI + +// Shift register panels +// --------------------- +// 2 wire Non-latching LCD SR from: +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection + +//#define SAV_3DLCD + +// @section extras + +// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino +//#define FAST_PWM_FAN + +// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency +// which is not as annoying as with the hardware PWM. On the other hand, if this frequency +// is too low, you should also increment SOFT_PWM_SCALE. +//#define FAN_SOFT_PWM + +// Incrementing this by 1 will double the software PWM frequency, +// affecting heaters, and the fan if FAN_SOFT_PWM is enabled. +// However, control resolution will be halved for each increment; +// at zero value, there are 128 effective control positions. +#define SOFT_PWM_SCALE 0 + +// Temperature status LEDs that display the hotend and bet temperature. +// If all hotends and bed temperature and temperature setpoint are < 54C then the BLUE led is on. +// Otherwise the RED led is on. There is 1C hysteresis. +//#define TEMP_STAT_LEDS + +// 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 + +// SkeinForge sends the wrong arc g-codes when using Arc Point as fillet procedure +//#define SF_ARC_FIX + +// Support for the BariCUDA Paste Extruder. +//#define BARICUDA + +//define BlinkM/CyzRgb Support +//#define BLINKM + +/*********************************************************************\ +* R/C SERVO support +* Sponsored by TrinityLabs, Reworked by codexmas +**********************************************************************/ + +// Number of servos +// +// If you select a configuration below, this will receive a default value and does not need to be set manually +// set it manually if you have more servos than extruders and wish to manually control some +// leaving it undefined or defining as 0 will disable the servo subsystem +// If unsure, leave commented / disabled +// +//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command + +// Servo Endstops +// +// This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. +// Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. +// +//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles + +/**********************************************************************\ + * Support for a filament diameter sensor + * Also allows adjustment of diameter at print time (vs at slicing) + * Single extruder only at this point (extruder 0) + * + * Motherboards + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) + * 301 - Rambo - uses Analog input 3 + * Note may require analog pins to be defined for different motherboards + **********************************************************************/ +// Uncomment below to enable +//#define FILAMENT_SENSOR + +#define FILAMENT_SENSOR_EXTRUDER_NUM 0 //The number of the extruder that has the filament sensor (0,1,2) +#define MEASUREMENT_DELAY_CM 14 //measurement delay in cm. This is the distance from filament sensor to middle of barrel + +#define DEFAULT_NOMINAL_FILAMENT_DIA 3.0 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software. Used for sensor reading validation +#define MEASURED_UPPER_LIMIT 3.3 //upper limit factor used for sensor reading validation in mm +#define MEASURED_LOWER_LIMIT 1.9 //lower limit factor for sensor reading validation in mm +#define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) + +//defines used in the code +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially + +//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. +//#define FILAMENT_LCD_DISPLAY + + + + + + +#include "Configuration_adv.h" +#include "thermistortables.h" + +#endif //CONFIGURATION_H diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index f988eb7c69..ea21ee8e8b 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -30,7 +30,7 @@ Here are some standard links for getting your machine calibrated: // You might need Z-Min endstop on SCARA-Printer to use this feature. Actually untested! // Uncomment to use Morgan scara mode #define SCARA -#define scara_segments_per_second 200 //careful, two much will decrease performance... +#define SCARA_SEGMENTS_PER_SECOND 200 // If movement is choppy try lowering this value // Length of inner support arm #define Linkage_1 150 //mm Preprocessor cannot handle decimal point... // Length of outer support arm Measure arm lengths precisely and enter @@ -288,44 +288,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: - -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -402,17 +382,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define Z_MAX_POS 225 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -433,7 +416,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index a706696aad..af4429b7e6 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 3000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -376,6 +400,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 308a05a6e4..8fb3e30fa6 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -256,44 +256,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius - -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -370,17 +350,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define Z_MAX_POS 200 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -401,7 +384,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 25abd17c2c..da2281eaf8 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -374,7 +398,16 @@ const unsigned int dropsegments=5; //everything with less than this number of st //The ASCII buffer for receiving from the serial: #define MAX_CMD_SIZE 96 -#define BUFSIZE 5 +#define BUFSIZE 4 + +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK // @section fwretract diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h new file mode 100644 index 0000000000..908acce5ab --- /dev/null +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -0,0 +1,803 @@ +#ifndef CONFIGURATION_H +#define CONFIGURATION_H + +#include "boards.h" + +//=========================================================================== +//============================= Getting Started ============================= +//=========================================================================== +/* +Here are some standard links for getting your machine calibrated: + * http://reprap.org/wiki/Calibration + * http://youtu.be/wAL9d7FgInk + * http://calculator.josefprusa.cz + * http://reprap.org/wiki/Triffid_Hunter%27s_Calibration_Guide + * http://www.thingiverse.com/thing:5573 + * https://sites.google.com/site/repraplogphase/calibration-of-your-reprap + * http://www.thingiverse.com/thing:298812 +*/ + +// This configuration file contains the basic settings. +// Advanced settings can be found in Configuration_adv.h +// BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration + +//=========================================================================== +//============================= DELTA Printer =============================== +//=========================================================================== +// For a Delta printer replace the configuration files with the files in the +// example_configurations/delta directory. +// + +//=========================================================================== +//============================= SCARA Printer =============================== +//=========================================================================== +// For a Delta printer replace the configuration files with the files in the +// example_configurations/SCARA directory. +// + +// User-specified version info of this build 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 +// build by the user have been successfully uploaded into firmware. +#define STRING_VERSION "1.0.3 dev" +#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time +#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. +#define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 +//#define STRING_SPLASH_LINE2 STRING_VERSION_CONFIG_H // will be shown during bootup in line2 + +// SERIAL_PORT selects which serial port should be used for communication with the host. +// This allows the connection of wireless adapters (for instance) to non-default port pins. +// Serial port 0 is still used by the Arduino bootloader regardless of this setting. +#define SERIAL_PORT 0 + +// This determines the communication speed of the printer +#define BAUDRATE 250000 + +// This enables the serial port associated to the Bluetooth interface +//#define BTENABLED // Enable BT interface on AT90USB devices + +// The following define selects which electronics board you have. +// Please choose the name from boards.h that matches your setup +#ifndef MOTHERBOARD + #define MOTHERBOARD BOARD_RUMBA +#endif + +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +#define CUSTOM_MACHINE_NAME "BI V2.5" + +// Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) +// You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) +// #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" + +// This defines the number of extruders +#define EXTRUDERS 2 + +//// The following define selects which power supply you have. Please choose the one that matches your setup +// 1 = ATX +// 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC) + +#define POWER_SUPPLY 1 + +// Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it. +// #define PS_DEFAULT_OFF + + +//=========================================================================== +//============================== Delta Settings ============================= +//=========================================================================== +// Enable DELTA kinematics and most of the default configuration for Deltas +#define DELTA + +// Make delta curves from many straight lines (linear interpolation). +// This is a trade-off between visible corners (not enough segments) +// and processor overload (too many expensive sqrt calls). +#define DELTA_SEGMENTS_PER_SECOND 100 + +// NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them + +// Center-to-center distance of the holes in the diagonal push rods. +#define DELTA_DIAGONAL_ROD 440.0 // mm + +// Horizontal offset from middle of printer to smooth rod center. +#define DELTA_SMOOTH_ROD_OFFSET 330.0 // mm + +// Horizontal offset of the universal joints on the end effector. +#define DELTA_EFFECTOR_OFFSET 50.0 // mm + +// Horizontal offset of the universal joints on the carriages. +#define DELTA_CARRIAGE_OFFSET 20.0 // mm + +// Horizontal distance bridged by diagonal push rods when effector is centered. +#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET) + +// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). +#define DELTA_PRINTABLE_RADIUS 160 + + +//=========================================================================== +//============================= Thermal Settings ============================ +//=========================================================================== +// +//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table +// +//// 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 - 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 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup) +// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) +// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) +// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) +// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) +// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) +// 10 is 100k RS thermistor 198-961 (4.7k pullup) +// 11 is 100k beta 3950 1% thermistor (4.7k pullup) +// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 20 is the PT100 circuit found in the Ultimainboard V2.x +// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 +// +// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k +// (but gives greater accuracy and more stable PID) +// 51 is 100k thermistor - EPCOS (1k pullup) +// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup) +// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) +// +// 1047 is Pt1000 with 4k7 pullup +// 1010 is Pt1000 with 1k pullup (non standard) +// 147 is Pt100 with 4k7 pullup +// 110 is Pt100 with 1k pullup (non standard) +// 998 and 999 are Dummy Tables. They will ALWAYS read 25°C or the temperature defined below. +// Use it for Testing or Development purposes. NEVER for production machine. +// #define DUMMY_THERMISTOR_998_VALUE 25 +// #define DUMMY_THERMISTOR_999_VALUE 100 +// :{ '0': "Not used", '4': "10k !! do not use for a hotend. Bad resolution at high temp. !!", '1': "100k / 4.7k - EPCOS", '51': "100k / 1k - EPCOS", '6': "100k / 4.7k EPCOS - Not as accurate as Table 1", '5': "100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '7': "100k / 4.7k Honeywell 135-104LAG-J01", '71': "100k / 4.7k Honeywell 135-104LAF-J01", '8': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9': "100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10': "100k / 4.7k RS 198-961", '11': "100k / 4.7k beta 3950 1%", '12': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13': "100k Hisens 3950 1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '60': "100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '55': "100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '2': "200k / 4.7k - ATC Semitec 204GT-2", '52': "200k / 1k - ATC Semitec 204GT-2", '-2': "Thermocouple + MAX6675 (only for sensor 0)", '-1': "Thermocouple + AD595", '3': "Mendel-parts / 4.7k", '1047': "Pt1000 / 4.7k", '1010': "Pt1000 / 1k (non standard)", '20': "PT100 (Ultimainboard V2.x)", '147': "Pt100 / 4.7k", '110': "Pt100 / 1k (non-standard)", '998': "Dummy 1", '999': "Dummy 2" } +#define TEMP_SENSOR_0 5 +#define TEMP_SENSOR_1 5 +#define TEMP_SENSOR_2 0 +#define TEMP_SENSOR_3 0 +#define TEMP_SENSOR_BED 1 + +// This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted. +//#define TEMP_SENSOR_1_AS_REDUNDANT +#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 + +// Actual temperature must be close to target for this long before M109 returns success +#define TEMP_RESIDENCY_TIME 10 // (seconds) +#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one +#define TEMP_WINDOW 1 // (degC) Window around target to start the residency 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 HEATER_3_MINTEMP 5 +#define BED_MINTEMP 5 + +// 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_3_MAXTEMP 275 +#define BED_MAXTEMP 150 + +// If your bed has low resistance e.g. .6 ohm and throws the fuse you can duty cycle it to reduce the +// average current. The value should be an integer and the heat bed will be turned on for 1 interval of +// HEATER_BED_DUTY_CYCLE_DIVIDER intervals. +//#define HEATER_BED_DUTY_CYCLE_DIVIDER 4 + +// If you want the M105 heater power reported in watts, define the BED_WATTS, and (shared for all extruders) EXTRUDER_WATTS +//#define EXTRUDER_WATTS (12.0*12.0/6.7) // P=I^2/R +//#define BED_WATTS (12.0*12.0/1.1) // P=I^2/R + +//=========================================================================== +//============================= PID Settings ================================ +//=========================================================================== +// PID Tuning Guide here: http://reprap.org/wiki/PID_Tuning + +// Comment the following line to disable PID and enable bang-bang. +#define PIDTEMP +#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current +#define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current +#ifdef PIDTEMP + //#define PID_DEBUG // Sends debug data to the serial port. + //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX + //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay + //#define PID_PARAMS_PER_EXTRUDER // Uses separate PID parameters for each extruder (useful for mismatched extruders) + // Set/get with gcode: M301 E[extruder number, 0-2] + #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature + // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. + #define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term + #define K1 0.95 //smoothing factor within the PID + +// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it +// Ultimaker + #define DEFAULT_Kp 22.2 + #define DEFAULT_Ki 1.08 + #define DEFAULT_Kd 114 + +// MakerGear +// #define DEFAULT_Kp 7.0 +// #define DEFAULT_Ki 0.1 +// #define DEFAULT_Kd 12 + +// Mendel Parts V9 on 12V +// #define DEFAULT_Kp 63.0 +// #define DEFAULT_Ki 2.25 +// #define DEFAULT_Kd 440 +#endif // PIDTEMP + +//=========================================================================== +//============================= PID > Bed Temperature Control =============== +//=========================================================================== +// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis +// +// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. +// If your PID_dT is the default, and correct for your hardware/configuration, that means 7.689Hz, +// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating. +// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. +// If your configuration is significantly different than this and you don't understand the issues involved, you probably +// shouldn't use bed PID until someone else verifies your hardware works. +// If this is enabled, find your own PID constants below. +//#define PIDTEMPBED +// +//#define BED_LIMIT_SWITCHING + +// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option. +// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis) +// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did, +// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED) +#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current + +//#define PID_BED_DEBUG // Sends debug data to the serial port. + +#ifdef PIDTEMPBED +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) + #define DEFAULT_bedKp 10.00 + #define DEFAULT_bedKi .023 + #define DEFAULT_bedKd 305.4 + +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from pidautotune +// #define DEFAULT_bedKp 97.1 +// #define DEFAULT_bedKi 1.41 +// #define DEFAULT_bedKd 1675.16 + +// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. +#endif // PIDTEMPBED + + +//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 +//if PREVENT_DANGEROUS_EXTRUDE is on, you can still disable (uncomment) very long bits of extrusion separately. +#define PREVENT_LENGTHY_EXTRUDE + +#define EXTRUDE_MINTEMP 170 +#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. + +//=========================================================================== +//======================== Thermal Runaway Protection ======================= +//=========================================================================== + +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ + +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed + +//=========================================================================== +//============================= Mechanical Settings ========================= +//=========================================================================== + +// Uncomment this option to enable CoreXY kinematics +// #define COREXY + +// Enable this option for Toshiba steppers +// #define CONFIG_STEPPERS_TOSHIBA + +// coarse Endstop Settings +#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors + +#ifndef ENDSTOPPULLUPS + // fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined + // #define ENDSTOPPULLUP_XMAX + // #define ENDSTOPPULLUP_YMAX + // #define ENDSTOPPULLUP_ZMAX + // #define ENDSTOPPULLUP_XMIN + // #define ENDSTOPPULLUP_YMIN + // #define ENDSTOPPULLUP_ZMIN +#endif + +// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). +const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +//#define DISABLE_MAX_ENDSTOPS +#define DISABLE_MIN_ENDSTOPS // Deltas only use min endstops for probing + +// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 +#define X_ENABLE_ON 0 +#define Y_ENABLE_ON 0 +#define Z_ENABLE_ON 0 +#define E_ENABLE_ON 0 // For all extruders + +// Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! +#define DISABLE_X false +#define DISABLE_Y false +#define DISABLE_Z false +#define DISABLE_E false // For all extruders +#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled + +// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. +#define INVERT_X_DIR false // DELTA does not invert +#define INVERT_Y_DIR false +#define INVERT_Z_DIR false +#define INVERT_E0_DIR false +#define INVERT_E1_DIR false +#define INVERT_E2_DIR false +#define INVERT_E3_DIR false + +// ENDSTOP SETTINGS: +// Sets direction of endstops when homing; 1=MAX, -1=MIN +#define X_HOME_DIR 1 // deltas always home to max +#define Y_HOME_DIR 1 +#define Z_HOME_DIR 1 + +#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS. +#define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below. + +// Travel limits after homing (units are in mm) +#define X_MIN_POS -DELTA_PRINTABLE_RADIUS +#define Y_MIN_POS -DELTA_PRINTABLE_RADIUS +#define Z_MIN_POS 0 +#define X_MAX_POS DELTA_PRINTABLE_RADIUS +#define Y_MAX_POS DELTA_PRINTABLE_RADIUS +#define Z_MAX_POS MANUAL_Z_HOME_POS + +//=========================================================================== +//========================= Filament Runout Sensor ========================== +//=========================================================================== +//#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament + // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. + // It is assumed that when logic high = filament available + // when logic low = filament ran out +//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned +//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + +//=========================================================================== +//=========================== Manual Bed Leveling =========================== +//=========================================================================== + +// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling +// #define MESH_BED_LEVELING // Enable mesh bed leveling + +#ifdef MANUAL_BED_LEVELING + #define MBL_Z_STEP 0.025 +#endif // MANUAL_BED_LEVELING + +#ifdef MESH_BED_LEVELING + #define MESH_MIN_X 10 + #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X) + #define MESH_MIN_Y 10 + #define MESH_MAX_Y (Y_MAX_POS - MESH_MIN_Y) + #define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited + #define MESH_NUM_Y_POINTS 3 + #define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0 +#endif // MESH_BED_LEVELING + +//=========================================================================== +//============================ Bed Auto Leveling ============================ +//=========================================================================== + +//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) +//#define Z_PROBE_REPEATABILITY_TEST // Z-Probe Repeatability test is not supported in Deltas yet. + +#ifdef ENABLE_AUTO_BED_LEVELING + + // There are 2 different ways to specify probing locations + // + // - "grid" mode + // Probe several points in a rectangular grid. + // You specify the rectangle and the density of sample points. + // This mode is preferred because there are more measurements. + // + // - "3-point" mode + // Probe 3 arbitrary points on the bed (that aren't colinear) + // You specify the XY coordinates of all 3 points. + + // Enable this to sample the bed in a grid (least squares solution) + // Note: this feature generates 10KB extra code size + #define AUTO_BED_LEVELING_GRID // Deltas only support grid mode + + #ifdef AUTO_BED_LEVELING_GRID + + #define DELTA_PROBABLE_RADIUS (DELTA_PRINTABLE_RADIUS - 10) + + #define LEFT_PROBE_BED_POSITION -DELTA_PROBABLE_RADIUS + #define RIGHT_PROBE_BED_POSITION DELTA_PROBABLE_RADIUS + #define FRONT_PROBE_BED_POSITION -DELTA_PROBABLE_RADIUS + #define BACK_PROBE_BED_POSITION DELTA_PROBABLE_RADIUS + + #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this + + // Non-linear bed leveling will be used. + // Compensate by interpolating between the nearest four Z probe values for each point. + // Useful for deltas where the print surface may appear like a bowl or dome shape. + // Works best with ACCURATE_BED_LEVELING_POINTS 5 or higher. + #define AUTO_BED_LEVELING_GRID_POINTS 9 + + #else // !AUTO_BED_LEVELING_GRID + + // Arbitrary points to probe. A simple cross-product + // is used to estimate the plane of the bed. + #define ABL_PROBE_PT_1_X 15 + #define ABL_PROBE_PT_1_Y 180 + #define ABL_PROBE_PT_2_X 15 + #define ABL_PROBE_PT_2_Y 20 + #define ABL_PROBE_PT_3_X 170 + #define ABL_PROBE_PT_3_Y 20 + + #endif // AUTO_BED_LEVELING_GRID + + // Offsets to the probe relative to the extruder tip (Hotend - Probe) + // X and Y offsets must be integers + #define X_PROBE_OFFSET_FROM_EXTRUDER 0 // Probe on: -left +right + #define Y_PROBE_OFFSET_FROM_EXTRUDER -10 // Probe on: -front +behind + #define Z_PROBE_OFFSET_FROM_EXTRUDER -3.5 // -below (always!) + + #define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z before homing (G28) for Probe Clearance. + // Be sure you have this distance over your Z_MAX_POS in case + + #define XY_TRAVEL_SPEED 4000 // X and Y axis travel speed between probes, in mm/min + + #define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point. + #define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when traveling from between next probing points + #define Z_RAISE_AFTER_PROBING 50 //How much the extruder will be raised after the last probing point. + +// #define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" //These commands will be executed in the end of G29 routine. + //Useful to retract a deployable probe. + + //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell + //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like. + + // Allen key retractable z-probe as seen on many Kossel delta printers - http://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe + // Deploys by touching z-axis belt. Retracts by pushing the probe down. Uses Z_MIN_PIN. + //#define Z_PROBE_ALLEN_KEY + #ifdef Z_PROBE_ALLEN_KEY + #define Z_PROBE_ALLEN_KEY_DEPLOY_X 30 + #define Z_PROBE_ALLEN_KEY_DEPLOY_Y DELTA_PRINTABLE_RADIUS + #define Z_PROBE_ALLEN_KEY_DEPLOY_Z 100 + + #define Z_PROBE_ALLEN_KEY_STOW_X -64 + #define Z_PROBE_ALLEN_KEY_STOW_Y 56 + #define Z_PROBE_ALLEN_KEY_STOW_Z 23 + #define Z_PROBE_ALLEN_KEY_STOW_DEPTH 20 + #endif + + //If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk + //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it. + // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile. + +// #define PROBE_SERVO_DEACTIVATION_DELAY 300 + + +//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing, +//it is highly recommended you let this Z_SAFE_HOMING enabled!!! + + #define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area. + // When defined, it will: + // - Allow Z homing only after X and Y homing AND stepper drivers still enabled + // - If stepper drivers timeout, it will need X and Y homing again before Z homing + // - Position the probe in a defined XY point before Z Homing when homing all axis (G28) + // - Block Z homing only when the probe is outside bed area. + + #ifdef Z_SAFE_HOMING + + #define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28) + #define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28) + + #endif + + // Support for a dedicated Z PROBE endstop separate from the Z MIN endstop. + // If you would like to use both a Z PROBE and a Z MIN endstop together or just a Z PROBE with a custom pin, uncomment #define Z_PROBE_ENDSTOP and read the instructions below. + // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. + // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. + // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 + // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. + // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. + // D32 is currently selected in the RAMPS 1.3/1.4 pin file. All other boards will need changes to the respective pins_XXXXX.h file. + // WARNING: Setting the wrong pin may have unexpected and potentially disastrous outcomes. Use with caution and do your homework. + + //#define Z_PROBE_ENDSTOP + +#endif // ENABLE_AUTO_BED_LEVELING + + +// The position of the homing switches +#define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used +//#define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0) + +// Manual homing switch locations: +// For deltabots this means top and center of the Cartesian print volume. +#ifdef MANUAL_HOME_POSITIONS + #define MANUAL_X_HOME_POS 0 + #define MANUAL_Y_HOME_POS 0 + #define MANUAL_Z_HOME_POS 405 // For delta: Distance between nozzle and print surface after homing. +#endif + +/** + * MOVEMENT SETTINGS + */ + + +// delta homing speeds must be the same on xyz +#define HOMING_FEEDRATE {200*30, 200*30, 200*30, 0} // set the homing speeds (mm/min) + +// default settings +// delta speeds must be the same on xyz +#define DEFAULT_AXIS_STEPS_PER_UNIT {72.9, 72.9, 72.9, 291} // default steps per unit for BI v2.5 (cable drive) +#define DEFAULT_MAX_FEEDRATE {500, 500, 500, 150} // (mm/sec) +#define DEFAULT_MAX_ACCELERATION {9000,9000,9000,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_ACCELERATION 3000 // X, Y, Z and E acceleration in mm/s^2 for printing moves +#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration in mm/s^2 for retracts +#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves + +// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). +// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). +// For the other hotends it is their distance from the extruder 0 hotend. +// #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis +// #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis + +// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) +#define DEFAULT_XYJERK 15.0 // (mm/sec) +#define DEFAULT_ZJERK 15.0 // (mm/sec) Must be same as XY for delta +#define DEFAULT_EJERK 5.0 // (mm/sec) + + +//============================================================================= +//============================= Additional Features =========================== +//============================================================================= + +// Custom M code points +#define CUSTOM_M_CODES +#ifdef CUSTOM_M_CODES + #ifdef ENABLE_AUTO_BED_LEVELING + #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851 + #define Z_PROBE_OFFSET_RANGE_MIN -20 + #define Z_PROBE_OFFSET_RANGE_MAX 20 + #endif +#endif + + +// EEPROM +// The microcontroller can store settings in the EEPROM, e.g. max velocity... +// M500 - stores parameters in EEPROM +// 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 + +#ifdef EEPROM_SETTINGS + // To disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out: + #define EEPROM_CHITCHAT // please keep turned on if you can. +#endif + +// 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 + +//==============================LCD and SD support============================= + +// Define your display language below. Replace (en) with your language code and uncomment. +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test +// See also language.h +#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) + +// Choose ONE of these 3 charsets. This has to match your hardware. Ignored for full graphic display. +// To find out what type you have - compile with (test) - upload - click to get the menu. You'll see two typical lines from the upper half of the charset. +// See also documentation/LCDLanguageFont.md + #define DISPLAY_CHARSET_HD44780_JAPAN // this is the most common hardware + //#define DISPLAY_CHARSET_HD44780_WESTERN + //#define DISPLAY_CHARSET_HD44780_CYRILLIC + +//#define ULTRA_LCD //general LCD support, also 16x2 +//#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family) +//#define SDSUPPORT // Enable SD Card Support in Hardware Console +//#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error) +//#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication +//#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder +//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. +//#define ULTIPANEL //the UltiPanel as on Thingiverse +//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P + +// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) +// http://reprap.org/wiki/PanelOne +//#define PANEL_ONE + +// The MaKr3d Makr-Panel with graphic controller and SD support +// http://reprap.org/wiki/MaKr3d_MaKrPanel +//#define MAKRPANEL + +// The Panucatt Devices Viki 2.0 and mini Viki with Graphic LCD +// http://panucatt.com +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +//#define VIKI2 +//#define miniVIKI + +// The RepRapDiscount Smart Controller (white PCB) +// http://reprap.org/wiki/RepRapDiscount_Smart_Controller +//#define REPRAP_DISCOUNT_SMART_CONTROLLER + +// The GADGETS3D G3D LCD/SD Controller (blue PCB) +// http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel +//#define G3D_PANEL + +// The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB) +// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller +// +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER + +// The RepRapWorld REPRAPWORLD_KEYPAD v1.1 +// http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626 +//#define REPRAPWORLD_KEYPAD +//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // how much should be moved when a key is pressed, eg 10.0 means 10mm per click + +// The Elefu RA Board Control Panel +// http://www.elefu.com/index.php?route=product/product&product_id=53 +// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C +//#define RA_CONTROL_PANEL + +// Delta calibration menu +// uncomment to add three points calibration menu option. +// See http://minow.blogspot.com/index.html#4918805519571907051 +// If needed, adjust the X, Y, Z calibration coordinates +// in ultralcd.cpp@lcd_delta_calibrate_menu() +// #define DELTA_CALIBRATION_MENU + +/** + * I2C Panels + */ + +//#define LCD_I2C_SAINSMART_YWROBOT + +// PANELOLU2 LCD with status LEDs, separate encoder and click inputs +//#define LCD_I2C_PANELOLU2 + +// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs +//#define LCD_I2C_VIKI + +// Shift register panels +// --------------------- +// 2 wire Non-latching LCD SR from: +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection + +//#define SAV_3DLCD + +// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino +//#define FAST_PWM_FAN + +// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency +// which is not as annoying as with the hardware PWM. On the other hand, if this frequency +// is too low, you should also increment SOFT_PWM_SCALE. +//#define FAN_SOFT_PWM + +// Incrementing this by 1 will double the software PWM frequency, +// affecting heaters, and the fan if FAN_SOFT_PWM is enabled. +// However, control resolution will be halved for each increment; +// at zero value, there are 128 effective control positions. +#define SOFT_PWM_SCALE 0 + +// Temperature status LEDs that display the hotend and bet temperature. +// If all hotends and bed temperature and temperature setpoint are < 54C then the BLUE led is on. +// Otherwise the RED led is on. There is 1C hysteresis. +//#define TEMP_STAT_LEDS + +// 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 + +// SF send wrong arc g-codes when using Arc Point as fillet procedure +//#define SF_ARC_FIX + +// Support for the BariCUDA Paste Extruder. +//#define BARICUDA + +//define BlinkM/CyzRgb Support +//#define BLINKM + +/*********************************************************************\ +* R/C SERVO support +* Sponsored by TrinityLabs, Reworked by codexmas +**********************************************************************/ + +// Number of servos +// +// If you select a configuration below, this will receive a default value and does not need to be set manually +// set it manually if you have more servos than extruders and wish to manually control some +// leaving it undefined or defining as 0 will disable the servo subsystem +// If unsure, leave commented / disabled +// +//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command + +// Servo Endstops +// +// This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. +// Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. +// +//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles + +/**********************************************************************\ + * Support for a filament diameter sensor + * Also allows adjustment of diameter at print time (vs at slicing) + * Single extruder only at this point (extruder 0) + * + * Motherboards + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) + * 301 - Rambo - uses Analog input 3 + * Note may require analog pins to be defined for different motherboards + **********************************************************************/ +// Uncomment below to enable +//#define FILAMENT_SENSOR + +#define FILAMENT_SENSOR_EXTRUDER_NUM 0 //The number of the extruder that has the filament sensor (0,1,2) +#define MEASUREMENT_DELAY_CM 14 //measurement delay in cm. This is the distance from filament sensor to middle of barrel + +#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software. Used for sensor reading validation +#define MEASURED_UPPER_LIMIT 3.30 //upper limit factor used for sensor reading validation in mm +#define MEASURED_LOWER_LIMIT 1.90 //lower limit factor for sensor reading validation in mm +#define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) + +//defines used in the code +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially + +//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. +//#define FILAMENT_LCD_DISPLAY + + + + + + +#include "Configuration_adv.h" +#include "thermistortables.h" + +#endif //CONFIGURATION_H diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h new file mode 100644 index 0000000000..e193015cc3 --- /dev/null +++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h @@ -0,0 +1,585 @@ +#ifndef CONFIGURATION_ADV_H +#define CONFIGURATION_ADV_H + +#include "Conditionals.h" + +// @section temperature + +//=========================================================================== +//=============================Thermal Settings ============================ +//=========================================================================== + +#ifdef BED_LIMIT_SWITCHING + #define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS +#endif +#define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control + +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 120 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 4 // Degrees Celsius +#endif + +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ +#ifdef PIDTEMP + // this adds an experimental additional term to the heating power, proportional to the extrusion speed. + // if Kc is chosen well, the additional required power due to increased melting should be compensated. + #define PID_ADD_EXTRUSION_RATE + #ifdef PID_ADD_EXTRUSION_RATE + #define DEFAULT_Kc (1) //heating power=Kc*(e_speed) + #endif +#endif + + +//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode. +//The maximum buffered steps/sec of the extruder motor are called "se". +//You enter the autotemp mode by a M109 S B F +// the target temperature is set to mintemp+factor*se[steps/sec] and limited by mintemp and maxtemp +// you exit the value by any M109 without F* +// Also, if the temperature is set to a value Z2 (yes, it is.. think about it) and the Z adjust would be positive. + // Play a little bit with small adjustments (0.5mm) and check the behaviour. + // The M119 (endstops report) will start reporting the Z2 Endstop as well. + + #define Z_DUAL_ENDSTOPS + + #ifdef Z_DUAL_ENDSTOPS + #define Z2_STEP_PIN E2_STEP_PIN // Stepper to be used to Z2 axis. + #define Z2_DIR_PIN E2_DIR_PIN + #define Z2_ENABLE_PIN E2_ENABLE_PIN + #define Z2_MAX_PIN 36 //Endstop used for Z2 axis. In this case I'm using XMAX in a Rumba Board (pin 36) + const bool Z2_MAX_ENDSTOP_INVERTING = false; + #define DISABLE_XMAX_ENDSTOP //Better to disable the XMAX to avoid conflict. Just rename "XMAX_ENDSTOP" by the endstop you are using for Z2 axis. + #endif + +#endif // Z_DUAL_STEPPER_DRIVERS + +// Same again but for Y Axis. +//#define Y_DUAL_STEPPER_DRIVERS + +// Define if the two Y drives need to rotate in opposite directions +#define INVERT_Y2_VS_Y_DIR true + +// Enable this for dual x-carriage printers. +// A dual x-carriage design has the advantage that the inactive extruder can be parked which +// prevents hot-end ooze contaminating the print. It also reduces the weight of each x-carriage +// allowing faster printing speeds. +//#define DUAL_X_CARRIAGE +#ifdef DUAL_X_CARRIAGE + // Configuration for second X-carriage + // Note: the first x-carriage is defined as the x-carriage which homes to the minimum endstop; + // the second x-carriage always homes to the maximum endstop. + #define X2_MIN_POS 80 // set minimum to ensure second x-carriage doesn't hit the parked first X-carriage + #define X2_MAX_POS 353 // set maximum to the distance between toolheads when both heads are homed + #define X2_HOME_DIR 1 // the second X-carriage always homes to the maximum endstop position + #define X2_HOME_POS X2_MAX_POS // default home position is the maximum carriage position + // However: In this mode the EXTRUDER_OFFSET_X value for the second extruder provides a software + // override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops + // without modifying the firmware (through the "M218 T1 X???" command). + // Remember: you should set the second extruder x-offset to 0 in your slicer. + + // Pins for second x-carriage stepper driver (defined here to avoid further complicating pins.h) + #define X2_ENABLE_PIN 29 + #define X2_STEP_PIN 25 + #define X2_DIR_PIN 23 + + // There are a few selectable movement modes for dual x-carriages using M605 S + // Mode 0: Full control. The slicer has full control over both x-carriages and can achieve optimal travel results + // as long as it supports dual x-carriages. (M605 S0) + // Mode 1: Auto-park mode. The firmware will automatically park and unpark the x-carriages on tool changes so + // that additional slicer support is not required. (M605 S1) + // Mode 2: Duplication mode. The firmware will transparently make the second x-carriage and extruder copy all + // actions of the first x-carriage. This allows the printer to print 2 arbitrary items at + // once. (2nd extruder x offset and temp offset are set using: M605 S2 [Xnnn] [Rmmm]) + + // This is the default power-up mode which can be later using M605. + #define DEFAULT_DUAL_X_CARRIAGE_MODE 0 + + // Default settings in "Auto-park Mode" + #define TOOLCHANGE_PARK_ZLIFT 0.2 // the distance to raise Z axis when parking an extruder + #define TOOLCHANGE_UNPARK_ZLIFT 1 // the distance to raise Z axis when unparking an extruder + + // Default x offset in duplication mode (typically set to half print bed width) + #define DEFAULT_DUPLICATION_X_OFFSET 100 + +#endif //DUAL_X_CARRIAGE + +// @section homing + +//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again: +#define X_HOME_BUMP_MM 5 +#define Y_HOME_BUMP_MM 5 +#define Z_HOME_BUMP_MM 5 // deltas need the same for all three axis +#define HOMING_BUMP_DIVISOR {10, 10, 20} // Re-Bump Speed Divisor (Divides the Homing Feedrate) +//#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. + +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + +// @section machine + +#define AXIS_RELATIVE_MODES {false, false, false, false} + +// @section machine + +//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step. +#define INVERT_X_STEP_PIN false +#define INVERT_Y_STEP_PIN false +#define INVERT_Z_STEP_PIN false +#define INVERT_E_STEP_PIN false + +// Default stepper release if idle. Set to 0 to deactivate. +#define DEFAULT_STEPPER_DEACTIVE_TIME 0 + +#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate +#define DEFAULT_MINTRAVELFEEDRATE 0.0 + +// @section lcd + +#ifdef ULTIPANEL + #define MANUAL_FEEDRATE {50*60, 50*60, 4*60, 60} // Feedrates for manual moves along X, Y, Z, E from panel + #define ULTIPANEL_FEEDMULTIPLY // Comment to disable setting feedrate multiplier via encoder +#endif + +// @section extras + +// minimum time in microseconds that a movement needs to take if the buffer is emptied. +#define DEFAULT_MINSEGMENTTIME 20000 + +// If defined the movements slow down when the look ahead buffer is only half full +// (don't use SLOWDOWN with DELTA because DELTA generates hundreds of segments per second) +//#define SLOWDOWN + +// Frequency limit +// See nophead's blog for more info +// Not working O +//#define XY_FREQUENCY_LIMIT 15 + +// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end +// of the buffer and all stops. This should not be much greater than zero and should only be changed +// if unwanted behavior is observed on a user's machine when running at very slow speeds. +#define MINIMUM_PLANNER_SPEED 0.05// (mm/sec) + +// Microstep setting (Only functional when stepper driver microstep pins are connected to MCU. +#define MICROSTEP_MODES {16,16,16,16,16} // [1,2,4,8,16] + +// Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) +#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) + +// uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro +//#define DIGIPOT_I2C +// Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 +#define DIGIPOT_I2C_NUM_CHANNELS 8 +// actual motor currents in Amps, need as many here as DIGIPOT_I2C_NUM_CHANNELS +#define DIGIPOT_I2C_MOTOR_CURRENTS {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0} + +//=========================================================================== +//=============================Additional Features=========================== +//=========================================================================== + +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value + +//#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ +#define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again + +// @section lcd + +#ifdef SDSUPPORT + + // 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 + + #define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers? + #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place. + + #define SDCARD_RATHERRECENTFIRST //reverse file order of sd card menu display. Its sorted practically after the file system block order. + // if a file is deleted, it frees a block. hence, the order is not purely chronological. To still have auto0.g accessible, there is again the option to do that. + // using: + //#define MENU_ADDAUTOSTART + + // Show a progress bar on HD44780 LCDs for SD printing + //#define LCD_PROGRESS_BAR + + #ifdef LCD_PROGRESS_BAR + // Amount of time (ms) to show the bar + #define PROGRESS_BAR_BAR_TIME 2000 + // Amount of time (ms) to show the status message + #define PROGRESS_BAR_MSG_TIME 3000 + // Amount of time (ms) to retain the status message (0=forever) + #define PROGRESS_MSG_EXPIRE 0 + // Enable this to show messages for MSG_TIME then hide them + //#define PROGRESS_MSG_ONCE + #endif + +#endif // SDSUPPORT + +// @section more + +// The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation. +//#define USE_WATCHDOG + +#ifdef USE_WATCHDOG +// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on. +// The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset. +// However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled. +//#define WATCHDOG_RESET_MANUAL +#endif + +// Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled. +//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + +// @section lcd + +// Babystepping enables the user to control the axis in tiny amounts, independently from the normal printing process +// it can e.g. be used to change z-positions in the print startup phase in real-time +// does not respect endstops! +//#define BABYSTEPPING +#ifdef BABYSTEPPING + #define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions + #define BABYSTEP_INVERT_Z false //true for inverse movements in Z + #define BABYSTEP_Z_MULTIPLICATOR 2 //faster z movements +#endif + +// @section extruder + +// extruder advance constant (s2/mm3) +// +// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K * cubic mm per second ^ 2 +// +// Hooke's law says: force = k * distance +// Bernoulli's principle says: v ^ 2 / 2 + g . h + pressure / density = constant +// so: v ^ 2 is proportional to number of steps we advance the extruder +//#define ADVANCE + +#ifdef ADVANCE + #define EXTRUDER_ADVANCE_K .0 + #define D_FILAMENT 2.85 + #define STEPS_MM_E 836 +#endif + +// @section extras + +// Arc interpretation settings: +#define MM_PER_ARC_SEGMENT 1 +#define N_ARC_CORRECTION 25 + +const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement + +// @section temperature + +// Control heater 0 and heater 1 in parallel. +//#define HEATERS_PARALLEL + +//=========================================================================== +//================================= Buffers ================================= +//=========================================================================== + +// @section hidden + +// The number of linear motions that can be in the plan at any give time. +// 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 ring-buffering. +#ifdef SDSUPPORT + #define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller +#else + #define BLOCK_BUFFER_SIZE 16 // maximize block buffer +#endif + +// @section more + +//The ASCII buffer for receiving from the serial: +#define MAX_CMD_SIZE 96 +#define BUFSIZE 4 + +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + +// @section fwretract + +// Firmware based and LCD controlled retract +// M207 and M208 can be used to define parameters for the retraction. +// The retraction can be called by the slicer using G10 and G11 +// until then, intended retractions can be detected by moves that only extrude and the direction. +// the moves are than replaced by the firmware controlled ones. + +#define FWRETRACT //ONLY PARTIALLY TESTED +#ifdef FWRETRACT + #define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt + #define RETRACT_LENGTH 5 //default retract length (positive mm) + #define RETRACT_LENGTH_SWAP 13 //default swap retract length (positive mm), for extruder change + #define RETRACT_FEEDRATE 100 //default feedrate for retracting (mm/s) + #define RETRACT_ZLIFT 0 //default retract Z-lift + #define RETRACT_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering) + #define RETRACT_RECOVER_LENGTH_SWAP 0 //default additional swap recover length (mm, added to retract length when recovering from extruder change) + #define RETRACT_RECOVER_FEEDRATE 100 //default feedrate for recovering from retraction (mm/s) +#endif + +// Add support for experimental filament exchange support M600; requires display +#ifdef ULTIPANEL + //#define FILAMENTCHANGEENABLE + #ifdef FILAMENTCHANGEENABLE + #define FILAMENTCHANGE_XPOS 3 + #define FILAMENTCHANGE_YPOS 3 + #define FILAMENTCHANGE_ZADD 10 + #define FILAMENTCHANGE_FIRSTRETRACT -2 + #define FILAMENTCHANGE_FINALRETRACT -100 + #endif +#endif + +/******************************************************************************\ + * enable this section if you have TMC26X motor drivers. + * you need to import the TMC26XStepper library into the arduino IDE for this + ******************************************************************************/ + +// @section tmc + +//#define HAVE_TMCDRIVER +#ifdef HAVE_TMCDRIVER + +// #define X_IS_TMC + #define X_MAX_CURRENT 1000 //in mA + #define X_SENSE_RESISTOR 91 //in mOhms + #define X_MICROSTEPS 16 //number of microsteps + +// #define X2_IS_TMC + #define X2_MAX_CURRENT 1000 //in mA + #define X2_SENSE_RESISTOR 91 //in mOhms + #define X2_MICROSTEPS 16 //number of microsteps + +// #define Y_IS_TMC + #define Y_MAX_CURRENT 1000 //in mA + #define Y_SENSE_RESISTOR 91 //in mOhms + #define Y_MICROSTEPS 16 //number of microsteps + +// #define Y2_IS_TMC + #define Y2_MAX_CURRENT 1000 //in mA + #define Y2_SENSE_RESISTOR 91 //in mOhms + #define Y2_MICROSTEPS 16 //number of microsteps + +// #define Z_IS_TMC + #define Z_MAX_CURRENT 1000 //in mA + #define Z_SENSE_RESISTOR 91 //in mOhms + #define Z_MICROSTEPS 16 //number of microsteps + +// #define Z2_IS_TMC + #define Z2_MAX_CURRENT 1000 //in mA + #define Z2_SENSE_RESISTOR 91 //in mOhms + #define Z2_MICROSTEPS 16 //number of microsteps + +// #define E0_IS_TMC + #define E0_MAX_CURRENT 1000 //in mA + #define E0_SENSE_RESISTOR 91 //in mOhms + #define E0_MICROSTEPS 16 //number of microsteps + +// #define E1_IS_TMC + #define E1_MAX_CURRENT 1000 //in mA + #define E1_SENSE_RESISTOR 91 //in mOhms + #define E1_MICROSTEPS 16 //number of microsteps + +// #define E2_IS_TMC + #define E2_MAX_CURRENT 1000 //in mA + #define E2_SENSE_RESISTOR 91 //in mOhms + #define E2_MICROSTEPS 16 //number of microsteps + +// #define E3_IS_TMC + #define E3_MAX_CURRENT 1000 //in mA + #define E3_SENSE_RESISTOR 91 //in mOhms + #define E3_MICROSTEPS 16 //number of microsteps + +#endif + +/******************************************************************************\ + * enable this section if you have L6470 motor drivers. + * you need to import the L6470 library into the arduino IDE for this + ******************************************************************************/ + +// @section l6470 + +//#define HAVE_L6470DRIVER +#ifdef HAVE_L6470DRIVER + +// #define X_IS_L6470 + #define X_MICROSTEPS 16 //number of microsteps + #define X_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define X_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define X_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define X2_IS_L6470 + #define X2_MICROSTEPS 16 //number of microsteps + #define X2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define X2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define X2_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define Y_IS_L6470 + #define Y_MICROSTEPS 16 //number of microsteps + #define Y_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Y_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define Y_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define Y2_IS_L6470 + #define Y2_MICROSTEPS 16 //number of microsteps + #define Y2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Y2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define Y2_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define Z_IS_L6470 + #define Z_MICROSTEPS 16 //number of microsteps + #define Z_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Z_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define Z_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define Z2_IS_L6470 + #define Z2_MICROSTEPS 16 //number of microsteps + #define Z2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Z2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define Z2_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define E0_IS_L6470 + #define E0_MICROSTEPS 16 //number of microsteps + #define E0_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E0_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define E0_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define E1_IS_L6470 + #define E1_MICROSTEPS 16 //number of microsteps + #define E1_MICROSTEPS 16 //number of microsteps + #define E1_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E1_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define E1_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define E2_IS_L6470 + #define E2_MICROSTEPS 16 //number of microsteps + #define E2_MICROSTEPS 16 //number of microsteps + #define E2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define E2_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +// #define E3_IS_L6470 + #define E3_MICROSTEPS 16 //number of microsteps + #define E3_MICROSTEPS 16 //number of microsteps + #define E3_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E3_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off + #define E3_STALLCURRENT 1500 //current in mA where the driver will detect a stall + +#endif + +#include "Conditionals.h" +#include "SanityCheck.h" + +#endif //CONFIGURATION_ADV_H diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index edf8a13f1e..c93347d5f9 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -286,44 +286,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: - -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -400,17 +380,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define Z_MAX_POS MANUAL_Z_HOME_POS //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -431,7 +414,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index cdfa7c8f93..a003186d81 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -377,6 +401,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 2cc7d4c663..0a7eb70a81 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -286,44 +286,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: - -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -400,17 +380,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define Z_MAX_POS MANUAL_Z_HOME_POS //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif + //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -431,7 +414,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== #define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 943022c819..c8ac659c32 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -376,6 +400,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 7223febd28..495b0057ee 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -256,44 +256,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: - -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -347,6 +327,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define INVERT_X_DIR false #define INVERT_Y_DIR false #define INVERT_Z_DIR false + #define INVERT_E0_DIR true #define INVERT_E1_DIR false #define INVERT_E2_DIR false @@ -370,17 +351,19 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define Z_MAX_POS 86 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. - +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -401,7 +384,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 8d451fd282..b08e8bc2ff 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -376,6 +400,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index e7602a6d0b..a9c492432a 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -258,44 +258,24 @@ Here are some standard links for getting your machine calibrated: #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. //=========================================================================== -//============================= Thermal Runaway Protection ================== +//======================== Thermal Runaway Protection ======================= //=========================================================================== -/* -This is a feature to protect your printer from burn up in flames if it has -a thermistor coming off place (this happened to a friend of mine recently and -motivated me writing this feature). - -The issue: If a thermistor come off, it will read a lower temperature than actual. -The system will turn the heater on forever, burning up the filament and anything -else around. - -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target -minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). - -If it stays longer than _PERIOD, it means the thermistor temperature -cannot catch up with the target, so something *may be* wrong. Then, to be on the -safe side, the system will he halt. - -Bear in mind the count down will just start AFTER the first time the -thermistor temperature is over the target, so you will have no problem if -your extruder heater takes 2 minutes to hit the target on heating. - -*/ -// If you want to enable this feature for all your extruder heaters, -// uncomment the 2 defines below: -// Parameters for all extruder heaters -//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius - -// If you want to enable this feature for your bed heater, -// uncomment the 2 defines below: - -// Parameters for the bed heater -//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds -//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius +/** + * Thermal Runaway Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long, + * the firmware will halt as a safety precaution. + */ +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -372,17 +352,20 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define Z_MAX_POS 120 //=========================================================================== -//============================= Filament Runout Sensor ====================== +//========================= Filament Runout Sensor ========================== //=========================================================================== //#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made. // It is assumed that when logic high = filament available // when logic low = filament ran out -//const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned -//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. +#ifdef FILAMENT_RUNOUT_SENSOR + const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned + #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. + #define FILAMENT_RUNOUT_SCRIPT "M600" +#endif //=========================================================================== -//============================ Manual Bed Leveling ========================== +//=========================== Manual Bed Leveling =========================== //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling @@ -403,7 +386,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #endif // MESH_BED_LEVELING //=========================================================================== -//============================= Bed Auto Leveling =========================== +//============================ Bed Auto Leveling ============================ //=========================================================================== //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 3187150ba9..a86b3279d4 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -14,14 +14,38 @@ #endif #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control -//// Heating sanity check: -// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE -//#define WATCH_TEMP_PERIOD 40000 //40 seconds -//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds +/** + * Thermal Protection parameters + */ +#ifdef THERMAL_PROTECTION_HOTENDS + #define THERMAL_PROTECTION_PERIOD 40 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + + /** + * Whenever an M104 or M109 increases the target temperature the firmware will wait for the + * WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE + * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, + * but only if the current temperature is far enough below the target for a reliable test. + */ + #define WATCH_TEMP_PERIOD 16 // Seconds + #define WATCH_TEMP_INCREASE 4 // Degrees Celsius +#endif + +#ifdef THERMAL_PROTECTION_BED + #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius +#endif +/** + * Automatic Temperature: + * The hotend target temperature is calculated by all the buffered lines of gcode. + * The maximum buffered steps/sec of the extruder motor is called "se". + * Start autotemp mode with M109 S B F + * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by + * mintemp and maxtemp. Turn this off by excuting M109 without F* + * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. + * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode + */ #ifdef PIDTEMP // this adds an experimental additional term to the heating power, proportional to the extrusion speed. // if Kc is chosen well, the additional required power due to increased melting should be compensated. @@ -376,6 +400,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients abort after 30 seconds in a timeout. +// Some other clients start sending commands while receiving a 'wait'. +// This "wait" is only sent when the buffer is empty. 1 second is a good value here. +//#define NO_TIMEOUTS 1000 // Milliseconds + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +//#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/language.h b/Marlin/language.h index acd773e9a7..8fb735f177 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -123,22 +123,24 @@ #define MSG_FREE_MEMORY " Free Memory: " #define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: " #define MSG_OK "ok" +#define MSG_WAIT "wait" #define MSG_FILE_SAVED "Done saving file." -#define MSG_ERR_LINE_NO1 "Line Number out of sequence. Expected: " -#define MSG_ERR_LINE_NO2 " Got: " +#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_M200_INVALID_EXTRUDER "M200 Invalid extruder " -#define MSG_M218_INVALID_EXTRUDER "M218 Invalid extruder " -#define MSG_M221_INVALID_EXTRUDER "M221 Invalid extruder " +#define MSG_INVALID_EXTRUDER "Invalid extruder" +#define MSG_INVALID_SOLENOID "Invalid solenoid" +#define MSG_M104_INVALID_EXTRUDER "M104 " MSG_INVALID_EXTRUDER " " +#define MSG_M105_INVALID_EXTRUDER "M105 " MSG_INVALID_EXTRUDER " " +#define MSG_M109_INVALID_EXTRUDER "M109 " MSG_INVALID_EXTRUDER " " +#define MSG_M200_INVALID_EXTRUDER "M200 " MSG_INVALID_EXTRUDER " " +#define MSG_M218_INVALID_EXTRUDER "M218 " MSG_INVALID_EXTRUDER " " +#define MSG_M221_INVALID_EXTRUDER "M221 " MSG_INVALID_EXTRUDER " " #define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature" -#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder " #define MSG_HEATING "Heating..." #define MSG_HEATING_COMPLETE "Heating done." #define MSG_BED_HEATING "Bed Heating." @@ -150,8 +152,6 @@ #define MSG_RESEND "Resend: " #define MSG_UNKNOWN_COMMAND "Unknown command: \"" #define MSG_ACTIVE_EXTRUDER "Active Extruder: " -#define MSG_INVALID_EXTRUDER "Invalid extruder" -#define MSG_INVALID_SOLENOID "Invalid solenoid" #define MSG_X_MIN "x_min: " #define MSG_X_MAX "x_max: " #define MSG_Y_MIN "y_min: " @@ -163,6 +163,7 @@ #define MSG_ERR_MATERIAL_INDEX "M145 S out of range (0-1)" #define MSG_ERR_M421_REQUIRES_XYZ "M421 requires XYZ parameters" #define MSG_ERR_MESH_INDEX_OOB "Mesh XY index is out of bounds" +#define MSG_ERR_M428_TOO_FAR "Too far from reference point" #define MSG_M119_REPORT "Reporting endstop status" #define MSG_ENDSTOP_HIT "TRIGGERED" #define MSG_ENDSTOP_OPEN "open" diff --git a/Marlin/language_fr.h b/Marlin/language_fr.h index be526a7235..9d001a5771 100644 --- a/Marlin/language_fr.h +++ b/Marlin/language_fr.h @@ -39,16 +39,17 @@ #define MSG_EXTRUDE "Extrusion" #define MSG_RETRACT "Retraction" #define MSG_MOVE_AXIS "Deplacer un axe" -#define MSG_MOVE_X "Move X" -#define MSG_MOVE_Y "Move Y" -#define MSG_MOVE_Z "Move Z" +#define MSG_MOVE_X "Depl. X" +#define MSG_MOVE_Y "Depl. Y" +#define MSG_MOVE_Z "Depl. Z" #define MSG_MOVE_E "Extruder" -#define MSG_MOVE_01MM "Move 0.1mm" -#define MSG_MOVE_1MM "Move 1mm" -#define MSG_MOVE_10MM "Move 10mm" +#define MSG_MOVE_01MM "Depl. 0.1mm" +#define MSG_MOVE_1MM "Depl. 1mm" +#define MSG_MOVE_10MM "Depl. 10mm" #define MSG_SPEED " Vitesse" #define MSG_NOZZLE "Buse" #define MSG_BED "Plateau" +#define MSG_LEVEL_BED "Regl. Niv. Plateau" #define MSG_FAN_SPEED "Vite. ventilateur" #define MSG_FLOW "Flux" #define MSG_CONTROL "Controler" @@ -102,7 +103,7 @@ #define MSG_DWELL "Repos..." #define MSG_USERWAIT "Atten. de l'util." #define MSG_RESUMING "Repri. de l'impr." -#define MSG_PRINT_ABORTED "Print aborted" +#define MSG_PRINT_ABORTED "Impr. Annulee" #define MSG_NO_MOVE "Aucun mouvement." #define MSG_KILLED "MORT." #define MSG_STOPPED "STOPPE." diff --git a/Marlin/motion_control.cpp b/Marlin/motion_control.cpp deleted file mode 100644 index b26cbafc8d..0000000000 --- a/Marlin/motion_control.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - motion_control.c - high level interface for issuing motion commands - Part of Grbl - - Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011 Sungeun K. Jeon - - Grbl is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Grbl is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Grbl. If not, see . -*/ - -#include "Marlin.h" -#include "stepper.h" -#include "planner.h" - -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, - uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ - // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); - // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc - float center_axis0 = position[axis_0] + offset[axis_0]; - float center_axis1 = position[axis_1] + offset[axis_1]; - float linear_travel = target[axis_linear] - position[axis_linear]; - float extruder_travel = target[E_AXIS] - position[E_AXIS]; - float r_axis0 = -offset[axis_0]; // Radius vector from center to current location - float r_axis1 = -offset[axis_1]; - float rt_axis0 = target[axis_0] - center_axis0; - float rt_axis1 = target[axis_1] - center_axis1; - - // CCW angle between position and target from circle center. Only one atan2() trig computation required. - float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); - if (angular_travel < 0) { angular_travel += 2*M_PI; } - if (isclockwise) { angular_travel -= 2*M_PI; } - - //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving - //to compensate when start pos = target pos && angle is zero -> angle = 2Pi - if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) - { - angular_travel += 2*M_PI; - } - //end fix G03 - - 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 - // all segments. - if (invert_feed_rate) { feed_rate *= segments; } - */ - float theta_per_segment = angular_travel/segments; - float linear_per_segment = linear_travel/segments; - float extruder_per_segment = extruder_travel/segments; - - /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, - and phi is the angle of rotation. Based on the solution approach by Jens Geisler. - r_T = [cos(phi) -sin(phi); - sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is - defined from the circle center to the initial position. Each line segment is formed by successive - vector rotations. This requires only two cos() and sin() computations to form the rotation - matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since - all double numbers are single precision on the Arduino. (True double precision will not have - round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. - - Small angle approximation may be used to reduce computation overhead further. This approximation - holds for everything, but very small circles and large mm_per_arc_segment values. In other words, - theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for - numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an - issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner - without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. - */ - // Vector rotation matrix values - float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation - float sin_T = theta_per_segment; - - float arc_target[4]; - float sin_Ti; - float cos_Ti; - float r_axisi; - uint16_t i; - int8_t count = 0; - - // Initialize the linear axis - arc_target[axis_linear] = position[axis_linear]; - - // Initialize the extruder axis - arc_target[E_AXIS] = position[E_AXIS]; - - for (i = 1; i. -*/ - -#ifndef motion_control_h -#define motion_control_h - -// Execute an arc in offset mode format. position == current xyz, target == target xyz, -// offset == offset from current xyz, axis_XXX defines circle plane in tool space, axis_linear is -// the direction of helical travel, radius == circle radius, isclockwise boolean. Used -// for vector transformation direction. -void mc_arc(float *position, float *target, float *offset, unsigned char axis_0, unsigned char axis_1, - unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise, uint8_t extruder); - -#endif diff --git a/Marlin/pins.h b/Marlin/pins.h index e45ba09dff..6af115d63a 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -34,7 +34,7 @@ #include "pins_SETHI.h" #elif MB(RAMPS_OLD) #include "pins_RAMPS_OLD.h" -#elif MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) +#elif MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) || MB(RAMPS_13_SF) #include "pins_RAMPS_13.h" #elif MB(DUEMILANOVE_328P) #include "pins_DUEMILANOVE_328P.h" @@ -190,6 +190,7 @@ #endif #if defined(DISABLE_Z_PROBE_ENDSTOP) || !defined(Z_PROBE_ENDSTOP) // Allow code to compile regardless of Z_PROBE_ENDSTOP setting. + #undef Z_PROBE_PIN #define Z_PROBE_PIN -1 #endif diff --git a/Marlin/pins_MEGATRONICS_3.h b/Marlin/pins_MEGATRONICS_3.h index 04a730670d..ed627274ce 100644 --- a/Marlin/pins_MEGATRONICS_3.h +++ b/Marlin/pins_MEGATRONICS_3.h @@ -8,6 +8,11 @@ #define LARGE_FLASH true + +#ifdef Z_PROBE_SLED + #define SLED_PIN -1 +#endif + // Servo support #ifdef NUM_SERVOS #define SERVO0_PIN 46 //AUX3-6 @@ -26,19 +31,19 @@ #define X_DIR_PIN 57 #define X_ENABLE_PIN 59 #define X_MIN_PIN 37 -#define X_MAX_PIN 40 // 2 // Max endstops default to disabled "-1", set to commented value to enable. +#define X_MAX_PIN 40 // put to -1 to disable -#define Y_STEP_PIN 5 // A6 -#define Y_DIR_PIN 17 // A0 +#define Y_STEP_PIN 5 +#define Y_DIR_PIN 17 #define Y_ENABLE_PIN 4 #define Y_MIN_PIN 41 -#define Y_MAX_PIN 38 // 15 +#define Y_MAX_PIN 38 // put to -1 to disable -#define Z_STEP_PIN 16 // A2 -#define Z_DIR_PIN 11 // A6 -#define Z_ENABLE_PIN 3 // A1 +#define Z_STEP_PIN 16 +#define Z_DIR_PIN 11 +#define Z_ENABLE_PIN 3 #define Z_MIN_PIN 18 -#define Z_MAX_PIN 19 +#define Z_MAX_PIN 19 // put to -1 to disable #define E0_STEP_PIN 28 #define E0_DIR_PIN 27 diff --git a/Marlin/pins_MKS_BASE.h b/Marlin/pins_MKS_BASE.h new file mode 100644 index 0000000000..5a5b8ea482 --- /dev/null +++ b/Marlin/pins_MKS_BASE.h @@ -0,0 +1,11 @@ +/** + * MKS BASE 1.0 – Arduino Mega2560 with RAMPS v1.4 pin assignments + */ + +#include "pins_RAMPS_13.h" + +#undef FAN_PIN +#define FAN_PIN 9 // (Sprinter config) + +#undef HEATER_1_PIN +#define HEATER_1_PIN 7 diff --git a/Marlin/pins_OMCA.h b/Marlin/pins_OMCA.h index 26a797362a..91efbd295f 100644 --- a/Marlin/pins_OMCA.h +++ b/Marlin/pins_OMCA.h @@ -48,9 +48,9 @@ #define Z_ENABLE_PIN 10 #define Z_STOP_PIN 2 -#define E0_STEP_PIN 24 -#define E0_DIR_PIN 21 -#define E0_ENABLE_PIN 10 +#define E0_STEP_PIN 24 +#define E0_DIR_PIN 21 +#define E0_ENABLE_PIN 10 // future proofing #define __FS 20 @@ -58,15 +58,15 @@ #define __GS 18 #define __GD 13 -#define UNUSED_PWM 14 // PWM on LEFT connector +#define UNUSED_PWM 14 // PWM on LEFT connector -#define E1_STEP_PIN -1 // 21 -#define E1_DIR_PIN -1 // 20 -#define E1_ENABLE_PIN -1 // 19 +#define E1_STEP_PIN -1 // 21 +#define E1_DIR_PIN -1 // 20 +#define E1_ENABLE_PIN -1 // 19 -#define E2_STEP_PIN -1 // 21 -#define E2_DIR_PIN -1 // 20 -#define E2_ENABLE_PIN -1 // 18 +#define E2_STEP_PIN -1 // 21 +#define E2_DIR_PIN -1 // 20 +#define E2_ENABLE_PIN -1 // 18 #define SDPOWER -1 #define SDSS 11 @@ -87,5 +87,6 @@ #define HEATER_BED_PIN 4 #define TEMP_BED_PIN 2 // 1,2 or I2C -#define I2C_SCL 16 -#define I2C_SDA 17 +#define I2C_SCL 16 +#define I2C_SDA 17 + diff --git a/Marlin/pins_RAMBO.h b/Marlin/pins_RAMBO.h index 6d782b9d9c..4c008d6ce3 100644 --- a/Marlin/pins_RAMBO.h +++ b/Marlin/pins_RAMBO.h @@ -22,6 +22,10 @@ #endif #endif +#ifdef Z_PROBE_SLED + #define SLED_PIN -1 +#endif + #undef X_MS1_PIN #undef X_MS2_PIN #undef Y_MS1_PIN diff --git a/Marlin/pins_RAMPS_13.h b/Marlin/pins_RAMPS_13.h index af1d2d3bbc..c9c796ed42 100644 --- a/Marlin/pins_RAMPS_13.h +++ b/Marlin/pins_RAMPS_13.h @@ -7,6 +7,7 @@ * RAMPS_13_EEB (Extruder, Extruder, Bed) * RAMPS_13_EFF (Extruder, Fan, Fan) * RAMPS_13_EEF (Extruder, Extruder, Fan) + * RAMPS_13_SF (Spindle, Controller Fan) * * Other pins_MYBOARD.h files may override these defaults */ @@ -81,7 +82,7 @@ #if MB(RAMPS_13_EFF) #define CONTROLLERFAN_PIN -1 // Pin used for the fan to cool controller #endif -#elif MB(RAMPS_13_EEF) +#elif MB(RAMPS_13_EEF) || MB(RAMPS_13_SF) #define FAN_PIN 8 #else #define FAN_PIN 4 // IO pin. Buffer needed @@ -101,7 +102,7 @@ #define HEATER_0_PIN 10 // EXTRUDER 1 #endif -#if MB(RAMPS_13_EFB) +#if MB(RAMPS_13_EFB) || MB(RAMPS_13_SF) #define HEATER_1_PIN -1 #else #define HEATER_1_PIN 9 // EXTRUDER 2 (FAN On Sprinter) @@ -113,7 +114,7 @@ #define TEMP_1_PIN 15 // ANALOG NUMBERING #define TEMP_2_PIN -1 // ANALOG NUMBERING -#if MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) +#if MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) || MB(RAMPS_13_SF) #define HEATER_BED_PIN -1 // NO BED #else #define HEATER_BED_PIN 8 // BED @@ -134,6 +135,10 @@ #endif #endif +#ifdef Z_PROBE_SLED + #define SLED_PIN -1 +#endif + #ifdef ULTRA_LCD #ifdef NEWPANEL diff --git a/Marlin/pins_SANGUINOLOLU_11.h b/Marlin/pins_SANGUINOLOLU_11.h index e7bdd974ea..ca41bdd970 100644 --- a/Marlin/pins_SANGUINOLOLU_11.h +++ b/Marlin/pins_SANGUINOLOLU_11.h @@ -44,6 +44,10 @@ #define FAN_PIN 4 #endif +#ifdef Z_PROBE_SLED + #define SLED_PIN -1 +#endif + #ifdef NUM_SERVOS #define SERVO0_PIN -1 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index a8558d6c49..3cd9894ca5 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -429,11 +429,12 @@ void check_axes_activity() { #ifdef FAN_KICKSTART_TIME static millis_t fan_kick_end; if (tail_fan_speed) { + millis_t ms = millis(); if (fan_kick_end == 0) { // Just starting up fan - run at full power. - fan_kick_end = millis() + FAN_KICKSTART_TIME; + fan_kick_end = ms + FAN_KICKSTART_TIME; tail_fan_speed = 255; - } else if (fan_kick_end > millis()) + } else if (fan_kick_end > ms) // Fan still spinning up. tail_fan_speed = 255; } else { @@ -959,7 +960,7 @@ float junction_deviation = 0.1; vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS)); //position.debug("in plan_get position"); - //plan_bed_level_matrix.debug("in plan_get bed_level"); + //plan_bed_level_matrix.debug("in plan_get_position"); matrix_3x3 inverse = matrix_3x3::transpose(plan_bed_level_matrix); //inverse.debug("in plan_get inverse"); position.apply_rotation(inverse); @@ -981,10 +982,10 @@ float junction_deviation = 0.1; apply_rotation_xyz(plan_bed_level_matrix, x, y, z); #endif - float nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]); - float ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]); - float nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]); - float ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]); + float nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]), + ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]), + nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]), + ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]); st_set_position(nx, ny, nz, ne); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. diff --git a/Marlin/Servo.cpp b/Marlin/servo.cpp similarity index 99% rename from Marlin/Servo.cpp rename to Marlin/servo.cpp index 576b394fb7..81d73ae870 100644 --- a/Marlin/Servo.cpp +++ b/Marlin/servo.cpp @@ -48,7 +48,7 @@ #include #include -#include "Servo.h" +#include "servo.h" #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds diff --git a/Marlin/Servo.h b/Marlin/servo.h similarity index 100% rename from Marlin/Servo.h rename to Marlin/servo.h diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index ca17b3f9f2..e614f5a89a 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1,22 +1,23 @@ -/* - stepper.c - stepper motor driver: executes motion plans using stepper motors - Part of Grbl - - Copyright (c) 2009-2011 Simen Svale Skogsrud - - Grbl is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Grbl is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Grbl. If not, see . -*/ +/** + * stepper.cpp - stepper motor driver: executes motion plans using stepper motors + * Marlin Firmware + * + * Derived from Grbl + * Copyright (c) 2009-2011 Simen Svale Skogsrud + * + * Grbl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Grbl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Grbl. If not, see . + */ /* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith and Philipp Tiefenbacher. */ @@ -45,7 +46,7 @@ block_t *current_block; // A pointer to the block currently being traced //static makes it impossible to be called from outside of this file by extern.! // Variables used by The Stepper Driver Interrupt -static unsigned char out_bits; // The next stepping-bits to be output +static unsigned char out_bits = 0; // The next stepping-bits to be output static unsigned int cleaning_buffer_counter; #ifdef Z_DUAL_ENDSTOPS @@ -73,10 +74,7 @@ static unsigned short step_loops_nominal; volatile long endstops_trigsteps[3] = { 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 volatile bool endstop_z_probe_hit = false; // Leaving this in even if Z_PROBE_ENDSTOP isn't defined, keeps code below cleaner. #ifdef it and usage below to save space. +static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED bool abort_on_endstop_hit = false; @@ -264,27 +262,27 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~BIT(OCIE1A) void endstops_hit_on_purpose() { - endstop_x_hit = endstop_y_hit = endstop_z_hit = endstop_z_probe_hit = false; // #ifdef endstop_z_probe_hit = to save space if needed. + endstop_hit_bits = 0; } void checkHitEndstops() { - if (endstop_x_hit || endstop_y_hit || endstop_z_hit || endstop_z_probe_hit) { // #ifdef || endstop_z_probe_hit to save space if needed. + if (endstop_hit_bits) { // #ifdef || endstop_z_probe_hit to save space if needed. SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT); - if (endstop_x_hit) { + if (endstop_hit_bits & BIT(X_MIN)) { SERIAL_ECHOPAIR(" X:", (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X"); } - if (endstop_y_hit) { + if (endstop_hit_bits & BIT(Y_MIN)) { SERIAL_ECHOPAIR(" Y:", (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y"); } - if (endstop_z_hit) { + if (endstop_hit_bits & BIT(Z_MIN)) { SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z"); } #ifdef Z_PROBE_ENDSTOP - if (endstop_z_probe_hit) { + if (endstop_hit_bits & BIT(Z_PROBE)) { SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP"); } @@ -366,9 +364,58 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) { return timer; } +// set the stepper direction of each axis +void set_stepper_direction() { + + // Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY) + if (TEST(out_bits, X_AXIS)) { + X_APPLY_DIR(INVERT_X_DIR,0); + count_direction[X_AXIS] = -1; + } + else { + X_APPLY_DIR(!INVERT_X_DIR,0); + count_direction[X_AXIS] = 1; + } + + if (TEST(out_bits, Y_AXIS)) { + Y_APPLY_DIR(INVERT_Y_DIR,0); + count_direction[Y_AXIS] = -1; + } + else { + Y_APPLY_DIR(!INVERT_Y_DIR,0); + count_direction[Y_AXIS] = 1; + } + + if (TEST(out_bits, Z_AXIS)) { + Z_APPLY_DIR(INVERT_Z_DIR,0); + count_direction[Z_AXIS] = -1; + } + else { + Z_APPLY_DIR(!INVERT_Z_DIR,0); + count_direction[Z_AXIS] = 1; + } + + #ifndef ADVANCE + if (TEST(out_bits, E_AXIS)) { + REV_E_DIR(); + count_direction[E_AXIS] = -1; + } + else { + NORM_E_DIR(); + count_direction[E_AXIS] = 1; + } + #endif //!ADVANCE +} + // Initializes the trapezoid generator from the current block. Called whenever a new // block begins. FORCE_INLINE void trapezoid_generator_reset() { + + if (current_block->direction_bits != out_bits) { + out_bits = current_block->direction_bits; + set_stepper_direction(); + } + #ifdef ADVANCE advance = current_block->initial_advance; final_advance = current_block->final_advance; @@ -441,47 +488,27 @@ ISR(TIMER1_COMPA_vect) { } if (current_block != NULL) { - // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt - out_bits = current_block->direction_bits; - - // Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY) - if (TEST(out_bits, X_AXIS)) { - X_APPLY_DIR(INVERT_X_DIR,0); - count_direction[X_AXIS] = -1; - } - else { - X_APPLY_DIR(!INVERT_X_DIR,0); - count_direction[X_AXIS] = 1; - } - - if (TEST(out_bits, Y_AXIS)) { - Y_APPLY_DIR(INVERT_Y_DIR,0); - count_direction[Y_AXIS] = -1; - } - else { - Y_APPLY_DIR(!INVERT_Y_DIR,0); - count_direction[Y_AXIS] = 1; - } - - #define _ENDSTOP(axis, minmax) axis ##_## minmax ##_endstop - #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN - #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING - #define _OLD_ENDSTOP(axis, minmax) old_## axis ##_## minmax ##_endstop - #define _AXIS(AXIS) AXIS ##_AXIS - #define _ENDSTOP_HIT(axis) endstop_## axis ##_hit - - #define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \ - bool _ENDSTOP(axis, minmax) = (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)); \ - if (_ENDSTOP(axis, minmax) && _OLD_ENDSTOP(axis, minmax) && (current_block->steps[_AXIS(AXIS)] > 0)) { \ - endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \ - _ENDSTOP_HIT(axis) = true; \ - step_events_completed = current_block->step_event_count; \ - } \ - _OLD_ENDSTOP(axis, minmax) = _ENDSTOP(axis, minmax); - - // Check X and Y endstops + // Check endstops if (check_endstops) { + + #define _ENDSTOP(axis, minmax) axis ##_## minmax ##_endstop + #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN + #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING + #define _OLD_ENDSTOP(axis, minmax) old_## axis ##_## minmax ##_endstop + #define _AXIS(AXIS) AXIS ##_AXIS + #define _HIT_BIT(AXIS) AXIS ##_MIN + #define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_HIT_BIT(AXIS)) + + #define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \ + bool _ENDSTOP(axis, minmax) = (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)); \ + if (_ENDSTOP(axis, minmax) && _OLD_ENDSTOP(axis, minmax) && (current_block->steps[_AXIS(AXIS)] > 0)) { \ + endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \ + _ENDSTOP_HIT(AXIS); \ + step_events_completed = current_block->step_event_count; \ + } \ + _OLD_ENDSTOP(axis, minmax) = _ENDSTOP(axis, minmax); + #ifdef COREXY // Head direction in -X axis for CoreXY bots. // If DeltaX == -DeltaY, the movement is only in Y axis @@ -534,15 +561,7 @@ ISR(TIMER1_COMPA_vect) { #ifdef COREXY } #endif - } - - if (TEST(out_bits, Z_AXIS)) { // -direction - - Z_APPLY_DIR(INVERT_Z_DIR,0); - count_direction[Z_AXIS] = -1; - - if (check_endstops) { - + if (TEST(out_bits, Z_AXIS)) { // z -direction #if HAS_Z_MIN #ifdef Z_DUAL_ENDSTOPS @@ -560,7 +579,7 @@ ISR(TIMER1_COMPA_vect) { z2_min_both = z2_min_endstop && old_z2_min_endstop; if ((z_min_both || z2_min_both) && current_block->steps[Z_AXIS] > 0) { endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - endstop_z_hit = true; + endstop_hit_bits |= BIT(Z_MIN); if (!performing_homing || (performing_homing && z_min_both && z2_min_both)) //if not performing home or if both endstops were trigged during homing... step_events_completed = current_block->step_event_count; } @@ -581,23 +600,13 @@ ISR(TIMER1_COMPA_vect) { if(z_probe_endstop && old_z_probe_endstop) { endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - endstop_z_probe_hit=true; - -// if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); + endstop_hit_bits |= BIT(Z_PROBE); + // if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); } old_z_probe_endstop = z_probe_endstop; #endif - - } // check_endstops - - } - else { // +direction - - Z_APPLY_DIR(!INVERT_Z_DIR,0); - count_direction[Z_AXIS] = 1; - - if (check_endstops) { - + } + else { // z +direction #if HAS_Z_MAX #ifdef Z_DUAL_ENDSTOPS @@ -615,7 +624,7 @@ ISR(TIMER1_COMPA_vect) { z2_max_both = z2_max_endstop && old_z2_max_endstop; if ((z_max_both || z2_max_both) && current_block->steps[Z_AXIS] > 0) { endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - endstop_z_hit = true; + endstop_hit_bits |= BIT(Z_MIN); // if (z_max_both) SERIAL_ECHOLN("z_max_endstop = true"); // if (z2_max_both) SERIAL_ECHOLN("z2_max_endstop = true"); @@ -633,33 +642,23 @@ ISR(TIMER1_COMPA_vect) { #endif // !Z_DUAL_ENDSTOPS #endif // Z_MAX_PIN - + #ifdef Z_PROBE_ENDSTOP UPDATE_ENDSTOP(z, Z, probe, PROBE); z_probe_endstop=(READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING); if(z_probe_endstop && old_z_probe_endstop) { endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - endstop_z_probe_hit=true; -// if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); + endstop_hit_bits |= BIT(Z_PROBE); +// if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); } old_z_probe_endstop = z_probe_endstop; #endif + } - } // check_endstops + } - } // +direction - #ifndef ADVANCE - if (TEST(out_bits, E_AXIS)) { // -direction - REV_E_DIR(); - count_direction[E_AXIS] = -1; - } - else { // +direction - NORM_E_DIR(); - count_direction[E_AXIS] = 1; - } - #endif //!ADVANCE // Take multiple steps per interrupt (For high speed moves) for (int8_t i = 0; i < step_loops; i++) { @@ -676,60 +675,34 @@ ISR(TIMER1_COMPA_vect) { #endif //ADVANCE #define _COUNTER(axis) counter_## axis - #define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW) #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN - #ifdef CONFIG_STEPPERS_TOSHIBA - /** - * The Toshiba stepper controller require much longer pulses. - * So we 'stage' decompose the pulses between high and low - * instead of doing each in turn. The extra tests add enough - * lag to allow it work with without needing NOPs - */ - #define STEP_ADD(axis, AXIS) \ - _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \ - if (_COUNTER(axis) > 0) { _WRITE_STEP(AXIS, HIGH); } - STEP_ADD(x,X); - STEP_ADD(y,Y); - STEP_ADD(z,Z); - #ifndef ADVANCE - STEP_ADD(e,E); - #endif - - #define STEP_IF_COUNTER(axis, AXIS) \ - if (_COUNTER(axis) > 0) { \ - _COUNTER(axis) -= current_block->step_event_count; \ - count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ - _WRITE_STEP(AXIS, LOW); \ - } - - STEP_IF_COUNTER(x, X); - STEP_IF_COUNTER(y, Y); - STEP_IF_COUNTER(z, Z); - #ifndef ADVANCE - STEP_IF_COUNTER(e, E); - #endif + #define STEP_ADD(axis, AXIS) \ + _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \ + if (_COUNTER(axis) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); } - #else // !CONFIG_STEPPERS_TOSHIBA + STEP_ADD(x,X); + STEP_ADD(y,Y); + STEP_ADD(z,Z); + #ifndef ADVANCE + STEP_ADD(e,E); + #endif - #define APPLY_MOVEMENT(axis, AXIS) \ - _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \ - if (_COUNTER(axis) > 0) { \ - _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); \ - _COUNTER(axis) -= current_block->step_event_count; \ - count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ - _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \ - } + #define STEP_IF_COUNTER(axis, AXIS) \ + if (_COUNTER(axis) > 0) { \ + _COUNTER(axis) -= current_block->step_event_count; \ + count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ + _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \ + } - APPLY_MOVEMENT(x, X); - APPLY_MOVEMENT(y, Y); - APPLY_MOVEMENT(z, Z); - #ifndef ADVANCE - APPLY_MOVEMENT(e, E); - #endif + STEP_IF_COUNTER(x, X); + STEP_IF_COUNTER(y, Y); + STEP_IF_COUNTER(z, Z); + #ifndef ADVANCE + STEP_IF_COUNTER(e, E); + #endif - #endif // CONFIG_STEPPERS_TOSHIBA step_events_completed++; if (step_events_completed >= current_block->step_event_count) break; } @@ -1016,14 +989,15 @@ void st_init() { #endif #endif -#if (defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0) && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used. - SET_INPUT(Z_PROBE_PIN); - #ifdef ENDSTOPPULLUP_ZPROBE - WRITE(Z_PROBE_PIN,HIGH); + #if (defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0) && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used. + SET_INPUT(Z_PROBE_PIN); + #ifdef ENDSTOPPULLUP_ZPROBE + WRITE(Z_PROBE_PIN,HIGH); + #endif #endif -#endif #define _STEP_INIT(AXIS) AXIS ##_STEP_INIT + #define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW) #define _DISABLE(axis) disable_## axis() #define AXIS_INIT(axis, AXIS, PIN) \ @@ -1099,6 +1073,8 @@ void st_init() { enable_endstops(true); // Start with endstops active. After homing they can be disabled sei(); + + set_stepper_direction(); // Init directions to out_bits = 0 } @@ -1136,9 +1112,8 @@ long st_get_position(uint8_t axis) { #ifdef ENABLE_AUTO_BED_LEVELING - float st_get_position_mm(uint8_t axis) { - float steper_position_in_steps = st_get_position(axis); - return steper_position_in_steps / axis_steps_per_unit[axis]; + float st_get_position_mm(AxisEnum axis) { + return st_get_position(axis) / axis_steps_per_unit[axis]; } #endif // ENABLE_AUTO_BED_LEVELING diff --git a/Marlin/stepper.h b/Marlin/stepper.h index d6c17d60f6..15d814332f 100644 --- a/Marlin/stepper.h +++ b/Marlin/stepper.h @@ -67,9 +67,9 @@ void st_set_e_position(const long &e); long st_get_position(uint8_t axis); #ifdef ENABLE_AUTO_BED_LEVELING -// Get current position in mm -float st_get_position_mm(uint8_t axis); -#endif //ENABLE_AUTO_BED_LEVELING + // Get current position in mm + float st_get_position_mm(AxisEnum axis); +#endif // The stepper subsystem goes to sleep when it runs out of things to execute. Call this // to notify the subsystem that it is time to go to work. diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 7bf0b6e53c..07db02ab49 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -73,16 +73,14 @@ unsigned char soft_pwm_bed; int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only #endif -#define HAS_HEATER_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0) -#define HAS_BED_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 && TEMP_SENSOR_BED != 0) -#if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION +#if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED) enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway }; void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc); - #if HAS_HEATER_THERMAL_PROTECTION + #ifdef THERMAL_PROTECTION_HOTENDS static TRState thermal_runaway_state_machine[4] = { TRReset, TRReset, TRReset, TRReset }; static millis_t thermal_runaway_timer[4]; // = {0,0,0,0}; #endif - #if HAS_BED_THERMAL_PROTECTION + #ifdef THERMAL_PROTECTION_BED static TRState thermal_runaway_bed_state_machine = TRReset; static millis_t thermal_runaway_bed_timer; #endif @@ -170,10 +168,10 @@ static float analog2temp(int raw, uint8_t e); static float analog2tempBed(int raw); static void updateTemperaturesFromRawValues(); -#ifdef WATCH_TEMP_PERIOD - int watch_start_temp[EXTRUDERS] = { 0 }; - millis_t watchmillis[EXTRUDERS] = { 0 }; -#endif //WATCH_TEMP_PERIOD +#ifdef THERMAL_PROTECTION_HOTENDS + int watch_target_temp[EXTRUDERS] = { 0 }; + millis_t watch_heater_next_ms[EXTRUDERS] = { 0 }; +#endif #ifndef SOFT_PWM_SCALE #define SOFT_PWM_SCALE 0 @@ -247,8 +245,8 @@ void PID_autotune(float temp, int extruder, int ncycles) } #endif - if (heating == true && input > temp) { - if (ms - t2 > 5000) { + if (heating && input > temp) { + if (ms > t2 + 5000) { heating = false; if (extruder < 0) soft_pwm_bed = (bias - d) >> 1; @@ -259,8 +257,9 @@ void PID_autotune(float temp, int extruder, int ncycles) max = temp; } } - if (heating == false && input < temp) { - if (ms - t1 > 5000) { + + if (!heating && input < temp) { + if (ms > t1 + 5000) { heating = true; t2 = ms; t_low = t2 - t1; @@ -313,7 +312,8 @@ void PID_autotune(float temp, int extruder, int ncycles) } } } - if (input > temp + 20) { + #define MAX_OVERSHOOT_PID_AUTOTUNE 20 + if (input > temp + MAX_OVERSHOOT_PID_AUTOTUNE) { SERIAL_PROTOCOLLNPGM(MSG_PID_TEMP_TOO_HIGH); return; } @@ -447,14 +447,14 @@ void checkExtruderAutoFans() // // Temperature Error Handlers // -inline void _temp_error(int e, const char *msg1, const char *msg2) { +inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) { if (IsRunning()) { SERIAL_ERROR_START; if (e >= 0) SERIAL_ERRORLN((int)e); - serialprintPGM(msg1); + serialprintPGM(serial_msg); MYSERIAL.write('\n'); #ifdef ULTRA_LCD - lcd_setalertstatuspgm(msg2); + lcd_setalertstatuspgm(lcd_msg); #endif } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE @@ -602,17 +602,17 @@ void manage_heater() { float ct = current_temperature[0]; if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0); if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0); - #endif //HEATER_0_USES_MAX6675 + #endif - #if defined(WATCH_TEMP_PERIOD) || !defined(PIDTEMPBED) || HAS_AUTO_FAN + #if defined(THERMAL_PROTECTION_HOTENDS) || !defined(PIDTEMPBED) || HAS_AUTO_FAN millis_t ms = millis(); #endif // Loop through all extruders for (int e = 0; e < EXTRUDERS; e++) { - #if HAS_HEATER_THERMAL_PROTECTION - thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS); + #ifdef THERMAL_PROTECTION_HOTENDS + thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS); #endif float pid_output = get_pid_output(e); @@ -620,26 +620,31 @@ void manage_heater() { // Check if temperature is within the correct range soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0; - #ifdef WATCH_TEMP_PERIOD - if (watchmillis[e] && ms > watchmillis[e] + WATCH_TEMP_PERIOD) { - if (degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE) { - setTargetHotend(0, e); - LCD_MESSAGEPGM(MSG_HEATING_FAILED_LCD); // translatable - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_HEATING_FAILED); + // Check if the temperature is failing to increase + #ifdef THERMAL_PROTECTION_HOTENDS + + // Is it time to check this extruder's heater? + if (watch_heater_next_ms[e] && ms > watch_heater_next_ms[e]) { + // Has it failed to increase enough? + if (degHotend(e) < watch_target_temp[e]) { + // Stop! + disable_all_heaters(); + _temp_error(e, PSTR(MSG_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD)); } else { - watchmillis[e] = 0; + // Start again if the target is still far off + start_watching_heater(e); } } - #endif //WATCH_TEMP_PERIOD + + #endif // THERMAL_PROTECTION_HOTENDS #ifdef TEMP_SENSOR_1_AS_REDUNDANT if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { disable_all_heaters(); _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP)); } - #endif // TEMP_SENSOR_1_AS_REDUNDANT + #endif } // Extruders Loop @@ -672,8 +677,8 @@ void manage_heater() { #if TEMP_SENSOR_BED != 0 - #if HAS_BED_THERMAL_PROTECTION - thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); + #ifdef THERMAL_PROTECTION_BED + thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS); #endif #ifdef PIDTEMPBED @@ -784,7 +789,7 @@ static void updateTemperaturesFromRawValues() { #ifdef HEATER_0_USES_MAX6675 current_temperature_raw[0] = read_max6675(); #endif - for(uint8_t e = 0; e < EXTRUDERS; e++) { + for (uint8_t e = 0; e < EXTRUDERS; e++) { current_temperature[e] = analog2temp(current_temperature_raw[e], e); } current_temperature_bed = analog2tempBed(current_temperature_bed_raw); @@ -996,19 +1001,24 @@ void tp_init() { #endif //BED_MAXTEMP } -void setWatch() { - #ifdef WATCH_TEMP_PERIOD - millis_t ms = millis(); - for (int e = 0; e < EXTRUDERS; e++) { - if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) { - watch_start_temp[e] = degHotend(e); - watchmillis[e] = ms; - } +#ifdef THERMAL_PROTECTION_HOTENDS + /** + * Start Heating Sanity Check for hotends that are below + * their target temperature by a configurable margin. + * This is called when the temperature is set. (M104, M109) + */ + void start_watching_heater(int e) { + millis_t ms = millis() + WATCH_TEMP_PERIOD * 1000; + if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1)) { + watch_target_temp[e] = degHotend(e) + WATCH_TEMP_INCREASE; + watch_heater_next_ms[e] = ms; } - #endif -} + else + watch_heater_next_ms[e] = 0; + } +#endif -#if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION +#if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED) void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { @@ -1074,7 +1084,7 @@ void setWatch() { } } -#endif // HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION +#endif // THERMAL_PROTECTION_HOTENDS || THERMAL_PROTECTION_BED void disable_all_heaters() { for (int i=0; i= 0) start_watching_heater(endnum); + #endif } void lcd_preheat_pla0() { _lcd_preheat(0, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); } void lcd_preheat_abs0() { _lcd_preheat(0, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); } @@ -878,10 +872,17 @@ static void lcd_control_menu() { * "Control" > "Temperature" submenu * */ - static void lcd_control_temperature_menu() { START_MENU(); + + // + // ^ Control + // MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); + + // + // Nozzle, Nozzle 2, Nozzle 3, Nozzle 4 + // #if TEMP_SENSOR_0 != 0 MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); #endif @@ -900,16 +901,32 @@ static void lcd_control_temperature_menu() { #endif // EXTRUDERS > 3 #endif // EXTRUDERS > 2 #endif // EXTRUDERS > 1 + + // + // Bed + // #if TEMP_SENSOR_BED != 0 MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); #endif + + // + // Fan Speed + // MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); + + // + // Autotemp, Min, Max, Fact + // #if defined(AUTOTEMP) && (TEMP_SENSOR_0 != 0) MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled); MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15); MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15); MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0); #endif + + // + // PID-P, PID-I, PID-D, PID-C + // #ifdef PIDTEMP // set up temp variables - undo the default scaling raw_Ki = unscalePID_i(PID_PARAM(Ki,0)); @@ -962,7 +979,15 @@ static void lcd_control_temperature_menu() { #endif//EXTRUDERS > 1 #endif //PID_PARAMS_PER_EXTRUDER #endif//PIDTEMP + + // + // Preheat PLA conf + // MENU_ITEM(submenu, MSG_PREHEAT_PLA_SETTINGS, lcd_control_temperature_preheat_pla_settings_menu); + + // + // Preheat ABS conf + // MENU_ITEM(submenu, MSG_PREHEAT_ABS_SETTINGS, lcd_control_temperature_preheat_abs_settings_menu); END_MENU(); } @@ -972,7 +997,6 @@ static void lcd_control_temperature_menu() { * "Temperature" > "Preheat PLA conf" submenu * */ - static void lcd_control_temperature_preheat_pla_settings_menu() { START_MENU(); MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); @@ -994,7 +1018,6 @@ static void lcd_control_temperature_preheat_pla_settings_menu() { * "Temperature" > "Preheat ABS conf" submenu * */ - static void lcd_control_temperature_preheat_abs_settings_menu() { START_MENU(); MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); @@ -1016,7 +1039,6 @@ static void lcd_control_temperature_preheat_abs_settings_menu() { * "Control" > "Motion" submenu * */ - static void lcd_control_motion_menu() { START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); @@ -1058,7 +1080,6 @@ static void lcd_control_motion_menu() { * "Control" > "Filament" submenu * */ - static void lcd_control_volumetric_menu() { START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); @@ -1086,7 +1107,6 @@ static void lcd_control_volumetric_menu() { * "Control" > "Contrast" submenu * */ - #ifdef HAS_LCD_CONTRAST static void lcd_set_contrast() { if (encoderPosition != 0) { @@ -1106,7 +1126,6 @@ static void lcd_control_volumetric_menu() { * "Control" > "Retract" submenu * */ - #ifdef FWRETRACT static void lcd_control_retract_menu() { START_MENU(); @@ -1144,7 +1163,6 @@ static void lcd_sd_updir() { * "Print from SD" submenu * */ - void lcd_sdcard_menu() { if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card) uint16_t fileCnt = card.getnrfilenames(); @@ -1290,7 +1308,7 @@ void lcd_quick_feedback() { #define LCD_FEEDBACK_FREQUENCY_DURATION_MS (1000/6) #endif lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); - #elif defined(BEEPER) && BEEPER > -1 + #elif defined(BEEPER) && BEEPER >= 0 #ifndef LCD_FEEDBACK_FREQUENCY_HZ #define LCD_FEEDBACK_FREQUENCY_HZ 5000 #endif @@ -1723,12 +1741,12 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } void lcd_buzz(long duration, uint16_t freq) { if (freq > 0) { - #if BEEPER > 0 + #ifdef LCD_USE_I2C_BUZZER + lcd.buzz(duration, freq); + #elif defined(BEEPER) && BEEPER >= 0 SET_OUTPUT(BEEPER); tone(BEEPER, freq, duration); delay(duration); - #elif defined(LCD_USE_I2C_BUZZER) - lcd.buzz(duration, freq); #else delay(duration); #endif diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 8f96f008ba..956b728286 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -106,7 +106,7 @@ FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {} FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_reset_alert_level() {} - FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {} + FORCE_INLINE void lcd_buzz(long duration, uint16_t freq) {} FORCE_INLINE bool lcd_detected(void) { return true; } #define LCD_MESSAGEPGM(x) do{}while(0) diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index eb1f525cc2..27e2be0e30 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -6,17 +6,17 @@ * When selecting the Russian language, a slightly different LCD implementation is used to handle UTF8 characters. **/ -#ifndef REPRAPWORLD_KEYPAD - extern volatile uint8_t buttons; //the last checked buttons in a bit array. -#else - extern volatile uint16_t buttons; //an extended version of the last checked buttons in a bit array. -#endif +//#ifndef REPRAPWORLD_KEYPAD +// extern volatile uint8_t buttons; //the last checked buttons in a bit array. +//#else + extern volatile uint8_t buttons; //an extended version of the last checked buttons in a bit array. +//#endif //////////////////////////////////// // Setup button and encode mappings for each panel (into 'buttons' variable // -// This is just to map common functions (across different panels) onto the same -// macro name. The mapping is independent of whether the button is directly connected or +// This is just to map common functions (across different panels) onto the same +// macro name. The mapping is independent of whether the button is directly connected or // via a shift/i2c register. #ifdef ULTIPANEL @@ -38,7 +38,7 @@ // #if defined(LCD_I2C_VIKI) #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + // button and encoder bit positions within 'buttons' #define B_LE (BUTTON_LEFT< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -156,28 +156,28 @@ #include #define LCD_CLASS LiquidTWI2 #if defined(DETECT_DEVICE) - LCD_CLASS lcd(LCD_I2C_ADDRESS, 1); + LCD_CLASS lcd(LCD_I2C_ADDRESS, 1); #else - LCD_CLASS lcd(LCD_I2C_ADDRESS); + LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include #define LCD_CLASS LiquidTWI2 #if defined(DETECT_DEVICE) - LCD_CLASS lcd(LCD_I2C_ADDRESS, 1); + LCD_CLASS lcd(LCD_I2C_ADDRESS, 1); #else - LCD_CLASS lcd(LCD_I2C_ADDRESS); + LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif #elif defined(LCD_I2C_TYPE_PCA8574) #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } #include @@ -353,159 +353,152 @@ static void lcd_implementation_init( #endif ) { -#if defined(LCD_I2C_TYPE_PCF8575) + #if defined(LCD_I2C_TYPE_PCF8575) lcd.begin(LCD_WIDTH, LCD_HEIGHT); - #ifdef LCD_I2C_PIN_BL - lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); - lcd.setBacklight(HIGH); - #endif - -#elif defined(LCD_I2C_TYPE_MCP23017) + #ifdef LCD_I2C_PIN_BL + lcd.setBacklightPin(LCD_I2C_PIN_BL, POSITIVE); + lcd.setBacklight(HIGH); + #endif + + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - -#elif defined(LCD_I2C_TYPE_MCP23008) + + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); -#elif defined(LCD_I2C_TYPE_PCA8574) - lcd.init(); - lcd.backlight(); - -#else + #elif defined(LCD_I2C_TYPE_PCA8574) + lcd.init(); + lcd.backlight(); + + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); -#endif + #endif - lcd_set_custom_characters( - #ifdef LCD_PROGRESS_BAR - progress_bar_set - #endif - ); + lcd_set_custom_characters( + #ifdef LCD_PROGRESS_BAR + progress_bar_set + #endif + ); - lcd.clear(); -} -static void lcd_implementation_clear() -{ - lcd.clear(); + lcd.clear(); } +static void lcd_implementation_clear() { lcd.clear(); } + /* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ char lcd_printPGM(const char* str) { - char c; - char n = 0; - while((c = pgm_read_byte(str++))) { - n += charset_mapper(c); - } + char c, n = 0; + while ((c = pgm_read_byte(str++))) n += charset_mapper(c); return n; } char lcd_print(char* str) { char c, n = 0;; unsigned char i = 0; - while((c = str[i++])) { - n += charset_mapper(c); - } + while ((c = str[i++])) n += charset_mapper(c); return n; } -unsigned lcd_print(char c) { - return charset_mapper(c); -} +unsigned lcd_print(char c) { return charset_mapper(c); } /* Possible status screens: -16x2 |0123456789012345| - |000/000 B000/000| - |Status line.....| +16x2 |000/000 B000/000| + |0123456789012345| -16x4 |0123456789012345| - |000/000 B000/000| - |SD100% Z000.0| +16x4 |000/000 B000/000| + |SD100% Z000.00 | |F100% T--:--| - |Status line.....| + |0123456789012345| -20x2 |01234567890123456789| - |T000/000D B000/000D | - |Status line.........| +20x2 |T000/000D B000/000D | + |01234567890123456789| -20x4 |01234567890123456789| - |T000/000D B000/000D | - |X000 Y000 Z000.00| +20x4 |T000/000D B000/000D | + |X000 Y000 Z000.00 | |F100% SD100% T--:--| - |Status line.........| + |01234567890123456789| -20x4 |01234567890123456789| - |T000/000D B000/000D | - |T000/000D Z000.0| +20x4 |T000/000D B000/000D | + |T000/000D Z000.00 | |F100% SD100% T--:--| - |Status line.........| + |01234567890123456789| */ static void lcd_implementation_status_screen() { - int tHotend = int(degHotend(0) + 0.5); - int tTarget = int(degTargetHotend(0) + 0.5); + + #define LCD_TEMP_ONLY(T1,T2) \ + lcd.print(itostr3(T1 + 0.5)); \ + lcd.print('/'); \ + lcd.print(itostr3left(T2 + 0.5)) + + #define LCD_TEMP(T1,T2,PREFIX) \ + lcd.print(PREFIX); \ + LCD_TEMP_ONLY(T1,T2); \ + lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); \ + if (T2 < 10) lcd.print(' ') + + // + // Line 1 + // + + lcd.setCursor(0, 0); #if LCD_WIDTH < 20 - lcd.setCursor(0, 0); - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); + // + // Hotend 0 Temperature + // + LCD_TEMP_ONLY(degHotend(0), degTargetHotend(0)); + // + // Hotend 1 or Bed Temperature + // #if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - // If we have an 2nd extruder or heated bed, show that in the top right corner lcd.setCursor(8, 0); #if EXTRUDERS > 1 - tHotend = int(degHotend(1) + 0.5); - tTarget = int(degTargetHotend(1) + 0.5); lcd.print(LCD_STR_THERMOMETER[0]); - #else // Heated bed - tHotend = int(degBed() + 0.5); - tTarget = int(degTargetBed() + 0.5); + LCD_TEMP_ONLY(degHotend(1), degTargetHotend(1)); + #else lcd.print(LCD_STR_BEDTEMP[0]); + LCD_TEMP_ONLY(degBed(), degTargetBed()); #endif - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); #endif // EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - #else // LCD_WIDTH > 19 + #else // LCD_WIDTH >= 20 - lcd.setCursor(0, 0); - lcd.print(LCD_STR_THERMOMETER[0]); - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (tTarget < 10) lcd.print(' '); + // + // Hotend 0 Temperature + // + LCD_TEMP(degHotend(0), degTargetHotend(0), LCD_STR_THERMOMETER[0]); + // + // Hotend 1 or Bed Temperature + // #if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - // If we have an 2nd extruder or heated bed, show that in the top right corner lcd.setCursor(10, 0); #if EXTRUDERS > 1 - tHotend = int(degHotend(1) + 0.5); - tTarget = int(degTargetHotend(1) + 0.5); - lcd.print(LCD_STR_THERMOMETER[0]); - #else // Heated bed - tHotend = int(degBed() + 0.5); - tTarget = int(degTargetBed() + 0.5); - lcd.print(LCD_STR_BEDTEMP[0]); + LCD_TEMP(degHotend(1), degTargetHotend(1), LCD_STR_THERMOMETER[0]); + #else + LCD_TEMP(degBed(), degTargetBed(), LCD_STR_BEDTEMP[0]); #endif - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (tTarget < 10) lcd.print(' '); #endif // EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - #endif // LCD_WIDTH > 19 + #endif // LCD_WIDTH >= 20 + + // + // Line 2 + // #if LCD_HEIGHT > 2 - // Lines 2 for 4 line LCD + #if LCD_WIDTH < 20 + #ifdef SDSUPPORT lcd.setCursor(0, 2); lcd_printPGM(PSTR("SD")); @@ -516,36 +509,48 @@ static void lcd_implementation_status_screen() { lcd.print('%'); #endif // SDSUPPORT - #else // LCD_WIDTH > 19 + #else // LCD_WIDTH >= 20 + + lcd.setCursor(0, 1); #if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0 - // If we both have a 2nd extruder and a heated bed, show the heated bed temp on the 2nd line on the left, as the first line is filled with extruder temps - tHotend = int(degBed() + 0.5); - tTarget = int(degTargetBed() + 0.5); - lcd.setCursor(0, 1); - lcd.print(LCD_STR_BEDTEMP[0]); - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (tTarget < 10) lcd.print(' '); + // If we both have a 2nd extruder and a heated bed, + // show the heated bed temp on the left, + // since the first line is filled with extruder temps + LCD_TEMP(degBed(), degTargetBed(), LCD_STR_BEDTEMP[0]); + #else - lcd.setCursor(0,1); + lcd.print('X'); - lcd.print(ftostr3(current_position[X_AXIS])); + if (axis_known_position[X_AXIS]) + lcd.print(ftostr3(current_position[X_AXIS])); + else + lcd_printPGM(PSTR("---")); + lcd_printPGM(PSTR(" Y")); - lcd.print(ftostr3(current_position[Y_AXIS])); + if (axis_known_position[Y_AXIS]) + lcd.print(ftostr3(current_position[Y_AXIS])); + else + lcd_printPGM(PSTR("---")); + #endif // EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - #endif // LCD_WIDTH > 19 + #endif // LCD_WIDTH >= 20 lcd.setCursor(LCD_WIDTH - 8, 1); lcd.print('Z'); - lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001)); + if (axis_known_position[Z_AXIS]) + lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001)); + else + lcd_printPGM(PSTR("---.--")); #endif // LCD_HEIGHT > 2 + // + // Line 3 + // + #if LCD_HEIGHT > 3 lcd.setCursor(0, 2); @@ -579,9 +584,10 @@ static void lcd_implementation_status_screen() { #endif // LCD_HEIGHT > 3 - /** - * Display Progress Bar, Filament display, and/or Status Message on the last line - */ + // + // Last Line + // Status Message (which may be a Progress Bar or Filament display) + // lcd.setCursor(0, LCD_HEIGHT - 1); @@ -728,13 +734,13 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + // Set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -766,4 +772,4 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const #endif // LCD_HAS_SLOW_BUTTONS -#endif //__ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H +#endif // ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H diff --git a/README.md b/README.md index 9b40193d25..20dab15454 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,7 @@ # Marlin 3D Printer Firmware - * [Configuration & Compilation](/Documentation/Compilation.md) - * Supported - * [Features](/Documentation/Features.md) - * [Hardware](/Documentation/Hardware.md) - * [GCodes](/Documentation/GCodes.md) - * Notes - * [Auto Bed Leveling](/Documentation/BedLeveling.md) - * [Filament Sensor](/Documentation/FilamentSensor.md) - * [Ramps Servo Power](/Documentation/RampsServoPower.md) - * [LCD Language - Font - System](Documentation/LCDLanguageFont.md) - * [Mesh Bed Leveling](/Documentation/MeshBedLeveling.md) - -##### [RepRap.org Wiki Page](http://reprap.org/wiki/Marlin) - -## Quick Information - -This is a firmware for reprap single-processor electronics setups. -It also works on the Ultimaker PCB. It supports printing from SD card+Folders and look-ahead trajectory planning. -This firmware is a mashup between [Sprinter](https://github.com/kliment/Sprinter), [grbl](https://github.com/simen/grbl), and many original parts. + Documentation has moved to http://www.marlinfirmware.org ## Current Status: Bug Fixing @@ -28,20 +10,28 @@ The Marlin development is currently revived. There's a long list of reported iss [![Coverity Scan Build Status](https://scan.coverity.com/projects/2224/badge.svg)](https://scan.coverity.com/projects/2224) [![Travis Build Status](https://travis-ci.org/MarlinFirmware/Marlin.svg)](https://travis-ci.org/MarlinFirmware/Marlin) +##### [RepRap.org Wiki Page](http://reprap.org/wiki/Marlin) + ## Contact -__Google Hangout:__ Hangout +__Google Hangout:__ . Hangout We have a hangout every 2 weeks. Search the issue list for "Hangout" and you will see what time and date the next event is going on. ## Credits The current Marlin dev team consists of: - Scott Lahteine [@thinkyhead] - - - -## Donation - -If you find our work usefull please consider donating. Donations will be used to pay for our website http://www.marlinfirmware.org/ and to pay some food or rent money for the very active Collaborators + - Andreas Hardtung [@AnHardt] + - [@Wurstnase] + - [@fmalpartida] + - [@CONSULitAS] + - [@maverikou] + - Chris Palmer [@nophead] + - [@paclema] + - [@epatel] + - Erik van der Zalm [@ErikZalm] + - David Braam [@daid] + - Bernhard Kubicek [@bkubicek] More features have been added by: - Lampmaker,