mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-12 06:17:23 +08:00
Merge branch 'devel'
This commit is contained in:
+16
-13
@@ -2,6 +2,15 @@
|
||||
Please add a note of your changes below this heading if you make a Pull Request.
|
||||
|
||||
# Releases
|
||||
## [0.4.2] - 2018-07-04
|
||||
### Added
|
||||
* Hall sensor feedback
|
||||
* Configurable RC PWM input
|
||||
* Ability to read axis FET temperature
|
||||
* Config settings for:
|
||||
* `motor.config.requested_current_range`
|
||||
* `motor.config.current_control_bandwidth` and `motor.set_current_control_bandwidth`. Latter required to invoke gain recalculation.
|
||||
* `encoder.config.bandwidth`
|
||||
|
||||
## [0.4.1] - 2018-07-01
|
||||
### Fixed
|
||||
@@ -12,13 +21,13 @@ Please add a note of your changes below this heading if you make a Pull Request.
|
||||
|
||||
## [0.4.0] - 2018-06-10
|
||||
### Added
|
||||
* Encoder can now go forever in velocity/torque mode due to using circular encoder space.
|
||||
* Protocol supports function return values
|
||||
* bake Git-derived firmware version into firmware binary. The firmware version is exposed through the `fw_version_[...]` properties.
|
||||
* `make write_otp` command to burn the board version onto the ODrive's one-time programmable memory. If you have an ODrive v3.4 or older, you should run this once for a better firmware update user experience in the future. Run the command without any options for more details. Once set, the board version is exposed through the `hw_version_[...]` properties.
|
||||
* infrastructure to publish the python tools to PyPi. See `tools/setup.py` for details.
|
||||
* Automated test script `run_tests.py`
|
||||
* System stats (e.g. stack usage) are exposed under `<odrv>.system_stats`
|
||||
* Encoder can now go forever in velocity/torque mode due to using circular encoder space.
|
||||
* Protocol supports function return values
|
||||
* bake Git-derived firmware version into firmware binary. The firmware version is exposed through the `fw_version_[...]` properties.
|
||||
* `make write_otp` command to burn the board version onto the ODrive's one-time programmable memory. If you have an ODrive v3.4 or older, you should run this once for a better firmware update user experience in the future. Run the command without any options for more details. Once set, the board version is exposed through the `hw_version_[...]` properties.
|
||||
* infrastructure to publish the python tools to PyPi. See `tools/setup.py` for details.
|
||||
* Automated test script `run_tests.py`
|
||||
* System stats (e.g. stack usage) are exposed under `<odrv>.system_stats`
|
||||
|
||||
### Changed
|
||||
* DFU script updates
|
||||
@@ -45,7 +54,6 @@ Please add a note of your changes below this heading if you make a Pull Request.
|
||||
* USB issue where the device would stop responding when the host script would quit abruptly or reset the device during operation
|
||||
|
||||
## [0.3.6] - 2018-03-26
|
||||
|
||||
### Added
|
||||
* **Storing of configuration parameters to Non Volatile Memory**
|
||||
* **USB Bootloader**
|
||||
@@ -68,7 +76,6 @@ Please add a note of your changes below this heading if you make a Pull Request.
|
||||
* malloc now fails if we run out of memory (before it would always succeed even if we are out of ram...)
|
||||
|
||||
## [0.3.5] - 2018-03-04
|
||||
|
||||
### Added
|
||||
* Reporting error if your encoder CPR is incorrect
|
||||
* Ability to start anticogging calibration over USB protocol
|
||||
@@ -82,12 +89,10 @@ Please add a note of your changes below this heading if you make a Pull Request.
|
||||
* Build system is now tup instead of make. Please check the [Readme](README.md#installing-prerequisites) for installation instructions.
|
||||
|
||||
## [0.3.4] - 2018-02-13
|
||||
|
||||
### Fixed
|
||||
* Broken way to check for python 2. Python 2 not supported yet.
|
||||
|
||||
## [0.3.3] - 2018-02-12
|
||||
|
||||
### Added
|
||||
* Liveplotter script
|
||||
* Automatic recovery of USB halt/stall condition
|
||||
@@ -99,14 +104,12 @@ Please add a note of your changes below this heading if you make a Pull Request.
|
||||
* USB CSC (USB serial) now reports a sensible baud rate
|
||||
|
||||
## [0.3.2] - 2018-02-02
|
||||
|
||||
### Added
|
||||
* Gimbal motor mode
|
||||
* Encoder index pulse support
|
||||
* `resistance_calib_max_voltage` parameter
|
||||
|
||||
## [0.3.1] - 2018-01-18
|
||||
|
||||
### Added
|
||||
* UUID Endpoint
|
||||
* Reporting of correct ODrive version on USB descriptor
|
||||
|
||||
@@ -80,6 +80,12 @@ void GPIO_set_to_analog(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin);
|
||||
uint16_t get_gpio_pin_by_pin(uint16_t GPIO_pin);
|
||||
GPIO_TypeDef* get_gpio_port_by_pin(uint16_t GPIO_pin);
|
||||
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR <= 4
|
||||
#define GPIO_COUNT 5
|
||||
#else
|
||||
#define GPIO_COUNT 8
|
||||
#endif
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -62,6 +62,7 @@ void CAN1_RX0_IRQHandler(void);
|
||||
void CAN1_RX1_IRQHandler(void);
|
||||
void CAN1_SCE_IRQHandler(void);
|
||||
void TIM8_TRG_COM_TIM14_IRQHandler(void);
|
||||
void TIM5_IRQHandler(void);
|
||||
void UART4_IRQHandler(void);
|
||||
void OTG_FS_IRQHandler(void);
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ extern TIM_HandleTypeDef htim1;
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
extern TIM_HandleTypeDef htim4;
|
||||
extern TIM_HandleTypeDef htim5;
|
||||
extern TIM_HandleTypeDef htim8;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
@@ -77,6 +78,7 @@ void MX_TIM1_Init(void);
|
||||
void MX_TIM2_Init(void);
|
||||
void MX_TIM3_Init(void);
|
||||
void MX_TIM4_Init(void);
|
||||
void MX_TIM5_Init(void);
|
||||
void MX_TIM8_Init(void);
|
||||
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
@@ -133,10 +133,11 @@ Mcu.IP10=TIM1
|
||||
Mcu.IP11=TIM2
|
||||
Mcu.IP12=TIM3
|
||||
Mcu.IP13=TIM4
|
||||
Mcu.IP14=TIM8
|
||||
Mcu.IP15=UART4
|
||||
Mcu.IP16=USB_DEVICE
|
||||
Mcu.IP17=USB_OTG_FS
|
||||
Mcu.IP14=TIM5
|
||||
Mcu.IP15=TIM8
|
||||
Mcu.IP16=UART4
|
||||
Mcu.IP17=USB_DEVICE
|
||||
Mcu.IP18=USB_OTG_FS
|
||||
Mcu.IP2=ADC3
|
||||
Mcu.IP3=CAN1
|
||||
Mcu.IP4=DMA
|
||||
@@ -145,7 +146,7 @@ Mcu.IP6=NVIC
|
||||
Mcu.IP7=RCC
|
||||
Mcu.IP8=SPI3
|
||||
Mcu.IP9=SYS
|
||||
Mcu.IPNb=18
|
||||
Mcu.IPNb=19
|
||||
Mcu.Name=STM32F405RGTx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PC13-ANTI_TAMP
|
||||
@@ -229,6 +230,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true
|
||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true
|
||||
NVIC.TIM1_UP_TIM10_IRQn=true\:0\:0\:false\:false\:false\:false\:true
|
||||
NVIC.TIM5_IRQn=true\:5\:0\:false\:false\:true\:true\:true
|
||||
NVIC.TIM8_TRG_COM_TIM14_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.TIM8_UP_TIM13_IRQn=true\:0\:0\:false\:false\:false\:false\:true
|
||||
NVIC.TimeBase=TIM8_TRG_COM_TIM14_IRQn
|
||||
@@ -266,12 +268,11 @@ PA15.Signal=GPIO_Input
|
||||
PA2.GPIOParameters=GPIO_Label
|
||||
PA2.GPIO_Label=GPIO_3
|
||||
PA2.Locked=true
|
||||
PA2.Signal=GPIO_Input
|
||||
PA3.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PA2.Signal=S_TIM5_CH3
|
||||
PA3.GPIOParameters=GPIO_Label
|
||||
PA3.GPIO_Label=GPIO_4
|
||||
PA3.GPIO_PuPd=GPIO_NOPULL
|
||||
PA3.Locked=true
|
||||
PA3.Signal=GPIO_Input
|
||||
PA3.Signal=S_TIM5_CH4
|
||||
PA4.GPIOParameters=GPIO_Label
|
||||
PA4.GPIO_Label=M1_TEMP
|
||||
PA4.Locked=true
|
||||
@@ -457,7 +458,7 @@ ProjectManager.StackSize=0x800
|
||||
ProjectManager.TargetToolchain=Makefile
|
||||
ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_ADC2_Init-ADC2-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_TIM8_Init-TIM8-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_ADC3_Init-ADC3-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_TIM2_Init-TIM2-false-HAL-true,13-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,14-MX_UART4_Init-UART4-false-HAL-true,15-MX_CAN1_Init-CAN1-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_ADC2_Init-ADC2-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_TIM8_Init-TIM8-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_TIM4_Init-TIM4-false-HAL-true,10-MX_SPI3_Init-SPI3-false-HAL-true,11-MX_ADC3_Init-ADC3-false-HAL-true,12-SystemClock_Config-RCC-false-HAL-true,13-MX_TIM2_Init-TIM2-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,15-MX_UART4_Init-UART4-false-HAL-true,16-MX_TIM5_Init-TIM5-false-HAL-true
|
||||
RCC.48MHZClocksFreq_Value=48000000
|
||||
RCC.AHBFreq_Value=168000000
|
||||
RCC.APB1CLKDivider=RCC_HCLK_DIV4
|
||||
@@ -538,6 +539,10 @@ SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface
|
||||
SH.S_TIM4_CH1.ConfNb=1
|
||||
SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface
|
||||
SH.S_TIM4_CH2.ConfNb=1
|
||||
SH.S_TIM5_CH3.0=TIM5_CH3,Input_Capture3_from_TI3
|
||||
SH.S_TIM5_CH3.ConfNb=1
|
||||
SH.S_TIM5_CH4.0=TIM5_CH4,Input_Capture4_from_TI4
|
||||
SH.S_TIM5_CH4.ConfNb=1
|
||||
SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1 CH1N
|
||||
SH.S_TIM8_CH1.ConfNb=1
|
||||
SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2 CH2N
|
||||
@@ -605,6 +610,14 @@ TIM4.IC2Filter=4
|
||||
TIM4.IC2Polarity=TIM_ICPOLARITY_RISING
|
||||
TIM4.IPParameters=EncoderMode,IC1Polarity,IC2Polarity,IC1Filter,IC2Filter,Period
|
||||
TIM4.Period=0xffff
|
||||
TIM5.Channel-Input_Capture3_from_TI3=TIM_CHANNEL_3
|
||||
TIM5.Channel-Input_Capture4_from_TI4=TIM_CHANNEL_4
|
||||
TIM5.ICFilter_CH3=15
|
||||
TIM5.ICFilter_CH4=15
|
||||
TIM5.ICPolarity_CH3=TIM_INPUTCHANNELPOLARITY_BOTHEDGE
|
||||
TIM5.ICPolarity_CH4=TIM_INPUTCHANNELPOLARITY_BOTHEDGE
|
||||
TIM5.IPParameters=Channel-Input_Capture3_from_TI3,Channel-Input_Capture4_from_TI4,ICFilter_CH3,ICFilter_CH4,ICPolarity_CH3,ICPolarity_CH4,Period
|
||||
TIM5.Period=0xFFFFFFFF
|
||||
TIM8.Channel-Output\ Compare4\ No\ Output=TIM_CHANNEL_4
|
||||
TIM8.Channel-PWM\ Generation1\ CH1\ CH1N=TIM_CHANNEL_1
|
||||
TIM8.Channel-PWM\ Generation2\ CH2\ CH2N=TIM_CHANNEL_2
|
||||
|
||||
@@ -106,12 +106,6 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PAPin PAPin PAPin */
|
||||
GPIO_InitStruct.Pin = GPIO_3_Pin|GPIO_4_Pin|GPIO_7_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PBPin PBPin */
|
||||
GPIO_InitStruct.Pin = GPIO_6_Pin|GPIO_8_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
@@ -125,6 +119,12 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(EN_GATE_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = GPIO_7_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIO_7_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = nFAULT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
|
||||
@@ -188,6 +188,7 @@ int main(void)
|
||||
MX_ADC3_Init();
|
||||
MX_TIM2_Init();
|
||||
MX_UART4_Init();
|
||||
MX_TIM5_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
//Required to use OC4 for ADC triggering.
|
||||
@@ -235,8 +236,9 @@ void SystemClock_Config(void)
|
||||
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 4;
|
||||
|
||||
@@ -43,10 +43,14 @@
|
||||
typedef void (*ADC_handler_t)(ADC_HandleTypeDef* hadc, bool injected);
|
||||
void ADC_IRQ_Dispatch(ADC_HandleTypeDef* hadc, ADC_handler_t callback);
|
||||
|
||||
typedef void (*TIM_capture_callback_t)(int channel, uint32_t timestamp);
|
||||
void decode_tim_capture(TIM_HandleTypeDef *htim, TIM_capture_callback_t callback);
|
||||
|
||||
// TODO: move somewhere else
|
||||
void pwm_trig_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
|
||||
void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
|
||||
void tim_update_cb(TIM_HandleTypeDef* htim);
|
||||
void pwm_in_cb(int channel, uint32_t timestamp);
|
||||
|
||||
extern TIM_HandleTypeDef htim1;
|
||||
extern I2C_HandleTypeDef hi2c1;
|
||||
@@ -59,6 +63,7 @@ extern ADC_HandleTypeDef hadc1;
|
||||
extern ADC_HandleTypeDef hadc2;
|
||||
extern ADC_HandleTypeDef hadc3;
|
||||
extern CAN_HandleTypeDef hcan1;
|
||||
extern TIM_HandleTypeDef htim5;
|
||||
extern TIM_HandleTypeDef htim8;
|
||||
extern DMA_HandleTypeDef hdma_uart4_rx;
|
||||
extern DMA_HandleTypeDef hdma_uart4_tx;
|
||||
@@ -314,6 +319,23 @@ void TIM8_TRG_COM_TIM14_IRQHandler(void)
|
||||
/* USER CODE END TIM8_TRG_COM_TIM14_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM5 global interrupt.
|
||||
*/
|
||||
void TIM5_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM5_IRQn 0 */
|
||||
|
||||
// We know we only use capture mode here, so bypass HAL
|
||||
decode_tim_capture(&htim5, &pwm_in_cb);
|
||||
|
||||
/* USER CODE END TIM5_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim5);
|
||||
/* USER CODE BEGIN TIM5_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM5_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles UART4 global interrupt.
|
||||
*/
|
||||
@@ -369,6 +391,25 @@ void ADC_IRQ_Dispatch(ADC_HandleTypeDef* hadc, ADC_handler_t callback) {
|
||||
}
|
||||
}
|
||||
|
||||
void decode_tim_capture(TIM_HandleTypeDef *htim, TIM_capture_callback_t callback) {
|
||||
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1)) {
|
||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC1);
|
||||
callback(1, htim->Instance->CCR1);
|
||||
}
|
||||
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC2)) {
|
||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC2);
|
||||
callback(2, htim->Instance->CCR2);
|
||||
}
|
||||
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC3)) {
|
||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC3);
|
||||
callback(3, htim->Instance->CCR3);
|
||||
}
|
||||
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC4)) {
|
||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC4);
|
||||
callback(4, htim->Instance->CCR4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
|
||||
*/
|
||||
|
||||
@@ -78,6 +78,7 @@ TIM_HandleTypeDef htim1;
|
||||
TIM_HandleTypeDef htim2;
|
||||
TIM_HandleTypeDef htim3;
|
||||
TIM_HandleTypeDef htim4;
|
||||
TIM_HandleTypeDef htim5;
|
||||
TIM_HandleTypeDef htim8;
|
||||
|
||||
/* TIM1 init function */
|
||||
@@ -272,6 +273,44 @@ void MX_TIM4_Init(void)
|
||||
_Error_Handler(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
/* TIM5 init function */
|
||||
void MX_TIM5_Init(void)
|
||||
{
|
||||
TIM_MasterConfigTypeDef sMasterConfig;
|
||||
TIM_IC_InitTypeDef sConfigIC;
|
||||
|
||||
htim5.Instance = TIM5;
|
||||
htim5.Init.Prescaler = 0;
|
||||
htim5.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim5.Init.Period = 0xFFFFFFFF;
|
||||
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
if (HAL_TIM_IC_Init(&htim5) != HAL_OK)
|
||||
{
|
||||
_Error_Handler(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
_Error_Handler(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_BOTHEDGE;
|
||||
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
|
||||
sConfigIC.ICFilter = 15;
|
||||
if (HAL_TIM_IC_ConfigChannel(&htim5, &sConfigIC, TIM_CHANNEL_3) != HAL_OK)
|
||||
{
|
||||
_Error_Handler(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (HAL_TIM_IC_ConfigChannel(&htim5, &sConfigIC, TIM_CHANNEL_4) != HAL_OK)
|
||||
{
|
||||
_Error_Handler(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
/* TIM8 init function */
|
||||
void MX_TIM8_Init(void)
|
||||
@@ -440,6 +479,38 @@ void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* tim_encoderHandle)
|
||||
/* USER CODE END TIM4_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_TIM_IC_MspInit(TIM_HandleTypeDef* tim_icHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
if(tim_icHandle->Instance==TIM5)
|
||||
{
|
||||
/* USER CODE BEGIN TIM5_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM5_MspInit 0 */
|
||||
/* TIM5 clock enable */
|
||||
__HAL_RCC_TIM5_CLK_ENABLE();
|
||||
|
||||
/**TIM5 GPIO Configuration
|
||||
PA2 ------> TIM5_CH3
|
||||
PA3 ------> TIM5_CH4
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_3_Pin|GPIO_4_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* TIM5 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM5_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM5_IRQn);
|
||||
/* USER CODE BEGIN TIM5_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM5_MspInit 1 */
|
||||
}
|
||||
}
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||
{
|
||||
|
||||
@@ -627,6 +698,31 @@ void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* tim_encoderHandle)
|
||||
|
||||
/* USER CODE END TIM4_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef* tim_icHandle)
|
||||
{
|
||||
|
||||
if(tim_icHandle->Instance==TIM5)
|
||||
{
|
||||
/* USER CODE BEGIN TIM5_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM5_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM5_CLK_DISABLE();
|
||||
|
||||
/**TIM5 GPIO Configuration
|
||||
PA2 ------> TIM5_CH3
|
||||
PA3 ------> TIM5_CH4
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_3_Pin|GPIO_4_Pin);
|
||||
|
||||
/* TIM5 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(TIM5_IRQn);
|
||||
/* USER CODE BEGIN TIM5_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM5_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
@@ -123,6 +123,12 @@ bool Axis::do_updates() {
|
||||
return error_ == ERROR_NONE;
|
||||
}
|
||||
|
||||
float Axis::get_temp() {
|
||||
float adc = adc_measurements_[hw_config_.thermistor_adc_ch];
|
||||
float normalized_voltage = adc / adc_full_scale;
|
||||
return horner_fma(normalized_voltage, thermistor_poly_coeffs, thermistor_num_coeffs);
|
||||
}
|
||||
|
||||
bool Axis::run_sensorless_spin_up() {
|
||||
// Early Spin-up: spiral up current
|
||||
float x = 0.0f;
|
||||
@@ -148,6 +154,11 @@ bool Axis::run_sensorless_spin_up() {
|
||||
return error_ |= ERROR_MOTOR_FAILED, false;
|
||||
return vel < config_.spin_up_target_vel;
|
||||
});
|
||||
|
||||
// call to controller.reset() that happend when arming means that vel_setpoint
|
||||
// is zeroed. So we make the setpoint the spinup target for smooth transition.
|
||||
controller_.vel_setpoint_ = config_.spin_up_target_vel;
|
||||
|
||||
return error_ == ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
bool check_PSU_brownout();
|
||||
bool do_checks();
|
||||
bool do_updates();
|
||||
float get_temp();
|
||||
|
||||
// @brief Runs the specified update handler at the frequency of the current measurements.
|
||||
//
|
||||
@@ -178,6 +179,7 @@ public:
|
||||
make_protocol_property("spin_up_acceleration", &config_.spin_up_acceleration),
|
||||
make_protocol_property("spin_up_target_vel", &config_.spin_up_target_vel)
|
||||
),
|
||||
make_protocol_function("get_temp", *this, &Axis::get_temp),
|
||||
make_protocol_object("motor", motor_.make_protocol_definitions()),
|
||||
make_protocol_object("controller", controller_.make_protocol_definitions()),
|
||||
make_protocol_object("encoder", encoder_.make_protocol_definitions()),
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef struct {
|
||||
uint16_t step_pin;
|
||||
GPIO_TypeDef* dir_port;
|
||||
uint16_t dir_pin;
|
||||
size_t thermistor_adc_ch;
|
||||
osPriority thread_priority;
|
||||
} AxisHardwareConfig_t;
|
||||
|
||||
@@ -61,15 +62,23 @@ typedef struct {
|
||||
} BoardHardwareConfig_t;
|
||||
|
||||
extern const BoardHardwareConfig_t hw_configs[2];
|
||||
extern const float thermistor_poly_coeffs[];
|
||||
extern const size_t thermistor_num_coeffs;
|
||||
|
||||
//TODO stick this in a C file
|
||||
#ifdef __MAIN_CPP__
|
||||
const float thermistor_poly_coeffs[] =
|
||||
{363.0172658f, -459.19773008f, 308.29273921f, -28.12731452f};
|
||||
const size_t thermistor_num_coeffs = sizeof(thermistor_poly_coeffs)/sizeof(thermistor_poly_coeffs[1]);
|
||||
|
||||
const BoardHardwareConfig_t hw_configs[2] = { {
|
||||
//M0
|
||||
.axis_config = {
|
||||
.step_port = GPIO_1_GPIO_Port,
|
||||
.step_pin = GPIO_1_Pin,
|
||||
.dir_port = GPIO_2_GPIO_Port,
|
||||
.dir_pin = GPIO_2_Pin,
|
||||
.thermistor_adc_ch = 15,
|
||||
.thread_priority = (osPriority)(osPriorityHigh + (osPriority)1),
|
||||
},
|
||||
.encoder_config = {
|
||||
@@ -99,6 +108,7 @@ const BoardHardwareConfig_t hw_configs[2] = { {
|
||||
.nFAULT_pin = nFAULT_Pin,
|
||||
}
|
||||
},{
|
||||
//M1
|
||||
.axis_config = {
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 5
|
||||
.step_port = GPIO_7_GPIO_Port,
|
||||
@@ -110,6 +120,11 @@ const BoardHardwareConfig_t hw_configs[2] = { {
|
||||
.step_pin = GPIO_3_Pin,
|
||||
.dir_port = GPIO_4_GPIO_Port,
|
||||
.dir_pin = GPIO_4_Pin,
|
||||
#endif
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 3
|
||||
.thermistor_adc_ch = 4,
|
||||
#else
|
||||
.thermistor_adc_ch = 1,
|
||||
#endif
|
||||
.thread_priority = osPriorityHigh,
|
||||
},
|
||||
|
||||
@@ -7,14 +7,6 @@ Encoder::Encoder(const EncoderHardwareConfig_t& hw_config,
|
||||
hw_config_(hw_config),
|
||||
config_(config)
|
||||
{
|
||||
// Calculate encoder pll gains
|
||||
// This calculation is currently identical to the PLL in SensorlessEstimator
|
||||
float pll_bandwidth = 1000.0f; // [rad/s]
|
||||
pll_kp_ = 2.0f * pll_bandwidth;
|
||||
|
||||
// Critically damped
|
||||
pll_ki_ = 0.25f * (pll_kp_ * pll_kp_);
|
||||
|
||||
if (config.pre_calibrated && (config.mode == Encoder::MODE_HALL)) {
|
||||
offset_ = config.offset;
|
||||
is_ready_ = true;
|
||||
@@ -137,6 +129,10 @@ bool Encoder::run_offset_calibration() {
|
||||
bool old_use_index = config_.use_index;
|
||||
config_.use_index = false;
|
||||
|
||||
// We use shadow_count_ to do the calibration, but the offset is used by count_in_cpr_
|
||||
// Therefore we have to sync them for calibration
|
||||
shadow_count_ = count_in_cpr_;
|
||||
|
||||
float voltage_magnitude;
|
||||
if (axis_->motor_.config_.motor_type == MOTOR_TYPE_HIGH_CURRENT)
|
||||
voltage_magnitude = axis_->motor_.config_.calibration_current * axis_->motor_.config_.phase_resistance;
|
||||
@@ -237,8 +233,12 @@ static bool decode_hall(uint8_t hall_state, int32_t* hall_cnt) {
|
||||
}
|
||||
|
||||
bool Encoder::update() {
|
||||
// Calculate encoder pll gains
|
||||
float pll_kp = 2.0f * config_.bandwidth; // basic conversion to discrete time
|
||||
float pll_ki = 0.25f * (pll_kp * pll_kp); // Critically damped
|
||||
|
||||
// Check that we don't get problems with discrete time approximation
|
||||
if (!(current_meas_period * pll_kp_ < 1.0f)) {
|
||||
if (!(current_meas_period * pll_kp < 1.0f)) {
|
||||
set_error(ERROR_UNSTABLE_GAIN);
|
||||
return false;
|
||||
}
|
||||
@@ -285,12 +285,12 @@ bool Encoder::update() {
|
||||
float delta_pos_cpr = (float)(count_in_cpr_ - (int32_t)floorf(pos_cpr_));
|
||||
delta_pos_cpr = wrap_pm(delta_pos_cpr, 0.5f * (float)(config_.cpr));
|
||||
// pll feedback
|
||||
pos_estimate_ += current_meas_period * pll_kp_ * delta_pos;
|
||||
pos_cpr_ += current_meas_period * pll_kp_ * delta_pos_cpr;
|
||||
pos_estimate_ += current_meas_period * pll_kp * delta_pos;
|
||||
pos_cpr_ += current_meas_period * pll_kp * delta_pos_cpr;
|
||||
pos_cpr_ = fmodf_pos(pos_cpr_, (float)(config_.cpr));
|
||||
pll_vel_ += current_meas_period * pll_ki_ * delta_pos_cpr;
|
||||
pll_vel_ += current_meas_period * pll_ki * delta_pos_cpr;
|
||||
bool snap_to_zero_vel = false;
|
||||
if (fabsf(pll_vel_) < 0.5f * current_meas_period * pll_ki_) {
|
||||
if (fabsf(pll_vel_) < 0.5f * current_meas_period * pll_ki) {
|
||||
pll_vel_ = 0.0f; //align delta-sigma on zero to prevent jitter
|
||||
snap_to_zero_vel = true;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
// index search succeeds
|
||||
float offset_float = 0.0f; // Sub-count phase alignment offset
|
||||
float calib_range = 0.02f;
|
||||
float bandwidth = 1000.0f;
|
||||
};
|
||||
|
||||
Encoder(const EncoderHardwareConfig_t& hw_config,
|
||||
@@ -70,8 +71,8 @@ public:
|
||||
float pos_estimate_ = 0.0f; // [rad]
|
||||
float pos_cpr_ = 0.0f; // [rad]
|
||||
float pll_vel_ = 0.0f; // [rad/s]
|
||||
float pll_kp_ = 0.0f; // [rad/s / rad]
|
||||
float pll_ki_ = 0.0f; // [(rad/s^2) / rad]
|
||||
// float pll_kp_ = 0.0f; // [rad/s / rad]
|
||||
// float pll_ki_ = 0.0f; // [(rad/s^2) / rad]
|
||||
|
||||
// Updated by low_level pwm_adc_cb
|
||||
uint8_t hall_state_ = 0x0; // bit[0] = HallA, .., bit[2] = HallC
|
||||
@@ -91,8 +92,8 @@ public:
|
||||
make_protocol_property("pos_cpr", &pos_cpr_),
|
||||
make_protocol_property("hall_state", &hall_state_),
|
||||
make_protocol_property("pll_vel", &pll_vel_),
|
||||
make_protocol_property("pll_kp", &pll_kp_),
|
||||
make_protocol_property("pll_ki", &pll_ki_),
|
||||
// make_protocol_property("pll_kp", &pll_kp_),
|
||||
// make_protocol_property("pll_ki", &pll_ki_),
|
||||
make_protocol_object("config",
|
||||
make_protocol_property("mode", &config_.mode),
|
||||
make_protocol_property("use_index", &config_.use_index),
|
||||
@@ -101,6 +102,7 @@ public:
|
||||
make_protocol_property("cpr", &config_.cpr),
|
||||
make_protocol_property("offset", &config_.offset),
|
||||
make_protocol_property("offset_float", &config_.offset_float),
|
||||
make_protocol_property("bandwidth", &config_.bandwidth),
|
||||
make_protocol_property("calib_range", &config_.calib_range)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Global constant data ------------------------------------------------------*/
|
||||
const float adc_full_scale = (float)(1 << 12);
|
||||
const float adc_ref_voltage = 3.3f;
|
||||
/* Global variables ----------------------------------------------------------*/
|
||||
|
||||
// This value is updated by the DC-bus reading ADC.
|
||||
@@ -422,7 +424,7 @@ float get_adc_voltage(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin) {
|
||||
channel = 15;
|
||||
}
|
||||
if (channel < ADC_CHANNEL_COUNT)
|
||||
return ((float)adc_measurements_[channel]) * (3.3f / (float)(1 << 12));
|
||||
return ((float)adc_measurements_[channel]) * (adc_ref_voltage / adc_full_scale);
|
||||
else
|
||||
return 0.0f / 0.0f; // NaN
|
||||
}
|
||||
@@ -432,7 +434,7 @@ float get_adc_voltage(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin) {
|
||||
//--------------------------------
|
||||
|
||||
void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected) {
|
||||
static const float voltage_scale = 3.3f * VBUS_S_DIVIDER_RATIO / (float)(1 << 12);
|
||||
static const float voltage_scale = adc_ref_voltage * VBUS_S_DIVIDER_RATIO / adc_full_scale;
|
||||
// Only one conversion in sequence, so only rank1
|
||||
uint32_t ADCValue = HAL_ADCEx_InjectedGetValue(hadc, ADC_INJECTED_RANK_1);
|
||||
vbus_voltage = ADCValue * voltage_scale;
|
||||
@@ -603,3 +605,122 @@ void update_brake_current() {
|
||||
safety_critical_disarm_brake_resistor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* RC PWM input --------------------------------------------------------------*/
|
||||
|
||||
// @brief Returns the ODrive GPIO number for a given
|
||||
// TIM2 or TIM5 input capture channel number.
|
||||
int tim_2_5_channel_num_to_gpio_num(int channel) {
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 3
|
||||
if (channel >= 1 && channel <= 4) {
|
||||
// the channel numbers just happen to coincide with
|
||||
// the GPIO numbers
|
||||
return channel;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
// Only ch4 is available on v3.2
|
||||
if (channel == 4) {
|
||||
return 4;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// @brief Returns the TIM2 or TIM5 channel number
|
||||
// for a given GPIO number.
|
||||
uint32_t gpio_num_to_tim_2_5_channel(int gpio_num) {
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 3
|
||||
switch (gpio_num) {
|
||||
case 1: return TIM_CHANNEL_1;
|
||||
case 2: return TIM_CHANNEL_2;
|
||||
case 3: return TIM_CHANNEL_3;
|
||||
case 4: return TIM_CHANNEL_4;
|
||||
default: return 0;
|
||||
}
|
||||
#else
|
||||
// Only ch4 is available on v3.2
|
||||
if (gpio_num == 4) {
|
||||
return TIM_CHANNEL_4;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void pwm_in_init() {
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
|
||||
|
||||
TIM_IC_InitTypeDef sConfigIC;
|
||||
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_BOTHEDGE;
|
||||
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
|
||||
sConfigIC.ICFilter = 15;
|
||||
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 3
|
||||
for (int gpio_num = 1; gpio_num <= 4; ++gpio_num) {
|
||||
#else
|
||||
int gpio_num = 4; {
|
||||
#endif
|
||||
if (is_endpoint_ref_valid(board_config.pwm_mappings[gpio_num - 1].endpoint)) {
|
||||
GPIO_InitStruct.Pin = get_gpio_pin_by_pin(gpio_num);
|
||||
HAL_GPIO_DeInit(get_gpio_port_by_pin(gpio_num), get_gpio_pin_by_pin(gpio_num));
|
||||
HAL_GPIO_Init(get_gpio_port_by_pin(gpio_num), &GPIO_InitStruct);
|
||||
HAL_TIM_IC_ConfigChannel(&htim5, &sConfigIC, gpio_num_to_tim_2_5_channel(gpio_num));
|
||||
HAL_TIM_IC_Start_IT(&htim5, gpio_num_to_tim_2_5_channel(gpio_num));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define TIM_2_5_CLOCK_HZ TIM_APB1_CLOCK_HZ
|
||||
#define PWM_MIN_HIGH_TIME ((TIM_2_5_CLOCK_HZ / 1000000UL) * 1000UL) // 1ms high is considered full reverse
|
||||
#define PWM_MAX_HIGH_TIME ((TIM_2_5_CLOCK_HZ / 1000000UL) * 2000UL) // 2ms high is considered full forward
|
||||
#define PWM_MIN_LEGAL_HIGH_TIME ((TIM_2_5_CLOCK_HZ / 1000000UL) * 500UL) // ignore high periods shorter than 0.5ms
|
||||
#define PWM_MAX_LEGAL_HIGH_TIME ((TIM_2_5_CLOCK_HZ / 1000000UL) * 2500UL) // ignore high periods longer than 2.5ms
|
||||
#define PWM_INVERT_INPUT false
|
||||
|
||||
void handle_pulse(int gpio_num, uint32_t high_time) {
|
||||
if (high_time < PWM_MIN_LEGAL_HIGH_TIME || high_time > PWM_MAX_LEGAL_HIGH_TIME)
|
||||
return;
|
||||
|
||||
if (high_time < PWM_MIN_HIGH_TIME)
|
||||
high_time = PWM_MIN_HIGH_TIME;
|
||||
if (high_time > PWM_MAX_HIGH_TIME)
|
||||
high_time = PWM_MAX_HIGH_TIME;
|
||||
float fraction = (float)(high_time - PWM_MIN_HIGH_TIME) / (float)(PWM_MAX_HIGH_TIME - PWM_MIN_HIGH_TIME);
|
||||
float value = board_config.pwm_mappings[gpio_num - 1].min +
|
||||
(fraction * (board_config.pwm_mappings[gpio_num - 1].max - board_config.pwm_mappings[gpio_num - 1].min));
|
||||
|
||||
Endpoint* endpoint = get_endpoint(board_config.pwm_mappings[gpio_num - 1].endpoint);
|
||||
if (!endpoint)
|
||||
return;
|
||||
|
||||
endpoint->set_from_float(value);
|
||||
}
|
||||
|
||||
void pwm_in_cb(int channel, uint32_t timestamp) {
|
||||
static uint32_t last_timestamp[GPIO_COUNT] = { 0 };
|
||||
static bool last_pin_state[GPIO_COUNT] = { false };
|
||||
static bool last_sample_valid[GPIO_COUNT] = { false };
|
||||
|
||||
int gpio_num = tim_2_5_channel_num_to_gpio_num(channel);
|
||||
if (gpio_num < 1 || gpio_num > GPIO_COUNT)
|
||||
return;
|
||||
bool current_pin_state = HAL_GPIO_ReadPin(get_gpio_port_by_pin(gpio_num), get_gpio_pin_by_pin(gpio_num)) != GPIO_PIN_RESET;
|
||||
|
||||
if (last_sample_valid[gpio_num - 1]
|
||||
&& (last_pin_state[gpio_num - 1] != PWM_INVERT_INPUT)
|
||||
&& (current_pin_state == PWM_INVERT_INPUT)) {
|
||||
handle_pulse(gpio_num, timestamp - last_timestamp[gpio_num - 1]);
|
||||
}
|
||||
|
||||
last_timestamp[gpio_num - 1] = timestamp;
|
||||
last_pin_state[gpio_num - 1] = current_pin_state;
|
||||
last_sample_valid[gpio_num - 1] = true;
|
||||
}
|
||||
@@ -17,9 +17,13 @@ extern "C" {
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define ADC_CHANNEL_COUNT 16
|
||||
extern const float adc_full_scale;
|
||||
extern const float adc_ref_voltage;
|
||||
/* Exported variables --------------------------------------------------------*/
|
||||
extern float vbus_voltage;
|
||||
extern bool brake_resistor_armed;
|
||||
extern uint16_t adc_measurements_[ADC_CHANNEL_COUNT];
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
@@ -35,6 +39,7 @@ extern "C" {
|
||||
void pwm_trig_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
|
||||
void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
|
||||
void tim_update_cb(TIM_HandleTypeDef* htim);
|
||||
void pwm_in_cb(int channel, uint32_t timestamp);
|
||||
}
|
||||
|
||||
// Initalisation
|
||||
@@ -43,8 +48,8 @@ void start_pwm(TIM_HandleTypeDef* htim);
|
||||
void sync_timers(TIM_HandleTypeDef* htim_a, TIM_HandleTypeDef* htim_b,
|
||||
uint16_t TIM_CLOCKSOURCE_ITRx, uint16_t count_offset);
|
||||
void start_general_purpose_adc();
|
||||
|
||||
float get_adc_voltage(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin);
|
||||
void pwm_in_init();
|
||||
|
||||
void update_brake_current();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
BoardConfig_t board_config;
|
||||
Encoder::Config_t encoder_configs[AXIS_COUNT];
|
||||
SensorlessEstimator::Config_t sensorless_configs[AXIS_COUNT];
|
||||
ControllerConfig_t controller_configs[AXIS_COUNT];
|
||||
MotorConfig_t motor_configs[AXIS_COUNT];
|
||||
AxisConfig_t axis_configs[AXIS_COUNT];
|
||||
@@ -22,6 +23,7 @@ Axis *axes[AXIS_COUNT];
|
||||
typedef Config<
|
||||
BoardConfig_t,
|
||||
Encoder::Config_t[AXIS_COUNT],
|
||||
SensorlessEstimator::Config_t[AXIS_COUNT],
|
||||
ControllerConfig_t[AXIS_COUNT],
|
||||
MotorConfig_t[AXIS_COUNT],
|
||||
AxisConfig_t[AXIS_COUNT]> ConfigFormat;
|
||||
@@ -30,6 +32,7 @@ void save_configuration(void) {
|
||||
if (ConfigFormat::safe_store_config(
|
||||
&board_config,
|
||||
&encoder_configs,
|
||||
&sensorless_configs,
|
||||
&controller_configs,
|
||||
&motor_configs,
|
||||
&axis_configs)) {
|
||||
@@ -45,6 +48,7 @@ void load_configuration(void) {
|
||||
ConfigFormat::safe_load_config(
|
||||
&board_config,
|
||||
&encoder_configs,
|
||||
&sensorless_configs,
|
||||
&controller_configs,
|
||||
&motor_configs,
|
||||
&axis_configs)) {
|
||||
@@ -52,6 +56,7 @@ void load_configuration(void) {
|
||||
board_config = BoardConfig_t();
|
||||
for (size_t i = 0; i < AXIS_COUNT; ++i) {
|
||||
encoder_configs[i] = Encoder::Config_t();
|
||||
sensorless_configs[i] = SensorlessEstimator::Config_t();
|
||||
controller_configs[i] = ControllerConfig_t();
|
||||
motor_configs[i] = MotorConfig_t();
|
||||
axis_configs[i] = AxisConfig_t();
|
||||
@@ -152,7 +157,7 @@ int odrive_main(void) {
|
||||
for (size_t i = 0; i < AXIS_COUNT; ++i) {
|
||||
Encoder *encoder = new Encoder(hw_configs[i].encoder_config,
|
||||
encoder_configs[i]);
|
||||
SensorlessEstimator *sensorless_estimator = new SensorlessEstimator();
|
||||
SensorlessEstimator *sensorless_estimator = new SensorlessEstimator(sensorless_configs[i]);
|
||||
Controller *controller = new Controller(controller_configs[i]);
|
||||
Motor *motor = new Motor(hw_configs[i].motor_config,
|
||||
hw_configs[i].gate_driver_config,
|
||||
@@ -176,6 +181,10 @@ int odrive_main(void) {
|
||||
// Init communications (this requires the axis objects to be constructed)
|
||||
init_communication();
|
||||
|
||||
// Start pwm-in compare modules
|
||||
// must happen after communication is initialized
|
||||
pwm_in_init();
|
||||
|
||||
// Setup hardware for all components
|
||||
for (size_t i = 0; i < AXIS_COUNT; ++i) {
|
||||
axes[i]->setup();
|
||||
|
||||
@@ -57,12 +57,16 @@ void Motor::reset_current_control() {
|
||||
// TODO: allow update on user-request or update automatically via hooks
|
||||
void Motor::update_current_controller_gains() {
|
||||
// Calculate current control gains
|
||||
float current_control_bandwidth = 1000.0f; // [rad/s]
|
||||
current_control_.p_gain = current_control_bandwidth * config_.phase_inductance;
|
||||
current_control_.p_gain = config_.current_control_bandwidth * config_.phase_inductance;
|
||||
float plant_pole = config_.phase_resistance / config_.phase_inductance;
|
||||
current_control_.i_gain = plant_pole * current_control_.p_gain;
|
||||
}
|
||||
|
||||
void Motor::set_current_control_bandwidth(float current_control_bandwidth) {
|
||||
config_.current_control_bandwidth = current_control_bandwidth;
|
||||
update_current_controller_gains();
|
||||
}
|
||||
|
||||
// @brief Set up the gate drivers
|
||||
void Motor::DRV8301_setup() {
|
||||
// for reference:
|
||||
|
||||
@@ -50,6 +50,7 @@ typedef struct {
|
||||
float current_lim = 10.0f; //[A]
|
||||
// Value used to compute shunt amplifier gains
|
||||
float requested_current_range = 70.0f; // [A]
|
||||
float current_control_bandwidth = 1000.0f; // [rad/s]
|
||||
} MotorConfig_t;
|
||||
|
||||
class Motor {
|
||||
@@ -101,6 +102,7 @@ public:
|
||||
void reset_current_control();
|
||||
|
||||
void update_current_controller_gains();
|
||||
void set_current_control_bandwidth(float current_control_bandwidth);
|
||||
void DRV8301_setup();
|
||||
bool check_DRV_fault();
|
||||
void set_error(Error_t error);
|
||||
@@ -209,8 +211,11 @@ public:
|
||||
make_protocol_property("direction", &config_.direction),
|
||||
make_protocol_property("motor_type", &config_.motor_type),
|
||||
make_protocol_property("current_lim", &config_.current_lim),
|
||||
make_protocol_property("requested_current_range", &config_.requested_current_range)
|
||||
)
|
||||
make_protocol_property("requested_current_range", &config_.requested_current_range),
|
||||
make_protocol_ro_property("current_control_bandwidth", &config_.current_control_bandwidth)
|
||||
),
|
||||
make_protocol_function("set_current_control_bandwidth", *this, &Motor::set_current_control_bandwidth,
|
||||
"current_control_bandwidth")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __ODRIVE_MAIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <fibre/protocol.hpp>
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -35,9 +36,6 @@ extern bool user_config_loaded_;
|
||||
extern uint64_t serial_number;
|
||||
extern char serial_number_str[13];
|
||||
|
||||
#define ADC_CHANNEL_COUNT 16
|
||||
extern uint16_t adc_measurements_[ADC_CHANNEL_COUNT];
|
||||
|
||||
typedef struct {
|
||||
bool fully_booted;
|
||||
uint32_t uptime; // [ms]
|
||||
@@ -55,6 +53,12 @@ extern SystemStats_t system_stats_;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
struct PWMMapping_t {
|
||||
endpoint_ref_t endpoint = { 0 };
|
||||
float min = 0;
|
||||
float max = 0;
|
||||
};
|
||||
|
||||
// @brief general user configurable board configuration
|
||||
struct BoardConfig_t {
|
||||
bool enable_uart = true;
|
||||
@@ -70,6 +74,7 @@ struct BoardConfig_t {
|
||||
//<! This protects against cases in which the power supply fails to dissipate
|
||||
//<! the brake power if the brake resistor is disabled.
|
||||
//<! The default is 26V for the 24V board version and 52V for the 48V board version.
|
||||
PWMMapping_t pwm_mappings[GPIO_COUNT];
|
||||
};
|
||||
extern BoardConfig_t board_config;
|
||||
extern bool user_config_loaded_;
|
||||
@@ -98,7 +103,6 @@ inline ENUMTYPE operator ~ (ENUMTYPE a) { return static_cast<ENUMTYPE>(~static_c
|
||||
|
||||
|
||||
// ODrive specific includes
|
||||
#include <fibre/protocol.hpp>
|
||||
#include <utils.h>
|
||||
#include <low_level.h>
|
||||
#include <encoder.hpp>
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
|
||||
#include "odrive_main.h"
|
||||
|
||||
SensorlessEstimator::SensorlessEstimator()
|
||||
{
|
||||
// Calculate pll gains
|
||||
// This calculation is currently identical to the PLL in Encoder
|
||||
float pll_bandwidth = 1000.0f; // [rad/s]
|
||||
pll_kp_ = 2.0f * pll_bandwidth;
|
||||
|
||||
// Critically damped
|
||||
pll_ki_ = 0.25f * (pll_kp_ * pll_kp_);
|
||||
}
|
||||
SensorlessEstimator::SensorlessEstimator(Config_t& config) :
|
||||
config_(config)
|
||||
{};
|
||||
|
||||
bool SensorlessEstimator::update() {
|
||||
// Algorithm based on paper: Sensorless Control of Surface-Mount Permanent-Magnet Synchronous Motors Based on a Nonlinear Observer
|
||||
@@ -21,12 +14,6 @@ bool SensorlessEstimator::update() {
|
||||
// is the one computed two cycles ago. To get the correct measurement, it was stored twice:
|
||||
// once by final_v_alpha/final_v_beta in the current control reporting, and once by V_alpha_beta_memory.
|
||||
|
||||
// Check that we don't get problems with discrete time approximation
|
||||
if (!(current_meas_period * pll_kp_ < 1.0f)) {
|
||||
error_ |= ERROR_UNSTABLE_GAIN;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clarke transform
|
||||
float I_alpha_beta[2] = {
|
||||
-axis_->motor_.current_meas_.phB - axis_->motor_.current_meas_.phC,
|
||||
@@ -50,13 +37,10 @@ bool SensorlessEstimator::update() {
|
||||
}
|
||||
|
||||
// Non-linear observer (see paper eqn 8):
|
||||
float pm_flux_sqr = pm_flux_linkage_ * pm_flux_linkage_;
|
||||
float pm_flux_sqr = config_.pm_flux_linkage * config_.pm_flux_linkage;
|
||||
float est_pm_flux_sqr = eta[0] * eta[0] + eta[1] * eta[1];
|
||||
float bandwidth_factor = 1.0f / pm_flux_sqr;
|
||||
float eta_factor = 0.5f * (observer_gain_ * bandwidth_factor) * (pm_flux_sqr - est_pm_flux_sqr);
|
||||
|
||||
static float eta_factor_avg_test = 0.0f;
|
||||
eta_factor_avg_test += 0.001f * (eta_factor - eta_factor_avg_test);
|
||||
float eta_factor = 0.5f * (config_.observer_gain * bandwidth_factor) * (pm_flux_sqr - est_pm_flux_sqr);
|
||||
|
||||
// alpha-beta vector operations
|
||||
for (int i = 0; i <= 1; ++i) {
|
||||
@@ -74,14 +58,24 @@ bool SensorlessEstimator::update() {
|
||||
|
||||
// PLL
|
||||
// TODO: the PLL part has some code duplication with the encoder PLL
|
||||
// Pll gains as a function of bandwidth
|
||||
float pll_kp = 2.0f * config_.pll_bandwidth;
|
||||
// Critically damped
|
||||
float pll_ki = 0.25f * (pll_kp * pll_kp);
|
||||
// Check that we don't get problems with discrete time approximation
|
||||
if (!(current_meas_period * pll_kp < 1.0f)) {
|
||||
error_ |= ERROR_UNSTABLE_GAIN;
|
||||
return false;
|
||||
}
|
||||
|
||||
// predict PLL phase with velocity
|
||||
pll_pos_ = wrap_pm_pi(pll_pos_ + current_meas_period * pll_vel_);
|
||||
// update PLL phase with observer permanent magnet phase
|
||||
phase_ = fast_atan2(eta[1], eta[0]);
|
||||
float delta_phase = wrap_pm_pi(phase_ - pll_pos_);
|
||||
pll_pos_ = wrap_pm_pi(pll_pos_ + current_meas_period * pll_kp_ * delta_phase);
|
||||
pll_pos_ = wrap_pm_pi(pll_pos_ + current_meas_period * pll_kp * delta_phase);
|
||||
// update PLL velocity
|
||||
pll_vel_ += current_meas_period * pll_ki_ * delta_phase;
|
||||
pll_vel_ += current_meas_period * pll_ki * delta_phase;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -8,23 +8,28 @@ public:
|
||||
ERROR_UNSTABLE_GAIN = 0x01,
|
||||
};
|
||||
|
||||
SensorlessEstimator();
|
||||
struct Config_t {
|
||||
float observer_gain = 1000.0f; // [rad/s]
|
||||
float pll_bandwidth = 1000.0f; // [rad/s]
|
||||
float pm_flux_linkage = 1.58e-3f; // [V / (rad/s)] { 5.51328895422 / (<pole pairs> * <rpm/v>) }
|
||||
};
|
||||
|
||||
SensorlessEstimator(Config_t& config);
|
||||
|
||||
bool update();
|
||||
|
||||
Axis* axis_ = nullptr; // set by Axis constructor
|
||||
Config_t& config_;
|
||||
|
||||
// TODO: expose on protocol
|
||||
Error_t error_ = ERROR_NONE;
|
||||
float phase_ = 0.0f; // [rad]
|
||||
float pll_pos_ = 0.0f; // [rad]
|
||||
float pll_vel_ = 0.0f; // [rad/s]
|
||||
float pll_kp_ = 0.0f; // [rad/s / rad]
|
||||
float pll_ki_ = 0.0f; // [(rad/s^2) / rad]
|
||||
float observer_gain_ = 1000.0f; // [rad/s]
|
||||
// float pll_kp_ = 0.0f; // [rad/s / rad]
|
||||
// float pll_ki_ = 0.0f; // [(rad/s^2) / rad]
|
||||
float flux_state_[2] = {0.0f, 0.0f}; // [Vs]
|
||||
float V_alpha_beta_memory_[2] = {0.0f, 0.0f}; // [V]
|
||||
float pm_flux_linkage_ = 1.58e-3f; // [V / (rad/s)] { 5.51328895422 / (<pole pairs> * <rpm/v>) }
|
||||
bool estimator_good_ = false;
|
||||
|
||||
// Communication protocol definitions
|
||||
@@ -34,8 +39,13 @@ public:
|
||||
make_protocol_property("phase", &phase_),
|
||||
make_protocol_property("pll_pos", &pll_pos_),
|
||||
make_protocol_property("pll_vel", &pll_vel_),
|
||||
make_protocol_property("pll_kp", &pll_kp_),
|
||||
make_protocol_property("pll_ki", &pll_ki_)
|
||||
// make_protocol_property("pll_kp", &pll_kp_),
|
||||
// make_protocol_property("pll_ki", &pll_ki_),
|
||||
make_protocol_object("config",
|
||||
make_protocol_property("observer_gain", &config_.observer_gain),
|
||||
make_protocol_property("pll_bandwidth", &config_.pll_bandwidth),
|
||||
make_protocol_property("pm_flux_linkage", &config_.pm_flux_linkage)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include <utils.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <cmsis_os.h>
|
||||
#include <stm32f4xx_hal.h>
|
||||
|
||||
@@ -133,12 +134,13 @@ float fast_atan2(float y, float x) {
|
||||
// a := min (|x|, |y|) / max (|x|, |y|)
|
||||
float abs_y = fabsf(y);
|
||||
float abs_x = fabsf(x);
|
||||
float a = MACRO_MIN(abs_x, abs_y) / MACRO_MAX(abs_x, abs_y);
|
||||
//s := a * a
|
||||
// inject FLT_MIN in denominator to avoid division by zero
|
||||
float a = MACRO_MIN(abs_x, abs_y) / (MACRO_MAX(abs_x, abs_y) + FLT_MIN);
|
||||
// s := a * a
|
||||
float s = a * a;
|
||||
//r := ((-0.0464964749 * s + 0.15931422) * s - 0.327622764) * s * a + a
|
||||
// r := ((-0.0464964749 * s + 0.15931422) * s - 0.327622764) * s * a + a
|
||||
float r = ((-0.0464964749f * s + 0.15931422f) * s - 0.327622764f) * s * a + a;
|
||||
//if |y| > |x| then r := 1.57079637 - r
|
||||
// if |y| > |x| then r := 1.57079637 - r
|
||||
if (abs_y > abs_x)
|
||||
r = 1.57079637f - r;
|
||||
// if x < 0 then r := 3.14159274 - r
|
||||
@@ -151,6 +153,16 @@ float fast_atan2(float y, float x) {
|
||||
return r;
|
||||
}
|
||||
|
||||
// Evaluate polynomials using Fused Multiply Add intrisic instruction.
|
||||
// coeffs[0] is highest order, as per numpy.polyfit
|
||||
// p(x) = coeffs[0] * x^deg + ... + coeffs[deg], for some degree "deg"
|
||||
float horner_fma(float x, const float *coeffs, size_t count) {
|
||||
float result = 0.0f;
|
||||
for (int idx = 0; idx < count; ++idx)
|
||||
result = fmaf(result, x, coeffs[idx]);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Modulo (as opposed to remainder), per https://stackoverflow.com/a/19288271
|
||||
int mod(int dividend, int divisor){
|
||||
int r = dividend % divisor;
|
||||
|
||||
@@ -94,6 +94,7 @@ static inline float fmodf_pos(float x, float y) {
|
||||
int SVM(float alpha, float beta, float* tA, float* tB, float* tC);
|
||||
|
||||
float fast_atan2(float y, float x);
|
||||
float horner_fma(float x, const float *coeffs, size_t count);
|
||||
int mod(int dividend, int divisor);
|
||||
|
||||
uint32_t deadline_to_timeout(uint32_t deadline_ms);
|
||||
|
||||
@@ -64,10 +64,20 @@ const uint8_t fw_version_revision = FW_VERSION_REVISION;
|
||||
const uint8_t fw_version_unreleased = FW_VERSION_UNRELEASED; // 0 for official releases, 1 otherwise
|
||||
|
||||
osThreadId comm_thread;
|
||||
volatile bool endpoint_list_valid = false;
|
||||
|
||||
static uint32_t test_property = 0;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
|
||||
auto make_protocol_definitions(PWMMapping_t& mapping) {
|
||||
return make_protocol_member_list(
|
||||
make_protocol_property("endpoint", &mapping.endpoint),
|
||||
make_protocol_property("min", &mapping.min),
|
||||
make_protocol_property("max", &mapping.max)
|
||||
);
|
||||
}
|
||||
|
||||
/* Function implementations --------------------------------------------------*/
|
||||
|
||||
void init_communication(void) {
|
||||
@@ -76,6 +86,9 @@ void init_communication(void) {
|
||||
// Start command handling thread
|
||||
osThreadDef(task_cmd_parse, communication_task, osPriorityNormal, 0, 5000 /* in 32-bit words */); // TODO: fix stack issues
|
||||
comm_thread = osThreadCreate(osThread(task_cmd_parse), NULL);
|
||||
|
||||
while (!endpoint_list_valid)
|
||||
osDelay(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +157,13 @@ static inline auto make_obj_tree() {
|
||||
make_protocol_property("enable_i2c_instead_of_can" , &board_config.enable_i2c_instead_of_can), // requires a reboot
|
||||
make_protocol_property("enable_ascii_protocol_on_usb", &board_config.enable_ascii_protocol_on_usb),
|
||||
make_protocol_property("dc_bus_undervoltage_trip_level", &board_config.dc_bus_undervoltage_trip_level),
|
||||
make_protocol_property("dc_bus_overvoltage_trip_level", &board_config.dc_bus_overvoltage_trip_level)
|
||||
make_protocol_property("dc_bus_overvoltage_trip_level", &board_config.dc_bus_overvoltage_trip_level),
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 3
|
||||
make_protocol_object("gpio1_pwm_mapping", make_protocol_definitions(board_config.pwm_mappings[0])),
|
||||
make_protocol_object("gpio2_pwm_mapping", make_protocol_definitions(board_config.pwm_mappings[1])),
|
||||
make_protocol_object("gpio3_pwm_mapping", make_protocol_definitions(board_config.pwm_mappings[2])),
|
||||
#endif
|
||||
make_protocol_object("gpio4_pwm_mapping", make_protocol_definitions(board_config.pwm_mappings[3]))
|
||||
),
|
||||
make_protocol_object("axis0", axes[0]->make_protocol_definitions()),
|
||||
make_protocol_object("axis1", axes[1]->make_protocol_definitions()),
|
||||
@@ -174,6 +193,9 @@ void communication_task(void * ctx) {
|
||||
// ends up with a stupid stack size of around 8000 bytes. Fix this.
|
||||
auto tree_ptr = new (tree_buffer) tree_type(make_obj_tree());
|
||||
fibre_publish(*tree_ptr);
|
||||
|
||||
// Allow main init to continue
|
||||
endpoint_list_valid = true;
|
||||
|
||||
start_uart_server();
|
||||
start_usb_server();
|
||||
|
||||
@@ -10,6 +10,7 @@ see protocol.md for the protocol specification
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
//#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "crc.hpp"
|
||||
@@ -74,7 +75,15 @@ constexpr uint16_t RX_BUF_SIZE = 128; // larger values than 128 have currently n
|
||||
// Maximum time we allocate for processing and responding to a request
|
||||
constexpr uint32_t PROTOCOL_SERVER_TIMEOUT_MS = 10;
|
||||
|
||||
template<typename T>
|
||||
|
||||
typedef struct {
|
||||
uint16_t json_crc;
|
||||
uint16_t node_id;
|
||||
uint16_t endpoint_id;
|
||||
} endpoint_ref_t;
|
||||
|
||||
|
||||
template<typename T, typename = typename std::enable_if_t<!std::is_const<T>::value>>
|
||||
inline size_t write_le(T value, uint8_t* buffer);
|
||||
|
||||
template<typename T>
|
||||
@@ -138,6 +147,12 @@ inline size_t write_le<float>(float value, uint8_t* buffer) {
|
||||
return write_le<uint32_t>(*value_as_uint32, buffer);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if_t<std::is_const<T>::value, size_t>
|
||||
write_le(T value, uint8_t* buffer) {
|
||||
return write_le<std::remove_const_t<T>>(value, buffer);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline size_t read_le<bool>(bool* value, const uint8_t* buffer) {
|
||||
*value = buffer[0];
|
||||
@@ -417,7 +432,29 @@ typedef std::function<void(void* ctx, const uint8_t* input, size_t input_length,
|
||||
|
||||
|
||||
template<typename T>
|
||||
void default_readwrite_endpoint_handler(const T* value, const uint8_t* input, size_t input_length, StreamSink* output) {
|
||||
void default_readwrite_endpoint_handler(endpoint_ref_t* value, const uint8_t* input, size_t input_length, StreamSink* output) {
|
||||
constexpr size_t size = sizeof(value->endpoint_id) + sizeof(value->json_crc);
|
||||
if (output) {
|
||||
// TODO: make buffer size dependent on the type
|
||||
uint8_t buffer[size];
|
||||
size_t cnt = write_le<decltype(value->endpoint_id)>(value->endpoint_id, buffer);
|
||||
cnt += write_le<decltype(value->json_crc)>(value->json_crc, buffer + cnt);
|
||||
if (cnt <= output->get_free_space())
|
||||
output->process_bytes(buffer, cnt, nullptr);
|
||||
}
|
||||
|
||||
// If a new value was passed, call the corresponding little endian deserialization function
|
||||
if (input_length >= size) {
|
||||
read_le<decltype(value->endpoint_id)>(&value->endpoint_id, input);
|
||||
read_le<decltype(value->json_crc)>(&value->json_crc, input + 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @brief Default endpoint handler for const types
|
||||
template<typename T>
|
||||
std::enable_if_t<!std::is_same<T, endpoint_ref_t>::value && std::is_const<T>::value>
|
||||
default_readwrite_endpoint_handler(T* value, const uint8_t* input, size_t input_length, StreamSink* output) {
|
||||
// If the old value was requested, call the corresponding little endian serialization function
|
||||
if (output) {
|
||||
// TODO: make buffer size dependent on the type
|
||||
@@ -428,10 +465,12 @@ void default_readwrite_endpoint_handler(const T* value, const uint8_t* input, si
|
||||
}
|
||||
}
|
||||
|
||||
// @brief Default endpoint handler for non-const types
|
||||
template<typename T>
|
||||
void default_readwrite_endpoint_handler(T* value, const uint8_t* input, size_t input_length, StreamSink* output) {
|
||||
std::enable_if_t<!std::is_same<T, endpoint_ref_t>::value && !std::is_const<T>::value>
|
||||
default_readwrite_endpoint_handler(T* value, const uint8_t* input, size_t input_length, StreamSink* output) {
|
||||
// Read the endpoint value into output
|
||||
default_readwrite_endpoint_handler<T>(const_cast<const T*>(value), input, input_length, output);
|
||||
default_readwrite_endpoint_handler<const T>(const_cast<const T*>(value), input, input_length, output);
|
||||
|
||||
// If a new value was passed, call the corresponding little endian deserialization function
|
||||
uint8_t buffer[sizeof(T)] = { 0 }; // TODO: make buffer size dependent on the type
|
||||
@@ -500,13 +539,18 @@ template<>
|
||||
inline constexpr const char* get_default_json_modifier<bool>() {
|
||||
return "\"type\":\"bool\",\"access\":\"rw\"";
|
||||
}
|
||||
template<>
|
||||
inline constexpr const char* get_default_json_modifier<endpoint_ref_t>() {
|
||||
return "\"type\":\"endpoint_ref\",\"access\":\"rw\"";
|
||||
}
|
||||
|
||||
class Endpoint {
|
||||
public:
|
||||
//const char* const name_;
|
||||
virtual void handle(const uint8_t* input, size_t input_length, StreamSink* output) = 0;
|
||||
virtual bool get_string(char * output, size_t length) { return false; };
|
||||
virtual bool get_string(char * output, size_t length) { return false; }
|
||||
virtual bool set_string(char * buffer, size_t length) { return false; }
|
||||
virtual bool set_from_float(float value) { return false; }
|
||||
};
|
||||
|
||||
static inline int write_string(const char* str, StreamSink* output) {
|
||||
@@ -719,6 +763,41 @@ ProtocolObject<TMembers...> make_protocol_object(const char * name, TMembers&&..
|
||||
return ProtocolObject<TMembers...>(name, std::forward<TMembers>(member_list)...);
|
||||
}
|
||||
|
||||
//template<typename T, typename = typename std>
|
||||
//bool set_from_float_ex(float value, T* property) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
namespace conversion {
|
||||
//template<typename T>
|
||||
template<typename T>
|
||||
bool set_from_float_ex(float value, float* property, int) {
|
||||
return *property = value, true;
|
||||
}
|
||||
template<typename T>
|
||||
bool set_from_float_ex(float value, bool* property, int) {
|
||||
return *property = (value >= 0.0f), true;
|
||||
}
|
||||
template<typename T, typename = std::enable_if_t<std::is_integral<T>::value && !std::is_const<T>::value>>
|
||||
bool set_from_float_ex(float value, T* property, int) {
|
||||
return *property = static_cast<T>(std::round(value)), true;
|
||||
}
|
||||
template<typename T>
|
||||
bool set_from_float_ex(float value, T* property, ...) {
|
||||
return false;
|
||||
}
|
||||
template<typename T>
|
||||
bool set_from_float(float value, T* property) {
|
||||
return set_from_float_ex<T>(value, property, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//template<typename T>
|
||||
//bool set_from_float_ex<>(float value, T* property) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
|
||||
template<typename TProperty>
|
||||
class ProtocolProperty : public Endpoint {
|
||||
public:
|
||||
@@ -793,12 +872,16 @@ public:
|
||||
return from_string(buffer, length, property_, 0);
|
||||
}
|
||||
|
||||
bool set_from_float(float value) final {
|
||||
return conversion::set_from_float(value, property_);
|
||||
}
|
||||
|
||||
void register_endpoints(Endpoint** list, size_t id, size_t length) {
|
||||
if (id < length)
|
||||
list[id] = this;
|
||||
}
|
||||
void handle(const uint8_t* input, size_t input_length, StreamSink* output) final {
|
||||
default_readwrite_endpoint_handler(property_, input, input_length, output);
|
||||
default_readwrite_endpoint_handler<TProperty>(property_, input, input_length, output);
|
||||
}
|
||||
/*void handle(const uint8_t* input, size_t input_length, StreamSink* output) {
|
||||
handle(input, input_length, output);
|
||||
@@ -1051,6 +1134,9 @@ extern uint16_t json_crc_;
|
||||
extern JSONDescriptorEndpoint json_file_endpoint_;
|
||||
extern EndpointProvider* application_endpoints_;
|
||||
|
||||
bool is_endpoint_ref_valid(endpoint_ref_t endpoint_ref);
|
||||
Endpoint* get_endpoint(endpoint_ref_t endpoint_ref);
|
||||
|
||||
// @brief Registers the specified application object list using the provided endpoint table.
|
||||
// This function should only be called once during the lifetime of the application. TODO: fix this.
|
||||
// @param application_objects The application objects to be registred.
|
||||
|
||||
@@ -213,3 +213,15 @@ int BidirectionalPacketBasedChannel::process_packet(const uint8_t* buffer, size_
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_endpoint_ref_valid(endpoint_ref_t endpoint_ref) {
|
||||
return (endpoint_ref.json_crc == json_crc_)
|
||||
&& (endpoint_ref.endpoint_id < n_endpoints_);
|
||||
}
|
||||
|
||||
Endpoint* get_endpoint(endpoint_ref_t endpoint_ref) {
|
||||
if (is_endpoint_ref_valid(endpoint_ref))
|
||||
return endpoint_list_[endpoint_ref.endpoint_id];
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,25 @@ import fibre.protocol
|
||||
class ObjectDefinitionError(Exception):
|
||||
pass
|
||||
|
||||
codecs = {}
|
||||
|
||||
class StructCodec():
|
||||
"""
|
||||
Generic serializer/deserializer based on struct pack
|
||||
"""
|
||||
def __init__(self, struct_format, target_type):
|
||||
self._struct_format = struct_format
|
||||
self._target_type = target_type
|
||||
def get_length(self):
|
||||
return struct.calcsize(self._struct_format)
|
||||
def serialize(self, value):
|
||||
value = self._target_type(value)
|
||||
return struct.pack(self._struct_format, value)
|
||||
def deserialize(self, buffer):
|
||||
value = struct.unpack(self._struct_format, buffer)
|
||||
value = value[0] if len(value) == 1 else value
|
||||
return self._target_type(value)
|
||||
|
||||
class RemoteProperty():
|
||||
"""
|
||||
Used internally by dynamically created objects to translate
|
||||
@@ -19,6 +38,7 @@ class RemoteProperty():
|
||||
"""
|
||||
def __init__(self, json_data, parent):
|
||||
self._parent = parent
|
||||
self.__channel__ = parent.__channel__
|
||||
id_str = json_data.get("id", None)
|
||||
if id_str is None:
|
||||
raise ObjectDefinitionError("unspecified endpoint ID")
|
||||
@@ -32,51 +52,28 @@ class RemoteProperty():
|
||||
if type_str is None:
|
||||
raise ObjectDefinitionError("unspecified type")
|
||||
|
||||
if type_str == "float":
|
||||
self._property_type = float
|
||||
self._struct_format = "<f"
|
||||
elif type_str == "bool":
|
||||
self._property_type = bool
|
||||
self._struct_format = "<?"
|
||||
elif type_str == "int8":
|
||||
self._property_type = int
|
||||
self._struct_format = "<b"
|
||||
elif type_str == "uint8":
|
||||
self._property_type = int
|
||||
self._struct_format = "<B"
|
||||
elif type_str == "int16":
|
||||
self._property_type = int
|
||||
self._struct_format = "<h"
|
||||
elif type_str == "uint16":
|
||||
self._property_type = int
|
||||
self._struct_format = "<H"
|
||||
elif type_str == "int32":
|
||||
self._property_type = int
|
||||
self._struct_format = "<i"
|
||||
elif type_str == "uint32":
|
||||
self._property_type = int
|
||||
self._struct_format = "<I"
|
||||
elif type_str == "int64":
|
||||
self._property_type = int
|
||||
self._struct_format = "<q"
|
||||
elif type_str == "uint64":
|
||||
self._property_type = int
|
||||
self._struct_format = "<Q"
|
||||
else:
|
||||
raise ObjectDefinitionError("unsupported type {}".format(type_str))
|
||||
# Find all codecs that match the type_str and build a dictionary
|
||||
# of the form {type1: codec1, type2: codec2}
|
||||
eligible_types = {k: v[type_str] for (k,v) in codecs.items() if type_str in v}
|
||||
|
||||
if not eligible_types:
|
||||
raise ObjectDefinitionError("unsupported codec {}".format(type_str))
|
||||
|
||||
# TODO: better heuristics to select a matching type (i.e. prefer non lossless)
|
||||
eligible_types = list(eligible_types.items())
|
||||
self._property_type = eligible_types[0][0]
|
||||
self._codec = eligible_types[0][1]
|
||||
|
||||
access_mode = json_data.get("access", "r")
|
||||
self._can_read = 'r' in access_mode
|
||||
self._can_write = 'w' in access_mode
|
||||
|
||||
def get_value(self):
|
||||
size = struct.calcsize(self._struct_format)
|
||||
buffer = self._parent.__channel__.remote_endpoint_operation(self._id, None, True, size)
|
||||
return struct.unpack(self._struct_format, buffer)[0]
|
||||
buffer = self._parent.__channel__.remote_endpoint_operation(self._id, None, True, self._codec.get_length())
|
||||
return self._codec.deserialize(buffer)
|
||||
|
||||
def set_value(self, value):
|
||||
value = self._property_type(value)
|
||||
buffer = struct.pack(self._struct_format, value)
|
||||
buffer = self._codec.serialize(value)
|
||||
# TODO: Currenly we wait for an ack here. Settle on the default guarantee.
|
||||
self._parent.__channel__.remote_endpoint_operation(self._id, buffer, True, 0)
|
||||
|
||||
@@ -91,6 +88,47 @@ class RemoteProperty():
|
||||
val_str = str(self.get_value())
|
||||
return "{} = {} ({})".format(self._name, val_str, self._property_type.__name__)
|
||||
|
||||
class EndpointRefCodec():
|
||||
"""
|
||||
Serializer/deserializer for an endpoint reference
|
||||
"""
|
||||
def get_length(self):
|
||||
return struct.calcsize("<HH")
|
||||
def serialize(self, value):
|
||||
if value is None:
|
||||
(ep_id, ep_crc) = (0, 0)
|
||||
elif isinstance(value, RemoteProperty):
|
||||
(ep_id, ep_crc) = (value._id, value.__channel__._interface_definition_crc)
|
||||
else:
|
||||
raise TypeError("Expected value of type RemoteProperty or None but got '{}'. En example for a RemoteProperty is this expression: odrv0.axis0.controller._remote_attributes['pos_setpoint']".format(type(value).__name__))
|
||||
return struct.pack("<HH", ep_id, ep_crc)
|
||||
def deserialize(self, buffer):
|
||||
return struct.unpack("<HH", buffer)
|
||||
|
||||
codecs[int] = {
|
||||
'int8': StructCodec("<b", int),
|
||||
'uint8': StructCodec("<B", int),
|
||||
'int16': StructCodec("<h", int),
|
||||
'uint16': StructCodec("<H", int),
|
||||
'int32': StructCodec("<i", int),
|
||||
'uint32': StructCodec("<I", int),
|
||||
'int64': StructCodec("<q", int),
|
||||
'uint64': StructCodec("<Q", int)
|
||||
}
|
||||
|
||||
codecs[bool] = {
|
||||
'bool': StructCodec("<?", bool)
|
||||
}
|
||||
|
||||
codecs[float] = {
|
||||
'float': StructCodec("<f", float)
|
||||
}
|
||||
|
||||
codecs[RemoteProperty] = {
|
||||
'endpoint_ref': EndpointRefCodec()
|
||||
}
|
||||
|
||||
|
||||
class RemoteFunction(object):
|
||||
"""
|
||||
Represents a callable function that maps to a function call on a remote object
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#%%
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
Rload = 3300
|
||||
R_25 = 10000
|
||||
T_25 = 25 + 273.15 #Kelvin
|
||||
Beta = 3380
|
||||
Tmin = 0
|
||||
Tmax = 140
|
||||
|
||||
temps = np.linspace(Tmin, Tmax, 1000)
|
||||
tempsK = temps + 273.15
|
||||
|
||||
# https://en.wikipedia.org/wiki/Thermistor#B_or_%CE%B2_parameter_equation
|
||||
r_inf = R_25 * np.exp(-Beta/T_25)
|
||||
R_temps = r_inf * np.exp(Beta/tempsK)
|
||||
V = Rload / (Rload + R_temps)
|
||||
|
||||
fit = np.polyfit(V, temps, 3)
|
||||
p1 = np.poly1d(fit)
|
||||
fit_temps = p1(V)
|
||||
|
||||
#%%
|
||||
print(fit)
|
||||
|
||||
plt.plot(V, temps, label='actual')
|
||||
plt.plot(V, fit_temps, label='fit')
|
||||
plt.xlabel('normalized voltage')
|
||||
plt.ylabel('Temp [C]')
|
||||
plt.legend(loc=0)
|
||||
plt.show()
|
||||
@@ -85,3 +85,15 @@ All variables that are part of a `[...].config` object can be saved to non-volat
|
||||
* `<odrv>.serial_number`: A number that uniquely identifies your device. When printed in upper case hexadecimal (`hex(<odrv>.serial_number).upper()`), this is identical to the serial number indicated by the USB descriptor.
|
||||
* `<odrv>.fw_version_major`, `<odrv>.fw_version_minor`, `<odrv>.fw_version_revision`: The firmware version that is currently running.
|
||||
* `<odrv>.hw_version_major`, `<odrv>.hw_version_minor`, `<odrv>.hw_version_revision`: The hardware version of your ODrive.
|
||||
|
||||
## Setting up sensorless
|
||||
The ODrive can run without encoder/hall feedback, but there is a minimum speed, usually around a few hunderd RPM.
|
||||
However the
|
||||
```
|
||||
odrv0.axis0.controller.config.vel_gain = 0.1
|
||||
odrv0.axis0.controller.config.vel_integrator_gain = 0
|
||||
odrv0.axis0.controller.config.control_mode = 2
|
||||
odrv0.axis0.controller.vel_setpoint = 400
|
||||
odrv0.axis0.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / (<pole pairs> * <motor kv>)
|
||||
```
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ You can also modify the compile-time defaults for all `.config` parameters. You
|
||||
* Connect `GND`, `SWD`, and `SWC` on connector J2 to the programmer. Note: Always plug in `GND` first!
|
||||
* You need to power the board by only **ONE** of the following: VCC(3.3v), 5V, or the main power connection (the DC bus). The USB port (J1) does not power the board.
|
||||
* Run `make flash` in the `Firmware` directory.
|
||||
__Note__: If you receive the error `can't find target interface/stlink-v2.cfg` or similar, create and set an environment variable named `OPENOCD_SCRIPTS` to the location of the openocd scripts directory.
|
||||
|
||||
If the flashing worked, you can connect to the board using the [odrivetool](getting-started#start-odrivetool).
|
||||
|
||||
|
||||
+48
-44
@@ -41,11 +41,11 @@ You will need:
|
||||
</div></details>
|
||||
|
||||
* A power supply (12V-24V for the 24V board variant, 12V-48V for the 48V board variant). A battery is also fine.
|
||||
<details><summary markdown="span">What voltage variant do I have?</summary><div markdown="block">
|
||||
On all ODrives shipped July 2018 or after have a silkscreen label clearly indicating the voltage variant.
|
||||
<details><summary markdown="span">What voltage variant do I have?</summary><div markdown="block">
|
||||
On all ODrives shipped July 2018 or after have a silkscreen label clearly indicating the voltage variant.
|
||||
|
||||
ODrives before this may or may not have this label. If you don't have a label, then you can look at the bus capacitors (8 gray cylinder components on the underside of the board). If they read 470uF, you have a 24V version; if they read 120uF you have a 48V version.
|
||||
</div></details>
|
||||
ODrives before this may or may not have this label. If you don't have a label, then you can look at the bus capacitors (8 gray cylinder components on the underside of the board). If they read 470uF, you have a 24V version; if they read 120uF you have a 48V version.
|
||||
</div></details>
|
||||
|
||||
## Wiring up the ODrive
|
||||
|
||||
@@ -68,12 +68,12 @@ Most instructions in this guide refer to a utility called `odrivetool`, so you s
|
||||
### Windows
|
||||
|
||||
1. Install Python 3. We recommend the Anaconda distribution because it packs a lot of useful scientific tools, however you can also install the standalone python.
|
||||
* __Anaconda__: Download the installer from [here](https://www.anaconda.com/download/#windows). Execute the downloaded file and follow the instructions.
|
||||
* __Standalone Python__: Download the installer from [here](https://www.python.org/downloads/). Execute the downloaded file and follow the instructions.
|
||||
* If you have Python 2 installed alongside Python 3, replace `pip` by `C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\Scripts\pip`. If you have trouble with this step then refer to [this walkthrough](https://www.youtube.com/watch?v=jnpC_Ib_lbc).
|
||||
* __Anaconda__: Download the installer from [here](https://www.anaconda.com/download/#windows). Execute the downloaded file and follow the instructions.
|
||||
* __Standalone Python__: Download the installer from [here](https://www.python.org/downloads/). Execute the downloaded file and follow the instructions.
|
||||
* If you have Python 2 installed alongside Python 3, replace `pip` by `C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\Scripts\pip`. If you have trouble with this step then refer to [this walkthrough](https://www.youtube.com/watch?v=jnpC_Ib_lbc).
|
||||
2. Launch the command prompt.
|
||||
* __Anaconda__: In the start menu, type `Anaconda Prompt` <kbd>Enter</kbd>
|
||||
* __Standalone Python__: In the start menu, type `cmd` <kbd>Enter</kbd>
|
||||
* __Anaconda__: In the start menu, type `Anaconda Prompt` <kbd>Enter</kbd>
|
||||
* __Standalone Python__: In the start menu, type `cmd` <kbd>Enter</kbd>
|
||||
3. Install the ODrive tools by typing `pip install odrive` <kbd>Enter</kbd>
|
||||
4. Plug in a USB cable into the microUSB connector on ODrive, and connect it to your PC.
|
||||
5. Use the [Zadig](http://zadig.akeo.ie/) utility to set ODrive driver to libusb-win32.
|
||||
@@ -157,42 +157,46 @@ You can read more about the odrivetool [here](odrivetool.md).
|
||||
|
||||
1. Set the limits:
|
||||
|
||||
<details><summary markdown="span">Wait, how do I set these?</summary><div markdown="block">
|
||||
<details><summary markdown="span">Wait, how do I set these?</summary><div markdown="block">
|
||||
|
||||
In the previous step we started `odrivetool`. In there, you can assign variables directly by name.
|
||||
In the previous step we started `odrivetool`. In there, you can assign variables directly by name.
|
||||
|
||||
For instance, to set the current limit of M0 to 10A you would type: `odrv0.axis0.motor.config.current_lim = 10` <kbd>Enter</kbd>
|
||||
For instance, to set the current limit of M0 to 10A you would type: `odrv0.axis0.motor.config.current_lim = 10` <kbd>Enter</kbd>
|
||||
|
||||
</div></details>
|
||||
</div></details>
|
||||
|
||||
* The current limit: `odrv0.axis0.motor.config.current_lim` [A]. The default current limit, for safety reasons, is set to 10A. This is quite weak, and good for making sure the drive is stable. Once you have tuned the drive, you can increase this to 75A to get some performance. Note that above 75A, you must change the current amplifier gains.
|
||||
* Note: The motor current and the current drawn from the power supply is not the same in general. You should not look at the power supply current to see what is going on with the motor current.
|
||||
<details><summary markdown="span">Ok so tell me how it actually works then...</summary><div markdown="block">
|
||||
The current in the motor is only connected to the current in the power supply _sometimes_ and other times it just cycles out of one phase and back in the other. This is what the modulation magnitude is (sometimes people call this duty cycle, but that's a bit confusing because we use SVM not straight PWM). When the modulation magnitude is 0, the average voltage seen across the motor phases is 0, and the motor current is never connected to the power supply. When the magnitude is 100%, it is always connected, and at 50% it's connected half the time, and cycled in just the motor half the time.
|
||||
* The current limit: `odrv0.axis0.motor.config.current_lim` [A]. The default current limit, for safety reasons, is set to 10A. This is quite weak, and good for making sure the drive is stable. Once you have tuned the drive, you can increase this to 75A to get some performance. Note that above 75A, you must change the current amplifier gains.
|
||||
* Note: The motor current and the current drawn from the power supply is not the same in general. You should not look at the power supply current to see what is going on with the motor current.
|
||||
<details><summary markdown="span">Ok so tell me how it actually works then...</summary><div markdown="block">
|
||||
The current in the motor is only connected to the current in the power supply _sometimes_ and other times it just cycles out of one phase and back in the other. This is what the modulation magnitude is (sometimes people call this duty cycle, but that's a bit confusing because we use SVM not straight PWM). When the modulation magnitude is 0, the average voltage seen across the motor phases is 0, and the motor current is never connected to the power supply. When the magnitude is 100%, it is always connected, and at 50% it's connected half the time, and cycled in just the motor half the time.
|
||||
|
||||
The largest effect on modulation magnitude is speed. There are other smaller factors, but in general: if the motor is still it's not unreasonable to have 50A in the motor from 5A on the power supply. When the motor is spinning close to top speed, the power supply current and the motor current will be somewhat close to each other.
|
||||
</div></details>
|
||||
* The velocity limit: `odrv0.axis0.controller.config.vel_limit` [counts/s]. The motor will be limited to this speed; again the default value is quite slow.
|
||||
* You can change `odrv0.axis0.motor.config.calibration_current` [A] to the largest value you feel comfortable leaving running through the motor continously when the motor is stationary.
|
||||
The largest effect on modulation magnitude is speed. There are other smaller factors, but in general: if the motor is still it's not unreasonable to have 50A in the motor from 5A on the power supply. When the motor is spinning close to top speed, the power supply current and the motor current will be somewhat close to each other.
|
||||
</div></details>
|
||||
* The velocity limit: `odrv0.axis0.controller.config.vel_limit` [counts/s]. The motor will be limited to this speed; again the default value is quite slow.
|
||||
* You can change `odrv0.axis0.motor.config.calibration_current` [A] to the largest value you feel comfortable leaving running through the motor continously when the motor is stationary.
|
||||
|
||||
2. Set other hardware parameters:
|
||||
|
||||
* `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`.
|
||||
* `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._
|
||||
* `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`).
|
||||
* `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`.
|
||||
* `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._
|
||||
* `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`).
|
||||
|
||||
<details><summary markdown="span">Which `motor_type` to choose?</summary><div markdown="block">
|
||||
<details><summary markdown="span">Which `motor_type` to choose?</summary><div markdown="block">
|
||||
|
||||
If you're using a regular hobby brushless motor like [this](https://hobbyking.com/en_us/turnigy-aerodrive-sk3-5065-236kv-brushless-outrunner-motor.html) one, you should set `motor_mode` to `MOTOR_TYPE_HIGH_CURRENT`. For low-current gimbal motors like [this](https://hobbyking.com/en_us/turnigy-hd-5208-brushless-gimbal-motor-bldc.html) one, you should choose `MOTOR_TYPE_GIMBAL`. Do not use `MOTOR_TYPE_GIMBAL` on a motor that is not a gimbal motor, as it may overheat the motor or the ODrive.
|
||||
If you're using a regular hobby brushless motor like [this](https://hobbyking.com/en_us/turnigy-aerodrive-sk3-5065-236kv-brushless-outrunner-motor.html) one, you should set `motor_mode` to `MOTOR_TYPE_HIGH_CURRENT`. For low-current gimbal motors like [this](https://hobbyking.com/en_us/turnigy-hd-5208-brushless-gimbal-motor-bldc.html) one, you should choose `MOTOR_TYPE_GIMBAL`. Do not use `MOTOR_TYPE_GIMBAL` on a motor that is not a gimbal motor, as it may overheat the motor or the ODrive.
|
||||
|
||||
**Further detail:**
|
||||
If 100's of mA of current noise is "small" for you, you can choose `MOTOR_TYPE_HIGH_CURRENT`.
|
||||
If 100's of mA of current noise is "large" for you, and you do not intend to spin the motor very fast (omega * L << R), and the motor is fairly large resistance (1 ohm or larger), you can chose `MOTOR_TYPE_GIMBAL`.
|
||||
If 100's of mA current noise is "large" for you, _and_ you intend to spin the motor fast, then you need to replace the shunt resistors on the ODrive.
|
||||
**Further detail:**
|
||||
If 100's of mA of current noise is "small" for you, you can choose `MOTOR_TYPE_HIGH_CURRENT`.
|
||||
If 100's of mA of current noise is "large" for you, and you do not intend to spin the motor very fast (omega * L << R), and the motor is fairly large resistance (1 ohm or larger), you can chose `MOTOR_TYPE_GIMBAL`.
|
||||
If 100's of mA current noise is "large" for you, _and_ you intend to spin the motor fast, then you need to replace the shunt resistors on the ODrive.
|
||||
|
||||
</div></details>
|
||||
</div></details>
|
||||
|
||||
* _if using encoder_: `odrv0.axis0.encoder.config.cpr`: Encoder Count Per Revolution (CPR). This is 4x the Pulse Per Revolution (PPR) value. Usually this is indicated in the datasheet of your encoder.
|
||||
* _if not using encoder_:
|
||||
* If you wish to run in sensorless mode, please see [Setting up Sensorless](commands.md#setting-up-sensorless).
|
||||
* If you are using hall sensor feedback, please see the [hoverboard motor example](hoverboard.md).
|
||||
|
||||
* `odrv0.axis0.encoder.config.cpr`: Encoder Count Per Revolution (CPR). This is 4x the Pulse Per Revolution (PPR) value. Usually this is indicated in the datasheet of your encoder.
|
||||
|
||||
3. Save configuration. You can save all `.config` parameters to persistent memory such that the ODrive remembers them between power cycles.
|
||||
* `odrv0.save_configuration()` <kbd>Enter</kbd>
|
||||
@@ -203,19 +207,19 @@ Let's get motor 0 up and running. The procedure for motor 1 is exactly the same,
|
||||
|
||||
1. Type `odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE` <kbd>Enter</kbd>. After about 2 seconds should hear a beep. Then the motor will turn slowly in one direction for a few seconds, then back in the other direction.
|
||||
|
||||
<details><summary markdown="span">What's the point of this?</summary><div markdown="block">
|
||||
This procedure first measures your motor's electrical properties (namely phase resistance and phase inductance) and then the offset between the motor's electrical phase and the encoder position.
|
||||
</div></details>
|
||||
<details><summary markdown="span">What's the point of this?</summary><div markdown="block">
|
||||
This procedure first measures your motor's electrical properties (namely phase resistance and phase inductance) and then the offset between the motor's electrical phase and the encoder position.
|
||||
</div></details>
|
||||
|
||||
The startup procedure is demonstrated [here](https://www.youtube.com/watch?v=VCX1bA2xnuY).
|
||||
The startup procedure is demonstrated [here](https://www.youtube.com/watch?v=VCX1bA2xnuY).
|
||||
|
||||
**Note**: the rotor must be allowed to rotate without any biased load during startup. That means mass and weak friction loads are fine, but gravity or spring loads are not okay. Also note that in the video, the motors spin after initalisation, but in the current software the default behaviour is not like that.
|
||||
**Note**: the rotor must be allowed to rotate without any biased load during startup. That means mass and weak friction loads are fine, but gravity or spring loads are not okay. Also note that in the video, the motors spin after initalisation, but in the current software the default behaviour is not like that.
|
||||
|
||||
<details><summary markdown="span">Help, something isn't working!</summary><div markdown="block">
|
||||
Check the encoder wiring and that the encoder is firmly connected to the motor. Check the value of `hex(odrv0.axis0.error)` and then refer to the [error code documentation](troubleshooting.md#error-codes) for details.
|
||||
<details><summary markdown="span">Help, something isn't working!</summary><div markdown="block">
|
||||
Check the encoder wiring and that the encoder is firmly connected to the motor. Check the value of `hex(odrv0.axis0.error)` and then refer to the [error code documentation](troubleshooting.md#error-codes) for details.
|
||||
|
||||
Once you have understood the error and fixed its cause, you may clear the error state (`odrv0.axis0.error = 0` <kbd>Enter</kbd>) and retry. You may also need to clear the error state of other subcomponents (e.g. `odrv0.axis0.motor.error`).
|
||||
</div></details>
|
||||
Once you have understood the error and fixed its cause, you may clear the error state (`odrv0.axis0.error = 0` <kbd>Enter</kbd>) and retry. You may also need to clear the error state of other subcomponents (e.g. `odrv0.axis0.motor.error`).
|
||||
</div></details>
|
||||
|
||||
2. Type `odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL` <kbd>Enter</kbd>. From now on the ODrive will try to hold the motor's position. If you try to turn it by hand, it will fight you gently. That is unless you bump up `odrv0.axis0.motor.config.current_lim`, in which case it will fight you more fiercely.
|
||||
3. Send the motor a new position setpoint. `odrv0.axis0.controller.pos_setpoint = 10000` <kbd>Enter</kbd>. The units are in encoder counts.
|
||||
@@ -229,8 +233,8 @@ The ODrive also supports velocity control and current (torque) control.
|
||||
|
||||
You can now:
|
||||
|
||||
* See what other [commands and parameters](commands.md) are available, including setting tuning parameters for better performance.
|
||||
* Control the ODrive from your own program or hook it up to an existing system through one of it's [interfaces](interfaces).
|
||||
* See how you can improve the behavior during the startup procedure, like [bypassing encoder calibration](encoders.md#encoder-with-index-signal).
|
||||
* See what other [commands and parameters](commands.md) are available, including setting tuning parameters for better performance.
|
||||
* Control the ODrive from your own program or hook it up to an existing system through one of it's [interfaces](interfaces).
|
||||
* See how you can improve the behavior during the startup procedure, like [bypassing encoder calibration](encoders.md#encoder-with-index-signal).
|
||||
|
||||
If you have any issues or any questions please get in touch. The [ODrive Community](https://discourse.odriverobotics.com/) warmly welcomes you.
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
|
||||
# Hoverboard motor and remote control setup guide
|
||||
By popular request here follows a step-by-step guide on how to setup the ODrive to drive hoverboard motors using RC PWM input.
|
||||
Each step is acompanied by some explanation so hopefully you can carry over some of the steps to other setups and configurations.
|
||||
|
||||
[](https://www.youtube.com/watch?v=ponx_U4xhoM) <br> Click above to play video.
|
||||
|
||||
### Hoverboard motor configuration
|
||||
Standard 6.5 inch hoverboard hub motors have 30 permanent magnet poles, and thus 15 pole pairs. If you have a different motor you need to count the magnets or have a reliable datasheet for this information.
|
||||
```txt
|
||||
odrv0.axis0.motor.config.pole_pairs = 15
|
||||
```
|
||||
|
||||
Hoverboard hub motors are quite high resistance compared to the hobby aircraft motors, so we want to use a bit higher voltage for the motor calibration, and set up the current sense gain to be more sensitive.
|
||||
The motors are also fairly high inductance, so we need to reduce the bandwidth of the current controller from the default to keep it stable.
|
||||
```txt
|
||||
odrv0.axis0.motor.config.resistance_calib_max_voltage = 4
|
||||
odrv0.axis0.motor.config.requested_current_range = 25 #Requires config save and reboot
|
||||
odrv0.axis0.motor.set_current_control_bandwidth(100)
|
||||
```
|
||||
|
||||
Set the encoder to hall mode (instead of incremental). See the [pinout](interfaces.md#hall-feedback-pinout) for instructions on how to plug in the hall feedback.
|
||||
The hall feedback has 6 states for every pole pair in the motor. Since we have 15 pole pairs, we set the cpr to 15*6 = 90.
|
||||
```txt
|
||||
odrv0.axis0.encoder.config.mode = ENCODER_MODE_HALL
|
||||
odrv0.axis0.encoder.config.cpr = 90
|
||||
```
|
||||
|
||||
Since the hall feedback only has 90 counts per revolution, we want to reduce the velocity tracking bandwidth to get smoother velocity estimates.
|
||||
We can also set these fairly modest gains that will be a bit sloppy but shouldn't shake your rig apart if it's built poorly. Make sure to tune the gains up when you have everything else working to a stiffness that is applicable to your application.
|
||||
Lets also start in velocity control mode since that is probably what you want for a wheeled robot. Note that in velocity mode `pos_gain` isn't used but I have given you a recommended value anyway in case you wanted to run position control mode.
|
||||
```txt
|
||||
odrv0.axis0.encoder.config.bandwidth = 100
|
||||
odrv0.axis0.controller.config.pos_gain = 1
|
||||
odrv0.axis0.controller.config.vel_gain = 0.02
|
||||
odrv0.axis0.controller.config.vel_limit = 1000
|
||||
odrv0.axis0.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL
|
||||
```
|
||||
|
||||
In the next step we are going to start powering the motor and so we want to make sure that some of the above settings that requrie a reboot are applied first.
|
||||
```txt
|
||||
odrv0.save_configuration()
|
||||
odrv0.reboot()
|
||||
```
|
||||
|
||||
Make sure the motor is free to move, then activate the motor calibration.
|
||||
```txt
|
||||
odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION
|
||||
```
|
||||
|
||||
You can read out all the data pertaining to the motor:
|
||||
```txt
|
||||
odrv0.axis0.motor
|
||||
```
|
||||
|
||||
Check to see that there is no error and that the phase resistance and inductance are reasonable. Here are the results I got:
|
||||
```txt
|
||||
error = 0x0000 (int)
|
||||
phase_inductance = 0.00033594953129068017 (float)
|
||||
phase_resistance = 0.1793474406003952 (float)
|
||||
```
|
||||
|
||||
If all looks good then you can tell the ODrive that saving this calibration to presistent memory is OK:
|
||||
```txt
|
||||
odrv0.axis0.motor.config.pre_calibrated = True
|
||||
```
|
||||
|
||||
Next step is to check the alignment between the motor and the hall sensor.
|
||||
Because of this step you are allowed to plug the motor phases in random order and also the hall signals can be random. Just don't change it after calibration.
|
||||
Make sure the motor is free to move and run:
|
||||
```txt
|
||||
odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
|
||||
```
|
||||
|
||||
Check the status of the encoder object:
|
||||
```txt
|
||||
odrv0.axis0.encoder
|
||||
```
|
||||
|
||||
Check that there are no errors. If your hall sensors has a standard timing angle then `offset_float` should be close to 0.5.
|
||||
```txt
|
||||
error = 0x0000 (int)
|
||||
offset_float = 0.5126956701278687 (float)
|
||||
```
|
||||
|
||||
If all looks good then you can tell the ODrive that saving this calibration to presistent memory is OK:
|
||||
```txt
|
||||
odrv0.axis0.encoder.config.pre_calibrated = True
|
||||
```
|
||||
|
||||
OK, we are now done with the motor configuration! Time to save, reboot, and then test it.
|
||||
The ODrive starts in idle (we will look at changing this later) so we can enable closed loop control.
|
||||
```txt
|
||||
odrv0.save_configuration()
|
||||
odrv0.reboot()
|
||||
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
|
||||
odrv0.axis0.controller.vel_setpoint = 120
|
||||
# Your motor should spin here
|
||||
odrv0.axis0.controller.vel_setpoint = 0
|
||||
odrv0.axis0.requested_state = AXIS_STATE_IDLE
|
||||
```
|
||||
|
||||
Hopefully you got your motor to spin! Feel free to repeat all of the above for the other axis if appropriate.
|
||||
|
||||
### PWM input
|
||||
If you want to drive your hoverboard wheels around with an RC remote contro you can use the [RC PWM input](interfaces.md#rc-pwm-input). There is more information in that link.
|
||||
Lets use GPIO 3/4 for the velocity inputs so that we don't have to disable UART.
|
||||
Then let's map the full stick range of these inputs to some suitable velocity setpoint range.
|
||||
We also have to reboot to activate the PWM input.
|
||||
```txt
|
||||
odrv0.config.gpio3_pwm_mapping.min = -200
|
||||
odrv0.config.gpio3_pwm_mapping.max = 200
|
||||
odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._remote_attributes['vel_setpoint']
|
||||
|
||||
odrv0.config.gpio4_pwm_mapping.min = -200
|
||||
odrv0.config.gpio4_pwm_mapping.max = 200
|
||||
odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis1.controller._remote_attributes['vel_setpoint']
|
||||
|
||||
odrv0.save_configuration()
|
||||
odrv0.reboot()
|
||||
```
|
||||
|
||||
Now we can check that the sticks are writing to the velocity setpoint. Move the stick, print `vel_setpoint`, move to a different position, check again.
|
||||
```txt
|
||||
In [1]: odrv0.axis1.controller.vel_setpoint
|
||||
Out[1]: 0.1904754638671875
|
||||
|
||||
In [2]: odrv0.axis1.controller.vel_setpoint
|
||||
Out[2]: 0.1904754638671875
|
||||
|
||||
In [3]: odrv0.axis1.controller.vel_setpoint
|
||||
Out[3]: 28.152389526367188
|
||||
|
||||
In [4]: odrv0.axis1.controller.vel_setpoint
|
||||
Out[4]: 61.21905517578125
|
||||
|
||||
In [5]: odrv0.axis1.controller.vel_setpoint
|
||||
Out[5]: -52.990474700927734
|
||||
```
|
||||
|
||||
Ok, now we should be able to turn on the drive and control the wheels!
|
||||
```txt
|
||||
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
|
||||
odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
|
||||
```
|
||||
|
||||
### Automatic startup
|
||||
Try to reboot and then activate AXIS_STATE_CLOSED_LOOP_CONTROL on both axis. Check that everything is operational and works as expected.
|
||||
If so, you can now make the ODrive turn on the motor power automatically after booting. This is useful if you are going to be running the ODrive without a PC or other logic board.
|
||||
```txt
|
||||
odrv0.axis0.config.startup_closed_loop_control = True
|
||||
odrv0.axis1.config.startup_closed_loop_control = True
|
||||
odrv0.save_configuration()
|
||||
odrv0.reboot()
|
||||
```
|
||||
+25
-14
@@ -37,6 +37,26 @@ 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()`
|
||||
|
||||
### Hall feedback pinout
|
||||
When the encoder mode is set to hall feedback, the pinout on the encoder port is as follows:
|
||||
|
||||
| Label on ODrive | Hall feedback |
|
||||
|-----------------|---------------|
|
||||
| A | Hall A |
|
||||
| B | Hall B |
|
||||
| Z | Hall C |
|
||||
|
||||
## 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 +96,36 @@ 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 `<axis>.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 `<axis>.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).
|
||||
|
||||
<!--
|
||||
## RC PWM input
|
||||
|
||||
You can control the ODrive directly from an hobby RC receiver.
|
||||
|
||||
Up to 4 channels (GPIOs 1, 2, 3 and 4) can be used simultaneously if the respective pins are not assigned to other functions. Any of the numerical parameters that are writable from the ODrive Tool can be hooked up to a PWM input.
|
||||
Some GPIO pins can be used for PWM input, if they are not allocated to other functions. For example, you must disable the UART to use GPIO 1,2. See the [pin function priorities](#pin-function-priorities) for more detail.
|
||||
|
||||
Any of the numerical parameters that are writable from the ODrive Tool can be hooked up to a PWM input.
|
||||
As an example, we'll configure GPIO4 to control the angle of axis 0. We want the axis to move within a range of -1500 to 1500 encoder counts.
|
||||
|
||||
1. Make sure you're able control the axis 0 angle by writing to `odrv0.axis0.controller.pos_setpoint`. If you need help with this follow the [getting started guide](getting-started.md).
|
||||
2. It is recommended that you configure the ODrive such that axis 0 automatically goes operational after a reboot. You may have to set `odrv0.axis0.config.startup_encoder_offset_calibration` and `odrv0.axis0.config.startup_closed_loop_control` to `True`. The exact procedure may vary depending on what type of encoder you're using.
|
||||
2. If you want to control your ODrive with the PWM input without using anything else to activate the ODrive, you can configure the ODrive such that axis 0 automatically goes operational at startup. See [here](commands.md#startup-procedure) for more information.
|
||||
3. In ODrive Tool, configure the PWM input mapping
|
||||
```
|
||||
In [1]: odrv0.config.gpio4_pwm_mapping.min = -1500
|
||||
|
||||
In [2]: odrv0.config.gpio4_pwm_mapping.max = 1500
|
||||
|
||||
In [3]: odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis0.controller._remote_attributes['pos_setpoint']
|
||||
```
|
||||
Note: you can disable the input by setting `odrv0.config.gpio4_pwm_mapping.endpoint = None`
|
||||
4. Save the configuration and reboot
|
||||
```
|
||||
In [4]: odrv0.save_configuration()
|
||||
|
||||
In [5]: odrv0.reboot()
|
||||
```
|
||||
5. 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.
|
||||
|
||||
-->
|
||||
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.
|
||||
|
||||
+4
-4
@@ -3,13 +3,13 @@
|
||||
|
||||
Communicating with an ODrive consists of a series of endpoint operations.
|
||||
An endpoint can theoretically be any kind data serialized in any way.
|
||||
There is a default seralization implementation for POD types; for custom types
|
||||
you must (de)seralize yourself. In the future we may provide a default seralizer
|
||||
for stucts.
|
||||
There is a default serialization implementation for POD types; for custom types
|
||||
you must (de)serialize yourself. In the future we may provide a default serializer
|
||||
for structs.
|
||||
The available endpoints can be enumerated by reading the JSON from endpoint 0
|
||||
and can theoretically be different for each communication interface (they are not in practice).
|
||||
|
||||
Each endpoint operation can send bytes to one endpoint (referenced by it's ID)
|
||||
Each endpoint operation can send bytes to one endpoint (referenced by its ID)
|
||||
and at the same time receive bytes from the same endpoint. The semantics of
|
||||
these payloads are specific to each endpoint's type, the name of which is
|
||||
indicated in the JSON.
|
||||
|
||||
@@ -31,3 +31,6 @@ CTRL_MODE_VOLTAGE_CONTROL = 0
|
||||
CTRL_MODE_CURRENT_CONTROL = 1
|
||||
CTRL_MODE_VELOCITY_CONTROL = 2
|
||||
CTRL_MODE_POSITION_CONTROL = 3
|
||||
|
||||
ENCODER_MODE_INCREMENTAL = 0
|
||||
ENCODER_MODE_HALL = 1
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ code_generator_parser.add_argument("-o", "--output", type=argparse.FileType('w')
|
||||
help="path of the generated output")
|
||||
code_generator_parser.set_defaults(template = os.path.join(script_path, 'odrive_header_template.h.in'))
|
||||
|
||||
subparsers.add_parser('liveplotter', help="Upgrade the ODrive's Firmware")
|
||||
subparsers.add_parser('liveplotter', help="For plotting of odrive parameters (i.e. position) in real time")
|
||||
subparsers.add_parser('drv-status', help="Show status of the on-board DRV8301 chips (for debugging only)")
|
||||
subparsers.add_parser('rate-test', help="Estimate the average transmission bandwidth over USB")
|
||||
subparsers.add_parser('udev-setup', help="Linux only: Gives users on your system permission to access the ODrive by installing udev rules")
|
||||
|
||||
Reference in New Issue
Block a user