Commit Graph

102 Commits

Author SHA1 Message Date
Markus Hitter b66ba4629a gcode_process.c: sort M112.
Counting to numbers up to 300 is apparently not everyone's
business, he he. :-)
2014-12-26 19:41:38 +01:00
Erik Jonsson fa0e0d37e7 gcode_process.c: added stop message when M2 is recieved.
This shall help stopping a simulator when G-code is done.
2014-08-31 19:12:36 +02:00
Markus Hitter 642948acb2 gcode_process.c: review G28 comment. 2014-08-31 19:12:11 +02:00
David Forrest b12157cb6f gcode_process.c: Add comment on units of P, I, and D parameters. 2014-08-31 19:06:52 +02:00
Phil Hord d3f49b3e95 DDA: Convert TARGET axis vars to array.
In preparation for more efficient and scalable code using axis-loops
for common operations, add two new array-types for signed and unsigned
32-bit values per axis. Make the TARGET type use this array instead of
its current X, Y, Z, and E variables.

Traumflug notes:

- Did the usual conversion to spaces for changed lines.

- Added X = 0 to the enum. Just for peace of mind.

- Excellent patch!

Initially I wanted to make the new array an anonymous union with the
old variables to allow accessing values both ways. This way it would
have been possible to do the transition in smaller pieces. But as
the patch worked so flawlessly and binary size is precisely the
same, I abandoned this idea. Maybe it's a good idea in other areas.
2014-08-31 19:03:17 +02:00
Markus Hitter e76bfa0d05 gcode_process.c: more preprocessor conditions for homing movements.
Well, optimizer isn't _that_ smart. It apparently removes
empty functions in the same compilation unit ( = source code file),
but not ones across units.

This saves 10 bytes binary size per endstop not used, so 30 bytes
in a standard configuration. All without any drawbacks.
2014-07-11 01:38:34 +02:00
Markus Hitter 7611872baa Get rid of E_STARTSTOP_STEPS.
This meant to be a firmware-provided retract feature but was
never really supported by G-code generators. Without their support
(by issueing M101/M103), it's pretty hard to detect extrusion
pauses, so this feature simply has no future.

As this was on by default, it saves over 200 bytes binary size
in a default configuration.
2014-07-11 01:37:48 +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 c5871d0303 gcode_process.c: show endstop status in clear text.
This costs 40 bytes, but should be a significant enhancement on
usability.
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
Phil Hord 498779d7ab gcode-process.c: fix HEATER_EXTRUDER reference.
A rare combination of factors makes this code assume HEATER_EXTRUDER
always exists, when that is not necessarily so.  Add the normal
guard around it.
2013-11-11 19:02:52 +01:00
Markus Hitter fc4bfca06a Rename M200 to M119 to meet Sprinter & Marlin.
No functional change.
2013-07-11 22:04:03 +02:00
Markus Hitter 23679bbd49 Remove M84.
Teacup handles motor on/off automatically and if your
intention is to stop the printer, M0 is appropriate (and
conforming with the NIST G-code standard).

That said, M84 is kept as a synonym for M2 to enhance compatibility
with slic3rs default end-G-code.
2013-07-11 22:03:51 +02:00
Markus Hitter b10b3db4f8 Wrap EEPROM storage related stuff in #ifdef EECONFIG.
Saves a whopping 600 bytes. Let's cross fingers stuff still works.
It should, using the hardcoded default values.
2013-02-05 14:10:31 +01:00
Markus Hitter faf737bbf5 gcode_process.c: remove commented M113. 2013-01-03 15:34:56 +01:00
Markus Hitter 49b76d6e25 gcode_process.c: make the extruder optional and ...
... default to the first available device if the intended
device isn't available.
2013-01-03 15:34:50 +01:00
Markus Hitter a0997fcee1 gcode_process.c: remove M190 and M191.
These were pointless anyways, the power supply is handled fully
automatic in Teacup.
2013-01-03 15:34:49 +01:00
Markus Hitter 7f903fe0e2 gcode_process.c: remove the now obsolete M135.
The replacement is the now generalised M106.
2013-01-03 15:34:48 +01:00
Markus Hitter 28a366fc48 Handle power_on() for heaters in heater.c.
This removes some instances in gcode_process.c and saves 26 bytes.
2013-01-03 15:34:45 +01:00
Markus Hitter 6f2ec09837 Make temperature sensor type TT_NONE obsolete.
The requirement was simply neither obvious nor intuitive. Drawback
is, the indices of temperature sensors can now differ from these
of the heaters. That's easier to recognize for newbies, though.
2013-01-03 15:34:41 +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 a054d4c6cd Remove all remaining evidence of M109.
M109 went away a few commits ago in favour of only M116.
2012-10-14 22:57:22 +02:00
Markus Hitter b83027def2 gcode_process.c: fix a comment. 2012-10-14 22:56:26 +02:00
Markus Hitter b4d202367c gcode_process.c: fix URL sent on M115. 2012-10-14 22:56:17 +02:00
Markus Hitter 47337f1213 gcode_process.c: join M250 and a stray message into M114.
Also, F is unsigned.
2012-09-29 23:01:42 +02:00
Markus Hitter d169a1fa3e gcode_process.c: remove M253: read arbitrary memory location, too.
Also pretty esoteric.
2012-09-29 23:01:17 +02:00
Markus Hitter 8e3cf55723 gcode_process.c: remove M254: write arbitrary memory location.
Pretty esoteric and I can't imagine how to make meaningful use
of this. And well, we have to make room for eeconfig commands.
2012-09-29 23:01:02 +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 c75693af38 gcode_process.c: remove support for M109.
This was deprecated in the wiki quite a while ago. Use M104,
followed by a M116, instead.

This saves a whopping 250 bytes binary size.
2012-09-29 22:59:33 +02:00
Markus Hitter 94ac2b11b8 gcode_process.c: remove M107 (fan off).
To turn the fan off, use M106 S0. This aligns with RepRap's
G-code wiki page.
2012-09-29 22:59:08 +02:00
Markus Hitter 06c546959c gcode_process.c: allow controlled fan speed. 2012-09-29 22:58:39 +02:00
Markus Hitter 37933c8a85 Fix temperature printing.
Remove the assumption there's always an extruder temperature
sensor and make reading on single sensors (e.g. M105 P2) more usable.

Apparently works very well, but *sigh* yet another 100 bytes of binary size.
2012-08-04 22:08:17 +02:00
Markus Hitter 9731868418 gcode_process.c: test seen_P before using P, same for seen_S / S.
There were a whole bunch of cases where P and/or S were used without
checking for the validity of the value. This led to all sorts of
confusion, for obvious reasons.
2012-08-04 22:08:01 +02:00
Markus Hitter 3d1ebf1186 Review power supply timeout.
- Move the variable from dda.c to pinio.c.

- Reset the timeout on each power on, to guarantee a minimum PSU on time.
2012-07-16 20:13:12 +02:00
Markus Hitter 1cb40082e4 gcode_process.c: remove more redundant code.
Saves yet another 122 bytes.
2012-07-16 20:13:01 +02:00
Markus Hitter fb5a32d344 Turn the PSU on before asking the endstops. 2012-05-13 20:18:33 +02:00
Markus Hitter 15476fa655 Fix "E ghost moves". 2012-05-11 13:51:11 +02:00
Markus Hitter 88236ba698 gcode_process.c: also reset E on G92 without arguments. 2012-05-11 13:50:55 +02:00
Markus Hitter 9dda3349be Revert the new relative handling for X, Y and Z.
These were commits 9dbfa7217e0de8b140846ab480d6b4a7fc9b6791 and
2b596cb05e621ed822071486f812eb334328267a.

There are several reasons why this new approach didn't work out well:

- The machine coordinate system is lost on relative movements.
  OK, we could keep tracking it, but this would mean even more
  code, so even more chances for bugs.

- With the lost coordinate system, no software endstops are possible.

- Neither of X, Y, Z will ever overflow.

- If a movement planner would appear one day, he'd have to handle
  relative movements as well. Even more code duplication.
2012-05-11 13:50:47 +02:00
Markus Hitter e5cc5ab066 dda.c: Fix a number of minor things, detected by Phord.
These were mistakes introduced with the last commit.
Thanks, Phord!
2012-05-11 13:50:35 +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 6864268df8 gcode_process.c: add notes about M82 and M83. 2012-03-03 16:58:41 +01:00
Markus Hitter 4e5f51f01e Store distances in the TARGET strucure in micrometers for all axes.
This extends the previous commit from X to Y, Z and E.
2011-11-17 13:48:36 +01:00
Markus Hitter c96ea0c773 Store distances in the TARGET structure always in micrometers.
This is a intrusive patch and for now, it's done for the X axis only.
To make comparison with the former approach easier ...

The advantages of this change:

- Converting from mm to steps in gcode_parse.c and back in dda.c
  wastes cycles and accuracy.

- In dda.c, UM_PER_STEP simply goes away, so distance calculations
  work now with STEPS_PER_MM > 500 just fine. 1/16 microstepping
  on threaded rods (Z axis) becomes possible.

- Distance calculations (feedrate, acceleration, ...) become much
  simpler.

- A wide range of STEPS_PER_M can now be handled at reasonable
  (4 decimal digit) accuracy with a simple macro. Formerly,
  we were limited to 500 steps/mm, now we can do 4'096 steps/mm
  and could easily raise this another digit.

Disadvantages:

- STEPS_PER_MM is gone in config.h, using STEPS_PER_M is required,
  because the preprocessor refuses to compare numbers with decimal
  points in them.

- The DDA has to store the position in steps anyways to avoid
  rounding errors.
2011-11-17 13:48:26 +01:00
Markus Hitter 2f04a9e58c Update current_position only as needed.
This saves almost 200 bytes and 100 runs of
update_current_position() per second.
2011-10-23 19:51:54 +02:00
Markus Hitter 3b4953a631 Remove a bunch of duplicate x_enable() etc.. 2011-10-05 14:13:22 +02:00
Markus Hitter b45969e57a Introduce stepper_enable() and stepper_disable().
This allows to heat up with disables steppers, even if all steppers
share a common enable pin.
2011-10-05 14:13:21 +02:00
Markus Hitter a6c22eed09 gcode_process.c: turn heaters off for M0/M2
This ensures heaters don't spring back to life in case power
is turned back on for something else.
2011-09-01 18:25:04 +02:00
Markus Hitter 24ba72e5d2 gcode_process.c: fix comment typos. 2011-08-22 18:20:08 +02:00