Commit Graph

59 Commits

Author SHA1 Message Date
jbernardis bb29d50f31 temp.c: also report target temperatures.
It's handy and some hosts actually expect this.
2015-04-21 02:11:01 +02:00
Markus Hitter f6115688c5 Move Intercom temp sensor initialisation from mendel.c to temp.c. 2014-12-26 19:41:38 +01:00
Markus Hitter a9f1d00865 Move MAX6675 initialisation from mendel.c to temp.c.
Also note a misplaced and misnamed pin.
2014-12-26 19:41:38 +01:00
Markus Hitter 6dbc7a7797 temp.c: fix typo. 2014-04-13 11:24:47 +02:00
Markus Hitter da8ccf7535 temp_achieved(): check only sensors/heaters turned on.
Problem spotted, described in a helpful manner and over-fixed
by @zungmann. This fix picks up his basic idea and implements it
with already existing state properties.
2014-03-04 19:58:19 +01:00
Phil Hord 21e5343552 Add config.h wrapper to simplify test automation
Test code which wants to customize config.h can do so without
touching config.h itself by wrapping config.h in a macro variable
which is passed in to the compiler.  It defaults to "config.h" if
no override is provided.

This change would break makefile dependency checking since the selection
of a different header file on the command line is not noticed by make
as a build-trigger.  To solve this, we add a layer to the BUILDDIR path
so build products are now specific to the USER_CONFIG choice if it is
not "config.h".
2014-03-04 19:56:23 +01:00
Phil Hord 452e2e5cd9 Restore simulation build target.
This code was accidentally removed long ago in a botched merge. This
patch recovers it and makes it build again. I've done minimal testing
and some necessary cleanup. It compiles and runs, but it probably still
has a few dust bunnies here and there.

I added registers and pin definitions to simulator.h and
simulator/simulator.c which I needed to match my Gen7-based config.
Other configs or non-AVR ports will need to define more or different
registers. Some registers are 16-bits, some are 8-bit, and some are just
constant values (enums). A more clever solution would read in the
chip-specific header and produce saner definitions which covered all
GPIOs. But this commit just takes the quick and easy path to support my
own hardware.

Most of this code originated in these commits:

	commit cbf41dd4ad
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:28:08 2010 +0200

	    document simulation

	commit 3028b297f3
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:15:59 2010 +0200

	    Add simulation code: use "make sim"

Additional tweaks:

Revert va_args processing for AVR, but keep 'int' generalization
for simulation. gcc wasn't lying. The sim really aborts without this.

Remove delay(us) from simulator (obsolete).

Improve the README.sim to demonstrate working pronterface connection
to sim. Also fix the build instructions.

Appease all stock configs.

Stub out intercom and shush usb_serial when building simulator.

Pretend to be all chip-types for config appeasement.

Replace sim_timer with AVR-simulator timer:

The original sim_timer and sim_clock provided direct replacements
for timer/clock.c in the main code. But when the main code changed,
simcode did not. The main clock.c was dropped and merged into timer.c.
Also, the timer.c now has movement calculation code in it in some
cases (ACCELERATION_TEMPORAL) and it would be wrong to teach the
simulator to do the same thing. Instead, teach the simulator to
emulate the AVR Timer1 functionality, reacting to values written to
OCR1A and OCR1B timer comparison registers.

Whenever OCR1A/B are changed, the sim_setTimer function needs to be
called. It is called automatically after a timer event, so changes
within the timer ISRs do not need to bother with this.

A C++ class could make this requirement go away by noticing the
assignment. On the other hand, a chip-agnostic timer.c would help
make the main code more portable. The latter cleanup is probably
better for us in the long run.
2013-12-06 19:24:58 +01:00
David Forrest 6ac79b288d temp.c: DEBUG_USER code for raw temp readings. 2013-07-11 22:03:21 +02:00
Markus Hitter 2ebfd44530 Clean up some unused delay related stuff. 2013-03-24 16:19:21 +01:00
Markus Hitter 042d9ddfc2 Move temp_all_zero() to heaters_all_zero().
We need the power supply for the heaters, after all, not for
the temperature sensors. Some heaters (e.g. fans) don't even have
a temp sensor.
2013-01-03 15:34:47 +01:00
Markus Hitter 6f2ec09837 Make temperature sensor type TT_NONE obsolete.
The requirement was simply neither obvious nor intuitive. Drawback
is, the indices of temperature sensors can now differ from these
of the heaters. That's easier to recognize for newbies, though.
2013-01-03 15:34:41 +01:00
Markus Hitter a2185a4154 temp.c: explicitely cast the EMWA algorithm result.
Contribution by DaveX, see:
http://forums.reprap.org/read.php?147,33082,160633#msg-160633
2012-11-08 16:25:35 +01:00
Markus Hitter 8e27595a5f temp.c: allow smoothing temperature readings.
This is done by an Exponentially Weighted Moving Average (EWMA)
formula. Contribution by DaveX, see
http://forums.reprap.org/read.php?147,33082,157978#msg-157978

Thanks a lot, Dave.
2012-11-08 16:22:31 +01:00
Markus Hitter 8b05e77d49 temp.c: try to deal with flakey temperature sensors. 2012-11-08 16:22:16 +01:00
Markus Hitter a054d4c6cd Remove all remaining evidence of M109.
M109 went away a few commits ago in favour of only M116.
2012-10-14 22:57:22 +02:00
Markus Hitter 97a663a00c analog.c: trim down analog values storage.
Saves 10 bytes RAM and 16 bytes binary size on an 1284P (8 ADC
channels) running two sensors. Should also be a bit faster, as one
loop runs fewer iterations.

Also, checking for NUM_TEMP_SENSORS was a mistake, as temp sensors
_not_ using an analog pin exist. Extreme case is, temp sensors
exist, but zero ADC channels are used.
2012-09-29 23:00:11 +02:00
Mikko Sivulainen bfe5e6f2fc Fixed ADC channel handling.
ADC pin is not the same as ADC channel in atmega1280/2560.
2012-09-29 22:57:55 +02:00
Markus Hitter 37933c8a85 Fix temperature printing.
Remove the assumption there's always an extruder temperature
sensor and make reading on single sensors (e.g. M105 P2) more usable.

Apparently works very well, but *sigh* yet another 100 bytes of binary size.
2012-08-04 22:08:17 +02:00
Markus Hitter 24561919bf temp.c: remove a redundant variable.
This doesn't save a single byte in binary size, as the optimizer
catches this anyways.
2012-08-04 22:08:09 +02:00
Markus Hitter 886bacdbe4 temp.c: remove the delay for the MAX6675.
Suggestion by JTrantow, see also
https://github.com/triffid/Teacup_Firmware/issues/22
2012-05-21 21:00:17 +02:00
Markus Hitter f9a4495aa1 Introduce TEMP_NONE, a "sensor" just storing the target temperature.
This is useful when operation a milling spindle. In this case,
set the spindle speed with M104 Sxxx, where xxx is 1..255.
M104 S0 turns the spindle off.
2011-09-01 19:03:33 +02:00
Markus Hitter 58f4678253 Catch by RobertFach: compatibility option for RepRap Host 20110509. 2011-08-30 12:01:48 +02:00
Michael Moon a68ae12679 add NO_AUTO_IDLE option to prevent powercuts after inactivity, add temp_all_zero so power isn't cut if heater remains off for a while but has a non-zero set temperature 2011-06-14 23:05:13 +10:00
Jim McGee 85a9f63dfb Pretest DEBUG_X constants for non-zero and && the test with all existing
& tests of the debug_flags. Currently the compiler is able to eliminate
the block and the & operation when the constant is zero, but since
the debug_flags variable is a volatile the compiler does not eliminate
the load of the variable. By pretesting and shortcutting the load is
eliminated. Saves a small number of bytes when the debug build is
disabled and costs nothing when it is enabled.
2011-05-15 09:56:33 +10:00
Sergey Batalov 03cebb5a82 TEMP_RESIDENCY now in units of 10ms rather than next_read_time
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-05-10 14:10:56 +10:00
Kieran Levin 61ca4c114e fixed temperature reading problem where ReplicatorG would freeze because there is no newline before the temperature prints out... 2011-04-29 10:15:40 +10:00
Markus Amsler e937b052af Add support for multiple thermistor tables.
DEFINE_TEMP_SENSOR takes one additional argument. For TT_THERMISOR you can specify there which thermistor table to use.
2011-04-12 20:00:18 +02:00
Markus Amsler 1d556e0278 Use HEATER_BED everywhere.
For intercom heated bed it may be different from HEATER_bed.
2011-04-11 22:41:50 +02:00
Markus Amsler 57a75ecbfb temp: TEMP_RESIDENCY_TIME is in seconds not in temp_ticks (=10ms) 2011-04-04 09:21:32 +10:00
Markus Amsler be18eb90b8 Convert TEMP_HYSTERESIS to Celsius. 2011-04-04 09:12:54 +10:00
Markus Amsler 093d20481e heater: fix residency compare.
labs requires a signed int.
2011-04-04 09:12:54 +10:00
Markus Amsler 9860d2850f heater: only reset residency if temp really changed
Skeinforge generates sometimes multiple calls to M104/M140, which would add a slow delay on the next M101.
2011-04-04 09:12:53 +10:00
Michael Moon 100b7c6c4a only check intercom every 250ms as we don't send packets more often 2011-03-27 19:34:16 +11:00
Michael Moon 0dc7d77885 Massive Doxygen documentation addition
'make doc' then point your browser at doc/html/

Needs plenty of cleanup and polishing, but the main bulk is here

even documents your configuration! ;)
2011-03-22 01:34:36 +11:00
Michael Moon 8188ff3593 merge intercom-protocol into master 2011-02-21 16:01:27 +11:00
Markus Amsler 52c2788997 intercom: updating the extruder in 250ms intervals should be fast enough. 2011-02-21 15:52:17 +11:00
Stephan Walter eecf3af9f1 analog mask calculated automagically 2011-02-21 13:57:51 +11:00
Markus Amsler 680b70ad0d intercom: Send packet only once. 2011-02-14 11:05:53 +11:00
Michael Moon b1a48994dd preliminary untested implementation of Markus Amsler's new extruder comms protocol 2011-02-12 23:59:19 +11:00
John Gilmore (none) 686e417401 Revised thermistor code. Thermistor table now in 14.2 fixed point
Two thermistor tables included:
  ThermistorTable.h.dist.old, which is the table we used to have, included so those already using it don't have to recalibrate.
  ThermistorTable.h.dist, which was generated with 50 entries, and trimmed down in lower temperature ranges where we don't care as much about accuracy and there's less deviation from a straight line anyway.

Corrected default temp sensor entry in config.h.dist to thermistor instead of intercom. (Now matches earlier definitions which by default say we're using a thermistor)

Added noheater sensor example to config.h.dist

Copied CreateTemperatureLook.py from "official" firmware, and modified it for 14.2 fixed point, no negative temperatures (we're using uint16_t's), and PROGMEM.

Since I simply copied the example linear interpolation formula from wikipedia, I'm certian that it could be more efficient. The code that was there wouldn't work with 14.2 table values, and my understanding of it was too shallow to fix it. This works, and upgading the calculations to uint32_t actually takes less code space than leaving them at uint16_t. I assume it's calling a library routine that's already being linked in for the 32-bit math.
2011-02-12 22:22:10 +11:00
Michael Moon e4fc55289b use constants for conditional compilation since preprocessor can't work out enums and we can't define in macros 2011-02-06 21:34:44 +11:00
Michael Moon d1b2754aba sorting out preprocessor interactions 2011-02-06 21:11:39 +11:00
Michael Moon 97f344f0fa changes discussed in chat on pull 19 2011-02-06 21:11:39 +11:00
Vik Olliver fa91ef8472 fix thermistor lookup table interpolation code
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-02-02 18:23:10 +11:00
Stephan Walter fcaa76d3c0 Simpler definition of temp sensors and heaters. 2011-02-01 19:40:27 +11:00
Michael Moon 14809c4a7c make bed heater define zero-based 2011-01-27 21:03:26 +11:00
plasmator 80e98e9b22 Added Heated Bed Support
Signed-off-by: plasmator <public@plasmatoruniversi.com>
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-01-27 20:31:39 +11:00
Michael Moon 096d7dfdf3 Merge release-candidate-triffid branch 2011-01-07 23:09:13 +11:00
Stephan Walter 3028b297f3 Add simulation code: use "make sim" 2010-10-21 11:05:55 +11:00
Casainho 3898626534 alter temperature reporting in reprap host compatibility mode
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2010-10-08 21:09:34 +11:00