Review power supply timeout.
- Move the variable from dda.c to pinio.c. - Reset the timeout on each power on, to guarantee a minimum PSU on time.
This commit is contained in:
parent
1cb40082e4
commit
3d1ebf1186
4
clock.c
4
clock.c
|
|
@ -25,14 +25,14 @@
|
||||||
void clock_250ms() {
|
void clock_250ms() {
|
||||||
#ifndef NO_AUTO_IDLE
|
#ifndef NO_AUTO_IDLE
|
||||||
if (temp_all_zero()) {
|
if (temp_all_zero()) {
|
||||||
if (steptimeout > (30 * 4)) {
|
if (psu_timeout > (30 * 4)) {
|
||||||
power_off();
|
power_off();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint8_t save_reg = SREG;
|
uint8_t save_reg = SREG;
|
||||||
cli();
|
cli();
|
||||||
CLI_SEI_BUG_MEMORY_BARRIER();
|
CLI_SEI_BUG_MEMORY_BARRIER();
|
||||||
steptimeout++;
|
psu_timeout++;
|
||||||
MEMORY_BARRIER();
|
MEMORY_BARRIER();
|
||||||
SREG = save_reg;
|
SREG = save_reg;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
dda.c
8
dda.c
|
|
@ -28,9 +28,6 @@
|
||||||
#error STEPS_PER_MM_Y is gone, review your config.h and use STEPS_PER_M_Y
|
#error STEPS_PER_MM_Y is gone, review your config.h and use STEPS_PER_M_Y
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// step timeout
|
|
||||||
volatile uint8_t steptimeout = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
position tracking
|
position tracking
|
||||||
*/
|
*/
|
||||||
|
|
@ -275,7 +272,6 @@ void dda_create(DDA *dda, TARGET *target) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// get steppers ready to go
|
// get steppers ready to go
|
||||||
steptimeout = 0;
|
|
||||||
power_on();
|
power_on();
|
||||||
stepper_enable();
|
stepper_enable();
|
||||||
x_enable();
|
x_enable();
|
||||||
|
|
@ -483,7 +479,7 @@ void dda_start(DDA *dda) {
|
||||||
// called from interrupt context: keep it simple!
|
// called from interrupt context: keep it simple!
|
||||||
if ( ! dda->nullmove) {
|
if ( ! dda->nullmove) {
|
||||||
// get ready to go
|
// get ready to go
|
||||||
steptimeout = 0;
|
psu_timeout = 0;
|
||||||
if (dda->z_delta)
|
if (dda->z_delta)
|
||||||
z_enable();
|
z_enable();
|
||||||
|
|
||||||
|
|
@ -823,7 +819,7 @@ void dda_step(DDA *dda) {
|
||||||
z_disable();
|
z_disable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
steptimeout = 0;
|
psu_timeout = 0;
|
||||||
|
|
||||||
#ifdef ACCELERATION_RAMPING
|
#ifdef ACCELERATION_RAMPING
|
||||||
// we don't hit maximum speed exactly with acceleration calculation, so limit it here
|
// we don't hit maximum speed exactly with acceleration calculation, so limit it here
|
||||||
|
|
|
||||||
4
dda.h
4
dda.h
|
|
@ -221,10 +221,6 @@ typedef struct {
|
||||||
variables
|
variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// steptimeout is set to zero when we step, and increases over time so we can turn the motors off when they've been idle for a while
|
|
||||||
/// It is also used inside and outside of interrupts, which is why it has been made volatile
|
|
||||||
extern volatile uint8_t steptimeout;
|
|
||||||
|
|
||||||
/// startpoint holds the endpoint of the most recently created DDA, so we know where the next one created starts. could also be called last_endpoint
|
/// startpoint holds the endpoint of the most recently created DDA, so we know where the next one created starts. could also be called last_endpoint
|
||||||
extern TARGET startpoint;
|
extern TARGET startpoint;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -704,7 +704,6 @@ void process_gcode_command() {
|
||||||
y_enable();
|
y_enable();
|
||||||
z_enable();
|
z_enable();
|
||||||
e_enable();
|
e_enable();
|
||||||
steptimeout = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 191:
|
case 191:
|
||||||
|
|
|
||||||
5
pinio.c
5
pinio.c
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
static char ps_is_on = 0;
|
static char ps_is_on = 0;
|
||||||
|
|
||||||
|
/// step/psu timeout
|
||||||
|
volatile uint8_t psu_timeout = 0;
|
||||||
|
|
||||||
void power_on() {
|
void power_on() {
|
||||||
|
|
||||||
if (ps_is_on == 0) {
|
if (ps_is_on == 0) {
|
||||||
|
|
@ -13,6 +16,8 @@ void power_on() {
|
||||||
#endif
|
#endif
|
||||||
ps_is_on = 1;
|
ps_is_on = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
psu_timeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void power_off() {
|
void power_off() {
|
||||||
|
|
|
||||||
7
pinio.h
7
pinio.h
|
|
@ -11,6 +11,13 @@
|
||||||
Power
|
Power
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/// psu_timeout is set to zero when we step, and increases over time so we can
|
||||||
|
/// turn the motors off when they've been idle for a while.
|
||||||
|
/// A second function is to guarantee a minimum on time of the PSU.
|
||||||
|
/// Timeout counting is done in clock.c.
|
||||||
|
/// It is used inside and outside of interrupts, which is why it has been made volatile
|
||||||
|
extern volatile uint8_t psu_timeout;
|
||||||
|
|
||||||
void power_on(void);
|
void power_on(void);
|
||||||
void power_off(void);
|
void power_off(void);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue