|
@@ -736,17 +736,6 @@ float Temperature::get_pid_output(const int8_t e) {
|
736
|
736
|
* - Apply filament width to the extrusion rate (may move)
|
737
|
737
|
* - Update the heated bed PID output value
|
738
|
738
|
*/
|
739
|
|
-
|
740
|
|
-/**
|
741
|
|
- * The following line SOMETIMES results in the dreaded "unable to find a register to spill in class 'POINTER_REGS'"
|
742
|
|
- * compile error.
|
743
|
|
- * thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
|
744
|
|
- *
|
745
|
|
- * This is due to a bug in the C++ compiler used by the Arduino IDE from 1.6.10 to at least 1.8.1.
|
746
|
|
- *
|
747
|
|
- * The work around is to add the compiler flag "__attribute__((__optimize__("O2")))" to the declaration for manage_heater()
|
748
|
|
- */
|
749
|
|
-//void Temperature::manage_heater() __attribute__((__optimize__("O2")));
|
750
|
739
|
void Temperature::manage_heater() {
|
751
|
740
|
|
752
|
741
|
if (!temp_meas_ready) return;
|
|
@@ -801,19 +790,16 @@ void Temperature::manage_heater() {
|
801
|
790
|
}
|
802
|
791
|
#endif
|
803
|
792
|
|
804
|
|
- // Control the extruder rate based on the width sensor
|
805
|
793
|
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
|
794
|
+ /**
|
|
795
|
+ * Filament Width Sensor dynamically sets the volumetric multiplier
|
|
796
|
+ * based on a delayed measurement of the filament diameter.
|
|
797
|
+ */
|
806
|
798
|
if (filament_sensor) {
|
807
|
799
|
meas_shift_index = filwidth_delay_index[0] - meas_delay_cm;
|
808
|
800
|
if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed
|
809
|
801
|
meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
|
810
|
|
-
|
811
|
|
- // Get the delayed info and add 100 to reconstitute to a percent of
|
812
|
|
- // the nominal filament diameter then square it to get an area
|
813
|
|
- float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0;
|
814
|
|
- NOLESS(vmroot, 0.1);
|
815
|
|
- planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = 1.0 / CIRCLE_AREA(vmroot / 2);
|
816
|
|
- planner.refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
|
|
802
|
+ calculate_volumetric_for_width_sensor(measurement_delay[meas_shift_index])
|
817
|
803
|
}
|
818
|
804
|
#endif // FILAMENT_WIDTH_SENSOR
|
819
|
805
|
|
|
@@ -999,15 +985,20 @@ void Temperature::updateTemperaturesFromRawValues() {
|
999
|
985
|
// Convert raw Filament Width to millimeters
|
1000
|
986
|
float Temperature::analog2widthFil() {
|
1001
|
987
|
return current_raw_filwidth * 5.0 * (1.0 / 16383.0);
|
1002
|
|
- //return current_raw_filwidth;
|
1003
|
988
|
}
|
1004
|
989
|
|
1005
|
|
- // Convert raw Filament Width to a ratio
|
1006
|
|
- int Temperature::widthFil_to_size_ratio() {
|
1007
|
|
- float temp = filament_width_meas;
|
1008
|
|
- if (temp < MEASURED_LOWER_LIMIT) temp = filament_width_nominal; //assume sensor cut out
|
1009
|
|
- else NOMORE(temp, MEASURED_UPPER_LIMIT);
|
1010
|
|
- return filament_width_nominal / temp * 100;
|
|
990
|
+ /**
|
|
991
|
+ * Convert Filament Width (mm) to a simple ratio
|
|
992
|
+ * and reduce to an 8 bit value.
|
|
993
|
+ *
|
|
994
|
+ * A nominal width of 1.75 and measured width of 1.73
|
|
995
|
+ * gives (100 * 1.75 / 1.73) for a ratio of 101 and
|
|
996
|
+ * a return value of 1.
|
|
997
|
+ */
|
|
998
|
+ int8_t Temperature::widthFil_to_size_ratio() {
|
|
999
|
+ if (WITHIN(filament_width_meas, MEASURED_LOWER_LIMIT, MEASURED_UPPER_LIMIT))
|
|
1000
|
+ return int(100.0 * filament_width_nominal / filament_width_meas) - 100;
|
|
1001
|
+ return 0;
|
1011
|
1002
|
}
|
1012
|
1003
|
|
1013
|
1004
|
#endif
|