Skip to content

Commit

Permalink
Fix race condition skipping reference velocity update (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored Mar 19, 2020
1 parent 632f57a commit f8c0311
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tfrog-motordriver/communication.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,10 +1524,12 @@ int command_analyze(unsigned char* data, int len)
case PARAM_w_ref:
i.integer *= 16;
case PARAM_w_ref_highprec:
if (motor[imotor].ref.vel != i.integer)
motor[imotor].ref.vel_changed = 1;
{
const char changed = (motor[imotor].ref.vel != i.integer);
motor[imotor].ref.vel = i.integer;
motor[imotor].ref.vel_changed = changed;
break;
}
case PARAM_p_toq_offset:
motor[imotor].ref.torque_offset = i.integer;
break;
Expand Down
2 changes: 1 addition & 1 deletion tfrog-motordriver/controlVelocity.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void ISR_VelocityControl()
motor[i].ref.vel_diff = 0;
}

motor[i].error = motor[i].ref.vel_buf - motor[i].vel;
motor[i].error = motor[i].ref.vel - motor[i].vel;
motor[i].error_integ += motor[i].error;
if (motor[i].error_integ > motor_param[i].integ_max)
{
Expand Down

0 comments on commit f8c0311

Please sign in to comment.