diff --git a/docs/hoverboard.md b/docs/hoverboard.md new file mode 100644 index 00000000..4b0efa83 --- /dev/null +++ b/docs/hoverboard.md @@ -0,0 +1,49 @@ +roflcopter + +```txt +odrv0.axis0.motor.config.pole_pairs = 15 +odrv0.axis0.motor.config.resistance_calib_max_voltage = 4 +odrv0.axis0.motor.config.requested_current_range = 25 +odrv0.axis0.motor.set_current_control_bandwidth(100) +odrv0.axis0.encoder.config.cpr = 90 +odrv0.axis0.encoder.config.mode = 1 +odrv0.axis0.encoder.config.bandwidth = 100 +``` + +```txt +odrv0.axis0.controller.config.pos_gain = 1 +odrv0.axis0.controller.config.vel_gain = 0.02 +``` + +```txt +odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION +odrv0.axis0.motor + error = 0x0000 (int) + phase_inductance = 0.00033594953129068017 (float) + phase_resistance = 0.1793474406003952 (float) +odrv0.axis0.motor.config.pre_calibrated = True +``` + +```txt +odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION + error = 0x0000 (int) + offset_float = 0.5126956701278687 (float) + something close to 0.5 is good +odrv0.axis0.encoder.config.pre_calibrated = True +``` + + +```txt +odrv0.config.enable_uart = False +odrv0.config.gpio1_pwm_mapping.min = -100 +odrv0.config.gpio1_pwm_mapping.max = 100 +odrv0.config.gpio1_pwm_mapping.endpoint = odrv0.axis0.controller._remote_attributes['vel_setpoint'] +odrv0.save_configuration() +odrv0.reboot() +odrv0.axis0.controller.vel_setpoint +``` + +```txt +odrv0.axis0.config.startup_closed_loop_control = True +odrv0.save_configuration() +``` \ No newline at end of file diff --git a/docs/interfaces.md b/docs/interfaces.md index e0c2ce7d..2e8c74c4 100644 --- a/docs/interfaces.md +++ b/docs/interfaces.md @@ -37,6 +37,17 @@ The ODrive can be controlled over various ports and protocols. If you're comfort ODrive v3.3 and onward have 5V tolerant GPIO pins. +### Pin function priorities +1. PWM in, if enabled. Disabled by default. +1. UART, **Enabled by default**. +1. Step/Dir, if enabled. Disabled by default. +1. Analog, default behaviour if not overriden (only on supported pins). +1. Digital in, default behaviour on pins not capable of analog input. + +For predictable results, try to have only one feature enabled for any one pin. When changing pin assignments you must: +* `odrv0.save_configuration()` +* `odrv0.reboot()` + ## Native Protocol This protocol is what the ODrive Tool uses to talk to the ODrive. If you have a choice, this is the recommended protocol for all applications. The native protocol runs on USB and can also be configured to run on UART. @@ -76,45 +87,37 @@ Pinout: * GND: you must connect the grounds of the devices together. Use any GND pin on J3 of the ODrive. To enable step/dir mode for the GPIO, set `.config.enable_step_dir` to true for each axis that you wish to use this on. -Axis 0 step/dir pins conflicts with UART, and the UART takes priority. So to be able to use step/dir on Axis 0, you must also set `odrv0.config.enable_uart = False`. -To apply these settings you must reboot, and to keep them on reboot you must save configuration: -* `odrv0.save_configuration()` -* `odrv0.reboot()` +Axis 0 step/dir pins conflicts with UART, and the UART takes priority. So to be able to use step/dir on Axis 0, you must also set `odrv0.config.enable_uart = False`. See the [pin function priorities](#pin-function-priorities) for more detail. Don't forget to save configuration and reboot. There is also a config variable called `.config.counts_per_step`, which specifies how many encoder counts a "step" corresponds to. It can be any floating point value. The maximum step rate is pending tests, but it should handle at least 50kHz. If you want to test it, please be aware that the failure mode on too high step rates is expected to be that the motors shuts down and coasts. Please be aware that there is no enable line right now, and the step/direction interface is enabled by default, and remains active as long as the ODrive is in position control mode. To get the ODrive to go into position control mode at bootup, see how to configure the [startup procedure](commands.md#startup-procedure). - +5. With the ODrive powered off, connect the RC receiver ground to the ODrive's GND and one of the RC receiver signals to GPIO4. You may try to power the receiver from the ODrive's 5V supply if it doesn't draw too much power. Power up the the RC transmitter. You should now be able to control axis 0 from one of the RC sticks. ## Ports Note: when you use an existing library you don't have to deal with the specifics described in this section.