Commit Graph

22 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
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 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 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 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 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
Bas Laarhoven 72fdd33958 Prevent unexpected macro expansion. 2011-08-16 13:59:41 +02: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 3ee3ee06a1 pinio.h: cosmetics. 2011-03-04 22:51:54 +01:00
Markus Hitter 4cc0c2ca4f Refine enhancements in ea4fdcf a bit. 2011-03-04 22:02:46 +01:00
Ben Jackson ea4fdcf26a mendel.c, pinio.c: Make Z axes optional. 2011-03-04 19:42:00 +11:00
Markus Hitter e688e8b788 Consequences of the stepping extruder now being optional. 2011-03-02 00:43:06 +01: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 475ca7d54a pinio.h: make ?_INVERT_DIR safer. 2011-03-02 00:43:01 +01:00
Markus Hitter 7e8c50fa58 pinio.h: make inverting pins actually work.
To INVERT an endstop, #define X_INVERT_MIN etc.
To leave it uninverted, define nothing, i.e. comment the #define out.

Probably, this change should be extended to INVERT_DIR and
INVERT_ENABLE, too.

The problem was, preprocessor flags are usually set with a simple
"#define X_INVERT_MIN", so X_INVERT_MIN is defined, but of
arbitrary value. Applies to other axes and INVERT_MAX also,
of course.

Initially, it was planned to allow "#define X_INVERT_MIN" as well
as "#define X_INVERT_MIN 0" but that turned out to be _really_
complex. See http://www.velocityreviews.com/forums/t720190-test-of-a-preprocessor-symbol-defined-as-nothing-vs-zero.html .

For curiosity, I've ported this to our purposes, debug messages
left in place:

	#ifdef X_INVERT_MAX
		#if CAT(1,X_INVERT_MAX) == 1
			#warning "X enabled, inverted"
			#define x_max()						(READ(X_MAX_PIN)?0:1)
		#elif X_INVERT_MAX
			#warning "X enabled, inverted"
			#define x_max()						(READ(X_MAX_PIN)?0:1)
		#else
			#warning "X enabled, uninverted"
			#define x_max()						(READ(X_MAX_PIN)?1:0)
		#endif
	#else
		#warning "X enabled, uninverted"
		#define x_max()						(READ(X_MAX_PIN)?1:0)
	#endif
	#warning "X disabled"
	#define	x_max()							(0)
2011-02-27 16:16:30 +01:00
Stephan Walter 8acb072e0b Actually set extruder enable pin if defined 2011-02-27 00:55:14 +11:00
Jacky2k aec41c59aa gcode_process and pinio need to include config.h
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-02-09 07:46:04 +11:00
Michael Moon 47a23317be allow home-to-max setups 2011-02-08 17:52:32 +11:00
Markus Amsler 021ac75e2f Fix typo in x_min 2011-02-05 13:33:26 +11:00
Michael Moon 266c6ee0e2 merge release-candidate-triffid 2011-01-07 23:29:32 +11:00