Finally, all seems to work as expected. Eureka!

parent 50c07eba
......@@ -42,6 +42,10 @@
CardReader card;
#endif
#if ENABLED(FLOWMETER_SENSOR) && ENABLED(MINFLOW_PROTECTION)
bool flow_firstread = false;
#endif
bool Running = true;
bool Printing = false;
......@@ -749,6 +753,9 @@ void setup() {
#endif
#if ENABLED(FLOWMETER_SENSOR)
#if ENABLED(MINFLOW_PROTECTION)
flow_firstread=false;
#endif
flow_init();
#endif
......@@ -2969,8 +2976,14 @@ inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_positio
#if ENABLED(FLOWMETER_SENSOR)
void print_flowratestates() {
ECHO_MV(" FLOW: ", get_flowrate(), 1);
ECHO_M(" ml/min ");
float readval;
readval = get_flowrate();
#if ENABLED(MINFLOW_PROTECTION)
if(readval > MINFLOW_PROTECTION)
flow_firstread=true;
#endif
ECHO_MV(" FLOW: ", readval);
ECHO_M(" l/min ");
}
#endif
......@@ -9252,14 +9265,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
if (max_inactive_time && ELAPSED(ms, previous_cmd_ms + max_inactive_time)) kill(PSTR(MSG_KILLED));
#if ENABLED(FLOWMETER_SENSOR) && ENABLED(MINFLOW_PROTECTION)
if (get_flowrate() < (MINFLOW_PROTECTION*1000)) {
if (Printing)
if (flow_firstread && Printing && (get_flowrate() < (float)MINFLOW_PROTECTION)) {
flow_firstread = false;
kill(PSTR(MSG_KILLED));
//else
// stop();
}
#endif
if (stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time)
&& !ignore_stepper_queue && !blocks_queued()) {
#if DISABLE_X == true
......@@ -9480,6 +9490,9 @@ void kill(const char* lcd_msg) {
#if ENABLED(KILL_METHOD) && KILL_METHOD == 1
HAL::resetHardware();
#endif
#if ENABLED(FLOWMETER_SENSOR) && ENABLED(MINFLOW_PROTECTION)
flow_firstread=false;
#endif
#if ENABLED(ULTRA_LCD)
lcd_setalertstatuspgm(lcd_msg);
......@@ -9593,6 +9606,9 @@ void kill(const char* lcd_msg) {
#endif // FAST_PWM_FAN
void stop() {
#if ENABLED(FLOWMETER_SENSOR) && ENABLED(MINFLOW_PROTECTION)
flow_firstread=false;
#endif
disable_all_heaters();
disable_all_coolers();
#ifdef LASER
......
......@@ -23,18 +23,16 @@
#if ENABLED(FLOWMETER_SENSOR)
volatile byte flowrate_pulsecount;
volatile int flowrate_pulsecount;
float flowrate;
unsigned int flowml;
static millis_t flowmeter_timer = 0;
static millis_t lastflow = 0;
void flowrate_pulsecounter();
void flow_init() {
flowrate = 0;
flowrate_pulsecount = 0;
flowml = 0;
pinMode(FLOWMETER_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN), flowrate_pulsecounter, FALLING);
......@@ -45,18 +43,25 @@ void flowrate_manage() {
now = millis();
if(ELAPSED(now, flowmeter_timer)) {
detachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN));
flowrate = ((1000.0 / (now - flowmeter_timer)) * flowrate_pulsecount) / FLOWMETER_CALIBRATION;
flowrate = (float)(((1000.0 / (float)((float)now - (float)lastflow)) * (float)flowrate_pulsecount) / (float)FLOWMETER_CALIBRATION);
#if ENABLED(FLOWMETER_DEBUG)
ECHO_M(" FLOWMETER DEBUG ");
ECHO_MV(" flowrate:", flowrate);
ECHO_MV(" flowrate_pulsecount:", flowrate_pulsecount);
ECHO_MV(" CALIBRATION:", FLOWMETER_CALIBRATION);
ECHO_E;
#endif
flowmeter_timer = now + 1000UL;
flowml = (flowrate / 60.0) * 1000;
lastflow = now;
flowrate_pulsecount = 0;
attachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN), flowrate_pulsecounter, FALLING);
}
}
int get_flowrate() {
return flowml;
float get_flowrate() {
return flowrate;
}
void flowrate_pulsecounter()
......
......@@ -24,7 +24,7 @@
#if ENABLED(FLOWMETER_SENSOR)
void flowrate_manage();
void flow_init();
int get_flowrate();
float get_flowrate();
#endif
......
......@@ -818,6 +818,10 @@ float get_pid_output(int h) {
#if ENABLED(PIDTEMPCOOLER)
float get_pid_output_cooler() {
float pid_output;
if(target_temperature_cooler == 0)
return 0
#if ENABLED(PID_OPENLOOP)
pid_output = constrain(target_temperature_cooler, 0, MAX_COOLER_POWER);
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment