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.
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.
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.
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().
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.
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.
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().
Temperature residency time / temperature achieved check is in
the order of seconds, while updates for residency time were being
called every 10ms - unnecessarily often.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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
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.
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.
When the simulator finishes processing the last gcode, it exits. This
leaves causes us to exit without completing the last commanded move.
Rework how we handle end-of-file parsing and wait for the dda queue to
empty before exiting at the end of file processing.
Add a function axes_um_to_steps to convert from um to steps on all axes
respecting current kinematics setting.
Extend code_stepper_axescode_axes_to_stepper_axes to convert all axes,
including E-axis for consistency.
It seems like axes_um_to_steps could be simplified to something like
"apply_kinematics_axes()" which would just do the transformation math
in-place on some axes[] to move from 'Cartesian' to 'target-kinematics'.
Then the original um_to_steps and delta_um code could remain untouched
since 2014. But I'm not sure how this will work with scara or delta
configurations. I'm fairly certain they only work from absolute positions
anyway.
Fixes#216.