Skip to content

Commit 47052c8

Browse files
committed
Merge branch 'master' into devel
2 parents fb5cae8 + f01031f commit 47052c8

File tree

9 files changed

+167
-31
lines changed

9 files changed

+167
-31
lines changed

docs/commands.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
We will use the `<odrv>` as a placeholder for any ODrive object. Every ODrive controller is an ODrive object. In `odrivetool` this is usually `odrv0`. Furthermore we use `<axis>` as a placeholder for any axis, which is an attribute of an ODrive object (for example `odrv0.axis0`). An axis represents where the motors are connected. (axis0 for M0 or axis1 for M1)
44

5+
### Table of contents
6+
<!-- TOC depthFrom:2 depthTo:2 -->
7+
8+
- [Per-Axis commands](#per-axis-commands)
9+
- [System monitoring commands](#system-monitoring-commands)
10+
- [General system commands](#general-system-commands)
11+
- [Setting up sensorless](#setting-up-sensorless)
12+
13+
<!-- /TOC -->
14+
515
## Per-Axis commands
616

717
For the most part, both axes on the ODrive can be controlled independently.
@@ -75,7 +85,7 @@ An upcoming feature will enable automatic tuning. Until then, here is a rough tu
7585

7686
### Encoder position and velocity
7787
* View encoder position with `<axis>.encoder.pos_estimate` [counts]
78-
* View rotational velocity with `<axis>.encoder.pll_vel` [counts/s]
88+
* View rotational velocity with `<axis>.encoder.vel_estimate` [counts/s]
7989

8090
### Motor current and torque estimation
8191
* View the commanded motor current with `<axis>.motor.current_control.Iq_setpoint` [A]

docs/configuring-vscode.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ Before doing the VSCode setup, make sure you've installed all of your [prerequis
1111
1. Install extensions. This can be done directly from VSCode (Ctrl+Shift+X)
1212
* Required extensions:
1313
* C/C++
14-
* Recommended Extensions:
1514
* Cortex-Debug
16-
* vscode-icons
17-
* Code Outline
15+
* Recommended Extensions:
1816
* Include Autocomplete
1917
* Path Autocomplete
2018
* Auto Comment Blocks
@@ -51,4 +49,4 @@ Note: If developing on Windows, you should have `arm-none-eabi-gdb` and `openOCD
5149

5250
## Cleaning the Build
5351
This sometimes needs to be done if you change branches.
54-
* Open a terminal (View -> Integrated Terminal) and enter `make clean`
52+
* Open a terminal (View -> Integrated Terminal) and enter `make clean`

docs/control.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ The motor controller is a cascaded style position, velocity and current control
44

55
![Cascaded pos vel I loops](https://static1.squarespace.com/static/58aff26de4fcb53b5efd2f02/t/5b66284a0e2e72aae8818d64/1533421649405/CascadedController.png?format=2500w)
66

7-
* The position controller is a P loop with a single proportional gain.
8-
* The velocity controller is a PI loop.
9-
* The current controller is a PI loop.
7+
### Position loop:
8+
The position controller is a P loop with a single proportional gain.
9+
```text
10+
pos_error = pos_setpoint - pos_feedback
11+
vel_cmd = pos_error * pos_gain + vel_feedforward
12+
```
13+
14+
### Velocity loop:
15+
The velocity controller is a PI loop.
16+
```text
17+
vel_error = vel_cmd - vel_feedback
18+
current_integral += vel_error * vel_integrator_gain
19+
current_cmd = vel_error * vel_gain + current_integral + current_feedforward
20+
```
21+
22+
### Current loop:
23+
The current controller is a PI loop.
24+
```text
25+
current_error = current_cmd - current_fb
26+
voltage_integral += current_error * current_integrator_gain
27+
voltage_cmd = current_error * current_gain + voltage_integral (+ voltage_feedforward when we have motor model)
28+
```
29+
30+
For more detail refer to [controller.cpp](https://github.com/madcowswe/ODrive/blob/master/Firmware/MotorControl/controller.cpp#L86).

docs/developer-guide.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ $ python --version # should be 3.7 or later
5252

5353
#### Linux (Ubuntu)
5454
```bash
55-
sudo apt-get install gcc-arm-none-eabi
56-
sudo apt-get install gdb-arm-none-eabi
55+
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
56+
sudo apt-get update
57+
sudo apt-get install gcc-arm-embedded
5758
sudo apt-get install openocd
5859
sudo add-apt-repository ppa:jonathonf/tup && sudo apt-get update && sudo apt-get install tup
5960
```

docs/getting-started.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ permalink: /
77
# Getting Started
88

99
### Table of contents
10-
11-
<!-- MarkdownTOC depth=2 autolink=true bracket=round -->
10+
<!-- TOC depthFrom:2 depthTo:2 -->
1211

1312
- [Hardware Requirements](#hardware-requirements)
1413
- [Wiring up the ODrive](#wiring-up-the-odrive)
@@ -18,7 +17,7 @@ permalink: /
1817
- [Position control of M0](#position-control-of-m0)
1918
- [What's next?](#whats-next)
2019

21-
<!-- /MarkdownTOC -->
20+
<!-- /TOC -->
2221

2322
## Hardware Requirements
2423

@@ -123,9 +122,9 @@ Try step 5 again
123122
2. Install the ODrive tools by opening a terminal and typing `pip install odrive` <kbd>Enter</kbd>
124123
3. __Linux__: set up USB permissions
125124
```bash
126-
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="0d[0-9][0-9]", MODE="0666"' | sudo tee /etc/udev/rules.d/50-odrive.rules
125+
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="0d[0-9][0-9]", MODE="0666"' | sudo tee /etc/udev/rules.d/91-odrive.rules
127126
sudo udevadm control --reload-rules
128-
sudo udevadm trigger # until you reboot you may need to do this everytime you reset the ODrive
127+
sudo udevadm trigger
129128
```
130129

131130
## Start `odrivetool`
@@ -175,7 +174,7 @@ For instance, to set the current limit of M0 to 10A you would type: `odrv0.axis0
175174

176175
### 2. Set other hardware parameters:
177176

178-
* `odrv0.config.brake_resistance` [Ohm]: This is the resistance of the brake resistor. If you are not using it, you may set it to `0`.
177+
* `odrv0.config.brake_resistance` [Ohm]: This is the resistance of the brake resistor. If you are not using it, you may set it to `0`. Note that there may be some extra resistance in your wiring and in the screw terminals, so if you are getting issues while braking you may want to increase this parameter by around 0.05 ohm.
179178
* `odrv0.axis0.motor.config.pole_pairs`: This is the number of **magnet poles** in the rotor, **divided by two**. You can simply count the number of permanent magnets in the rotor, if you can see them. _Note: this is not the same as the number of coils in the stator._
180179
* `odrv0.axis0.motor.config.motor_type`: This is the type of motor being used. Currently two types of motors are supported: High-current motors (`MOTOR_TYPE_HIGH_CURRENT`) and Gimbal motors (`MOTOR_TYPE_GIMBAL`).
181180

@@ -229,7 +228,7 @@ Let's get motor 0 up and running. The procedure for motor 1 is exactly the same,
229228
### Other control modes
230229
The ODrive also supports velocity control and current (torque) control.
231230
* **Velocity control**: Set `odrv0.axis0.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL`. You can now control the velocity with `odrv0.axis0.controller.vel_setpoint = 5000`. Units are counts/s.
232-
* **Current control**: Set `odrv0.axis0.controller.config.control_mode = CTRL_MODE_CURRENT_CONTROL`. You can now control the current with `odrv0.axis0.controller.vel_setpoint = 3`. Units are A. **NOTE**: There is no velocity limiting in current control mode. Make sure that you don't overrev the motor, or exceed the max speed for your encoder.
231+
* **Current control**: Set `odrv0.axis0.controller.config.control_mode = CTRL_MODE_CURRENT_CONTROL`. You can now control the current with `odrv0.axis0.controller.current_setpoint = 3`. Units are A. **NOTE**: There is no velocity limiting in current control mode. Make sure that you don't overrev the motor, or exceed the max speed for your encoder.
233232

234233
## What's next?
235234

docs/interfaces.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
The ODrive can be controlled over various ports and protocols. If you're comfortable with embedded systems development, you can also run custom code directly on the ODrive. For that refer to the [developer documentation](developer-guide.md).
66

77
### Table of contents
8-
9-
<!-- MarkdownTOC depth=2 autolink=true bracket=round -->
8+
<!-- TOC depthFrom:2 depthTo:2 -->
109

1110
- [Pinout](#pinout)
1211
- [Native Protocol](#native-protocol)
13-
- [ASCII Protocol](#ascii-protocol) (and Arduino)
12+
- [ASCII protocol](#ascii-protocol)
1413
- [Step/direction](#stepdirection)
15-
- [RC PWM input](#rc-pwm-input) (coming soon)
14+
- [RC PWM input](#rc-pwm-input)
1615
- [Ports](#ports)
17-
- [USB](#usb)
18-
- [UART](#uart)
1916

20-
<!-- /MarkdownTOC -->
17+
<!-- /TOC -->
2118

2219
## Pinout
2320

docs/odrivetool.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
The ODrive Tool is the accompanying PC program for the ODrive. It's main purpose is to provide an interactive shell to control the device manually, as well as some supporting functions like firmware update.
44

5+
### Table of contents
6+
<!-- TOC depthFrom:2 depthTo:2 -->
7+
8+
- [Installation](#installation)
9+
- [Multiple ODrives](#multiple-odrives)
10+
- [Configuration Backup](#configuration-backup)
11+
- [Device Firmware Update](#device-firmware-update)
12+
- [Flashing with an STLink](#flashing-with-an-stlink)
13+
- [Liveplotter](#liveplotter)
14+
15+
<!-- /TOC -->
16+
517
## Installation
618

719
Refer to the [Getting Started guide](getting-started#downloading-and-installing-tools).
@@ -62,7 +74,7 @@ Note that this command will connect to GitHub servers to retrieve the latest fir
6274
If you have a non-default configuration saved on the device, ODrive Tool will try to carry over the configuration across the firmware update. If any of the settings are removed or renamed, you will get warning messages.
6375

6476
<details><summary markdown="span">How to flash a custom firmware</summary><div markdown="block">
65-
If you want to flash a specific firmware file instead of automatically downloading one, you can run `odrivetool dfu [path/to/firmware/file.hex]`.
77+
If you want to flash a specific firmware file instead of automatically downloading one, you can run `odrivetool dfu path/to/firmware/file.hex`
6678

6779
You can download one of the officially released firmware files from [here](https://github.com/madcowswe/ODrive/releases). You will need one of the __.hex__ files (not the __.elf__ file). Make sure you select the file that matches your board version.
6880

docs/troubleshooting.md

Lines changed: 103 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Troubleshooting
22

3+
Table of Contents:
4+
<!-- TOC depthFrom:2 depthTo:2 -->
5+
6+
- [Error codes](#error-codes)
7+
- [Common Axis Errors](#common-axis-errors)
8+
- [Common Motor Errors](#common-motor-errors)
9+
- [Common Encoder Errors](#common-encoder-errors)
10+
- [USB Connectivity Issues](#usb-connectivity-issues)
11+
- [Firmware Issues](#firmware-issues)
12+
- [Other issues that may not produce an error code](#other-issues-that-may-not-produce-an-error-code)
13+
14+
<!-- /TOC -->
15+
316
## Error codes
417
If your ODrive is not working as expected, run `odrivetool` and type `hex(<axis>.error)` <kbd>Enter</kbd> where `<axis>` is the axis that isn't working. This will display a [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) representation of the error code. Each bit represents one error flag.
518

@@ -21,18 +34,64 @@ The axis error may say that some other component has failed. Say it reports `ERR
2134
* Encoder error flags defined [here](../Firmware/MotorControl/encoder.hpp).
2235
* Sensorless estimator error flags defined [here](../Firmware/MotorControl/sensorless_estimator.hpp).
2336

24-
## DRV fault
37+
## Common Axis Errors
38+
39+
* `ERROR_INVALID_STATE = 0x01`
40+
41+
Typically returned along with another error. Resolve that error and then reboot using `odrv0.reboot()` or remoivng power, waiting 5 seconds and restoring power to return to normal operating.
42+
43+
* `ERROR_DC_BUS_UNDER_VOLTAGE = 0x02`
44+
45+
Confirm that your power leads are connected securely. For initial testing a 12V PSU which can supply a couple of amps should be sufficient while the use of low current 'wall wart' plug packs may lead to inconsistent behaviour and is not recommended.
46+
47+
You can monitor your PUS voltage using liveplotter in odrive tool by entering `start_liveplotter(lambda: [odrv0.vbus_voltage])`. If you see your votlage drop below ~ 8V then you will trip this error. Even a relatively small motor can draw multiple kW momentary and so unless you have a very large PSU or are running of a battery you may encounter this error when executing high speed movements with a high current limit. To limit your PSU power draw you can limit your motor current and/or velocity limit `odrv0.axis0.controller.config.vel_limit` and `odrv0.axis0.motor.config.current_lim`.
48+
49+
* `ERROR_DC_BUS_OVER_VOLTAGE = 0x04`
50+
51+
Confirm that you have a break resistor of the correct value connected securly and that `odrv0.config.brake_resistance` is set to the value of your break resistor.
52+
53+
You can monitor your PUS voltage using liveplotter in odrive tool by entering `start_liveplotter(lambda: [odrv0.vbus_voltage])`. If during a move you see the voltage rise above your PSU's nominal set voltage then you have your break resistance set too low. This may happen if you are using long wires or small gauge wires to connect your break resistor to your odrive which will added extra resistance. This extra resistance needs to be accounted for to prevent this voltage spike. If you have checked all your connections you can also try increasing your break resistance by ~ 0.01 Ohm at a time to a maximum of 0.05 greater than your break resistor value.
54+
55+
## Common Motor Errors
56+
57+
* `ERROR_PHASE_RESISTANCE_OUT_OF_RANGE = 0x0001` and `ERROR_PHASE_INDUCTANCE_OUT_OF_RANGE = 0x0002`
58+
59+
During calibration the motor resistance and [inductance](https://en.wikipedia.org/wiki/Inductance) is measured. If the measured motor resistance or inductance falls outside a set range this error will be returned. Check that all motor leads are connected securely.
60+
61+
The measured values can be viewed using odrivetool as is shown below:
62+
```
63+
In [2]: odrv0.axis0.motor.config.phase_inductance
64+
Out[2]: 1.408751450071577e-05
65+
66+
In [3]: odrv0.axis0.motor.config.phase_resistance
67+
Out[3]: 0.029788672924041748
68+
```
69+
Some motors will have a considerably different phase resistance and inductance than this. For example, gimbal motors, some small motors (e.g. < 10A peak current). If you think this applies to you try increasing `odrv0.axis0.motor.config.resistance_calib_max_voltage` from its default value of 1 using odrive tool and repeat the motor calibration process. If your motor has a small peak current draw (e.g. < 20A) you can also try decreasing `odrv0.axis0.motor.config.calibration_current` from its default value of 10A.
70+
71+
* `ERROR_DRV_FAULT = 0x0008`
2572

2673
The ODrive v3.4 is known to have a hardware issue whereby the motors would stop operating
2774
when applying high currents to M0. The reported error of both motors in this case
2875
is `ERROR_DRV_FAULT`.
2976

3077
The conjecture is that the high switching current creates large ripples in the
31-
power supply of the DRV8301 gate driver chips, thus tripping its undervoltage
32-
fault detection.
78+
power supply of the DRV8301 gate driver chips, thus tripping its under-voltage fault detection.
3379

34-
* Limit the M0 current to 40A. The lowest current at which the DRV fault was observed is 45A on one test motor and 50A on another test motor.
35-
* Refer to [this post](https://discourse.odriverobotics.com/t/drv-fault-on-odrive-v3-4/558) for instructions for a hardware fix
80+
To resolve this issue you can limit the M0 current to 40A. The lowest current at which the DRV fault was observed is 45A on one test motor and 50A on another test motor. Refer to [this post](https://discourse.odriverobotics.com/t/drv-fault-on-odrive-v3-4/558) for instructions for a hardware fix.
81+
82+
## Common Encoder Errors
83+
84+
* `ERROR_CPR_OUT_OF_RANGE = 0x02`
85+
86+
Confirm you have entered the correct count per rotation (CPR) for [your encoder](https://docs.odriverobotics.com/encoders). Note that the AMT encoders are configurable using the micro-switches on the encoder PCB and so you may need to check that these are in the right positions. If your encoder lists its pulse per rotation (PPR) multiply that number by four to get CPR.
87+
88+
* `ERROR_NO_RESPONSE = 0x04`
89+
90+
Confirm that your encoder is plugged into the right pins on the odrive board.
91+
92+
* `ERROR_INDEX_NOT_FOUND_YET = 0x20`
93+
94+
Check that your encoder is a model that has an index pulse. If your encoder does not have a wire connected to pin Z on your odrive then it does not output an index pulse.
3695

3796

3897
## USB Connectivity Issues
@@ -47,3 +106,42 @@ fault detection.
47106
* Run `odrivetools` with the `--verbose` option.
48107
* Run `PYUSB_DEBUG=debug odrivetools` to get even more log output.
49108
* If you're a developer you can use Wireshark to capture USB traffic.
109+
* Try a different USB cable
110+
* Try routing your USB cable so that it is far away from the motor and PSU cables to reduce EMI
111+
112+
## Firmware Issues
113+
114+
### Failure to build the firmware when running `make`
115+
- Clear out temporary files from previous compiles by first running `make clean` to prevent conflicts.
116+
- **Windows users**: Confirm that tup has been correctly added to path by running `env|grep PATH` in Git Bash. If you see no mention of tup then you must [add its location to your PATH environment variable.](https://docs.alfresco.com/4.2/tasks/fot-addpath.html). Note that you may need to restart for the added path to take effect.
117+
118+
### Failure to flash the firmware when running `make flash`
119+
- If using an ST-link, confirm that the ST-link is connected the correct pins and that you have power supplied to the board. This can be by the 5V pin on the ST link or the main DC power jack. No power is supplied over the USB connection.
120+
121+
## Other issues that may not produce an error code
122+
123+
### Motor cuts off or spins uncontrollably at high rotational speeds (ie: > 5000 RPM)
124+
- You may be approaching the limit of your encoder. The 2400 count/rotation encoders that were initially included with odrive are realistically limited to around 5000 RPM. Exceeding this speed causes the odrive to lose track of position. This can only be fixed by using an alternative encoder or gearing down the output of your motor onto your encoder so that it still sees < 5000RPM at full speed. If using the gearing options be sure to change your counts/rotation accordingly.
125+
126+
### Motor vibrates when stationary or makes constant noise
127+
128+
- Likely due to incorrect gains, specifically `vel_gain` may be set too high. Try following the [tuning procedure](https://docs.odriverobotics.com/commands).
129+
- Check encoder shaft connection. Grub screws may vibrate lose with time. If using a CUI shaft encoder try remounting the plastic retaining ring and confirm that it is not coming into contact with the encoder housing. Also confirm that the encoder is securely mounted.
130+
- If you are using a high resolution encoder (>4000 counts/rotation) then increasing encoder_pll_bandwidth may help reduce vibration.
131+
- If you connect your motor to an object with a large moment of inertia (such as a flywheel) this will help reduce vibrations at high gians. However, make sure that all connections are ridged. Cheap shaft couplers or belts under low tension can introduce enough flex into a system that the motor may still vibrate independently.
132+
133+
### Motor overshoots target position or oscillates back and forth
134+
- Likely due to incorrect gains for a given motor current limit. Specifically `pos_gain` is set too high. Try following the [tuning procedure](https://docs.odriverobotics.com/commands).
135+
- Increase the current limit of your motor for more torque.
136+
137+
### Motor slowly starts to increase in speed
138+
- Encoder has likely slipped. This may occur when your motor makes a hard stop or violently vibrates causing something to come lose. Power the board off and on again so that it undertakes a new calibration. If you are using an index search on startup then you will need to repeat the index calibration process.
139+
140+
### Motor feels like it has less torque than it should and/or gets hot sitting still while under no load.
141+
- Encoder has likely slipped causing the motor controller to commutate the wrong windings slightly which reduces output torque and produces excess heat as the motor 'fights itself'.
142+
143+
### False steps or direction changes when using step/dir
144+
- Prior to Odrive board V3.5 no filtering is present on the GPIO pins used for step/dir interface and so inductively coupled noise may causes false steps to be detected. Odrive V3.5 and has onboard filtering to resolve this issue.
145+
- If you experience this issue use a twisted pair cable between your microcontroller that’s generating the step/dir signals and your odrive board. A section cut from cat-5 cable works well as does just twisting some normal insulated wire together.
146+
- Ensure that the step/dir signal cables are not draped over the odrive board, are not running in parallel to the motor or power supply cables.
147+
- If the above does not resolve your issue on V3.4 boards and lower try adding a ~22 Ohm resistor in series with the step and direction pins along with a ~ 4.7 nF capacitor between the ground pin and the step and dir pins such as shown [here](https://cdn.discordapp.com/attachments/369667319280173069/420811057431445504/IMG_20180306_211224.jpg).

0 commit comments

Comments
 (0)