Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
ee98a976
Commit
ee98a976
authored
May 19, 2015
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Pid endstop and fix M303 error
parent
7f4d4221
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
119 deletions
+103
-119
Configuration.h
MarlinKimbra/Configuration.h
+1
-1
Configuration_adv.h
MarlinKimbra/Configuration_adv.h
+1
-1
Marlin.h
MarlinKimbra/Marlin.h
+1
-0
Marlin_main.cpp
MarlinKimbra/Marlin_main.cpp
+12
-7
comunication.h
MarlinKimbra/comunication.h
+9
-9
stepper.cpp
MarlinKimbra/stepper.cpp
+72
-93
temperature.cpp
MarlinKimbra/temperature.cpp
+6
-7
temperature.h
MarlinKimbra/temperature.h
+1
-1
No files found.
MarlinKimbra/Configuration.h
View file @
ee98a976
...
...
@@ -21,7 +21,6 @@
// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
// build by the user have been successfully uploaded into firmware.
#define STRING_VERSION "4.1.3"
#define STRING_URL "reprap.org"
#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time
#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
#define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1
...
...
@@ -222,6 +221,7 @@
#define PID_FUNCTIONAL_RANGE 10 // degC
#define PID_INTEGRAL_DRIVE_MAX PID_MAX // Limit for the integral term
#define K1 0.95 // Smoothing factor within the PID
#define MAX_OVERSHOOT_PID_AUTOTUNE 20 // Max valor for overshoot autotune
// HotEnd{HE0,HE1,HE2,HE3}
#define DEFAULT_Kp {40, 40, 40, 40} // Kp for E0, E1, E2, E3
...
...
MarlinKimbra/Configuration_adv.h
View file @
ee98a976
...
...
@@ -31,7 +31,7 @@
/**
* Whenever an M104 or M109 increases the target temperature the firmware will wait for the
* WATCH_TEMP_PERIOD to
trans
pire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE
* WATCH_TEMP_PERIOD to
ex
pire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE
* degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109,
* but only if the current temperature is far enough below the target for a reliable test.
*/
...
...
MarlinKimbra/Marlin.h
View file @
ee98a976
...
...
@@ -36,6 +36,7 @@
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((d)*180.0/M_PI)
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
...
...
MarlinKimbra/Marlin_main.cpp
View file @
ee98a976
...
...
@@ -3667,11 +3667,13 @@ inline void gcode_G92() {
didXYZ
=
true
;
}
}
#if defined(DELTA) || defined(SCARA)
if
(
didXYZ
)
sync_plan_position_delta
();
#else
if
(
didXYZ
)
sync_plan_position
();
#endif
if
(
didXYZ
)
{
#if defined(DELTA) || defined(SCARA)
sync_plan_position_delta
();
#else
sync_plan_position
();
#endif
}
}
#ifdef ULTIPANEL
...
...
@@ -5961,7 +5963,7 @@ inline void gcode_T() {
#else // !DUAL_X_CARRIAGE
// Offset hotend (only by XY)
#if HOTENDS > 1
for
(
int
i
=
X_AXIS
;
i
<=
Y_AXIS
;
i
++
)
for
(
int
i
=
X_AXIS
;
i
<=
Y_AXIS
;
i
++
)
current_position
[
i
]
+=
hotend_offset
[
i
][
target_extruder
]
-
hotend_offset
[
i
][
active_extruder
];
#endif // HOTENDS > 1
...
...
@@ -6409,7 +6411,10 @@ void process_next_command() {
#endif // PREVENT_DANGEROUS_EXTRUDE
case
303
:
// M303 PID autotune
gcode_M303
();
break
;
gcode_M303
();
gcode_LastN
+=
1
;
FlushSerialRequestResend
();
break
;
#ifdef PIDTEMPBED
case
304
:
// M304
...
...
MarlinKimbra/comunication.h
View file @
ee98a976
...
...
@@ -39,15 +39,15 @@
#endif
#endif
#define START "start"
//start for host
#define OK "ok"
//ok answer for host
#define ER "Error:
"
//error for host
#define WT "wait"
//wait for host
#define DB "
<MK4>: "
//message for user
#define RS "Resend:
"
//resend for host
#define PAUSE "//action:pause"
//command for host that support action
#define RESUME "//action:resume"
//command for host that support action
#define DISCONNECT "//action:disconnect"
//command for host that support action
#define START "start" //start for host
#define OK "ok" //ok answer for host
#define ER "Error:
"
//error for host
#define WT "wait" //wait for host
#define DB "
MK4: "
//message for user
#define RS "Resend:
"
//resend for host
#define PAUSE "//action:pause" //command for host that support action
#define RESUME "//action:resume" //command for host that support action
#define DISCONNECT "//action:disconnect" //command for host that support action
#define SERIAL_INIT(baud) MYSERIAL.begin(baud), delay(1)
#define SERIAL_WRITE(x) MYSERIAL.write(x)
...
...
MarlinKimbra/stepper.cpp
View file @
ee98a976
...
...
@@ -76,6 +76,11 @@ volatile long endstops_trigsteps[3] = { 0 };
volatile
long
endstops_stepsTotal
,
endstops_stepsDone
;
static
volatile
char
endstop_hit_bits
=
0
;
// use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
static
char
old_endstop_bits
=
0
;
// use X_MIN, X_MAX... Z_MAX, Z_PROBE
#ifdef Z_DUAL_ENDSTOPS
static
char
old_dual_endstop_bits
=
0
;
// actually only implemented for Z
#endif
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
bool
abort_on_endstop_hit
=
false
;
#endif
...
...
@@ -84,35 +89,6 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROB
int
motor_current_setting
[
3
]
=
DEFAULT_PWM_MOTOR_CURRENT
;
#endif
#if HAS_X_MIN
static
bool
old_x_min_endstop
=
false
;
#endif
#if HAS_X_MAX
static
bool
old_x_max_endstop
=
false
;
#endif
#if HAS_Y_MIN
static
bool
old_y_min_endstop
=
false
;
#endif
#if HAS_Y_MAX
static
bool
old_y_max_endstop
=
false
;
#endif
static
bool
old_z_min_endstop
=
false
;
static
bool
old_z_max_endstop
=
false
;
#ifdef Z_DUAL_ENDSTOPS
static
bool
old_z2_min_endstop
=
false
;
static
bool
old_z2_max_endstop
=
false
;
#endif
#ifdef Z_PROBE_ENDSTOP // No need to check for valid pin, SanityCheck.h already does this.
static
bool
old_z_probe_endstop
=
false
;
#endif
#ifdef NPR2
static
bool
old_e_min_endstop
=
false
;
#endif
static
bool
check_endstops
=
true
;
volatile
long
count_position
[
NUM_AXIS
]
=
{
0
};
...
...
@@ -159,11 +135,11 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
#define Z_APPLY_STEP(v,Q) \
if (performing_homing) { \
if (Z_HOME_DIR > 0) {\
if (!(
old_z_max_endstop
&& (count_direction[Z_AXIS] > 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
if (!(
old_z2_max_endstop
&& (count_direction[Z_AXIS] > 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
if (!(
TEST(old_endstop_bits, Z_MAX)
&& (count_direction[Z_AXIS] > 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
if (!(
TEST(old_dual_endstop_bits, Z_MAX)
&& (count_direction[Z_AXIS] > 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
} else {\
if (!(
old_z_min_endstop
&& (count_direction[Z_AXIS] < 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
if (!(
old_z2_min_endstop
&& (count_direction[Z_AXIS] < 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
if (!(
TEST(old_endstop_bits, Z_MIN)
&& (count_direction[Z_AXIS] < 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
if (!(
TEST(old_dual_endstop_bits, Z_MIN)
&& (count_direction[Z_AXIS] < 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
} \
} else { \
Z_STEP_WRITE(v); \
...
...
@@ -489,24 +465,33 @@ ISR(TIMER1_COMPA_vect) {
// Check endstops
if
(
check_endstops
)
{
#define _ENDSTOP(axis, minmax) axis ##_## minmax ##_endstop
char
current_endstop_bits
;
#ifdef Z_DUAL_ENDSTOPS
char
current_dual_endstop_bits
;
#endif
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _OLD_ENDSTOP(axis, minmax) old_## axis ##_## minmax ##_endstop
#define _AXIS(AXIS) AXIS ##_AXIS
#define _HIT_BIT(AXIS) AXIS ##_MIN
#define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_HIT_BIT(AXIS))
#define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \
bool _ENDSTOP(axis, minmax) = (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)); \
if (_ENDSTOP(axis, minmax) && _OLD_ENDSTOP(axis, minmax) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
#define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_ENDSTOP(AXIS, MIN))
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
// GET_ENDSTOP_STATUS: set the current endstop bits for an endstop to its status
#define GET_ENDSTOP_STATUS(endstop, AXIS, MINMAX) SET_BIT(endstop, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
// TEST_ENDSTOP: test the old and the current status of an endstop
#define TEST_ENDSTOPS(AXIS, MINMAX) (TEST(current_endstop_bits, _ENDSTOP(AXIS, MINMAX)) && TEST(old_endstop_bits, _ENDSTOP(AXIS, MINMAX)))
// TEST_DUAL_ENDSTOP: same like TEST_ENDSTOP for dual endstops
#define TEST_DUAL_ENDSTOPS(AXIS, MINMAX) (TEST(current_dual_endstop_bits, _ENDSTOP(AXIS, MINMAX)) && TEST(old_dual_endstop_bits, _ENDSTOP(AXIS, MINMAX)))
#define UPDATE_ENDSTOP(AXIS,MINMAX) \
GET_ENDSTOP_STATUS(current_endstop_bits, AXIS, MINMAX); \
if (TEST_ENDSTOPS(AXIS, MINMAX) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \
_ENDSTOP_HIT(AXIS); \
step_events_completed = current_block->step_event_count; \
} \
_OLD_ENDSTOP(axis, minmax) = _ENDSTOP(axis, minmax);
}
#ifdef COREXY
// Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis
...
...
@@ -522,7 +507,7 @@ ISR(TIMER1_COMPA_vect) {
#endif
{
#if HAS_X_MIN
UPDATE_ENDSTOP
(
x
,
X
,
min
,
MIN
);
UPDATE_ENDSTOP
(
X
,
MIN
);
#endif
}
}
...
...
@@ -533,7 +518,7 @@ ISR(TIMER1_COMPA_vect) {
#endif
{
#if HAS_X_MAX
UPDATE_ENDSTOP
(
x
,
X
,
max
,
MAX
);
UPDATE_ENDSTOP
(
X
,
MAX
);
#endif
}
}
...
...
@@ -548,12 +533,12 @@ ISR(TIMER1_COMPA_vect) {
#endif
{
// -direction
#if HAS_Y_MIN
UPDATE_ENDSTOP
(
y
,
Y
,
min
,
MIN
);
UPDATE_ENDSTOP
(
Y
,
MIN
);
#endif
}
else
{
// +direction
#if HAS_Y_MAX
UPDATE_ENDSTOP
(
y
,
Y
,
max
,
MAX
);
UPDATE_ENDSTOP
(
Y
,
MAX
);
#endif
}
#ifdef COREXY
...
...
@@ -563,43 +548,38 @@ ISR(TIMER1_COMPA_vect) {
#if HAS_Z_MIN
#ifdef Z_DUAL_ENDSTOPS
GET_ENDSTOP_STATUS
(
current_endstop_bits
,
Z
,
MIN
);
#if HAS_Z2_MIN
GET_ENDSTOP_STATUS
(
current_dual_endstop_bits
,
Z
,
MIN
);
#endif
bool
z_test
=
TEST_ENDSTOPS
(
Z
,
MIN
)
#if HAS_Z2_MIN
&&
TEST_DUAL_ENDSTOPS
(
Z
,
MIN
)
#endif
;
bool
z_min_endstop
=
READ
(
Z_MIN_PIN
)
!=
Z_MIN_ENDSTOP_INVERTING
,
z2_min_endstop
=
#if HAS_Z2_MIN
READ
(
Z2_MIN_PIN
)
!=
Z2_MIN_ENDSTOP_INVERTING
#else
z_min_endstop
#endif
;
bool
z_min_both
=
z_min_endstop
&&
old_z_min_endstop
,
z2_min_both
=
z2_min_endstop
&&
old_z2_min_endstop
;
if
((
z_min_both
||
z2_min_both
)
&&
current_block
->
steps
[
Z_AXIS
]
>
0
)
{
if
(
z_test
&&
current_block
->
steps
[
Z_AXIS
]
>
0
)
{
endstops_trigsteps
[
Z_AXIS
]
=
count_position
[
Z_AXIS
];
endstop_hit_bits
|=
BIT
(
Z_MIN
);
if
(
!
performing_homing
||
(
performing_homing
&&
z_min_both
&&
z2_min_both
))
//if not performing home or if both endstops were trigged during homing...
if
(
!
performing_homing
||
(
performing_homing
&&
!
z_test
))
//if not performing home or if both endstops were trigged during homing...
step_events_completed
=
current_block
->
step_event_count
;
}
old_z_min_endstop
=
z_min_endstop
;
old_z2_min_endstop
=
z2_min_endstop
;
#else // !Z_DUAL_ENDSTOPS
UPDATE_ENDSTOP
(
z
,
Z
,
min
,
MIN
);
UPDATE_ENDSTOP
(
Z
,
MIN
);
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MIN_PIN
#ifdef Z_PROBE_ENDSTOP
UPDATE_ENDSTOP
(
z
,
Z
,
probe
,
PROBE
);
z_probe_endstop
=
(
READ
(
Z_PROBE_PIN
)
!=
Z_PROBE_ENDSTOP_INVERTING
);
if
(
z_probe_endstop
&&
old_z_probe_endstop
)
{
UPDATE_ENDSTOP
(
Z
,
PROBE
);
GET_ENDSTOP_STATUS
(
current_endstop_bits
,
Z
,
PROBE
);
if
(
TEST_ENDSTOPS
(
Z
,
PROBE
))
{
endstops_trigsteps
[
Z_AXIS
]
=
count_position
[
Z_AXIS
];
endstop_hit_bits
|=
BIT
(
Z_PROBE
);
}
old_z_probe_endstop
=
z_probe_endstop
;
#endif
}
else
{
// z +direction
...
...
@@ -607,40 +587,39 @@ ISR(TIMER1_COMPA_vect) {
#ifdef Z_DUAL_ENDSTOPS
bool
z_max_endstop
=
READ
(
Z_MAX_PIN
)
!=
Z_MAX_ENDSTOP_INVERTING
,
z2_max_endstop
=
#if HAS_Z2_MAX
READ
(
Z2_MAX_PIN
)
!=
Z2_MAX_ENDSTOP_INVERTING
#else
z_max_endstop
#endif
;
bool
z_max_both
=
z_max_endstop
&&
old_z_max_endstop
,
z2_max_both
=
z2_max_endstop
&&
old_z2_max_endstop
;
if
((
z_max_both
||
z2_max_both
)
&&
current_block
->
steps
[
Z_AXIS
]
>
0
)
{
endstops_trigsteps
[
Z_AXIS
]
=
count_position
[
Z_AXIS
];
endstop_hit_bits
|=
BIT
(
Z_MIN
);
GET_ENDSTOP_STATUS
(
current_endstop_bits
,
Z
,
MAX
);
#if HAS_Z2_MAX
GET_ENDSTOP_STATUS
(
current_dual_endstop_bits
,
Z
,
MAX
);
#endif
// if (z_max_both) ECHO_EV("z_max_endstop = true");
// if (z2_max_both) ECHO_EV("z2_max_endstop = true");
bool
z_test
=
TEST_ENDSTOPS
(
Z
,
MAX
)
#if HAS_Z2_MAX
&&
TEST_DUAL_ENDSTOPS
(
Z
,
MAX
)
#endif
;
if
(
!
performing_homing
||
(
performing_homing
&&
z_max_both
&&
z2_max_both
))
//if not performing home or if both endstops were trigged during homing...
if
(
z_test
&&
current_block
->
steps
[
Z_AXIS
]
>
0
)
{
endstops_trigsteps
[
Z_AXIS
]
=
count_position
[
Z_AXIS
];
endstop_hit_bits
|=
BIT
(
Z_MIN
);
if
(
!
performing_homing
||
(
performing_homing
&&
!
z_test
))
//if not performing home or if both endstops were trigged during homing...
step_events_completed
=
current_block
->
step_event_count
;
}
old_z_max_endstop
=
z_max_endstop
;
old_z2_max_endstop
=
z2_max_endstop
;
#else // !Z_DUAL_ENDSTOPS
UPDATE_ENDSTOP
(
z
,
Z
,
max
,
MAX
);
UPDATE_ENDSTOP
(
Z
,
MAX
);
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MAX_PIN
}
old_endstop_bits
=
current_endstop_bits
;
#ifdef Z_DUAL_ENDSTOPS
old_dual_endstop_bits
=
current_dual_endstop_bits
;
#endif
}
// Take multiple steps per interrupt (For high speed moves)
for
(
int8_t
i
=
0
;
i
<
step_loops
;
i
++
)
{
#ifndef AT90USB
...
...
MarlinKimbra/temperature.cpp
View file @
ee98a976
...
...
@@ -55,9 +55,9 @@ float current_temperature_bed = 0.0;
#endif
#ifdef PIDTEMPBED
float
bedKp
=
DEFAULT_bedKp
;
float
bedKi
=
(
DEFAULT_bedKi
*
PID_dT
);
float
bedKd
=
(
DEFAULT_bedKd
/
PID_dT
);
float
bedKp
=
DEFAULT_bedKp
;
float
bedKi
=
(
DEFAULT_bedKi
*
PID_dT
);
float
bedKd
=
(
DEFAULT_bedKd
/
PID_dT
);
#endif //PIDTEMPBED
#ifdef FAN_SOFT_PWM
...
...
@@ -181,8 +181,7 @@ static void updateTemperaturesFromRawValues();
//================================ Functions ================================
//===========================================================================
void
PID_autotune
(
float
temp
,
int
hotend
,
int
ncycles
)
{
void
PID_autotune
(
float
temp
,
int
hotend
,
int
ncycles
)
{
float
input
=
0.0
;
int
cycles
=
0
;
bool
heating
=
true
;
...
...
@@ -300,7 +299,7 @@ void PID_autotune(float temp, int hotend, int ncycles)
}
}
}
if
(
input
>
temp
+
20
)
{
if
(
input
>
temp
+
MAX_OVERSHOOT_PID_AUTOTUNE
)
{
ECHO_LM
(
ER
,
MSG_PID_TEMP_TOO_HIGH
);
return
;
}
...
...
@@ -315,7 +314,7 @@ void PID_autotune(float temp, int hotend, int ncycles)
}
else
{
p
=
soft_pwm
[
hotend
];
ECHO_SMV
(
OK
,
MSG_T
,
input
);
ECHO_SMV
(
OK
,
MSG_T
,
input
,
1
);
ECHO_EMV
(
MSG_AT
,
p
);
}
...
...
MarlinKimbra/temperature.h
View file @
ee98a976
...
...
@@ -66,7 +66,7 @@ extern float current_temperature_bed;
#ifdef PIDTEMP
extern
float
Kp
[
HOTENDS
],
Ki
[
HOTENDS
],
Kd
[
HOTENDS
];
#define PID_PARAM(param,e) param[e] // use macro to point to array value
#define PID_PARAM(param,
e) param[e] // use macro to point to array value
float
scalePID_i
(
float
i
);
float
scalePID_d
(
float
d
);
float
unscalePID_i
(
float
i
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment