You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1005 B

3 years ago
3 years ago
  1. #include "motor_drive.h"
  2. void motor_init()
  3. {
  4. }
  5. void motor_encoder_init()
  6. {
  7. }
  8. bool motor_cmd_set_position(int speed_level, double position, int direction)
  9. {
  10. int last_direction = direction;
  11. if (!motor_validation_set_position_parameters(speed_level, position, direction))
  12. {
  13. return false;
  14. }
  15. if (direction == 0)
  16. {
  17. last_direction = motor_find_short_path_direction(position);
  18. }
  19. motor_set_position(speed_level, position, last_direction);
  20. return true;
  21. }
  22. void motor_set_position(int speed_level, double position, int direction)
  23. {
  24. }
  25. bool motor_validation_set_position_parameters(int speed_level, double position, int direction)
  26. {
  27. return true;
  28. }
  29. int motor_find_short_path_direction(double position)
  30. {
  31. double encoder_position = 0.0;
  32. encoder_position = motor_read_encoder();
  33. if (encoder_position > position)
  34. {
  35. return 2;
  36. }
  37. else
  38. {
  39. return 1;
  40. }
  41. return -1;
  42. }
  43. double motor_read_encoder()
  44. {
  45. return 0.0;
  46. }