minor fixes: comments, indenting, etc
This commit is contained in:
parent
f037bb5320
commit
c1dbd869f5
100
dda.c
100
dda.c
|
|
@ -252,15 +252,15 @@ void dda_create(DDA *dda, TARGET *target) {
|
|||
else
|
||||
dda->accel = 0;
|
||||
#elif defined ACCELERATION_RAMPING
|
||||
dda->ramp_steps = dda->total_steps / 2;
|
||||
dda->step_no = 0;
|
||||
// c is initial step time in IOclk ticks
|
||||
dda->c = ACCELERATION_STEEPNESS << 8;
|
||||
dda->c_min = (move_duration / target->F) << 8;
|
||||
dda->n = 1;
|
||||
dda->ramp_state = RAMP_UP;
|
||||
dda->ramp_steps = dda->total_steps / 2;
|
||||
dda->step_no = 0;
|
||||
// c is initial step time in IOclk ticks
|
||||
dda->c = ACCELERATION_STEEPNESS << 8;
|
||||
dda->c_min = (move_duration / target->F) << 8;
|
||||
dda->n = 1;
|
||||
dda->ramp_state = RAMP_UP;
|
||||
#else
|
||||
dda->c = (move_duration / target->F) << 8;
|
||||
dda->c = (move_duration / target->F) << 8;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -383,52 +383,52 @@ void dda_step(DDA *dda) {
|
|||
#endif
|
||||
|
||||
#ifdef ACCELERATION_REPRAP
|
||||
// linear acceleration magic, courtesy of http://www.embedded.com/columns/technicalinsights/56800129?printable=true
|
||||
if (dda->accel) {
|
||||
if (
|
||||
((dda->n > 0) && (dda->c > dda->end_c)) ||
|
||||
((dda->n < 0) && (dda->c < dda->end_c))
|
||||
) {
|
||||
dda->c = (int32_t) dda->c - ((int32_t) (dda->c * 2) / dda->n);
|
||||
dda->n += 4;
|
||||
setTimer(dda->c >> 8);
|
||||
// linear acceleration magic, courtesy of http://www.embedded.com/columns/technicalinsights/56800129?printable=true
|
||||
if (dda->accel) {
|
||||
if (
|
||||
((dda->n > 0) && (dda->c > dda->end_c)) ||
|
||||
((dda->n < 0) && (dda->c < dda->end_c))
|
||||
) {
|
||||
dda->c = (int32_t) dda->c - ((int32_t) (dda->c * 2) / dda->n);
|
||||
dda->n += 4;
|
||||
setTimer(dda->c >> 8);
|
||||
}
|
||||
else if (dda->c != dda->end_c) {
|
||||
dda->c = dda->end_c;
|
||||
setTimer(dda->c >> 8);
|
||||
}
|
||||
// else we are already at target speed
|
||||
}
|
||||
else if (dda->c != dda->end_c) {
|
||||
dda->c = dda->end_c;
|
||||
setTimer(dda->c >> 8);
|
||||
}
|
||||
// else we are already at target speed
|
||||
}
|
||||
#endif
|
||||
#ifdef ACCELERATION_RAMPING
|
||||
// - algorithm courtesy of http://www.embedded.com/columns/technicalinsights/56800129?printable=true
|
||||
// - for simplicity, taking even/uneven number of steps into account dropped
|
||||
// - number of steps moved is always accurate, speed might be one step off
|
||||
switch (dda->ramp_state) {
|
||||
case RAMP_UP:
|
||||
case RAMP_MAX:
|
||||
if (dda->step_no >= dda->ramp_steps) {
|
||||
// RAMP_UP: time to decelerate before reaching maximum speed
|
||||
// RAMP_MAX: time to decelerate
|
||||
dda->ramp_state = RAMP_DOWN;
|
||||
dda->n = -((int32_t)2) - dda->n;
|
||||
// - algorithm courtesy of http://www.embedded.com/columns/technicalinsights/56800129?printable=true
|
||||
// - for simplicity, taking even/uneven number of steps into account dropped
|
||||
// - number of steps moved is always accurate, speed might be one step off
|
||||
switch (dda->ramp_state) {
|
||||
case RAMP_UP:
|
||||
case RAMP_MAX:
|
||||
if (dda->step_no >= dda->ramp_steps) {
|
||||
// RAMP_UP: time to decelerate before reaching maximum speed
|
||||
// RAMP_MAX: time to decelerate
|
||||
dda->ramp_state = RAMP_DOWN;
|
||||
dda->n = -((int32_t)2) - dda->n;
|
||||
}
|
||||
if (dda->ramp_state == RAMP_MAX)
|
||||
break;
|
||||
case RAMP_DOWN:
|
||||
dda->n += 4;
|
||||
// be careful of signedness!
|
||||
dda->c = (int32_t)dda->c - ((int32_t)(dda->c * 2) / dda->n);
|
||||
if (dda->c <= dda->c_min) {
|
||||
// maximum speed reached
|
||||
dda->c = dda->c_min;
|
||||
dda->ramp_state = RAMP_MAX;
|
||||
dda->ramp_steps = dda->total_steps - dda->step_no;
|
||||
}
|
||||
setTimer(dda->c >> 8);
|
||||
break;
|
||||
}
|
||||
if (dda->ramp_state == RAMP_MAX)
|
||||
break;
|
||||
case RAMP_DOWN:
|
||||
dda->n += 4;
|
||||
// be careful of signedness!
|
||||
dda->c = (int32_t)dda->c - ((int32_t)(dda->c * 2) / dda->n);
|
||||
if (dda->c <= dda->c_min) {
|
||||
// maximum speed reached
|
||||
dda->c = dda->c_min;
|
||||
dda->ramp_state = RAMP_MAX;
|
||||
dda->ramp_steps = dda->total_steps - dda->step_no;
|
||||
}
|
||||
setTimer(dda->c >> 8);
|
||||
break;
|
||||
}
|
||||
dda->step_no++;
|
||||
dda->step_no++;
|
||||
#endif
|
||||
|
||||
if (did_step) {
|
||||
|
|
|
|||
2
temp.c
2
temp.c
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
This file currently reads temp from a MAX6675 on the SPI bus.
|
||||
|
||||
ALL VALUES are in units of 0.25 degrees celsius, so temp_set(500) will set the temperature to 125 celsius, and temp_get() = 600 is reporting a temperature of 150 celsius.
|
||||
temp fields are 14.2 fixed point, so temp_set(500) will set the temperature to 125 celsius, and temp_get() = 600 is reporting a temperature of 150 celsius.
|
||||
|
||||
the conversion to/from this unit is done in gcode.c, near:
|
||||
if (next_target.M == 104)
|
||||
|
|
|
|||
4
timer.c
4
timer.c
|
|
@ -96,7 +96,7 @@ uint16_t getTimerCeiling(const uint32_t delay)
|
|||
|
||||
void setTimer(uint32_t delay)
|
||||
{
|
||||
// delay is the delay between steps in microsecond ticks.
|
||||
// delay is the delay between steps in IOclk ticks.
|
||||
//
|
||||
// we break it into 5 different resolutions based on the delay.
|
||||
// then we set the resolution based on the size of the delay.
|
||||
|
|
@ -115,7 +115,7 @@ void setTimer(uint32_t delay)
|
|||
void delay(uint32_t delay) {
|
||||
wd_reset();
|
||||
while (delay > 65535) {
|
||||
delayMicrosecondsInterruptible(65534);
|
||||
delayMicrosecondsInterruptible(65533);
|
||||
delay -= 65535;
|
||||
wd_reset();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue