Commit Graph

1476 Commits

Author SHA1 Message Date
Wurstnase b52a1217a9 temp.c: refactor MCP3008 to similar structure. 2016-06-23 22:32:51 +02:00
Phil Hord 05565a0aec temp.c: use free-running readings in EMWA mode.
If we have EMWA mode turned on, then the user wants to average
several samples from the temp sensors over time. But now we read
temp sensors only 4 times per second making this averaging take
much longer.

Read the temperatures continuously -- as fast as supported by the
probe type -- if we are using weight averaging (TEMP_EMWA < 1.0).
2016-06-23 22:32:51 +02:00
Phil Hord 6cf845ecda temp.c: remove write-only "temp_flags". 2016-06-23 22:32:51 +02:00
Phil Hord 9d53c13ebd temp.c: assemble cooperative state machine.
Heater PID loops must be called every 250ms, and temperature
probes do not need to be called any more often than that. Some
probes require some asynchronous operations to complete before
they're ready.  Handle these in a state machine that first begins
the conversion and finally completes it on some future tick.
Signal it is complete by setting the new state variable to IDLE.

Kick off the heater PID loop by simply beginning the temperature
conversion on all the temperature probes.  When each completes,
it will finish the process by calling its PID routine.

Remove the "next_read_time" concept altogether and just run each
temp conversion at fixed 250ms intervals.
2016-06-23 22:32:51 +02:00
Phil Hord 335437022c temp.c: refactor temperature reads into functions.
Every type of temp sensor has its own special way to be read
and the once-simple loop has grown complex.  Restore some sanity
by isolating the code for each sensor into its own inline
function.

In the process I noticed temp_flags is only ever set (never read)
and is used only in MAX6675.  I don't understand what it was used
for, so for now, let's comment it out and revisit this later in
this series.
2016-06-23 22:32:51 +02:00
Phil Hord afb81f21be temp.c: cleanup temp_sensor_tick() and next_read_time sanity.
Integrate the next_read_time countdown into the loop as is common.

Check for start_adc() in the same loop -- before decrementing the
timer -- and call it when needed on the tick before we need the
results.

One concern I have still is that start_adc() may be called twice
within a few microseconds if two probes need to be read. I expect
it should only be called once, but I am not readily familiar with
the AVR ADC conversion protocol.
2016-06-23 22:32:51 +02:00
Robert Konklewski 86c3d97315 temp.c: integrate next_start_adc_time clock into next_read_time.
Extra clock next_start_adc_time was unnecessary. As @phord
observed, it was more understandable to explicitly call start_adc()
1 cycle ahead during temp_sensor_tick(), for sensors which use
analog_read().
2016-06-23 22:32:51 +02:00
Robert Konklewski 1aa8698f62 temp.c: improved condition checks for next_read_time timers.
As @phord observed, the conditions and the meaning of
next_read_time was not very intuitive. Changed that so that now
it represents the number of 10ms clock ticks before next sensor
reading, i.e. 1 is for 10ms, 2 for 20ms, etc.
2016-06-23 22:32:51 +02:00
Robert Konklewski 678184b037 Temp: request ADC reads only when necessary.
Issues ADC reads (via start_adc()) only when actually needed.
When EWMA is enabled, then reads are performed at every
temp_sensor_tick() call, i.e. every 10ms. That's to ensure EWMA
gets updated frequently enough.

When EWMA is disabled, then the only other use for analog reads
is heater control, i.e. heater_tick(). It's run on a 250ms clock,
so that's how often analog reads need to be performed in that
case.

Additionally, ADC conversions are being started 10ms in advance,
so that they can finish before their results are read.
2016-06-23 22:32:51 +02:00
Robert Konklewski 1236a352c9 Temp: fix a one-off error in sensor read counter check condition. 2016-06-23 22:32:51 +02:00
Robert Konklewski b5cbba7ed8 Temp: read ADC on-demand, instead of constantly running.
On AVRs analog conversions were running in essentially
free-running mode, i.e.  next conversion was being started
immediately after the previous one ended. This caused many
unnecessary interrupts.

Now, conversions are initiated manually by start_adc(). This
causes a single read on each of the registered channels. Once
all channels are read, conversions stop until the next call of
start_adc().
2016-06-23 22:32:51 +02:00
Robert Konklewski 03c8d71a56 Temp: have residency updates on 1s clock.
Temperature residency time / temperature achieved check is in
the order of seconds, while updates for residency time were being
called every 10ms - unnecessarily often.
2016-06-23 22:32:51 +02:00
Robert Konklewski 8e977d50ce Temp: have heater update on 250ms intervals.
Thermal managers (PID, bang-bang, etc.) assume they're being
ticked on 250ms intervals. In reality, they were being updated on
each temperature reading, which was between 10ms and 250ms. This
caused thermal management to malfunction.

https://github.com/Traumflug/Teacup_Firmware/issues/211
2016-06-23 22:32:51 +02:00
Phil Hord 803ff6e8b3 fix ACCELERATION_REPRAP build (moved/extra vars)
REPRAP style acceleration broke quite a while ago, but no one noticed.
Maybe it's not being used, and therefore also not tested. But it should
at least compile while it remains an option.

The compiler complains that dda->n is not defined and that current_id is
never used.  The first bug goes back to f0b9daeea0 in late 2013.

In the interest of supporting exploratory accelerations, fix this to
build when ACCELERATION_REPRAP is chosen.
2016-06-22 19:28:38 -04:00
Markus Hitter c3f0d05581 Attic: gzip single file storage.
Also to reduce clutter on recursive greps.
2016-06-12 19:30:54 +02:00
Markus Hitter 62b5bb01dc Attic: tar up 'accel_clock'. 2016-06-12 19:27:18 +02:00
Markus Hitter f291e33acd Attic: tar up 'eeconfig'. 2016-06-12 19:24:34 +02:00
Markus Hitter a4fcd0e32f Attic: tar up 'input-float'. 2016-06-12 19:22:01 +02:00
Markus Hitter 4c4f2603f5 Attic: tar up 'original-pff' for less clutter on grep'ing. 2016-06-12 19:18:47 +02:00
Markus Hitter c79dc3206e Move branch ProportionalBandPID to the attic.
As far as I (Traumflug) can see, this was an attempt to ease PID
tuning by setting PID parameters according to a model easier
understandable by humans.

This was moved to the attic because because automatic PID tuning
is around the corner, so users (hopefully) no longer have to mess
with PID parameters at all before too long.
2016-06-12 19:14:25 +02:00
Markus Hitter 5baa188826 Attic: add explaining README. 2016-06-12 19:09:03 +02:00
Phil Hord 592df2c73f Drop redundant "simulator.h" includes.
simulator.h is already included in config.h/arduino.h, so it doesn't
need to be included again most of the time. In some cases it was
included twice on purpose to undo some intervening include file, but
these intervening includes were unnecessary. Remove some related
include file redundancy by re-ordering the include files and relocating
some nested includes up to the parent .c file.
2016-06-11 15:12:40 +02:00
Markus Hitter 11e907de03 Configtool: also deal with PS_INVERT_ON.
This partially solves issue #165.
2016-06-11 13:10:09 +02:00
Markus Hitter bb275e2c21 Configtool: use platform.startswith() everywhere.
Using this instead of a direct comparison may make the code more
future proof, because exact versions (e.g. "win32" vs. "win64")
are ignored, then.
2016-06-11 12:41:10 +02:00
Markus Hitter c135c4c502 Configtool: simpler regex on OS X in the Save As... dialog as well.
Not neccessary on vintage Mac OS X 10.4, but might help with
issue #165.
2016-06-11 12:40:46 +02:00
Markus Hitter e0e6c33bc4 pinio.c: introduce PS_INVERT_ON.
Some non-ATX PSUs require the pin to go high for turning it on.
2016-06-11 12:36:18 +02:00
Markus Hitter bcfb13d4e2 Regression tests: make sure we have a valid thermistor table.
So far it worked only if the user happened to have a table for
two thermistors. Having a table for only one thermistor made all
regression tests fail.
2016-06-07 20:15:10 +02:00
benj919 84d8cf4d1b Configtool: write RX/TX_ENABLE_PIN as-is.
Because these two pins have no presence in Configtool's GUI, they
got dropped when writing a board config file. These pins are
needed for Gen3 Extruder Board support.

This should solve issue #179.
2016-06-06 14:38:07 +02:00
Markus Hitter d51edaf705 Regression tests: remove the script based integrity test.
Looks like it's obsolete now, superseeded by the one actually
running Configtool.
2016-06-06 14:18:08 +02:00
Markus Hitter fdf9534ed9 check_configtool.sh: comment on comment stripping. 2016-06-06 14:18:08 +02:00
Markus Hitter b3f77a89b2 check_configtool.sh: remove test files on success. 2016-06-06 14:18:02 +02:00
Markus Hitter e35fe22f74 check_configtool.sh: allow spaces in paths.
To the best of my bash script knowledge, this also means we have
to break on the first error, because pipe terms run in a subshell,
so they can't pass variables to the parent.
2016-06-06 14:15:14 +02:00
Phil Hord 21ac717d6d Configtool: add integrity tests for Configtool output.
Add a test that puts the stock config files through the
Configtool input/output parsers and verifies the output matches
the input.  If Configtool breaks down in the future and produces
different output, this should catch it.

If this fails because of some intentional change in the tool or
in the stock config files, then the tool or stock config files
should be updated to be compatible again before merging the result.
2016-06-06 12:36:53 +02:00
Phil Hord 2a6f00454f Configtool: add --quit and --save commandline switches.
Teach configtool to save ini, board and printer files with the
--save commandline switch.  Add a feature to Printer and Board
to let us pass None for the "values" to save; this causes the
class to save the previously loaded settings instead of taking
new settings in the argument.

Also add --quit switch to tell commandline not to continue to run the
GUI.  There's not much point in running the gui after many of these
switches, but that will change in the future.  Add this --quit option
to quit early so we can begin to use this new mode for test validation.
2016-06-06 12:36:17 +02:00
Phil Hord ba5447b409 Configtool: add --show-all switch.
Show all the loaded (defined) variables. Leave out the commented
variables for now.
2016-06-05 21:09:25 +02:00
Phil Hord 0c8ae903e9 Configtool: add --load switch to load printer, board or ini.
Teach configtool command line functions to load the printer, board
or ini file settings into internal classes. For now this only
exercises the "load" functionality of the classes, but with -vv
you can also see the results of the load dumped to the console.
2016-06-05 21:09:18 +02:00
Phil Hord 2c5a36b14e Configtool: make Settings the "global" container.
Instead of passing myriad variables around in arguments to
classes and functions, put the global settings like "verbose" and
"cmdFolder" in the Settings object and pass that in to the top.
2016-06-05 21:09:11 +02:00
Phil Hord eafb8e0bfb Configtool: begin command line automation.
Add a command line handler mode to Configtool to permit automation
for scripts.

Traumflug's review note: restored Python 3 checks.
2016-06-05 21:09:04 +02:00
Phil Hord 11bb6bb1cf Configtool: refactor printerpanel for MVC.
Move model functionality out of printerpanel.py into a new class,
Printer, so we can more easily add commandline driven tests in
the future and to help identify code reuse opportunities.
2016-06-05 21:08:55 +02:00
Phil Hord d3062ca1dd Configtool: refactor boardpanel for MVC.
Move model functionality out of boardpanel.py into a new class,
Board, so we can more easily add commandline driven tests in the
future.
2016-06-05 21:08:41 +02:00
Markus Hitter c80b4d4d28 Revert "Configtool: attempt to fix broken pin definitions."
This worked only when the GUI came up, so a better fix was found
with commit

  "Configtool: deal with missing #defines requiring a value."
2016-06-05 21:07:54 +02:00
Markus Hitter 5a28a62717 Configtool: default new config options to disabled.
New boolean options were all enabled, which was a problem
especially with the boolean choices DISPLAY_BUS_xxx and
DISPLAY_TYPE_xxx: all choice entries were set to True, so display
code was not only enabled behind the users back, but also set to
an arbitrary value (depending on the Python implementation).
2016-06-05 15:03:13 +02:00
Markus Hitter 776b3dec94 Configtool: try to repair broken value-#defines.
Previously, #defines requiring a value, but configured as boolean,
broke GUI code. While Configtool its self should never write such
broken #defines, they can happen with manual config file edits.

IMHO it's fine to do such repair attempts as long as it doesn't
hobble other functionality. Whatever was broken at read time will
end up disabled at write time, unless the user changes that value
in the GUI.
2016-06-05 15:03:13 +02:00
Markus Hitter 490e58a43c Configtool: simplify board config parsing (a little bit).
There should be no functional change. Mostly done for consistency
with other, similar code sections.
2016-06-05 15:03:13 +02:00
Markus Hitter d49520c36d Configtool: deal with missing #defines requiring a value.
This is done by parsing values from the generic config before
parsing those in the user config. Values existing in the user
config overwrite those in the generic config; values not
existing there stay at the value in the generic config.

Previously, only boolean #defines were handled properly (and
by code somewhere else). Missing #defines with value were
written as boolean #define, making the file unparseable on
the next read.
2016-06-05 15:03:13 +02:00
Markus Hitter 9d3a064f40 Configtool: remove redundant code.
There is no point in parsing candidates, just to throw away them
a moment later.
2016-06-05 15:03:13 +02:00
Markus Hitter 09bcb0cf42 Configtool: attempt to fix broken pin definitions.
We can't magically find out what the right pin is, but we can at
least make sure it gets written with valid syntax next time. This
also ensures pins can be handled in the GUI, avoiding failures
like the one reported by inline comments here:

b9fe0a5dd0
2016-06-01 13:20:14 +02:00
Phil Hord d9cf035687 simulator: suppress position display unless something changed
Also coalesce multiple pin-steps occurring at the same clock-time into
a single step.  This allows us to treat X+Y movements at the same moment
into a single step on corexy.
2016-05-31 15:21:49 -04:00
Phil Hord aebaa3bf40 simulator: add --pinouts to show pin activity on console
We show pin output on the console when --verbose is 2.  But this gets in
the way of other verbose output we may want to monitor.  Move the pinouts
option to an explicit switch instead of relying on the --verbose flag.
2016-05-31 15:21:49 -04:00
Phil Hord 65b176e2f6 simulator: Add --no-color option to turn off ANSI controls 2016-05-31 15:21:49 -04:00