Enforce complete AXIS control inventory
This commit is contained in:
@@ -274,8 +274,8 @@ int sim_io_spindle_adjust(sim_io *io, uint32_t spindle, double delta) {
|
||||
state = &io->state.spindles[spindle];
|
||||
// Match LinuxCNC EMCMOT_SPINDLE_INCREASE/DECREASE: change the signed
|
||||
// speed only while the spindle is running and keep its direction.
|
||||
if (state->command_rpm > 0.0) target = state->command_rpm + delta;
|
||||
else if (state->command_rpm < 0.0) target = state->command_rpm - delta;
|
||||
if (state->command_rpm > 0.0) target = fmax(0.0, state->command_rpm + delta);
|
||||
else if (state->command_rpm < 0.0) target = fmin(0.0, state->command_rpm - delta);
|
||||
else target = 0.0;
|
||||
target = fmax(-state->max_rpm, fmin(state->max_rpm, target));
|
||||
state->command_rpm = state->enabled && !state->inhibit && !state->amp_fault ? target : 0.0;
|
||||
|
||||
@@ -43,6 +43,11 @@ int main(void) {
|
||||
assert(sim_io_spindle_set_override(&io, 0, 1.0) == SIM_IO_OK && io.state.spindles[0].command_rpm == 1200.0);
|
||||
assert(sim_io_spindle_adjust(&io, 0, -100.0) == SIM_IO_OK && io.state.spindles[0].command_rpm == 1100.0);
|
||||
assert(sim_io_spindle_adjust(&io, 0, 100.0) == SIM_IO_OK && io.state.spindles[0].command_rpm == 1200.0);
|
||||
assert(sim_io_spindle_command(&io, 0, 1.0, 1) == SIM_IO_OK);
|
||||
assert(sim_io_spindle_adjust(&io, 0, -100.0) == SIM_IO_OK && io.state.spindles[0].command_rpm == 0.0);
|
||||
assert(sim_io_spindle_command(&io, 0, -1.0, 1) == SIM_IO_OK);
|
||||
assert(sim_io_spindle_adjust(&io, 0, -100.0) == SIM_IO_OK && io.state.spindles[0].command_rpm == 0.0);
|
||||
assert(sim_io_spindle_command(&io, 0, 1200.0, 1) == SIM_IO_OK);
|
||||
spindle_step_status = sim_io_step(&io, 10);
|
||||
assert(spindle_step_status == SIM_IO_OK && io.state.spindles[0].speed_rpm == 600.0);
|
||||
assert(sim_io_step(&io, 10) == SIM_IO_OK && io.state.spindles[0].at_speed == 1);
|
||||
|
||||
Reference in New Issue
Block a user