Commit Graph

1700 Commits

Author SHA1 Message Date
Markus Hitter 194e5d5b98 I2C: use pinio.h to handle pins.
This removes the need for four user configuration options.
2016-04-20 21:15:11 +02:00
Markus Hitter 6ef9e1a2ee I2C: encapsulate bus states.
No functional changes.
2016-04-20 21:15:11 +02:00
Markus Hitter 061225f72d I2C: get rid of these unimplemented error handlers.
Naively restarting I2C immediately is certainly not the solution
and just leads to an interrupt flood. As I2C is currently meant
to drive displays, where successful data transmission isn't
crucial, we now simply stop transmission on errors.

This saves another 80 bytes binary size:

    FLASH  : 23094 bytes
    RAM    :  2051 bytes
    EEPROM :    32 bytes
2016-04-20 21:15:11 +02:00
Markus Hitter 3ced6aae4a I2C: handling another master sending is part of slave mode.
At least, avr-libc says so. Saves some 36 bytes in interrupt
context.
2016-04-20 21:15:11 +02:00
Markus Hitter e4067dc235 I2C: use avr-libc bus status names.
No need to reinvent the wheel.
2016-04-20 21:15:11 +02:00
Ruslan Popov 619560c112 I2C: initial support.
This commit squashes in some fixes found after debugging on the
topic branch. Test code by Traumflug, collected from Ruslan's
code on the topic branch.

Before, same as now without I2C:

    FLASH  : 22408 bytes
    RAM    :  1393 bytes
    EEPROM :    32 bytes

Now with I2C:

    FLASH  : 23224 bytes
    RAM    :  2057 bytes
    EEPROM :    32 bytes

This totals to some 800 bytes with a whole lot of test code, so
implementation is pretty small :-)
2016-04-20 21:15:11 +02:00
Phil Hord 537b93ae89 Properly handle temp sensor initialization
The existing code eschews "break" apparently thinking that it will
exit the loop prematurely.  In fact this will only exit the switch
correctly.  The loop will run as normal.

Maybe it's not a big deal, though, since the sensors get re-inited
each time the type of sensor is encountered in the loop.  Presumably
it's ok for each of these sensors to get inited multiple times. If
that's always the case, maybe there's no problem here. But with the
current code sensor types might be initialized even when there is no
sensor defined for that type if the TEMP_* boolean is #defined.

For example, if I have this in my config:

    #define TEMP_MAX6675
    #define TEMP_MCP3008
    //#define TEMP_INTERCOM

    DEFINE_TEMP_SENSOR(extruder, TT_MAX6675, AIO5,  0)
    DEFINE_TEMP_SENSOR(bed,      TT_MAX6675, AIO7,  0)

Then the MAX6675 initialization code will be run twice and the MCP3008
code will, too, even though no temp sensor is defined for that type.

This change does not address the "init runs twice" problem.  It only
addresses the "initialization of unused types" problem.
2016-04-20 10:33:12 -04:00
Phil Hord fbe1832467 Optimize ADC temperature search
Use a binary search to find our target temperate in fewer
comparisons.  The search algorithm is ostensibly slower because
it involves a division, but it's a div-by-two so should be
optimized into a simple bit-shift.  Fewer comparisons involves
fewer pgm_read_words and should be faster overall, but the gain
is arguably tiny.

Note by Traumflug:

According to @Wurstnase's performance measurements, gain is
actually pretty huge. Temp conversions 0..1024 before this
and the previous few commits:

  minimum: 1011.84 clock cycles.
  maximum: 1993.92 clock cycles.
  average: 1768.85 clock cycles.

Now:

  minimum: 437.72 clock cycles.
  maximum: 494.76 clock cycles.
  average: 470.278 clock cycles.

That's a speedup by factor 3.7 on average!
2016-04-17 14:31:54 +02:00
Markus Hitter 65857b17dc temp.c: get rid of TEMPTABLE_FORMAT.
Detecting tables by data size works fine, the optimiser removes
unneeded code successfully. Binary size stays the same.
2016-04-17 14:31:52 +02:00
Phil Hord 2291642456 Expand thermistortable to include precomputed slope
Save a division at runtime by pre-calculating the slope between each
pair of adjacent thermistortable values.  Since we use the larger value
each time, save the slope between two values A and B in the table
with the B data.  Therefore the slope is that between each value and
its predecessor in the list.

Store this new value in the third element of the now 3-integers-wide
array which makes up the table. Use fixed-point 6.10 format to store
the slope.  This is almost too narrow for some slopes and maybe it
should be changed to 8.8 fixed-point. In practice this presents a
loss in accuracy, but it is still significantly better than the
previous fixed-sample-size table production method. In particular no
provision is made to handle values which scale over 65535, and it
seems we should at least warn about this if not simply fail before
letting the user go off compiling his code.

Add a new flag TEMPTABLE_FORMAT and define it as 1 to tell the code
that we are using this new and incompatible format.  This lets us
tolerate old hand-crafted thermistor tables by keeping the slower
algorithm in case one is still used.  New thermistor tables should be
defined with this new format and with the FORMAT define set accordingly.

With the default 25 samples this adds 100 bytes to the flash image for
the thermistortable storage for two different thermistors.  But the
code is simplified and saves me 134 bytes in the bargain for a net
decrease in flash size of 34 bytes.
2016-04-17 14:31:12 +02:00
Phil Hord fe006021ee thermistortablefile.py: keep fractional part when computing table.
The Thermistortablefile.py routine prematurely drops the
fractional part of the temperature when computing the 14.2
temperature values to emit in the code. Keep this instead until
the last moment when we finally calculate the integer format we
will store.
2016-04-16 01:01:16 +02:00
Markus Hitter 74769f4275 Simulator: add help messsage for -T.
Taken from the previous commit message.
2016-04-16 01:00:01 +02:00
Phil Hord 47e62f572c Sim: add --report-temptables option
Teach simulator to calculate temperatures for all possible ADC
values using the compiled-in temperature tables and report the
resulting conversion.  Do no other run-time simulation; exit
after reporting the conversion results.  Output is suitable for
gnuplot for example like this:

  gnuplot --persist -e "plot '< ./sim -T0' u 1:2 with lines,
                             '< ./sim -T1' u 1:2 with lines"
2016-04-16 00:59:55 +02:00
Robert Konklewski ab55b86472 Add board config for the Tronxy/Cstar P802E. 2016-04-15 14:59:03 +02:00
Robert Konklewski 347fbcef5f Add printer config for the Tronxy. 2016-04-14 23:39:10 +02:00
Robert Konklewski c36f899811 .gitignore: add entries for Atmel Studio project files.
Decided to not include project files into the repo, because the
projects seem to include some absolute paths, which is not good
for developer cooperation.
2016-04-14 23:04:05 +02:00
Robert Konklewski 14788b3fe3 sersendf.c: fix printing signed 16-bit values.
The function converted int16_t to unsigned before printing it,
resulting in integer overflow.
2016-04-14 22:59:52 +02:00
Robert Konklewski 9a731c83dc watchdog.c: fix compilation with module enabled.
There was a linker error regarding missing MASK function, which
is actually a macro defined in 'pinio.h'. After #including the
file, problem disappeared.
2016-04-14 22:51:22 +02:00
Phil Hord 090be579d1 Refactor temp table optimization for any algorithm
This should be squashed but is separated here for comparison.
2016-04-14 13:26:17 +02:00
Phil Hord b7a2d58b31 Restrict thermistor table range to 0C-500C
We don't care about the accuracy of very cold temperatures
or unreasonably hot ones.
2016-04-14 13:24:59 +02:00
Phil Hord 6542c284fb Optimize temperature tables for accuracy
Temperature tables are emitted by selecting arbitrary sample values
to be used for the linear lookup table.  This is fine in the range
where the thermistor produces linear output, but it is markedly wrong
near the extremes where the thermister output begins to curve.

Introduce a new sample selector which chooses samples based on the "most
incorrect estimate" and improves from there to ensure we get a cleaner
approximation across the selected range.

Traumflug: this topic is tracked here:
https://github.com/Traumflug/Teacup_Firmware/pull/208
2016-04-14 13:03:30 +02:00
Witold Sowa fdf6dbe849 Added support for MCP3008 and MCP3004 ADC for temperature read 2016-04-12 22:37:50 +02:00
Phil Hord 52e5d784fd Remove useless lines from Configtool
I don't know what these lines were intended for, but the 'idx'
variable is not used anywhere else, so setting it is pointless.
2016-04-12 14:15:11 +02:00
Markus Hitter 67f0f6ef0e check_integrity.sh: move to a less user visible place.
No functional changes.
2016-04-12 00:11:43 +02:00
Markus Hitter 32f10e4f4b check_integrity.sh: check only version controlled files.
Checking files customized by the user is out of scope of this
tool and sometimes even workflow hindering.
2016-04-12 00:11:32 +02:00
Markus Hitter 595dd017ea Fix config files which didn't pass the new regression test.
All the changes are pretty much dummies, no functional change
anywhere.
2016-03-28 01:34:07 +02:00
Markus Hitter f0604b5e9d Add test for config files integrity.
It happens all to often that a #define is added or removed here
or there, but some related files gets forgotten. Now at least
existence of all the #defines is cross-checked.
2016-03-28 01:29:38 +02:00
Markus Hitter 4c205704ad config.h.Profiling: add Z_AUTODISABLE here, too. 2016-03-27 20:41:36 +02:00
Markus Hitter 7faab99671 board.gen7-arm.h: adjust for the released Gen7-ARM.
Just a few pin changes and similar stuff, no code change.
2016-03-27 20:36:03 +02:00
Markus Hitter 82374b8e24 Rename Z_LATE_ENABLE to Z_AUTODISABLE and refine description.
Also turn it on by default for the Mendel printer.

Also add the forgotten Mendel90 printer.
2016-03-27 20:23:05 +02:00
Wurstnase 57afef9fdd Add Z late enable.
Until this commit, the Z axis is disabled after each move and
only enabled when the Z axis will move. Now you can enable this
as a feature. Some printer axes are too heavy or have a high
pitch which are not self locking. In that case simply do nothing.
It's now off by default.
2016-03-27 20:14:04 +02:00
Markus Hitter 57cf28ad36 Add a board config for the SinapTec AT328-02.
See http://www.reprap.org/wiki/SinapTec
2016-02-28 15:57:54 +01:00
Phil Hord edae0dd31d Reduce lookahead "error" to "notice"
The marlin firmware reportedly reports "Error" instead of "!!", indicating
a machine failure which is followed by a full power-down.  The Octoprint
GCode-sender assumes a reported Error means the print has failed and
the machine turned off.

In Teacup we report an "Error" when lookahead was too slow to join
movements, but this is interpreted as an emergency-stop by Octoprint who
then stops the job and leaves the printer idle with all the heaters running.

Change this "Error" to a "Notice" to avoid this problem.  Add a comment
prefix while we're at it to fit the de facto standard better.

See http://reprap.org/wiki/G-code
2015-11-18 16:07:35 -05:00
Phil Hord 6ef35a11f2 Add test for "no endstops defined" build
This configuration used to fail.  Now it's fixed.  Test the
configuration to ensure it doesn't break again in the future.
2015-11-18 14:53:12 -05:00
Phil Hord 4f30e270b2 Don't declare variables which never get used
Fix a compiler warning about "unused variables" when no endstops
are defined.
2015-11-18 14:53:12 -05:00
Phil Hord 890879e7ee Messages: more newlines needed.
The recent switch to send 'ok' postponed requires also sending a
newline in a few places, because this 'ok' is no longer at the
start of the line. Now it appears in its own line.

A recent commit tried to correct this already, but it missed a
few locations.  Also remove the comments promising a forthcoming
newline from gcode_parse.
2015-09-23 08:21:16 -04:00
Markus Hitter 777967b3d5 Add configuration for a Mendel90 printer.
Derived from a contribution of Neil Darlow. Thank you, Neil!
2015-09-14 17:20:07 +02:00
Markus Hitter ba007f6265 Add configuration for a Melzi board.
Derived from a contribution of Neil Darlow. Thank you, Neil!

The adjustments done were reverting customisations like moving
direction reversals (which depend on motor wiring) or custom
thermistor beta values. Everything else left as-is.
2015-09-14 15:51:02 +02:00
Markus Hitter 959e803eac Git tools: a few minor improvements.
Behaviour should be unchanged, but the same tools can be used for
gEDA/pcb now, too.
2015-09-14 15:24:03 +02:00
Phil Hord 47f0f0045c MOVEBUFFER_SIZE really does not have to be power of 2
A comment in dda_queue.h says that MOVEBUFFER_SIZE no longer needs to be
a power of 2 in size.  The comment is from a commit in 2011, but only
queue_full seems to be modified to make this true.  Other places in the
code still assume that MOVEBUFFER_SIZE is always a power of 2, wrapping
it with "& (MOVEBUFFER_SIZE-1)".

Add a MB_NEXT(x) macro which can be used to definitively find the next
slot in the queue without using any boolean math.  Replace all the
queue-position functions with new code that uses this MB_NEXT function
instead.

Also change the queue_full function to use this simpler method instead
of the complicated multi-step confusion which it did.
2015-09-14 15:17:20 +02:00
Markus Hitter 040e95b555 ARM: generic port is done, all printing relevant stuff works.
Also we can compile *.c now.

:-)
2015-08-13 17:12:13 +02:00
Markus Hitter 9c29665a72 ARM: take care of system startup status.
Not much to do, still it was necessary to review this topic.
2015-08-13 17:12:13 +02:00
Markus Hitter 2376242c36 ARM: last not least, enable CANNED_CYCLE.
Was just a matter of removing the wrappers, tests ran fine.
2015-08-13 17:12:13 +02:00
Markus Hitter 5c203b6689 ARM: get watchdog.c in.
The last .c file of the generic ARM port! Again made sure it
doesn't accidentially slip in.
2015-08-13 17:12:13 +02:00
Markus Hitter f8230d6565 ARM: get usb_serial.c in.
Once more just made sure it doesn't accidentially slip in without
giving the user a warning.
2015-08-13 17:12:13 +02:00
Markus Hitter fb317fef08 ARM: get spi.c, pff.c and pff_diskio.c (SD card handling) in.
Neither is ported for now, but also not essential for printing,
so it's just made sure it's always disabled on ARM.
2015-08-13 17:12:13 +02:00
Markus Hitter d2fcc57ed4 Introduce #ifdef SPI.
It's better to separate this by function than by usage.
2015-08-13 17:12:12 +02:00
Markus Hitter 274f6c954b ARM: get graycode.c and intercom.c in.
Also both used only in unusual setups, so no functional or binary
size change for ARM.
2015-08-13 17:12:12 +02:00
Markus Hitter cc6600ca76 ARM: get debug.c and crc.c in.
Both used only in special cases, so no binary size change.
2015-08-13 17:12:12 +02:00
Markus Hitter b849e28836 ARM: get home.c in.
As usual, homing works just fine.
2015-08-13 17:12:12 +02:00