Commit Graph

1518 Commits

Author SHA1 Message Date
Markus Hitter 20a0808887 DDA: don't count individual axis steps.
Using the Bresenham algorithm it's safe to assume that if the axis
with the most steps is done, all other axes are done, too.

This way we save a lot of variable loading in dda_step(). We also
save this very expensive comparison of all axis counters against
zero. Minor drawback: update_current_position() is now even slower.

About performance. The slowest step decreased from 719 to 604
clocks, which is quite an improvement. Average step time increased
for single axis movements by 16 clocks and decreased for multi-
axis movements. At the bottom line this should improve real-world
performance quite a bit, because a printer movement speed isn't
limited by average timings, but by the time needed for the slowest
step.

Along the way, binary size dropped by nice 244 bytes, RAM usage by
also nice 16 bytes.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19564 bytes      137%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 326 clock cycles.
  LED on time maximum: 595 clock cycles.
  LED on time average: 333.62 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 318 clock cycles.
  LED on time maximum: 604 clock cycles.
  LED on time average: 333.311 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 318 clock cycles.
  LED on time maximum: 585 clock cycles.
  LED on time average: 335.233 clock cycles.
2016-11-22 19:13:41 +01:00
Markus Hitter 92516b55ea run-in-simulavr.sh: enable size report.
Apparently this got forgotten earlier.
2016-11-21 19:56:19 +01:00
Markus Hitter 6e87ee5f96 Makefile-AVR: add a target for our standard performance test.
Our standard performance test is to run these three G-code files
in SimulAVR and recording step pulse timings. While this certainly
doesn't cover everything related to possible performance
measurements, it's a good basic standard to compare code changes.

Current performance:
  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19808 bytes      139%       65%       32%       16%
     Data:   2191 bytes      214%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 308 clock cycles.
  LED on time maximum: 729 clock cycles.
  LED on time average: 317.393 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 308 clock cycles.
  LED on time maximum: 726 clock cycles.
  LED on time average: 354.825 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 308 clock cycles.
  LED on time maximum: 719 clock cycles.
  LED on time average: 336.327 clock cycles.
2016-11-21 19:54:59 +01:00
Markus Hitter 77a790e094 Makefile-AVR: add a target for running in SimulAVR.
This is useful for running in a standardised environment and also
demonstrates how to run an executable in SimulAVR.
2016-11-21 18:01:40 +01:00
Wurstnase 47dc3aed89 dda_lookahead.c: one more debug variable defined out by default.
Traumflug's note: if one uses #define LOOKAHEAD_DEBUG at line 177,
  one should use the same symbol in line 321. Edited the commit to
  do so.

This reduces binary size by 38 bytes and RAM usage by 4 bytes.
2016-11-20 15:18:37 +01:00
Matt Gilbert a691f2a8ab PCBScriber config files.
PCBScriber is a printer for the scratch 'n etch method, see

  http://reprap.org/wiki/PCBScriber

Commit reviewer Traumflug's note:

 - Rebased to current branch 'experimental', which adds
   USE_INTERNAL_PULLDOWNS.

 - Removed DEFINE_HOMING for now, this part isn't cooked, yet.
   For example, it doesn't pass regression tests.

 - Thank you very much for the contribution!
2016-11-20 14:45:45 +01:00
Markus Hitter 85fc7f86f4 Teacup_Firmware.ino: add a hint to Configtool. 2016-11-19 10:24:51 +01:00
Markus Hitter 417d519ca5 Rename the Arduino IDE sketch file from .pde to .ino.
Arduino IDE versions requiring .pde as extension are now gone for
quite a while.
2016-11-19 10:15:58 +01:00
Markus Hitter a0fc485fa6 Move branch 'issue-196' to the attic.
This was an attempt to make Teacup sources compatible with
Arduino IDE 1.6.0 - 1.6.9 and became obsolete as of 1.6.10. The
problem was fixed on the Arduino IDE side.
2016-11-19 10:15:01 +01:00
wurstnase cd66feb8d1 dda.c: let's save 3 divisions. 2016-11-14 21:49:44 +01:00
wurstnase 5b11a39155 DDA: make lookahead independent of X.
We calculate all steps from the fastest axis now. So X and Y
steps_per_m don't have to be the same anymore.

Traumflug's: another 16 bytes program size off on AVR, same size
on LPC1114.
2016-11-14 21:43:54 +01:00
wurstnase 2b1f3371c7 DDA: get rid of fast_spm.
We need the fastest axis instead of its steps.

Eleminates also an overflow when ACCELERATION > 596.

We save 118 bytes program and 2 bytes data.

Reviewer Traumflug's note: I see 100 bytes program and 32 bytes
RAM saving on ATmegas here. 16 and 32 on the LPC 1114. Either way:
great stuff!
2016-11-14 21:36:00 +01:00
Wurstnase 39cababb07 dda.c: don't apply feedrate multiplier when searching endstops.
With M220 we can increase the step rate while printing. But when
using this feature it could cause unexpected behaviour while
homing.
2016-11-08 21:21:34 +01:00
Phil Hord 9d42fa4ac1 Configtool: speed up startup with wx-tricks.
This should fix issue #235.

Recently ConfigTool has been very slow for me on Ubuntu Linux.
When I run the app there is a 15 second wait before the window is
first displayed.  I bisected the problem and found it was tied to
the number of pins in `pinNames`, and ultimately that it was
caused by a slow initializer in wx.Choice() when the choices are
loaded when the widget is created.  For some reason, moving the
load after the widget is created is significantly faster.  This
change reduces my startup time to just under 4 seconds.

Further speedup could be had by using lazy initialization of the
controls.  But the controls are too bound up in the loaded data
to make this simple.  Maybe I will attack it later.

There is still a significant delay when closing the window, but I
haven't tracked what causes it.  Maybe it is caused just by
destroying all these pin controls.

In the process of making this change, I wanted to simplify the
number of locations that bothered to copy the pinNames list and,
to support lazy loading, to try to keep the same list in all
pinChoice controls.  I noticed that all the pinChoice controls
already have the same parameters passed to the addPinChoice
function which makes them redundant and confusing.  I removed the
extra initializers and just rely on pinNames as the only list
option in addPinChoice for now.  Maybe this flexibility is needed
for some reason later, but I can't see a purpose for it now.

Notes by reviewer Traumflug:

First of all, which "trick"? That's an excellent code
simplification and if this happens to make startup faster (it
does), all the better.

Measured startup & shutdown time here (click window close as soon
as it appears):

  Before:                With this commit:
  real    0m4.222s       real    0m3.780s
  user    0m3.864s       user    0m3.452s
  sys     0m0.084s       sys     0m0.100s

As the speedup was far more significant on the commit author's
machine, it might be a memory consumption issue (leading to
swapping on a small RAM machine). Linux allows to view this in
/proc/<pid>/status.

         Before:          Now:
VmPeak:	  708360 kB     708372 kB
VmSize:	  658916 kB     658756 kB
VmHWM:	   73792 kB      73492 kB
VmRSS:	   73792 kB      73492 kB
VmData:	  402492 kB     402332 kB

Still no obvious indicator, but a 300 kB smaller memory footprint
is certainly nice.
2016-10-26 22:00:21 +02:00
Markus Hitter 36f54adb7f thermistortablefile.py: fix output parameter list.
If you attempt a Steinhart-Hart table in the configtool with
parameters (4700, 25, 100000, 209, 475, 256, 201) it fails with a:

...
 File "/Users/drf/2014/RepRap/GIT/Teacup_Firmware/configtool/
   thermistortablefile.py", line 169, in SteinhartHartTable
   (i, int(t * 4), int(delta * 4 * 256), c, int(t), int(round(r))),
  TypeError: not enough arguments for format string

Catched and fix provided by dr5fn, this should fix issue #246.
2016-10-26 20:32:45 +02:00
Markus Hitter ef94d0672d Configtool: don't assign values to tuples.
Heck, that's simply forbidden. A C compiler had catched this in a
split second at compile time, Python didn't until the faulty code
section was actually executed (a section of code for rare cases).

The simple fix is to replace the old tuple with a changed, new
tuple.

This resolved issue #242.
2016-10-21 22:03:34 +02:00
Wurstnase dc5c9656ed dda_lookahead.c: remove use_lookahead.
Use of this variable is gone 2013. No functional change, no
binary size change.
2016-10-21 21:55:11 +02:00
Markus Hitter e9b2bf45cb Config files: update comment/help text for USE_INTERNAL_PULLUPS. 2016-09-30 13:51:01 +02:00
Markus Hitter e49de09f58 Config files: introduce USE_INTERNAL_PULLDOWN. 2016-09-30 13:48:46 +02:00
Markus Hitter b47e625d58 pinio.h: support USE_INTERNAL_PULLDOWNS.
That's the counterpart to USE_INTERNAL_PULLUPS and needed on the
Gen7-ARM board.
2016-09-30 13:16:01 +02:00
Markus Hitter aed6f5a14b pinio.h: support pulldown resistors.
These are ARM only, because ATmegas have no such feature.
2016-09-30 13:15:31 +02:00
Markus Hitter 35191306d7 pinio.c/.h: rename PULLUP_OFF() to PULL_OFF().
Before too long we'll support pulldown resistors, so the name
becomes ambiguous (PULLDOWN_OFF() would also turn off a pullup).
2016-09-30 12:42:47 +02:00
Markus Hitter bed5dcb210 dda_lookahead.c/.h: more debugging code removal/wrapping.
Program size -76 bytes,
Data size unchanged.
2016-09-06 21:50:33 +02:00
Wurstnase 0e7165f22f dda_lookahead.c/.h: #ifdef's around some debug-variables.
Move debug.h from .c to .h so debug-vars are available when DEBUG
is defined in debug.h.

Program -78 Bytes
Data -8 Bytes

No functional change.
2016-09-06 21:41:41 +02:00
Wurstnase 4a5e28975e dda_lookahead.h: remove old, unused macros. 2016-09-06 21:30:53 +02:00
Phil Hord c3b8aa310b Define missing DEBUG_LED_PIN in simulator
Turning this feature on without this definition causes the simulator build
to fail since the "pin" is never defined.
2016-08-08 13:34:39 -04:00
Ilya Epifanov 6dce728219 Configtool: fixed GUI crash when using DC extruder. 2016-07-30 11:02:29 +02:00
Phil Hord 5f6371c53d M220: add support for feedrate override percentage.
Similar to M221 which sets a variable flow rate percentage, add
support for M220 which sets a percentage modifier for the
feedrate, F.

It seems a little disturbing that the flow rate modifies the next
G1 command and does not touch the buffered commands, but this
seems like the only reasonable thing to do since the M221 setting
could be embedded in the source gcode for some use cases.  Perhaps
an "immediate" setting using P1 could be considered later if
needed.
2016-07-09 14:18:06 +02:00
Phil Hord 6679dd6562 dda_create(): treat 'target' as const and input only.
`target` is an input to dda_create, but we don't modify it.  We
copy it into dda->endpoint and modify that instead, if needed.
Make `target` const so this treatment is explicit.

Rely on dda->endpoint to hold our "target" data so any decisions
we make leading up to using it will be correctly reflected in our
math.
2016-07-09 14:17:51 +02:00
Markus Hitter 95787f3a34 Regressiontests: define $MCU and $F_CPU explicitely on all tests.
Nothing new, but was forgotten on a few tests.
2016-07-09 14:15:40 +02:00
Markus Hitter 0555299717 Regressiontests: add test for ACCELERATION_TEMPORAL. 2016-07-09 13:53:57 +02:00
Markus Hitter 76efe06284 Regressiontests: add a test for ACCELERATION_REPRAP. 2016-07-09 13:48:56 +02:00
Markus Hitter 58553a5033 Regressiontests: trust our dependency system.
In a test, the system worked fine even for a change in config.h,
which is #included by a variable (config_wrapper.h, line 20).
This should speed up repeated regression test, e.g. when doing a
'git regtest', substantially.
2016-07-09 13:45:25 +02:00
Markus Hitter 801362d541 Lookahead: disable in config_wrapper.h, not in dda_lookahead.h.
Disable it only when appropriate, of course.

The move of this code makes Teacup compiling with both,
ACCELERATION_REPRAP and LOOKAHEAD enabled. Such a configuration
makes no sense, but can happen anyways.
2016-07-09 13:36:22 +02:00
Phil Hord 51321910bc M221: use 256 for 100% flow internally for faster math
The flow rate is given as a percentage which is kept as
100 = 100% internally. But this means we must divide by 100 for
every movement which can be expensive.  Convert the value to
256 = 100% so the compiler can optimize the division to a
byte-shift.

Also, avoid the math altogether in the normal case where the
flow rate is already 100% and no change is required.

Note: This also requires an increase in the size of e_multiplier
to 16 bits so values >= 100% can be stored.  Previously flow
rates only up to 255% (2.5x) were supported which may have
surprised some users.  Now the flow rate can be as high as
10000% (100x), at least internally.
2016-07-09 11:42:16 +02:00
wurstnase 9b010e65ee Introduce M221 aka flow-control.
Now it is possible to control the extruders flow.

  M221 S100 = 100% of the extruders steps
  M221 S90  = 90% of the extruders steps

M221 is also used in other firmwares for this. Also a lot of
hosts, like Octoprint and Pronterface using this M-Code for
this behaviour.
2016-07-09 11:42:16 +02:00
wurstnase 280edf6dbc dda_kinematics.c: note about unrolling loops.
Note a performance improvement opportunity.

Review note by Traumflug: the original commit didn't add a
comment, but replaced the existing code with what's in the
comment now.

According to the comment in issue #223:

Pre-unroll:
LED on time minimum: 3138.44 clock cycles.
LED on time maximum: 5108.8 clock cycles.
LED on time average: 4590.58 clock cycles.

Unrolled:
LED on time minimum: 3016.92 clock cycles.
LED on time maximum: 4987.28 clock cycles.
LED on time average: 4469.06 clock cycles.
2016-07-09 11:42:16 +02:00
Markus Hitter 6cce9d173a DDA: extruders aren't subject to kinematics.
As such, move extruder handling out of dda_kinematics.c into
dda.c.
2016-07-09 11:42:16 +02:00
wurstnase 705e4563db DDA: X is not critical anymore.
It's prepared here:

  https://github.com/Traumflug/Teacup_Firmware/commit/294f0eda26

And gone here:

  https://github.com/Traumflug/Teacup_Firmware/commit/4f0a00c1a

Anyhow, we have a calculation with X in dda_lookahead.c

Traumflugs review note: true, at least until we get distinct
acceleration on each axis.
2016-07-02 22:07:27 +02:00
Wurstnase efb781bed5 Temp: faster cycles in continuous mode.
Thermistors and AD595 can be faster in that mode.

The new stategy is:

  1. read the value
  2. start the adc
  3. return the result
  - next cycle

instead of:

  1. start the adc
  - wait 10ms
  2. read the value
  3. return the result
  - next cycle

Review changes by Traumflug: fixed the warnings appearing in some
configurations (case NEEDS_START_ADC undefined and case
NEEDS_START_ADC defined, but TEMP_READ_CONTINUOUS == 0)
2016-06-25 15:54:53 +02:00
wurstnase 66f06d20a2 Temp: change TEMP_EWMA to integer.
This allows to use EWMA_ALPHA in an #if clause, which is needed
for the next commit.

Review changes by Traumflug: made changes to comments more
complete, added rounding ("+ 500") and also adjusted Configtool
for the change.
2016-06-25 14:30:59 +02:00
Markus Hitter 29cb2e801a analog-avr.c: no need to re-initialise adc_counter.
After firmware startup it's always in a valid range, even in the
unlikely case analog_init() is called twice.

This saves 4 bytes binary size without drawback.
2016-06-23 22:34:31 +02:00
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