Integrate flowrate sensor

parent 331fbeba
...@@ -1074,7 +1074,7 @@ ...@@ -1074,7 +1074,7 @@
* You also need to set FLOWMETER_PIN in Configurations_pins.h * * You also need to set FLOWMETER_PIN in Configurations_pins.h *
* * * *
**************************************************************************/ **************************************************************************/
//#define FLOMETER_SENSOR //#define FLOWMETER_SENSOR
#define FLOWMETER_MAXFLOW 6.0 // Liters per minute max #define FLOWMETER_MAXFLOW 6.0 // Liters per minute max
#define FLOWMETER_MAXFREQ 55 // frequency of pulses at max flow #define FLOWMETER_MAXFREQ 55 // frequency of pulses at max flow
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "Configuration_Feature.h" #include "Configuration_Feature.h"
#include "Configuration_Overall.h" #include "Configuration_Overall.h"
#include "module/flowrate/flowrate.h"
#if ENABLED(LASER) #if ENABLED(LASER)
#include "Configuration_Laser.h" #include "Configuration_Laser.h"
#if ENABLED(LASER_RASTER) #if ENABLED(LASER_RASTER)
......
...@@ -748,6 +748,10 @@ void setup() { ...@@ -748,6 +748,10 @@ void setup() {
laser_init(); laser_init();
#endif #endif
#if ENABLED(FLOWMETER_SENSOR)
flow_init();
#endif
#if ENABLED(COLOR_MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1 #if ENABLED(COLOR_MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
// Initialize mixing to 100% color 1 // Initialize mixing to 100% color 1
for (uint8_t i = 0; i < DRIVER_EXTRUDERS; i++) { for (uint8_t i = 0; i < DRIVER_EXTRUDERS; i++) {
...@@ -2959,6 +2963,13 @@ inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_positio ...@@ -2959,6 +2963,13 @@ inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_positio
} }
#endif // HAS(TEMP_COOLER) #endif // HAS(TEMP_COOLER)
#if ENABLED(FLOWMETER_SENSOR)
void print_flowratestates() {
ECHO_MV(" FLOW: ", get_flowrate(), 1);
ECHO_MV(" ml/min ");
}
#endif
inline void wait_heater(bool no_wait_for_cooling = true) { inline void wait_heater(bool no_wait_for_cooling = true) {
#if ENABLED(TEMP_RESIDENCY_TIME) #if ENABLED(TEMP_RESIDENCY_TIME)
...@@ -5751,6 +5762,9 @@ inline void gcode_M105() { ...@@ -5751,6 +5762,9 @@ inline void gcode_M105() {
#if HAS(TEMP_COOLER) #if HAS(TEMP_COOLER)
print_coolerstates(); print_coolerstates();
#endif #endif
#if HAS(FLOWMETER_SENSOR)
print_flowratestates();
#endif
#else // HASNT(TEMP_0) && HASNT(TEMP_BED) #else // HASNT(TEMP_0) && HASNT(TEMP_BED)
ECHO_LM(ER, SERIAL_ERR_NO_THERMISTORS); ECHO_LM(ER, SERIAL_ERR_NO_THERMISTORS);
#endif #endif
...@@ -9190,6 +9204,9 @@ void idle( ...@@ -9190,6 +9204,9 @@ void idle(
#endif #endif
) { ) {
manage_temp_controller(); manage_temp_controller();
#if ENABLED(FLOWMETER_SENSOR)
flowrate_manage();
#endif
manage_inactivity( manage_inactivity(
#if ENABLED(FILAMENT_CHANGE_FEATURE) #if ENABLED(FILAMENT_CHANGE_FEATURE)
no_stepper_sleep no_stepper_sleep
...@@ -9226,6 +9243,12 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { ...@@ -9226,6 +9243,12 @@ 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 (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 (IsRunning()) kill(PSTR(MSG_KILLED)) : stop();
}
#endif
if (stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time) if (stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time)
&& !ignore_stepper_queue && !blocks_queued()) { && !ignore_stepper_queue && !blocks_queued()) {
#if DISABLE_X == true #if DISABLE_X == true
...@@ -9453,6 +9476,7 @@ void kill(const char* lcd_msg) { ...@@ -9453,6 +9476,7 @@ void kill(const char* lcd_msg) {
cli(); // Stop interrupts cli(); // Stop interrupts
disable_all_heaters(); disable_all_heaters();
disable_all_coolers();
disable_all_steppers(); disable_all_steppers();
#if ENABLED(LASER) #if ENABLED(LASER)
......
...@@ -270,6 +270,10 @@ extern uint8_t active_driver; ...@@ -270,6 +270,10 @@ extern uint8_t active_driver;
void print_coolerstates(); void print_coolerstates();
#endif #endif
#if ENABLED(FLOWMETER_SENSOR)
void print_flowratestates();
#endif
#if ENABLED(FIRMWARE_TEST) #if ENABLED(FIRMWARE_TEST)
void FirmwareTest(); void FirmwareTest();
#endif #endif
......
...@@ -28,6 +28,7 @@ float flowrate; ...@@ -28,6 +28,7 @@ float flowrate;
unsigned int flowml; unsigned int flowml;
static millis_t flowmeter_timer = 0; static millis_t flowmeter_timer = 0;
void flowrate_pulsecounter();
void flow_init() { void flow_init() {
...@@ -54,6 +55,10 @@ void flowrate_manage() { ...@@ -54,6 +55,10 @@ void flowrate_manage() {
} }
int get_florate() {
return flowml;
}
void flowrate_pulsecounter() void flowrate_pulsecounter()
{ {
// Increment the pulse counter // Increment the pulse counter
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#if ENABLED(FLOWMETER_SENSOR) #if ENABLED(FLOWMETER_SENSOR)
void flowrate_manage(); void flowrate_manage();
void flow_init();
int get_flowrate();
#endif // FLOWMETER_SENSOR #endif // FLOWMETER_SENSOR
......
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