Commit Graph

92 Commits

Author SHA1 Message Date
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
Markus Hitter a241ef2fa3 gcode_process.c: get rid of duplicate comments and those ===='s
These ==== are nasty if you grep a directory for patch conflicts.
2011-08-22 18:15:02 +02:00
Markus Hitter dcc2255526 gcode_process.c: implement proper M2, comment on M0. 2011-08-22 18:15:00 +02:00
Markus Hitter ffdfde8d8d gcode_process.c: re-add comment about G28, remove now obsolete functions. 2011-08-16 15:31:09 +02:00
Michael Moon 8483073380 revert G28 to homing, as no-one uses it properly anyway 2011-07-16 21:01:31 +10:00
Michael Moon 131d7390c0 fix move to zero in next move after homing command, add M84 disable motors 2011-06-26 17:41:33 +10:00
Michael Moon 9bd8a048ea new option: enforce_order. causes M105 and friends to wait for queue to empty before reporting 2011-06-18 22:47:53 +10:00
Jens Ch. Restemeier b39a7b8d84 fixed documentation errors 2011-06-03 02:02:47 +10:00
Jens Ch. Restemeier 14afa84aca Added gcode documentation and extraction tool 2011-06-03 02:02:46 +10:00
Jim McGee 85a9f63dfb Pretest DEBUG_X constants for non-zero and && the test with all existing
& tests of the debug_flags. Currently the compiler is able to eliminate
the block and the & operation when the constant is zero, but since
the debug_flags variable is a volatile the compiler does not eliminate
the load of the variable. By pretesting and shortcutting the load is
eliminated. Saves a small number of bytes when the debug build is
disabled and costs nothing when it is enabled.
2011-05-15 09:56:33 +10: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