From e9a32ddf7f3e5e6a8ebe609f681c9ee74e7c5305 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Thu, 26 Sep 2019 12:35:02 -0700 Subject: [PATCH 1/8] Update troubleshooting.md --- docs/troubleshooting.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 2307c4bd..ba0ad021 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_OUT_OF_RANGE = 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.config.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` From 77b645374c4001538f96f429679d176085a80274 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Thu, 26 Sep 2019 12:36:29 -0700 Subject: [PATCH 2/8] Update troubleshooting.md --- docs/troubleshooting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index ba0ad021..6ba3752e 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -86,7 +86,7 @@ For gimbal motors, it is recommended to set the `motor.config.calibration_curren * `ERROR_CPR_OUT_OF_RANGE = 0x02` -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.config.pole_pairs` to measure the CPR. So you should also double check this value. +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. From 30f57115eec0a54cfbeb9b7d7337d607c4cce335 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sat, 19 Oct 2019 23:14:14 -0700 Subject: [PATCH 3/8] Update developer-guide.md --- docs/developer-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer-guide.md b/docs/developer-guide.md index dee4cdbb..dfa871b5 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -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: From 6b77a17bda88f2d709ae4d3d26a81c7aed50d384 Mon Sep 17 00:00:00 2001 From: Paul Guenette Date: Thu, 31 Oct 2019 18:16:55 -0400 Subject: [PATCH 4/8] Change link for manual install of openOCD --- docs/developer-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer-guide.md b/docs/developer-guide.md index dfa871b5..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)
From 8b10429738bb1100e7b5a181291f2b3d3694a8eb Mon Sep 17 00:00:00 2001 From: Richard Parsons <503426+Capo01@users.noreply.github.com> Date: Tue, 10 Dec 2019 15:45:23 +1100 Subject: [PATCH 5/8] Included that Zadig has native and CDC interfaces listed --- docs/troubleshooting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 6ba3752e..bd02b737 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -113,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. From 6e6363322696064125d3263311a66459cea3e756 Mon Sep 17 00:00:00 2001 From: Paul Guenette Date: Wed, 11 Dec 2019 22:27:02 -0500 Subject: [PATCH 6/8] Update configuring-vscode.md --- docs/configuring-vscode.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/configuring-vscode.md b/docs/configuring-vscode.md index 572f9933..69edf772 100644 --- a/docs/configuring-vscode.md +++ b/docs/configuring-vscode.md @@ -40,6 +40,7 @@ An extension called Cortex-Debug has recently been released which is designed sp Note: If developing on Windows, you should have `arm-none-eabi-gdb` and `openOCD` on your PATH. * Make sure you have the Firmware folder as your active folder + * Set `CONFIG_DEBUG=true` in the tup.config file * Flash the board with the newest code (starting debug session doesn't do this) * Debug -> Start Debugging (or press F5) * The processor will reset and halt. From 595bfdabbaa6ea43f30eaba2ff647d49c82947f7 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Tue, 17 Dec 2019 18:52:13 -0800 Subject: [PATCH 7/8] add back manual udev rule setup to getting started --- docs/getting-started.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/getting-started.md b/docs/getting-started.md index 9cd6ecf2..a2d50cc6 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -17,6 +17,7 @@ permalink: / - [Configure M0](#configure-m0) - [Position control of M0](#position-control-of-m0) - [Other control modes](#other-control-modes) +- [Watchdog Timer](#watchdog-timer) - [What's next?](#whats-next) @@ -126,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 From 42b6effedd49dbfffa82321fc98918c832589114 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 26 Mar 2020 17:20:32 -0400 Subject: [PATCH 8/8] Implement a better brake resistor current handler --- Firmware/.vscode/c_cpp_properties.json | 2 +- Firmware/.vscode/settings.json | 3 --- Firmware/MotorControl/low_level.cpp | 7 ++++++- Firmware/MotorControl/odrive_main.h | 1 + Firmware/communication/communication.cpp | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Firmware/.vscode/c_cpp_properties.json b/Firmware/.vscode/c_cpp_properties.json index c4a2f37c..e8523423 100644 --- a/Firmware/.vscode/c_cpp_properties.json +++ b/Firmware/.vscode/c_cpp_properties.json @@ -24,7 +24,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 6125c99c..91fc9c94 100644 --- a/Firmware/MotorControl/low_level.cpp +++ b/Firmware/MotorControl/low_level.cpp @@ -592,9 +592,14 @@ void update_brake_current() { } float brake_current = -Ibus_sum; // Clip negative values to 0.0f - if (brake_current < 0.0f) brake_current = 0.0f; + if (brake_current < 0.0f) + brake_current = 0.0f; float brake_duty = brake_current * board_config.brake_resistance / vbus_voltage; + 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 677fb996..6d2b312d 100644 --- a/Firmware/MotorControl/odrive_main.h +++ b/Firmware/MotorControl/odrive_main.h @@ -76,6 +76,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; //