Skip to content

Commit

Permalink
Merge pull request #3808 from thinkyhead/rc_singlenozzle
Browse files Browse the repository at this point in the history
SINGLENOZZLE
  • Loading branch information
thinkyhead committed May 23, 2016
2 parents 678cbad + 0c7c450 commit 89e630b
Show file tree
Hide file tree
Showing 22 changed files with 86 additions and 7 deletions.
10 changes: 10 additions & 0 deletions Marlin/Conditionals.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,16 @@

#define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1)

/**
* With SINGLENOZZLE all "extruders" are in the same place
*/
#if ENABLED(SINGLENOZZLE)
#undef EXTRUDER_OFFSET_X
#undef EXTRUDER_OFFSET_Y
#define EXTRUDER_OFFSET_X { 0 }
#define EXTRUDER_OFFSET_Y { 0 }
#endif

/**
* Z_DUAL_ENDSTOPS endstop reassignment
*/
Expand Down
3 changes: 3 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
4 changes: 3 additions & 1 deletion Marlin/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@
#error "EXTRUDERS must be 1 with Z_DUAL_STEPPER_DRIVERS."
#endif

#endif // EXTRUDERS > 1
#elif ENABLED(SINGLENOZZLE)
#error "SINGLENOZZLE requires 2 or more EXTRUDERS."
#endif

/**
* Limited number of servos
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/Felix/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/Felix/DUAL/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 2

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/Hephestos/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/Hephestos_2/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/K8200/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/RigidBot/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1 // Single extruder. Set to 2 for dual extruders

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/SCARA/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/TAZ4/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/WITBOX/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/adafruit/ST7565/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/delta/biv2.5/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 2

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/delta/generic/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/delta/kossel_xl/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/makibox/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
3 changes: 3 additions & 0 deletions Marlin/example_configurations/tvrrug/Round2/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
// :[1,2,3,4]
#define EXTRUDERS 1

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand Down
22 changes: 16 additions & 6 deletions Marlin/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,19 +417,29 @@ float Temperature::get_pid_output(int e) {

pid_output = pTerm[e] + iTerm[e] - dTerm[e];

#if ENABLED(SINGLENOZZLE)
#define _NOZZLE_TEST true
#define _NOZZLE_EXTRUDER active_extruder
#define _CTERM_INDEX 0
#else
#define _NOZZLE_TEST e == active_extruder
#define _NOZZLE_EXTRUDER e
#define _CTERM_INDEX e
#endif

#if ENABLED(PID_ADD_EXTRUSION_RATE)
cTerm[e] = 0;
if (e == active_extruder) {
cTerm[_CTERM_INDEX] = 0;
if (_NOZZLE_TEST) {
long e_position = stepper.position(E_AXIS);
if (e_position > last_position[e]) {
lpq[lpq_ptr++] = e_position - last_position[e];
last_position[e] = e_position;
if (e_position > last_position[_NOZZLE_EXTRUDER]) {
lpq[lpq_ptr++] = e_position - last_position[_NOZZLE_EXTRUDER];
last_position[_NOZZLE_EXTRUDER] = e_position;
}
else {
lpq[lpq_ptr++] = 0;
}
if (lpq_ptr >= lpq_len) lpq_ptr = 0;
cTerm[e] = (lpq[lpq_ptr] / planner.axis_steps_per_unit[E_AXIS]) * PID_PARAM(Kc, e);
cTerm[_CTERM_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_unit[E_AXIS]) * PID_PARAM(Kc, e);
pid_output += cTerm[e];
}
#endif //PID_ADD_EXTRUSION_RATE
Expand Down

6 comments on commit 89e630b

@MagoKimbra
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But all the pieces of code on the temperature control of a single hotend not you used them?

@thinkyhead
Copy link
Member Author

@thinkyhead thinkyhead commented on 89e630b May 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But all the pieces of code on the temperature control of a single hotend not you used them?

Is there a piece of SINGLENOZZLE code that I failed to include, that you wish to point out? I did a search of the source code for SINGLENOZZLE and adapted all the code that I found. The PID_ADD_EXTRUSION_RATE code above is adapted from MarlinKimbra, and should be 100% equivalent.

@MagoKimbra
Copy link
Contributor

@MagoKimbra MagoKimbra commented on 89e630b May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have active singlenozzle, it should only be activated a temperature sensor. It must be on a single heater. The M104 and M109 commands should set the temperature of the only hotend value equal to the active one.
Example

T1
M104 T0 s200
M104 T1 S210 -> this is the value to use
M104 T2 S190
#if HOTENDS == 1
  if (target_extruder != active_extruder) return;
#endif

in temperature.h

#if HOTENDS <= 1
   #define HOTEND_ARG 0
#else
   #define HOTEND_ARG hotend
#endif

and in deghotend and settargethotend

FORCE_INLINE float degHotend (uint8_t hotend) {return current_temperature [HOTEND_ARG]; }
FORCE_INLINE setTargetHotend void (const float & celsius, uint8_t hotend) {
   target_temperature [HOTEND_ARG] = Celsius;

In this way both reading and writing the temperature is always routed to the only hotend

See https://github.com/MarlinFirmware/MarlinDev/pull/86/commits/ea4ec0ebea1fa4fca08a98823f4029364f84b0fd

@thinkyhead
Copy link
Member Author

@thinkyhead thinkyhead commented on 89e630b May 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm integrating the EXTRUDER => NOZZLE changes.
Q: How important do you think these lines are in M104 and M109…?

+  #if HOTENDS == 1
+    if (target_extruder != active_extruder) return;
+  #endif

…and should they use SINGLENOZZLE instead…?

+  #if ENABLED(SINGLENOZZLE)
+    if (target_extruder != active_extruder) return;
+  #endif

…or even be…?

+  #if ENABLED(SINGLENOZZLE)
+    if (target_extruder != 0) return;
+  #endif

@MagoKimbra
Copy link
Contributor

@MagoKimbra MagoKimbra commented on 89e630b May 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Difficult to explain in English for me, but I try.
If I have 4 extruders can also have 4 different materials. With CURA and SLIC3R I can put commands M104 or M019 in Gcode change tools.
The firmware will have to take the new temperature refers only to the extruder current.
Example.
In my Gcode post change tools i have this:

{IF_EXT0}M104 T0 S{TEMP0}
{IF_EXT1}M104 T1 S{TEMP1}
{IF_EXT2}M104 T2 S{TEMP2}
{IF_EXT3}M104 T3 S{TEMP3}

The result post slicing is:

M104 T0 195
M104 T1 195
M104 T2 220
M104 T3 270

Now when change tools the FW take new temperature for apply to single nozzle...

T1 --> T3

M104 T0 195 call routine M104 but the target-extruder(T0) is different to actual_extruder(T3) and exit routine.
M104 T1 195 is equal.
M104 T2 220 is equal
M104 T3 270 call routine M104 but now target extruder is equal actual extruder... Now this the new temperature the nozzle....

The same for M109 command...

This is a example: http://www.thingiverse.com/thing:765744
Printed with raft in Pla, Abs wings and logo, PetG for plane structure.

@thinkyhead
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that "the standard" for the way that multi-extruder GCode should typically be? It should include temperatures for all extruders, but only apply a given temperature if the "tool" specified in the command is the current one? And the tool-change always occurs before this set of temperature commands?

Please sign in to comment.