background image

Step 5.

The automatically generated STM32CubeMX project miss some peripheral configurations. The
following changes must be done:

Step 5a.

Reset configuration for PB0 (Reset_State option in drop-down list)

Step 5b.

Configure PF1 as GPIO_EXTI1 and label it “M1_ENCODER_Z”

Step 5c.

Configure PA15 as GPIO_Output and label it “RS485_DE”

Step 5d.

Configure PF0 as GPIO_Output and label it “LED”

Step 5e.

Configure the USART1 for asynchronous operation and map TX/RX to PB6/PB7 GPIOs. No
hardware flow control is required.
Details about configuration of the UART are shown in the following figures.

Figure 3. 

UART configuration panel (basic)

Figure 4. 

UART configuration panel (advanced)

Step 5f.

Configure one of the available timers as PWM no output for the MODBUS RTU timeout
management (by default TIM14).
It must be set in order to increment at a 50 μs rate (PSC = 2399 for 48 MHz clock).

UM2711

Starting from MotorControl Workbench project

UM2711

 - 

Rev 1

page 7/18

Содержание UM2711

Страница 1: ...se brushless servomotor solution consisting of the STSPIN32F0A control board and a maxon EC i 40 brushless DC motor Figure 1 EVALKIT ROBOT 1 Getting started with the STSW ROBOT 1 UM2711 User manual UM2711 Rev 1 April 2020 For further information contact your local STMicroelectronics sales office www st com ...

Страница 2: ... supported development toolchains IAR Embedded Workbench for ARM Keil microcontroller development kit STM32CubeIDE An SWD programmer debugger supporting the STM32F0 family such as the STLINK V3 from STMicroelectronics 1 The operating range of the control electronics is between 12 V and 45 V However the system provides best performance with a supply voltage of 36 V 20 UM2711 Hardware and software r...

Страница 3: ...itioning_LL folder containing the source code the CobeMX project file and the toolchains projects The source code sub folder structure is the following Drivers STM32 HAL and LL libraries and CMSIS drivers MCSDK_v5 4 3 Motor control Field Oriented Control middleware modbus MODBUS communication middleware Inc Application include files Src Application source files EWARM IAR Embedded Workbench V8 proj...

Страница 4: ...ol state machine MC_GetAlignmentStatusMotor1 Returns the status of the encoder alignment start up sequence MC_GetOccurredFaultsMotor1 Returns a bitfield showing the new faults detected by the motor control algorithm MC_AcknowledgeFaultMotor1 Acknowledge a Motor Control fault occurred during motor control enabling a new command execution 2 4 MB_API The MODBUS RTU API modbus mb_API c manages the dir...

Страница 5: ...task h Number of discrete inputs bits MB_FUNC_OTHER_REP_SLAVEID_ENABLED mbconfig h Enable Disable Report Slave ID function MB_FUNC_READ_INPUT_ENABLED mbconfig h Enable Disable read input register function MB_FUNC_READ_HOLDING_ENABLED mbconfig h Enable Disable read holding register function MB_FUNC_WRITE_HOLDING_ENABLED mbconfig h Enable Disable write holding register function MB_FUNC_WRITE_MULTIPL...

Страница 6: ... use the UPDATE function This option does not overwrite the STM32CubeMX project You can immediately open the output project for the target toolchain and jump to step 4 in Section 3 3 Some changes on the peripheral setup or a complete clean up of the project is needed use the GENERATE function and follow the steps below Step 4 After the code generation is completed click on Run STM32CubeMX UM2711 S...

Страница 7: ...abel it LED Step 5e Configure the USART1 for asynchronous operation and map TX RX to PB6 PB7 GPIOs No hardware flow control is required Details about configuration of the UART are shown in the following figures Figure 3 UART configuration panel basic Figure 4 UART configuration panel advanced Step 5f Configure one of the available timers as PWM no output for the MODBUS RTU timeout management by de...

Страница 8: ...Hz clock and with a period of 2 ms ARR 1999 Figure 6 TIM16 configuration panel Step 5h Enable interrupts for USART priority 3 and timers priority 2 From the code generation point of view select sequence ordering IRQ handler generation and HAL_Handler call for the timers For the USART only select sequence ordering and IRQ handler generation UM2711 Starting from MotorControl Workbench project UM2711...

Страница 9: ...Step 7 Click on Generate Code button Step 8 After the code generation is completed click on open project Step 9 Open the stm32f0xx_it c file and modify the empty interrupt handlers Step 10 Modify the IRQ_Handler of the MODBUS RTU Timeout timer as shown below Figure 9 MODBUS RTU timeout IRQ handler UM2711 Starting from MotorControl Workbench project UM2711 Rev 1 page 9 18 ...

Страница 10: ...scheduler timer as shown below Figure 10 MODBUS scheduler timer IRQ handler Step 12 Modify the IRQ_Handler of the UART interface as shown below Figure 11 UART IRQ handler UM2711 Starting from MotorControl Workbench project UM2711 Rev 1 page 10 18 ...

Страница 11: ...1_IRQHandler handler Step 14 Compile the project 3 3 Starting from STM32CubeMX project The package contains the STM32CubeMX project used for the code generation Using this project it is possible to modify the configuration of all the hardware NOT directly related to the motor control algorithm Note The configuration of the peripherals related to the motor control algorithm should be modified thoug...

Страница 12: ... secondary output OC_SEL internal STSPIN32F0A signal setting overcurrent protection mode PA0 PA1 PA2 unused GPIOs connected to the digital Hall effect sensors of the motor PA13 PA14 SWD interface pins using this pin for other functions disables the debug interface UART interface Not motor control timers TIM14 MODBUS timeout counter TIM16 MODBUS polling timer TIM2 unused timer also connected to the...

Страница 13: ... code generation has completed click on open project Step 4 Open stm32f0xx_mc_it c file and replace the automatically generated EXTI0_1_IRQHandler function with the custom on available in the USER CODE 1 section You can find it between the USER CODE BEGIN 1 and USER CODE END 1 comments at the end of the file as shown below Figure 14 Custom EXTI0_1_IRQHandler handler Step 5 Compile the project UM27...

Страница 14: ...Revision history Table 2 Document revision history Date Version Changes 07 Apr 2020 1 Initial release UM2711 UM2711 Rev 1 page 14 18 ...

Страница 15: ...lders structure 3 2 2 Main application code 3 2 3 MC_API 4 2 4 MB_API 4 3 Customization 5 3 1 MODBUS section customization 5 3 2 Starting from MotorControl Workbench project 5 3 3 Starting from STM32CubeMX project 11 Revision history 14 UM2711 Contents UM2711 Rev 1 page 15 18 ...

Страница 16: ...uration panel 8 Figure 7 NVIC configuration panel 9 Figure 8 NVIC configuration panel code generation 9 Figure 9 MODBUS RTU timeout IRQ handler 9 Figure 10 MODBUS scheduler timer IRQ handler 10 Figure 11 UART IRQ handler 10 Figure 12 Custom EXTI0_1_IRQHandler handler 11 Figure 13 STM32CubeMX project file pinout configuration 12 Figure 14 Custom EXTI0_1_IRQHandler handler 13 UM2711 List of figures ...

Страница 17: ...List of tables Table 1 MODBUS configuration parameters 5 Table 2 Document revision history 14 UM2711 List of tables UM2711 Rev 1 page 17 18 ...

Страница 18: ...cts and ST assumes no liability for application assistance or the design of Purchasers products No license express or implied to any intellectual property right is granted by ST herein Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product ST and the ST logo are trademarks of ST For additional information about S...

Отзывы: