Advertisement
Guest User

Untitled

a guest
Sep 11th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. diff --git a/src/hal/drivers/mesa-hostmot2/encoder.c b/src/hal/drivers/mesa-hostmot2/encoder.c
  2. index fc260f0..e03ad7a 100644
  3. --- a/src/hal/drivers/mesa-hostmot2/encoder.c
  4. +++ b/src/hal/drivers/mesa-hostmot2/encoder.c
  5. @@ -931,15 +931,8 @@ static void hm2_encoder_instance_process_tram_read(hostmot2_t *hm2, int instance
  6.  
  7. dS_pos_units = dS_counts / e->hal.param.scale;
  8.  
  9. - // FIXME: There's a bug somewhere in this code that
  10. - // sometimes makes encoder.velocity NaN. Observed by
  11. - // micges, but never reproduced.
  12. - if (dT_clocks < 1) {
  13. - HM2_PRINT("(%s:%d) uh-oh, encoder vel is broken when slow\n", __FILE__, __LINE__);
  14. - HM2_PRINT(" please email a bug report to the linuxcnc-devel list!\n");
  15. - HM2_PRINT(" dS_counts=%d, dT_clocks=%d\n", dS_counts, dT_clocks);
  16. - HM2_PRINT(" prev_update_dS_counts=%d, prev_update_dT_clocks=%d\n", prev_update_dS_counts, prev_update_dT_clocks);
  17. - } else {
  18. + // we can calculate velocity only if timestamp changed along with counts
  19. + if (dT_clocks > 0) {
  20. // we know the encoder velocity is not faster than this
  21. vel = dS_pos_units / dT_s;
  22. if (fabs(vel) < fabs(*e->hal.pin.velocity)) {
  23. @@ -992,15 +985,8 @@ static void hm2_encoder_instance_process_tram_read(hostmot2_t *hm2, int instance
  24.  
  25. dS_pos_units = dS_counts / e->hal.param.scale;
  26.  
  27. - // FIXME: There's a bug somewhere in this code that
  28. - // sometimes makes encoder.velocity NaN. Observed by
  29. - // micges, but never reproduced.
  30. - if (dT_clocks < 1) {
  31. - HM2_PRINT("(%s:%d) uh-oh, encoder vel is broken with an edge\n", __FILE__, __LINE__);
  32. - HM2_PRINT(" please email a bug report to the linuxcnc-devel list!\n");
  33. - HM2_PRINT(" dS_counts=%d, dT_clocks=%d\n", dS_counts, dT_clocks);
  34. - HM2_PRINT(" prev_update_dS_counts=%d, prev_update_dT_clocks=%d\n", prev_update_dS_counts, prev_update_dT_clocks);
  35. - } else {
  36. + // we can calculate velocity only if timestamp changed along with counts
  37. + if (dT_clocks > 0) {
  38. // finally time to do Relative-Time Velocity Estimation
  39. *e->hal.pin.velocity = dS_pos_units / dT_s;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement