Commit Graph

361 Commits

Author SHA1 Message Date
Scott Lahteine
81aab828e2 Fix a "Heating failed" error
Addressing #3085. If the target_temperature is set directly it never invokes or disables the timer set in `start_watching_heater`, so after _stopping a print_ or turning off _all heaters_ you could get a “Heating failed” error.
2016-03-11 05:07:48 -08:00
Scott Lahteine
27f244ba2c Support MAX31855 as Temperature Sensor -3 2016-03-10 02:49:54 -08:00
jbrazio
986b508ff7 Print timer now stops when it sees the last extruder temperature being shutdown 2016-03-08 18:11:02 +00:00
Scott Lahteine
ff13070b59 Use _BV macros, patch up others 2016-03-06 05:51:55 -08:00
Scott Lahteine
209f5f21e0 Use macros where possible
Apply `constrain`, `NOMORE`, `NOLESS` and `CRITICAL_SECTION` macros
wherever possible.
2016-03-06 05:51:55 -08:00
Scott Lahteine
3a3d358df9 Fix Printrboard with LCD (redo)
Based on #2860 - rebased for RCBugFix
2016-03-05 22:13:00 -08:00
Blue-Marlin
0631541166 Fix disable_all_heaters() for MAX6675 2016-03-02 14:17:23 +01:00
AnHardt
57da1b8497 Host parseble output for M109, M190 and M303
Make the output of M105 more similar to Repetier.
Make the text-print pert of M105 an extra function to make it reusable. `print_heaterstates()`
Use `print_heaterstates()` in M019, M190 and M303
2015-12-07 15:37:53 -06:00
Richard Wackerbarth
956418c674 Kc is also a multi-PID parameter 2015-11-23 06:08:01 -06:00
Scott Lahteine
dbd4c17096 Init Kp, Ki, Kd to 0 2015-11-12 00:03:22 -06:00
Scott Lahteine
b4af4441c5 Clean up watchdog impl. 2015-11-12 00:03:22 -06:00
Scott Lahteine
9bdab4f3a8 Clean up "else" and other spacing 2015-11-12 00:03:21 -06:00
Richard Wackerbarth
25d636c9e0 Compiler issues (PR#2696) 2015-11-11 23:52:11 -06:00
AnHardt
47401ec97b MSG_EXTRUDER_SWITCHED_OFF was renamed to MSG_REDUNDANCY
in language.h, but was not renamed here. If TEMP_SENSOR_1 is enabled as redundant then
an error is thrown that MSG_EXTRUDER_SWITCHED_OFF is not defined.

Originaly by @12dstring
2015-10-08 10:45:11 -05:00
Scott Lahteine
0c7f7ebcfb Styling adjustments (PR#2668 & PR#2670)
Keep "astyled" reformatting
2015-10-03 22:02:45 -05:00
Scott Lahteine
bc50db9cf6 Implement PID_ADD_EXTRUSION_RATE 2015-09-12 07:53:20 -05:00
Scott Lahteine
51e89a269c Overridable Options - Part 9 (PR#2561)
Apply `ENABLED` / `DISABLED` macros to temperature-related files.
2015-07-31 01:05:55 -05:00
AnHardt
d17f7ebc8a Multiply WATCH_TEMP_PERIOD by 1000UL (PR#2535)
instead of 1000.  Else we get errors with times over 32 seconds.
2015-07-27 20:30:53 -05:00
Scott Lahteine
e4c01f1c7e Simplify init with ARRAY_BY_EXTRUDERS1 macro (PR#2507) 2015-07-26 20:40:27 -05:00
Scott Lahteine
77e80ef367 Require extruders for thermal code 2015-07-16 16:36:30 -05:00
Scott Lahteine
3bde4f4855 Require temp sensor for bed thermal protection 2015-07-16 16:36:30 -05:00
ayberkozgur
7268d46508 Always calculate extruder temperature PID d term (PR#2432) 2015-07-13 13:22:26 -05:00
Scott Lahteine
a274769f4f Clean up spacing and comments
Also clean up some trailing spaces in a few other sources
2015-06-15 20:20:31 -05:00
Scott Lahteine
1d94d098bf Formatting tweaks as part of fixing issue 1497 2015-06-14 19:57:27 -05:00
Scott Lahteine
e602c28ad9 Set auto fan pins to OUTPUT during init
Fixes the problem of these pins being left in INPUT state, as described
in #1497
2015-06-14 19:57:27 -05:00
MagoKimbra
eb81982fcd Fix error next command in autotune (PR#2274)
Now send only temperature for T or B, but not send OK.
Host interprets the line to show the right temperature, but not in
response to M105 then stop and send commands until it ends the autotune.
2015-06-12 07:10:38 -05:00
AnHardt
b1404a0743 fix thermal protection state machine target temp. V2
If the target temperature is changed then it would always stay in the reset state.
Thanks to @tonokip.

Replaces #2119
2015-06-02 12:26:21 +02:00
Jonathan Bastien-Filiatrault
e86f2342c0 Separate the maximum integral power for the bed from PID_INTEGRAL_DRIVE_MAX / PID_MAX.
My PID_INTEGRAL_DRIVE_MAX was at 96, which was insufficient for my bed
to reach its intended temperature. The head requires a low maximum power since
I run on 24 volts and it has a somewhat low thermal mass.
2015-05-28 11:48:04 -04:00
AnHardt
da246f5cb1 Activate BED_MINTEMP error.
And call _temp_error() directly for ERR_MAXTEMP_BED to avoid the only one time use of bed_max_temp_error().

Includes #2156.
2015-05-25 13:23:19 +02:00
AnHardt
959da98d8e Call kill() only once when triggered by a temperature error
to avoid stack overflow when called from interrupt.

Some clean up for calls of disable_all_heaters().
'disable_all_heaters()' is called in kill() and again when 'killed' is already set inside _temp_error().
2015-05-25 12:44:03 +02:00
Scott Lahteine
063881b5bd Fix a couple of doubled semicolons 2015-05-21 18:15:29 -07:00
Scott Lahteine
00716d0ca0 Small start_watching_heater adjustment 2015-05-21 16:44:49 -07:00
AnHardt
4422365a53 Merge branch 'Development' of https://github.com/MarlinFirmware/Marlin into _temp_error 2015-05-20 23:34:39 +02:00
AnHardt
4113762062 Merge pull request #2130 from AnHardt/kill2
Add a string parameter to kill()
2015-05-20 23:32:51 +02:00
AnHardt
120d4c7a8c Merge remote-tracking branch 'origin/kill2' into _temp_error 2015-05-20 21:25:32 +02:00
AnHardt
cb6e82dc60 Change from kill() to kill(const char *)
in temperature.cpp
2015-05-20 21:22:48 +02:00
AnHardt
9d13942278 Use new kill() with parameter. 2015-05-20 21:18:52 +02:00
AnHardt
2990c6c45f Use new kill_() for _temp_error()
instead of stop(). We really want to require a reset and no chance to set a new temperature.
2015-05-20 14:03:14 +02:00
AnHardt
70163dafb9 Use _temp_error() for all errors thrown by different mechanisms
Now ending in an endless loop.
Tidy up the output format.
We now get:
ERRORTEXT ", system stopped! Heater_ID: " HEATERID

Where ERRORTEXT can be:
"Heating failed"
"Thermal Runaway"
"MAXTEMP triggered"
"MINTEMP triggered"
and soon
"Thermal Jump"

HEATERID can be
0, 1, 2 ,3 , "bed"

This messages are always followed by the common:
"Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
2015-05-18 20:26:25 +02:00
AnHardt
97ca1b3f4d Name magic value 20 to MAX_OVERSHOOT_PID_AUTOTUNE
to make it better findable.
2015-05-18 14:15:29 +02:00
Scott Lahteine
f65833931d Formatting tweaks 2015-05-13 02:02:19 -07:00
Scott Lahteine
d693e0f378 Use WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1 as difference limit 2015-05-12 18:30:38 -07:00
Scott Lahteine
6697a8f375 Watch the heater a little longer 2015-05-12 18:22:47 -07:00
Scott Lahteine
5693a6e3c9 Fix heating error message 2015-05-12 18:17:13 -07:00
Scott Lahteine
8332a15899 Fix testing of runaway options in temperature.cpp 2015-05-10 23:03:24 -07:00
Scott Lahteine
2445ae3d3a Combine thermal runaway and watch-period
- Make thermal protection for all hotends and/or bed into simple
switches
- Now enable `WATCH_TEMP_PERIOD` when `THERMAL_PROTECTION_HOTENDS` is
enabled
- Move detailed thermal parameters to `Configuration_adv.h`
- Add sanity checks to warn about old configurations
- Change `WATCH_TEMP_PERIOD` to seconds instead of milliseconds
2015-05-10 22:52:01 -07:00
Scott Lahteine
9b3d4380d3 Only watch the heater that was set 2015-05-10 20:26:45 -07:00
Scott Lahteine
28c87ec81b Disable all heaters on temp error 2015-05-08 23:17:25 -07:00
Scott Lahteine
54deb9eea3 Enable WATCH_TEMP_PERIOD by default 2015-05-08 22:36:02 -07:00
Scott Lahteine
deedb00c18 Document WATCH_TEMP_PERIOD 2015-05-08 22:25:51 -07:00
Scott Lahteine
a120bf3fe4 Latest upstream commits 2015-04-27 22:40:19 -07:00
Scott Lahteine
ae53b3cdc3 Fix the M303 S-1 report text 2015-04-27 22:25:00 -07:00
Scott Lahteine
0fca084ea6 Make EEPROM reproducible in GCode
With these changes the output of `M503 S0` is all you need to restore
the EEPROM. Building on this it is straightforward to save and restore
the EEPROM state using the SD card or external GCode file.

- Added `M145` to set “heatup states” for the LCD menu
- Added `M420` to toggle Mesh Bed Leveling
- Added `M421` to set a single Mesh coordinate
- Extended `Config_PrintSettings` with added M codes
- Cleaned up some comments here and there
2015-04-26 20:56:33 -07:00
paclema
581685a231 Added new PID autotune info, to make easy copy & paste results to marlin 2015-04-17 11:15:09 +02:00
Scott Lahteine
09d60e0128 Naming and code comments 2015-04-13 17:17:36 -07:00
Scott Lahteine
257a907456 Fix typo in next_bed_check_ms 2015-04-12 23:17:28 -07:00
Scott Lahteine
e4b1e8651b next_ vars faster than previous_
- Change some `previous_` time vars to `next_` so an add only happens
at intervals
- Fix `HEATER_0_USES_MAX6675` polling too frequently, or not at all
2015-04-12 23:06:50 -07:00
Scott Lahteine
ccddc280be Apply three more commits 2015-04-12 22:47:44 -07:00
Scott Lahteine
27cb90da8b IsStopped / IsRunning inline 2015-04-08 00:56:19 -07:00
Scott Lahteine
e502144eda Fixup formatting of last commit 2015-04-06 21:28:14 -07:00
Richard Miles
1a5293c2ce Prevents MINTEMP / MAXTEMP when no heaters present
This commit checks whether or not HEATER_0 is in use, and if not, skips
the MIN / MAX temperature checks.
2015-04-05 22:27:14 +01:00
Scott Lahteine
b0f198c153 heater_index above its use 2015-04-04 06:18:08 -07:00
Scott Lahteine
60f8e0386f More thermal runaway states 2015-04-04 05:45:36 -07:00
Scott Lahteine
f9dbd73652 Fix tr_target_temperature type - float! 2015-04-04 05:25:53 -07:00
Scott Lahteine
a3e129e091 Merge pull request #1801 from thinkyhead/fixup_probing
Minor optimizations
2015-04-03 22:30:01 -07:00
Natealus
a6ba40ae48 Compiling error temperature.cpp with multiple extruders defined
It wouldn't compile because of this line in temperature.cpp it turns out
it was just a stray ( that didn't line up with the previous lines so I
just made it in line with the rest and it compiled fine.
2015-04-03 23:09:31 -06:00
Scott Lahteine
fc3c76fc16 Fix #1800 2015-04-03 22:04:42 -07:00
Scott Lahteine
9ba55baa5b Track target temperature separately for each heater 2015-04-03 19:42:40 -07:00
Scott Lahteine
528e32a1d4 Fix timeout in thermal_runaway when temperature is set higher 2015-04-03 19:34:55 -07:00
Scott Lahteine
b98ebd517e disable / enable_all_steppers functions 2015-04-03 19:25:22 -07:00
Scott Lahteine
c756b4cf07 Comment tweak 2015-04-02 06:11:03 -07:00
Scott Lahteine
e96df67630 Clarify thermal_runaway_protection
- Add comments documenting `thermal_runaway_protection`
- Add an enum for the thermal runaway states
- Add macros for temperature helper functions
- Fix a glitch with the z probe sled in homeaxis
2015-04-02 05:10:14 -07:00
AnHardt
488666832b Remove the previously introduced () 2015-04-01 13:40:05 +02:00
AnHardt
3f2e863206 Improve conditions for HAS_TEMP
and use them in temperuture.h

Flattened the if structure - the preprocessor is doing the work - not the Arduino. Arduino.
2015-04-01 02:56:14 +02:00
AnHardt
85f8a26ba4 Fix MIN&MAX temperatures again
replaced GE0 with th matching GEX in the second row.
added some ()
2015-04-01 00:48:04 +02:00
Scott Lahteine
571652c49b Fix LCD click
- Make the default LCD click sound more pleasant
- Fix warnings about bed temperature runaway
2015-03-31 01:41:24 -07:00
AnHardt
7b2550a604 Times can't be negative.
cardreader.cpp needs temperature.h for autotempShutdown() when
AUTOTEMP is defined but warns about unused variables.
Unpublished variables by putting them in to temperature.cpp.
2015-03-30 01:58:46 +02:00
Scott Lahteine
ba871e46bf Fix compiler warnings
- Patched up for most included configurations
2015-03-27 20:29:05 -07:00
Scott Lahteine
df02b992b0 Fix redundant_temperatrure_raw setting 2015-03-27 16:37:22 -07:00
Scott Lahteine
ce485175eb Give all temp arrays 4 indices 2015-03-27 16:11:28 -07:00
Scott Lahteine
410f64782a Always 4 temp sensors 2015-03-26 16:22:21 -07:00
Scott Lahteine
ad05a726c1 Merge pull request #1691 from AnHardt/PID_dt
Move definition of PIDdT back to temperature.h
2015-03-25 21:22:39 -07:00
AnHardt
f680e509c4 Enclosed error-messages for TEMP_SENSOR_1_AS_REDUNDANT in PSTR() 2015-03-25 23:26:06 +01:00
AnHardt
ac81b4084f Make variables and function static. 2015-03-25 21:37:15 +01:00
AnHardt
01cc97a3c3 Corected condition for PIDdT 2015-03-25 12:08:23 +01:00
AnHardt
94330705c7 Move definition of PIDdT back to temperature.h
make it unconditional
remove all definitions in the 'Configuration.h's
remove form 'Conditionals.h'
2015-03-25 11:51:41 +01:00
AnHardt
dd0067afa6 Fix MAX6675 again and introduce set_current_temp_raw()
to make the temperature-code work again with Arduino 1.0.6.

Sorry could not make an extra block on base level.
2015-03-25 11:08:24 +01:00
Scott Lahteine
0d81abe1c9 Merge branch 'Development' into config_testing
Latest upstream commits
2015-03-23 21:13:04 -07:00
Scott Lahteine
fc53e43de6 Don't test raw temp for MAX6675
- Remove test of raw temp for thermistor 0 when using MAX6675
- Longer `raw_temp_value` array for `TEMP_SENSOR_1_AS_REDUNDANT`
2015-03-23 20:55:48 -07:00
Scott Lahteine
1fac388664 Revert measurement loop 2015-03-23 15:18:22 -07:00
Scott Lahteine
6bdee87be3 Cleanup temperature code
- Get rid of unused temp states in the ISR, resulting in more frequent
temperature reading with fewer sensors
- Shrink code slightly in min/max testing
2015-03-23 00:27:29 -07:00
Scott Lahteine
15eb5d35a2 Merge branch 'Development' into config_testing
Latest upstream commits
2015-03-21 15:42:45 -07:00
Scott Lahteine
3703694e30 Fix temperature min/max test
- Base tests on all thermistors/thermocouples, not just heater 0
2015-03-21 14:23:43 -07:00
Scott Lahteine
63d5d28085 Merge branch 'Development' into config_testing
Latest upstream changes
2015-03-20 04:15:18 -07:00
Scott Lahteine
670006b919 Remove invariant code from Configurations
- Add `Conditionals.h` with calculated configuration values
- Add `SanityCheck.h` with checks for configuration errors
- Remove equivalent code from all configurations
- Move error checks from some sources to `SanityCheck.h` also
- Fix initialization of count_direction in stepper.cpp
2015-03-19 22:22:23 -07:00
AnHardt
47c1ea72af Merge https://github.com/kieranc/Marlin into PIDdebug
Conflicts:
	Marlin/temperature.cpp

Cleaned merge conflict.

Codeposition had changed.
Variable pid_input had vanished.

Signed-off-by: AnHardt <github@kitelab.de>
2015-03-20 00:07:36 +01:00
AnHardt
28b1c37dea Fix for #1612 2015-03-15 21:35:33 +01:00
Scott Lahteine
bb4cb1b15a Merge pull request #1606 from thinkyhead/cleanup_stepper
Cleanup of stepper.cpp
2015-03-15 06:05:08 -07:00
Scott Lahteine
c37f7d15c9 - Rename WRITE_E_STEP for consistency
- Add BIT and TEST macros
- Add _APPLY_ macros to stepper.cpp to help with consolidation
- Consolidate code in stepper.cpp using macros
- Apply standards in stepper.cpp
- Use >= 0 instead of > -1 as a better semantic
- Replace DUAL_Y_CARRIAGE with Y_DUAL_STEPPER_DRIVERS
2015-03-14 04:28:22 -07:00
Scott Lahteine
cb57fc727d Declare pid_output for PIDBEDTEMP 2015-03-13 20:19:51 -07:00
Scott Lahteine
3d6deb9bdf Simplify manage_heater
- Make separate get_pid_output(e) and get_pid_output_bed() function
- Reduce size of manage_heater function
- Hopefully work around linker errors
2015-03-13 19:49:41 -07:00
Scott Lahteine
e3ca9137b5 Fix missing temp_error declarations
- Fix for #1591 replacing #1595
2015-03-11 16:38:42 -07:00
AnHardt
3024f6c706 Undubble MSG_MIN &MSG MAX 2015-03-06 00:25:44 +01:00
Scott Lahteine
dfb38874f8 Some suggested changes for #1555 2015-03-03 00:48:20 -08:00
Scott Lahteine
1a7b0d9a37 Redo HAS_* macros to fix define error 2015-02-26 01:14:59 -08:00
Scott Lahteine
864dddc878 Macros to the top, a few HAS_* macros 2015-02-26 00:33:30 -08:00
Scott Lahteine
fd1ea9d56f Move literal strings to language files 2015-02-24 23:03:08 -08:00
Scott Lahteine
aa9c1f1bed Better name for ADC macro 2015-02-24 05:38:10 -08:00
Scott Lahteine
9c9726d469 Cleanup of temperature code
- Reduce calls to millis()
- General cleanup of manage_heaters
- General cleanup of pid autotune
- Formatting here & there
- Macros to clean up and shrink ISR code (reduced by ~364 lines)
2015-02-24 04:46:11 -08:00
Scott Lahteine
e3fd3e8fa4 Fix typos in checkExtruderAutoFans 2015-02-20 00:08:59 -08:00
Natealus
ea9e49b20d ARRAY_BY_EXTRUDERS 4th hotend PID parameters 2015-02-12 00:56:47 -07:00
kieranc
0a19109476 Enable PID debugging for heated bed 2015-02-10 14:11:44 +01:00
Natealus
f4b0a40abb Additional fixes to temperature.cpp and found another missing line
Looks like INVERT_E3_DIR was missing in the configuration.h also as I
did a test compile with 4 extruders and Azteeg X3 Pro defined. So I also
added those lines too. Additional formatting to make the comments line
up better in that section.
2015-02-08 15:43:58 -07:00
Natealus
697ee2dc50 Compiling errors with 4 Extruders defined
Here were a few changes that I had to make/add lines for the 4th hotend.
A compiling problem in the Temperature.cpp and missing lines in
configuration.h and configuration_adv.h. I added these lines in all of
the example configs too.
2015-02-08 01:05:05 -07:00
MagoKimbra
3021f7f743 Fix PID_dT
Add PID_dT in temeprature.cpp
2015-01-25 17:56:14 +01:00
MagoKimbra
ef5959a705 Fix Temperature
Githun insert this line when i merge with actual Branch development...
2015-01-24 13:49:29 +01:00
MagoKimbra
3d4ee6c868 Merge branch '4th-extruders' of https://github.com/MagoKimbra/Marlin into 4th-extruders
Conflicts:
	Marlin/temperature.cpp
2015-01-24 13:41:15 +01:00
MagoKimbra
986e723eeb Add 4th extruder 2015-01-24 13:37:58 +01:00
Scott Lahteine
f16bdd2ff2 Borrow from Ultimaker to fix MAX6675 SPI conflict
Changes to temperature.cpp from Ultimaker fork, intended to address
#1226 and #1227
2015-01-24 03:49:15 -08:00
MagoKimbra
0ebf896070 Add 4th extruder 2015-01-23 23:13:06 +01:00
Mark Hindess
0ce252ba7a This ifdef is for bed code so should use bed constants for testing.
Without this fix, the code wont compile with extruder but without bed
runaway protection defined.
2015-01-23 16:30:13 +00:00
daid
53f971095d Revert "Reduce PROGMEM warnings" 2015-01-16 16:48:22 +01:00
galexander1
d4880a9e60 Revert "Move Sd library out into library" 2015-01-15 18:52:10 -05:00
Bo Herrmannsen
4b51b5a46d Merge pull request #1357 from odewdney/SDlib
Move Sd library out into library
2015-01-15 10:56:07 +01:00
odewdney
f84ff4ba7d Move SD Fat library out of main src 2015-01-13 13:31:55 +00:00
Bo Herrmannsen
ab074dac17 Merge pull request #1344 from grob6000/independent_pid
Independent PID parameters for each extruder
2015-01-13 12:10:37 +01:00
Bo Herrmannsen
d4a665694a Merge pull request #1350 from odewdney/Development
Reduce PROGMEM warnings
2015-01-13 11:26:50 +01:00
odewdney
538859669d Removing compiler warnings for progmem 2015-01-11 18:14:21 +00:00
grob6000
bf2c923db5 Make multiple PID parameters a config option
* Adds config parameter `PID_PARAMS_PER_EXTRUDER` - allows single PID
parameters to be used where this would be preferable (e.g. dual
identical extruders)
* When disabled, will use `float Kp, Ki, Kd, Kc;` as before.
Preprocessor macros used to switch between.
* ultralcd.cpp defines extra menus for extra parameters only where
required
* M301 reports `e:xx` only if independent pid parameters enabled
* EEPROM structure still leaves space for 3 extruders worth, when undef
will save single parameter to all extruder positions, but only read the
first
* Switching off saves approx 330 B with no LCD enabled, 2634B with LCD
(RRD) enabled: this is significant.
* LCD modifications should be tested.
2015-01-11 13:50:17 +11:00
grob6000
37c7e8300f Independent PID parameters for each extruder
* Variables Kp, Ki, Kd, Kc now arrays of size EXTRUDERS
* M301 gains (optional, default=0) E parameter to define which
extruder's settings to modify. Tested, works with Repetier Host's EEPROM
config window, albeit only reads/updates settings for E0.
* All Kp, Ki, Kd, Kc parameters saved in EEPROM (version now v14), up to
3 extruders supported (same as Marlin in general)
2015-01-10 16:35:12 +11:00
Dino Del Favero
038fccd7a1 I have added some code in the "temperature.cpp" for have the possibility of control the time of the states with the heater drived by relays, with this feature now it is possible use PID function in conjunction with relay to control the temperature. I have made some tests and the temperature stay always in the range of +-1°C from the setted temp.
There is the possibility of turn on this features adding "#define SLOW_PWM_HEATERS" in Configuration.h
2015-01-06 18:32:17 +01:00
Philippe L
30248214c7 temp runaway: proper cast to prevent any overflow. 2015-01-04 14:23:31 +01:00
Alexander Hirzel
ae12ad0d6c Fix typo, PID_BED_POWER -> MAX_BED_POWER 2015-01-02 01:38:03 -05:00
alexborro
80b17ab573 Merge pull request #1285 from drf5n/PID_CI_v2
temperature.cpp: Fix typo of MAX_BED_PID to MAX_BED_POWER.
2015-01-01 22:56:21 -02:00
David Forrest
625860f086 temperature.cpp: Fix typo of PID_MAX to MAX_BED_POWER for the bed. 2015-01-01 19:24:42 -05:00
David Forrest
6583bb781d temperature.cpp: Fix typo of MAX_BED_PID to MAX_BED_POWER. 2015-01-01 19:11:42 -05:00
Bo Herrmannsen
0d957872a0 Merge pull request #1234 from gregrebholz/issue_1069
Fixes #1069.  Added "auto fan" checks to PID_autotune.
2014-12-28 10:12:08 +01:00
David Forrest
984177c40c temperature.cpp:Add PID Conditional integration on heated bed. 2014-12-27 15:26:09 -05:00
David Forrest
c9b8435749 heater.c: Limit PID I term with conditional integration. 2014-12-27 15:26:09 -05:00
Greg Rebholz
7ecb7cbd46 Added "auto fan" checks to PID_autotune 2014-12-23 23:50:00 -05:00
Denis Chertykov
b086394178 Fix syntax errors in #ifdef. 2014-12-20 19:33:43 +03:00
Scott Lahteine
f83d0f2a68 Defines for electronics boards
Added boards.h which contains defines for all the board numbers, plus
some shorthand macros for less typing.
2014-12-18 13:59:31 -08:00
Erik van der Zalm
058e446531 Merge pull request #1037 from filipmu/Filament-Sensor
Support for a filament diameter sensor
2014-10-11 22:56:01 +02:00
Filip Mulier
62db9848d3 Improvements and bug fixes in sensor delay buffer for filament sensor code
Improvement to avoid reinitializing delay buffer with every print. Fixed
issues in buffer indexing and memory out of bounds due to floating point
imprecision.  Simplified the code by avoiding conversion to standard
diameter and 1cu mm extrusion, which caused complications in determining
mm extruded.
2014-08-16 06:50:13 -05:00
Filip Mulier
85649a4549 Real-time filament diameter measurement and control
This feature allows the printer to read the filament diameter
automatically and adjust the printer in real time.  Added code to read
an analog voltage that represents a filament diameter measurement.  This
measurement is delayed in a ring buffer to compensate for sensors that
are a distance away from the extruder.  The measurement is used to
adjust the volumetric_multiplier for the extruder.  Some additional g
codes (M404, M405, M406, M407) are used to set parameters and turn
on/off the control. g code M221 is updated.  Pins for RAMPS1.4, RAMBO,
and Printrboard are identified for analog input.  The configuration file
is updated with relevant user parameters.
2014-08-06 19:30:57 -05:00
Grogyan
82606354dd Update temperature.cpp
Enables both SD card and MAX6675 to talk with each other
Fixes also issue #750
2014-07-05 17:17:17 +12:00
alexborro
43c298a7a9 Add "Thermal Runaway Protection" feature
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.
2014-06-30 15:22:49 -03:00
Erik van der Zalm
cfb98ef682 More coverity fixes 2014-05-15 22:09:50 +02:00
Erik van der Zalm
9db9842aea Fixed error found by the free coverity tool (https://scan.coverity.com/)
===================================================
Hi,

Please find the latest report on new defect(s) introduced to ErikZalm/Marlin found with Coverity Scan.

Defect(s) Reported-by: Coverity Scan
Showing 15 of 15 defect(s)

** CID 59629:  Unchecked return value  (CHECKED_RETURN)
/Marlin_main.cpp: 2154 in process_commands()()

** CID 59630:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp: 319 in tone(unsigned char, unsigned int, unsigned long)()

** CID 59631:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1187 in process_commands()()

** CID 59632:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1193 in process_commands()()

** CID 59633:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 914 in disable_heater()()

** CID 59634:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 913 in disable_heater()()

** CID 59635:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 626 in analog2temp(int, unsigned char)()

** CID 59636:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 620 in analog2temp(int, unsigned char)()

** CID 59637:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 202 in PID_autotune(float, int, int)()

** CID 59638:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 214 in PID_autotune(float, int, int)()

** CID 59639:  Out-of-bounds write  (OVERRUN)
/Marlin_main.cpp: 2278 in process_commands()()

** CID 59640:  Out-of-bounds read  (OVERRUN)
/Marlin_main.cpp: 1802 in process_commands()()

** CID 59641:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 51 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()

** CID 59642:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 45 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()

** CID 59643:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 32 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()

________________________________________________________________________________________________________
*** CID 59629:  Unchecked return value  (CHECKED_RETURN)
/Marlin_main.cpp: 2154 in process_commands()()
2148                 }
2149               #endif
2150             }
2151           }
2152           break;
2153         case 85: // M85
   CID 59629:  Unchecked return value  (CHECKED_RETURN)
   Calling "code_seen" without checking return value (as is done elsewhere 66 out of 67 times).
2154           code_seen('S');
2155           max_inactive_time = code_value() * 1000;
2156           break;
2157         case 92: // M92
2158           for(int8_t i=0; i < NUM_AXIS; i++)
2159           {

________________________________________________________________________________________________________
*** CID 59630:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp: 319 in tone(unsigned char, unsigned int, unsigned long)()
313         else
314         {
315           // two choices for the 16 bit timers: ck/1 or ck/64
316           ocr = F_CPU / frequency / 2 - 1;
317
318           prescalarbits = 0b001;
   CID 59630:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
   "ocr > 65535U" is always false regardless of the values of its operands. This occurs as the logical operand of if.
319           if (ocr > 0xffff)
320           {
321             ocr = F_CPU / frequency / 2 / 64 - 1;
322             prescalarbits = 0b011;
323           }
324

________________________________________________________________________________________________________
*** CID 59631:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1187 in process_commands()()
1181         case 2: // G2  - CW ARC
1182           if(Stopped == false) {
1183             get_arc_coordinates();
1184             prepare_arc_move(true);
1185             return;
1186           }
   CID 59631:  Missing break in switch  (MISSING_BREAK)
   The above case falls through to this one.
1187         case 3: // G3  - CCW ARC
1188           if(Stopped == false) {
1189             get_arc_coordinates();
1190             prepare_arc_move(false);
1191             return;
1192           }

________________________________________________________________________________________________________
*** CID 59632:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1193 in process_commands()()
1187         case 3: // G3  - CCW ARC
1188           if(Stopped == false) {
1189             get_arc_coordinates();
1190             prepare_arc_move(false);
1191             return;
1192           }
   CID 59632:  Missing break in switch  (MISSING_BREAK)
   The above case falls through to this one.
1193         case 4: // G4 dwell
1194           LCD_MESSAGEPGM(MSG_DWELL);
1195           codenum = 0;
1196           if(code_seen('P')) codenum = code_value(); // milliseconds to wait
1197           if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
1198

________________________________________________________________________________________________________
*** CID 59633:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 914 in disable_heater()()
908          WRITE(HEATER_0_PIN,LOW);
909        #endif
910       #endif
911
912       #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1
913         target_temperature[1]=0;
   CID 59633:  Out-of-bounds write  (OVERRUN)
   Overrunning array "soft_pwm" of 1 bytes at byte offset 1 using index "1".
914         soft_pwm[1]=0;
915         #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
916           WRITE(HEATER_1_PIN,LOW);
917         #endif
918       #endif
919

________________________________________________________________________________________________________
*** CID 59634:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 913 in disable_heater()()
907        #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1
908          WRITE(HEATER_0_PIN,LOW);
909        #endif
910       #endif
911
912       #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1
   CID 59634:  Out-of-bounds write  (OVERRUN)
   Overrunning array "target_temperature" of 1 2-byte elements at element index 1 (byte offset 2) using index "1".
913         target_temperature[1]=0;
914         soft_pwm[1]=0;
915         #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
916           WRITE(HEATER_1_PIN,LOW);
917         #endif
918       #endif

________________________________________________________________________________________________________
*** CID 59635:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 626 in analog2temp(int, unsigned char)()
620       if(heater_ttbl_map[e] != NULL)
621       {
622         float celsius = 0;
623         uint8_t i;
624         short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]);
625
   CID 59635:  Out-of-bounds read  (OVERRUN)
   Overrunning array "heater_ttbllen_map" of 1 bytes at byte offset 1 using index "e" (which evaluates to 1).
626         for (i=1; i<heater_ttbllen_map[e]; i++)
627         {
628           if (PGM_RD_W((*tt)[i][0]) > raw)
629           {
630             celsius = PGM_RD_W((*tt)[i-1][1]) +
631               (raw - PGM_RD_W((*tt)[i-1][0])) *

________________________________________________________________________________________________________
*** CID 59636:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 620 in analog2temp(int, unsigned char)()
614         if (e == 0)
615         {
616           return 0.25 * raw;
617         }
618       #endif
619
   CID 59636:  Out-of-bounds read  (OVERRUN)
   Overrunning array "heater_ttbl_map" of 1 2-byte elements at element index 1 (byte offset 2) using index "e" (which evaluates to 1).
620       if(heater_ttbl_map[e] != NULL)
621       {
622         float celsius = 0;
623         uint8_t i;
624         short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]);
625

________________________________________________________________________________________________________
*** CID 59637:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 202 in PID_autotune(float, int, int)()
196       {
197          soft_pwm_bed = (MAX_BED_POWER)/2;
198          bias = d = (MAX_BED_POWER)/2;
199        }
200        else
201        {
   CID 59637:  Out-of-bounds write  (OVERRUN)
   Overrunning array "soft_pwm" of 1 bytes at byte offset 1 using index "extruder" (which evaluates to 1).
202          soft_pwm[extruder] = (PID_MAX)/2;
203          bias = d = (PID_MAX)/2;
204       }
205
206
207

________________________________________________________________________________________________________
*** CID 59638:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 214 in PID_autotune(float, int, int)()
208
209      for(;;) {
210
211         if(temp_meas_ready == true) { // temp sample ready
212           updateTemperaturesFromRawValues();
213
   CID 59638:  Out-of-bounds read  (OVERRUN)
   Overrunning array "current_temperature" of 1 4-byte elements at element index 1 (byte offset 4) using index "extruder" (which evaluates to 1).
214           input = (extruder<0)?current_temperature_bed:current_temperature[extruder];
215
216           max=max(max,input);
217           min=min(min,input);
218           if(heating == true && input > temp) {
219             if(millis() - t2 > 5000) {

________________________________________________________________________________________________________
*** CID 59639:  Out-of-bounds write  (OVERRUN)
/Marlin_main.cpp: 2278 in process_commands()()
2272               tmp_extruder = code_value();
2273               if(tmp_extruder >= EXTRUDERS) {
2274                 SERIAL_ECHO_START;
2275                 SERIAL_ECHO(MSG_M200_INVALID_EXTRUDER);
2276               }
2277             }
   CID 59639:  Out-of-bounds write  (OVERRUN)
   Overrunning array "volumetric_multiplier" of 1 4-byte elements at element index 1 (byte offset 4) using index "tmp_extruder" (which evaluates to 1).
2278             volumetric_multiplier[tmp_extruder] = 1 / area;
2279           }
2280           break;
2281         case 201: // M201
2282           for(int8_t i=0; i < NUM_AXIS; i++)
2283           {

________________________________________________________________________________________________________
*** CID 59640:  Out-of-bounds read  (OVERRUN)
/Marlin_main.cpp: 1802 in process_commands()()
1796             int pin_status = code_value();
1797             int pin_number = LED_PIN;
1798             if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
1799               pin_number = code_value();
1800             for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
1801             {
   CID 59640:  Out-of-bounds read  (OVERRUN)
   Overrunning array "sensitive_pins" of 28 2-byte elements at element index 55 (byte offset 110) using index "i" (which evaluates to 55).
1802               if (sensitive_pins[i] == pin_number)
1803               {
1804                 pin_number = -1;
1805                 break;
1806               }
1807             }

________________________________________________________________________________________________________
*** CID 59641:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 51 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()
45     }
46
47     LiquidCrystal::LiquidCrystal(uint8_t rs,  uint8_t enable,
48     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
49     {
50       init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);
   CID 59641:  Uninitialized scalar field  (UNINIT_CTOR)
   Non-static class member "_initialized" is not initialized in this constructor nor in any functions that it calls.
51     }
52
53     void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
54     			 uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
55     			 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
56     {

________________________________________________________________________________________________________
*** CID 59642:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 45 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()
39     }
40
41     LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
42     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
43     {
44       init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0);
   CID 59642:  Uninitialized scalar field  (UNINIT_CTOR)
   Non-static class member "_initialized" is not initialized in this constructor nor in any functions that it calls.
45     }
46
47     LiquidCrystal::LiquidCrystal(uint8_t rs,  uint8_t enable,
48     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
49     {
50       init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);

________________________________________________________________________________________________________
*** CID 59643:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 32 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()
26
27     LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
28     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
29     			     uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
30     {
31       init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7);
   CID 59643:  Uninitialized scalar field  (UNINIT_CTOR)
   Non-static class member "_initialized" is not initialized in this constructor nor in any functions that it calls.
32     }
33
34     LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable,
35     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
36     			     uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
37     {

________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, http://scan.coverity.com/projects/2224?tab=overview
2014-05-14 21:59:48 +02:00
Cameron Lai
6460709d92 Fix bug in PID Autotune report 2014-04-25 16:05:05 +08:00