Commit Graph

62 Commits

Author SHA1 Message Date
Markus Hitter 23be2d1449 SD card: finally(!) implement printing from SD card.
Turned out to be pretty easy with all the more complex bits
already in place.

Strategy is to always parse a full line from one of the sources.
Accordingly, simply sending a character on the serial line stops
reading from SD until the line coming in over serial is completed.
2015-07-07 19:07:35 +02:00
Markus Hitter c7b134bc65 SD card: change demo code for performance measurement.
As we're around here, lets see how fast this implementation is.
All measurements are raw reading performance, without actual
parsing of the G-code.

With SPI_2X disabled (see line 8 in spi.h), performance is
195 seconds per megabyte, equivalent to about 50'000 baud.

With SPI_2X enabled, performance is 159 seconds per megabyte,
or 60'000 baud.

Still, SPI_2X is left disabled to increase reliability. Reading
from SD is faster by design, because there is no checksumming and
also no waiting for the "ok" to be sent back. In case reading
G-code from SD ever becomes a bottleneck, there are even more
opportunities in addition to enabling SPI_2X, like making sdbuffer
bigger, like micro-optimizing spi_rw() and similar stuff.
2015-07-07 14:36:46 +02:00
Markus Hitter d3f548a895 SD card: actually read the characters from the file.
Next to the implementation of sd_read_byte() as well as M24 and
M25, yet another demo: read the file and write it to the serial
line, to show correctness of the implementation.
2015-07-07 14:36:44 +02:00
Markus Hitter 30ce8eb1b4 SD card: remove the demonstration code.
We're about to do some real stuff ...
2015-07-05 23:32:48 +02:00
Markus Hitter 9de0c65460 SD card: add the layer between hardware and Petit FatFs.
This is all the commands to read from and write to SPI,
initializing the card, read in blocks and so on. This should
make Petit FatFs actually usable.

So far read-only and no M-codes to let end users play with
this stuff.

The demonstration code was changed to list the SD card's
top level directory over and over again.
2015-07-05 23:32:48 +02:00
Markus Hitter 63c4dbaea9 mendel.c: do module enabling differently.
Same result, but 8 bytes less binary size. With SD card disabled,
binary size is now the same as before getting SPI running.
2015-07-05 23:32:48 +02:00
Markus Hitter 1fb3ece31e SD card: establish spi.c/.h and sd.c/.h and get SPI running.
For now this is just a nice demonstration on how to send bytes
over SPI. Add SD_CARD_SELECT_PIN to your configuration board
file manually to see data signals on MOSI dancing on the scope.

The TODO's about SS in arduino*.h were wrong, SS does have a
chip-specific special meaning (used in SPI multi-master or SPI
slave mode). Still, a #define MAX6675_SELECT_PIN is missing.

Squashed in this commit from the SPI development topic branch to
get this first step working:

Author: jbernardis <jeff.bernardis@gmail.com>
2015-02-04 22:35:07
mendel.c: disable SPI in power management only when not needed.

If we want to talk to a SD card connected to SPI, we need SPI
powered, of course.

From Traumflug: nice catch, Jeff!
2015-07-05 23:32:46 +02:00
Markus Hitter a217465e65 SIMINFO: fetch device name from Makefile / compile parameters.
It's also possible to do this by stringifying MCU, but this
requires double redirection, which isn't easily readable in a .c
file. For stringification, see the bottom example at
https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
2015-04-21 02:51:31 +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 5cc84a069a Canned G-code: setup right in config.h.
This works with Arduino IDE as well and should be easier to figure
for inexperienced users.
2014-08-31 19:31:39 +02:00
Markus Hitter 7f990a298c Canned G-code: don't miss first character. 2014-08-31 19:22:24 +02:00
Markus Hitter 1e97e51d2a Canned G-code: fix reading flash memory. 2014-08-31 19:20:50 +02:00
Michael Moon aed4bfdb5b Canned G-code: implement continuous replay of G-code stored on flash. 2014-08-31 19:19:21 +02:00
David Forrest 2bf98feaaa mendel.c: Enable DEBUG_LED_PIN output if defined. 2014-05-29 21:48:46 +02:00
Phil Hord 96b7b8e6c9 Update URLs for new github location 2014-03-04 19:57:08 +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
Markus Hitter 71ae941a09 Add simulation info for SimulAVR.
This shouldn't change the running binary at all, so it shouldn't
harm. However, it allows to run Teacup inside SimulAVR and accessing
Teacups' serial line through the console/terminal.

For detailed instructions, see http://reprap.org/wiki/SimulAVR .
2013-12-06 19:24:58 +01:00
Phil Hord b65efe9b03 Move argc/argv processing deeper into simulator.
Less magic == more better.
2013-12-06 19:24:58 +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
Markus Hitter 01f7c99881 config.h: introduce PS_MOSFET_PIN for Sanguish support. 2013-10-27 20:01:51 +01:00
Markus Hitter 5d6de1761b Enable internal pullups for endstops on demand, only.
The binary size impact is moderate, like 18 bytes plus
4 bytes per endstop defined.

The story is a follows:

The endstop logic can be used to use a touch probe with PCB
milling. Connect the (conductive) PCB surface to GND, the
spindle/mill bit to the signal line, turn the internal pullups
on and there you go.

However, doing so with pullups always enabled and while milling
under (conductive) water showed polished mill and drill bits to
become matte after a few hours of usage. Obviously, this small
0.5 mA current from the pullup resistors going through the
rotating mill bit is sufficient to get some spark erosion going.
That's bad, as spark erosion happening also means tools become
dull faster than neccessary.

With this patch, pullups are turned on while being used, only,
so this sparc erosion should go away.
2012-12-03 19:48:13 +01:00
Markus Hitter d3af5460f1 Move heater initialisation from mendel.c to heater.c.
This enhances encapsulation.

An attempt to initialise only the timers in use was abandoned.
This isn't only unneccessary, as pins are still in normal
operation mode unless their bits in TCCR0A/TCCR2A/... are set,
even with the timer behind the pins running, it's also at least
tricky to sort pins and their timer bits at compile time. Doing
the sorting at runtime would cause additional binary size.
2012-11-08 16:22:46 +01:00
David Forrest 52ce6b5f52 More enablement of ATmega32U chip.
- ATmega32U timer 4 register handling differs from other AVRs:
  Change heater.c and mendel.c.
- LUFA USB recognition expanded in Makefile.
- Add section for __AVR_ATmega32U4__ in arduino.h.
2012-10-14 22:56:09 +02:00
Markus Hitter f06b013179 clock.c: introduce clock().
This simplifies calls to clock_10ms() a bit and saves 18 bytes
binary size.
2012-09-29 23:00:24 +02:00
Markus Hitter eaf6c453be Introduce gcode_init() and honor E_ABSOLUTE as the default. 2012-05-11 13:50:51 +02:00
Markus Hitter 5f9ae5b087 Implement M82/M83 and handle relative movements entirely different.
Instead of converting them to absolute first, then back to
relative and having all the fuzz with working on the queue's
start vs. working at the queue's end, mark a movement as relative
and use this directly.
2012-05-11 13:50:33 +02:00
Markus Hitter 86e20580f8 Make fast PWM optional.
In some cases the heater switching MOSFETs overheat and using a lower
PWM frequency is advised. See also:
http://reprap.org/wiki/Gen7_Research#Heat_vs._PWM_Frequency
2012-03-03 16:56:36 +01:00
Markus Hitter 2eff194cdf Rename STEPPER_ENABLE_INVERT to STEPPER_INVERT_ENABLE.
No functional change, just match the naming of single stepper
enable pins.
2011-10-05 14:13:28 +02:00
Markus Hitter a33964fc51 Clean up enable pin handling.
This includes:

- Initialize them in mendel.c.

- While running, switch the pin only.

- Sort mendel.c the same order as in pinio.h.

- Remove the requirement of a parameter for this flag, like
  it's with all other flags.
2011-10-05 14:13:25 +02:00
Markus Hitter 090da8ddad Clean up handling PS_ON_PIN and STEPPER_ENABLE_PIN.
This means moving power_on() from a macro to a function and
initializing the STEPPER_ENABLE_PIN in mendel.c.
2011-10-05 14:13:15 +02:00
Markus Hitter 51be23177a dda: move dda->n out into a new state variable
This required to also introduce dda_init() and re-adjust the
number of accelerating steps a bit.

Goal of this is to make look-ahead possible by just reducing
the number of deceleration steps and acceleration steps of
the next move. dda->c and dda->n no longer go down to their
initial values, then.

Also, quite a number of variables in the dda struct are used only when
the dda is live, so there is no need to store that for each
movement of the queue.
2011-05-15 20:34:35 +02:00
Jim McGee f22e691fee Convert the clock_flag variable into 3 separate varables.
This costs 2 bytes of ram, but saves 60 bytes of flash. Doing so
also eliminates the need to disable interrupts while clearing flags
in the ifclock macro.

Conflicts:

	clock.c
	timer.c
	timer.h
2011-05-15 09:56:32 +10:00
Michael Moon 2822721a59 improve and simplify heater pin initialisation by moving to io_init[mendel.c] and using macro magic with DEFINE_HEATER 2011-05-05 00:02:06 +10: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
Markus Hitter 1214646ca8 mendel.c: Repsnapper expects a lowercase "start". 2011-03-20 02:09:16 +01:00
Ben Jackson 3543c6f081 mendel.c: ifdefs for hardware features in powerdown code 2011-03-04 19:42:21 +11:00
Ben Jackson ea4fdcf26a mendel.c, pinio.c: Make Z axes optional. 2011-03-04 19:42:00 +11:00
Michael Moon c6a9f24e24 don't set up SPI pins unless we're using them for a max6675 2011-03-03 11:22:49 +11:00
Markus Hitter d2bf65822e Make the extruder stepper optional.
Think of DC extruders, milling Mendels, ...
2011-03-02 00:43:03 +01:00
Markus Hitter d93e6e5d2c Internal pullup resistors: intitialize them in the correct order.
It was brought to my attention, one has to set them as input first,
then to configure them to use the Pullups.
2011-03-01 17:07:27 +01:00
Markus Hitter b7afdda3f7 Make the use of the internal pullup resistors optional.
All other firmwares set them to zero -> no internal pullup resistor,
as they counter-work to the design of the electronic endstops.
However, in conjunction with mechanical endstops, they're very practical.
2011-03-01 16:10:52 +01:00
Michael Moon 8188ff3593 merge intercom-protocol into master 2011-02-21 16:01:27 +11:00
Stephan Walter eecf3af9f1 analog mask calculated automagically 2011-02-21 13:57:51 +11:00
Stephan Walter 760487979c Added sample configuration for GEN6 board 2011-02-15 10:03:12 +11:00
Markus Amsler e41e659e66 intercom: Disable rx while doing tx. Avoids local RS485 half-duplex echo.
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-02-14 11:31:45 +11:00
Markus Amsler b7f84a1812 itercom: Enable the RS485 transceiver on the host. 2011-02-14 11:05:52 +11:00
Markus Amsler 398f68e2db make *_MIN_PIN defines optional 2011-02-09 07:47:41 +11:00
Michael Moon 007d3c9736 initialise 16-bit timers on the mega1280 correctly 2011-01-25 12:47:22 +11:00
Michael Moon 096d7dfdf3 Merge release-candidate-triffid branch 2011-01-07 23:09:13 +11:00