Advertisement
Supernova1114

Untitled

Apr 16th, 2024
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.13 KB | None | 0 0
  1. # Odrive S1 config - Firmware 0.6.8
  2. # For the NEO V1.1 motor.
  3. # https://www.revrobotics.com/rev-21-1650/
  4.  
  5. CAN_NODE_ID = 6
  6. CAN_BAUD_RATE = 1000000
  7. ENABLE_BRAKE_RESISTOR = True
  8.  
  9. odrv = odrv0
  10. odrv.config.dc_bus_overvoltage_trip_level = 30
  11. odrv.config.dc_bus_undervoltage_trip_level = 19.2
  12. odrv.config.dc_max_positive_current = 40
  13. odrv.config.dc_max_negative_current = -7
  14. odrv.axis0.config.motor.motor_type = MotorType.HIGH_CURRENT
  15.  
  16. # 8.27 / Motor KV (rpm/V)
  17. odrv.axis0.config.motor.torque_constant = 8.27 / 473
  18.  
  19. odrv.axis0.config.motor.pole_pairs = 7
  20. odrv.axis0.config.motor.current_soft_max = 40
  21. odrv.axis0.config.motor.current_hard_max = 80
  22.  
  23. # Half the continuous current rating of the motor
  24. odrv.axis0.config.motor.calibration_current = 20
  25. odrv.axis0.config.calibration_lockin.current = 20
  26.  
  27. # calib_max_voltage < 0.5 * vbus_voltage &&
  28. # calib_max_voltage > calibration_current * phase_resistance
  29. odrv.axis0.config.motor.resistance_calib_max_voltage = 5
  30.  
  31. odrv.axis0.controller.config.control_mode = ControlMode.VELOCITY_CONTROL
  32. odrv.axis0.controller.config.input_mode = InputMode.VEL_RAMP
  33. odrv.axis0.controller.config.vel_ramp_rate = 100
  34. odrv.axis0.controller.config.vel_limit = 100
  35. odrv.axis0.controller.config.vel_limit_tolerance = 1.2  
  36.  
  37. # Disable spinout detection
  38. odrv.axis0.controller.config.spinout_electrical_power_threshold = 9999
  39. odrv.axis0.controller.config.spinout_mechanical_power_threshold = -9999
  40.  
  41. # Brake Resistor
  42. odrv.config.brake_resistor0.enable = ENABLE_BRAKE_RESISTOR
  43. odrv.config.brake_resistor0.resistance = 2
  44. odrv.config.brake_resistor0.enable_dc_bus_voltage_feedback = True
  45. odrv.config.brake_resistor0.dc_bus_voltage_feedback_ramp_start = 40
  46. odrv.config.brake_resistor0.dc_bus_voltage_feedback_ramp_end = 46
  47.  
  48. odrv.axis0.config.torque_soft_min = -1.25
  49. odrv.axis0.config.torque_soft_max = 1.25
  50.  
  51. #odrv.axis0.config.torque_soft_min = -0.25
  52. #odrv.axis0.config.torque_soft_max = 0.25
  53.  
  54.  
  55. odrv.axis0.config.enable_watchdog = True
  56. odrv.axis0.config.watchdog_timeout = 2
  57.  
  58. odrv.axis0.config.encoder_bandwidth = 100
  59. odrv.hall_encoder0.config.enabled = True
  60. odrv.axis0.config.load_encoder = EncoderId.HALL_ENCODER0
  61. odrv.axis0.config.commutation_encoder = EncoderId.HALL_ENCODER0
  62.  
  63. # PID Loop
  64. odrv.axis0.controller.config.vel_gain = 0.04
  65. odrv.axis0.controller.config.vel_integrator_gain = 0.5 * 10 * odrv.axis0.controller.config.vel_gain
  66. # The '10' above being in Hz from encoder_bandwidth (1/100ms = 1/0.1s = 10Hz)
  67.  
  68. odrv.can.config.protocol = Protocol.SIMPLE
  69.  
  70. # Add can bus functionality
  71. # CAN node ID must be different for each device.
  72. odrv.config.enable_can_a = True
  73. odrv.can.config.protocol = Protocol.SIMPLE
  74. odrv.axis0.config.can.node_id = CAN_NODE_ID
  75. odrv.can.config.baud_rate = CAN_BAUD_RATE
  76.  
  77. # Enable cyclical data to reach over CAN
  78. odrv = odrv0
  79. odrv.axis0.config.can.heartbeat_msg_rate_ms = 100
  80. odrv.axis0.config.can.encoder_msg_rate_ms = 10
  81. odrv.axis0.config.can.iq_msg_rate_ms = 0
  82. odrv.axis0.config.can.torques_msg_rate_ms = 0
  83. odrv.axis0.config.can.error_msg_rate_ms = 0
  84. odrv.axis0.config.can.temperature_msg_rate_ms = 0
  85. odrv.axis0.config.can.bus_voltage_msg_rate_ms = 0
  86.  
  87. odrv.save_configuration()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement