diff --git a/Firmware/.vscode/c_cpp_properties.json b/Firmware/.vscode/c_cpp_properties.json
index 9c1aec97..26b5fc0a 100644
--- a/Firmware/.vscode/c_cpp_properties.json
+++ b/Firmware/.vscode/c_cpp_properties.json
@@ -10,7 +10,7 @@
"USE_HAL_DRIVER",
"HW_VERSION_MAJOR=3",
"HW_VERSION_MINOR=6",
- "HW_VERSION_VOLTAGE=56",
+ "HW_VERSION_VOLTAGE=24",
"USB_PROTOCOL_NATIVE",
"__weak=\"__attribute__((weak))\"",
"__packed=\"__attribute__((__packed__))\"",
diff --git a/Firmware/.vscode/settings.json b/Firmware/.vscode/settings.json
index 39c28f82..b0396fc7 100644
--- a/Firmware/.vscode/settings.json
+++ b/Firmware/.vscode/settings.json
@@ -1,9 +1,6 @@
{
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
- "files.exclude": {
- "build": true
- },
"files.associations": {
"memory": "cpp",
"utility": "cpp",
diff --git a/Firmware/MotorControl/low_level.cpp b/Firmware/MotorControl/low_level.cpp
index 908ffb9f..c5656f12 100644
--- a/Firmware/MotorControl/low_level.cpp
+++ b/Firmware/MotorControl/low_level.cpp
@@ -594,7 +594,11 @@ void update_brake_current() {
// Don't start braking until -Ibus > regen_current_allowed
float brake_current = std::max(-Ibus_sum - board_config.max_regen_current, 0.0f);
float brake_duty = std::max(brake_current * std::abs(board_config.brake_resistance) / vbus_voltage, 0.0f);
+ brake_duty = std::max((vbus_voltage - board_config.nominal_voltage) / (VBUS_OVERVOLTAGE_LEVEL/0.9f - board_config.nominal_voltage), brake_duty);
+ // Clamp the duty cycle
+ brake_duty = brake_duty < 0.0f ? 0.0f : (brake_duty > 0.9f ? 0.9f : brake_duty);
+
// Duty limit at 90% to allow bootstrap caps to charge
// If brake_duty is NaN, this expression will also evaluate to false
if ((brake_duty >= 0.0f) && (brake_duty <= 0.9f)) {
diff --git a/Firmware/MotorControl/odrive_main.h b/Firmware/MotorControl/odrive_main.h
index cee9d871..5f2f3ade 100644
--- a/Firmware/MotorControl/odrive_main.h
+++ b/Firmware/MotorControl/odrive_main.h
@@ -90,6 +90,7 @@ struct BoardConfig_t {
#else
float brake_resistance = 0.47f; // [ohm]
#endif
+ float nominal_voltage = VBUS_OVERVOLTAGE_LEVEL;
float dc_bus_undervoltage_trip_level = 8.0f; // Start Debugging (or press F5)
* The processor will reset and halt.
diff --git a/docs/developer-guide.md b/docs/developer-guide.md
index dee4cdbb..6f351070 100644
--- a/docs/developer-guide.md
+++ b/docs/developer-guide.md
@@ -85,7 +85,7 @@ Some instructions in this document may assume that you're using a bash command p
* __Note 2__: 8-2018-q4-major seems to have a bug on Windows. Please use 7-2018-q2-update.
* [Tup](http://gittup.org/tup/index.html)
* [GNU MCU Eclipse's Windows Build Tools](https://github.com/gnu-mcu-eclipse/windows-build-tools/releases)
-* [OpenOCD](http://gnuarmeclipse.github.io/openocd/install/).
+* [OpenOCD](https://github.com/xpack-dev-tools/openocd-xpack/releases/).
* [ST-Link/V2 Drivers](http://www.st.com/web/en/catalog/tools/FM147/SC1887/PF260219)
@@ -166,7 +166,7 @@ How to use these is shown in the following example.
* We do all changes to the STM32CubeMX config and regenerate the code on top of `STM32CubeMX-start`.
* `git checkout STM32CubeMX-start`
* Run stm32cubeMX and load the `Firmware/Board/v3/Odrive.ioc` project file.
- * If the tool asks if you wish to migrate to a new version, choose to migrate.
+ * If the tool asks if you wish to migrate to a new version, choose to download the old firmware package (unless you want to use the latest libraries)
* Without changing any settings, press `Project -> Generate code`.
* You may need to let it download some drivers and such.
* STM32CubeMX may now have a newer version of some of the libraries, so there may be changes to the generated code even though we didn't change any settings. We need to check that everything is still working, and hence check in the changes:
diff --git a/docs/getting-started.md b/docs/getting-started.md
index 1ea259c2..df3a8ad9 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -127,6 +127,12 @@ Try step 5 again
### Linux
1. [Install Python 3](https://www.python.org/downloads/). (for example, on Ubuntu, `sudo apt install python3 python3-pip`)
2. Install the ODrive tools by opening a terminal and typing `sudo pip3 install odrive` Enter
+ * This should automatically add the udev rules. If this fails for some reason you can add them manually:
+ ```bash
+ echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="0d[0-9][0-9]", MODE="0666"' | sudo tee /etc/udev/rules.d/91-odrive.rules
+ sudo udevadm control --reload-rules
+ sudo udevadm trigger
+ ```
3. (needed on Ubuntu, maybe other distros too) Add odrivetool into the path, by adding `~/.local/bin/` into `~/.bash_profile`, for example by running `nano ~/.bashrc`, scrolling to the bottom, pasting `PATH=$PATH:~/.local/bin/`, and then saving and closing, and close and reopen the terminal window.
## Firmware
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md
index c7bd6ad4..8419a8be 100644
--- a/docs/troubleshooting.md
+++ b/docs/troubleshooting.md
@@ -86,7 +86,9 @@ For gimbal motors, it is recommended to set the `motor.config.calibration_curren
* `ERROR_CPR_POLEPAIRS_MISMATCH = 0x02`
-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.
+Confirm you have entered the correct count per rotation (CPR) for [your encoder](https://docs.odriverobotics.com/encoders). The ODrive uses your supplied value for the motor pole pairs to measure the CPR. So you should also double check this value.
+
+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.
* `ERROR_NO_RESPONSE = 0x04`
@@ -111,7 +113,7 @@ You can also try increasing `.controller.config.vel_limit_tolerance`. The
* **Linux**: Type `lsusb` to list all USB devices. Verify that your ODrive is listed.
* **Linux**: Make sure you [set up your udev rules](getting-started#downloading-and-installing-tools) correctly.
* **Windows**: Right-click on the start menu and open "Device Manager". Verify that your ODrive is listed.
- * **Windows**: Use the [Zadig utility](http://zadig.akeo.ie/) to verify the driver is set to `libusb-win32`.
+ * **Windows**: Use the [Zadig utility](http://zadig.akeo.ie/) to verify the driver is set to `libusb-win32`. Note that there are two options listed in Zadig for Odrive: `ODrive 3.x Native Interface (Interface 2)` and `ODrive 3.x CDC Interface (Interface 0)`. Only the native interface should have `libusb-win32` while the CDC interface should use `WinUSB`.
* Ensure that no other ODrive program is running
* Run `odrivetools` with the `--verbose` option.
* Run `PYUSB_DEBUG=debug odrivetools` to get even more log output.