summaryrefslogtreecommitdiffstats
path: root/pressure_control
diff options
context:
space:
mode:
authormb <mb@frink.(none)>2009-05-03 12:55:59 +0200
committermb <mb@frink.(none)>2009-05-03 12:55:59 +0200
commit117c46526241b433abd2ce198d9a9e03c1587e7f (patch)
treed582826e918acfaaf711505557d3adec7b36a2f3 /pressure_control
parentf6164dcedbd3c6d9ad094fd34a0ec031692385cb (diff)
downloadcnc-117c46526241b433abd2ce198d9a9e03c1587e7f.tar.xz
cnc-117c46526241b433abd2ce198d9a9e03c1587e7f.zip
pressure_control: Disarm auto-idle while pressure is low.
Signed-off-by: mb <mb@frink.(none)>
Diffstat (limited to 'pressure_control')
-rw-r--r--pressure_control/firmware/main.c8
-rw-r--r--pressure_control/firmware/valves.c20
-rw-r--r--pressure_control/firmware/valves.h2
3 files changed, 24 insertions, 6 deletions
diff --git a/pressure_control/firmware/main.c b/pressure_control/firmware/main.c
index af779a7..01933ce 100644
--- a/pressure_control/firmware/main.c
+++ b/pressure_control/firmware/main.c
@@ -169,6 +169,14 @@ static void check_pressure(void)
report_change = (cur_state != VALVES_IDLE);
valves_global_switch(VALVES_IDLE);
}
+ if (state.mbar < 800) {
+ /* If the pressure in the reservoir is low,
+ * the feedforward of the pneumatic valve for
+ * flow-out might not work correctly. So force poke
+ * the valves again until we reach a good pressure. */
+ __valves_global_switch(valves_get_global_state());
+ valves_disarm_auto_idle();
+ }
}
if (abs((int32_t)state.mbar - (int32_t)state.reported_mbar) >= 100)
report_change = 1;
diff --git a/pressure_control/firmware/valves.c b/pressure_control/firmware/valves.c
index 86ea85b..700760a 100644
--- a/pressure_control/firmware/valves.c
+++ b/pressure_control/firmware/valves.c
@@ -59,10 +59,12 @@ void valve1_switch(uint8_t state)
void valves_global_switch(uint8_t state)
{
- if (state == current_global_state)
- return;
- current_global_state = state;
+ if (state != current_global_state)
+ __valves_global_switch(state);
+}
+void __valves_global_switch(uint8_t state)
+{
switch (state) {
case VALVES_IDLE:
valve0_switch(VALVE_STATE_12);
@@ -79,6 +81,12 @@ void valves_global_switch(uint8_t state)
}
switch_to_idle_time = get_jiffies() + msec_to_jiffies(VALVE_TOGGLE_MSEC);
need_switch_to_idle = 1;
+ current_global_state = state;
+}
+
+void valves_disarm_auto_idle(void)
+{
+ need_switch_to_idle = 0;
}
void valves_work(void)
@@ -104,7 +112,7 @@ static inline void valves_ddr_setup(void)
void valves_shutdown(void)
{
- valves_global_switch(VALVES_FLOW_OUT);
+ __valves_global_switch(VALVES_FLOW_OUT);
valve_wait_toggle();
valve0_switch(VALVE_STATE_IDLE);
valve1_switch(VALVE_STATE_IDLE);
@@ -113,7 +121,7 @@ void valves_shutdown(void)
void valves_emergency_state(void)
{
valves_ddr_setup();
- valves_global_switch(VALVES_IDLE);
+ __valves_global_switch(VALVES_IDLE);
valve_wait_toggle();
valve0_switch(VALVE_STATE_IDLE);
valve1_switch(VALVE_STATE_IDLE);
@@ -122,5 +130,5 @@ void valves_emergency_state(void)
void valves_init(void)
{
valves_ddr_setup();
- valves_global_switch(VALVES_IDLE);
+ __valves_global_switch(VALVES_IDLE);
}
diff --git a/pressure_control/firmware/valves.h b/pressure_control/firmware/valves.h
index 1b50b3a..b2df104 100644
--- a/pressure_control/firmware/valves.h
+++ b/pressure_control/firmware/valves.h
@@ -33,6 +33,8 @@ void valves_work(void);
void valves_emergency_state(void);
void valves_shutdown(void);
void valves_global_switch(uint8_t global_state);
+void __valves_global_switch(uint8_t global_state);
+void valves_disarm_auto_idle(void);
uint8_t valves_get_global_state(void);
void valve0_switch(uint8_t state);
bues.ch cgit interface