cancel
Showing results for 
Search instead for 
Did you mean: 

2 Motors with STM32H755ZI

Zeno
Associate III

Hi, 

I managed to create a custom inverter board using STMC Board Designer which is basically 1 Nucleo-H755ZI-Q inverter and 2 times a IHM08M1 power board(see Other post about creating bridge ) . One of the 2 power boards is therefore connected to other pins of the Nucleo-H755ZI-Q in order for me to drive 2 motors independently. (included board below)

That all worked and I'm able to create a STMC Workbench project (included below) and configure the encoder, stages, etc. 

All goes well until I want to generate the code, from what I understand is that there are some bindings missing in the foc_assign.ftl templates. There's no support for M2_ADC listed which causes several files to be incomplete (mc_tasks.c and stm32h7xx_mc_it.c as far as I can tell). I've added the files with fault codes aswell. 

 

Could you guys help me create the correct .ftl files in order for me to generate the project for 2 motors for a STM32H755 MCU using the workbench? 

5 REPLIES 5
Zeno
Associate III

Managed to change some of the .ftl and .xml files in order to get the generation working properly. Could you guys check and verify if all is setup correctly and this would work? 

  • MotorControl_Configs.xml at ./MCSDK_v6.3.2-Full/MotorControl under the section for "stm32h7xx_mc_foc_it.c.ftl"
    • <Argument GenericType="simple" Name="M2_CS_ADC_PHASE_SHARED" />
    • <Argument GenericType="simple" Name="M2_CS_ADC_U" />
    • <Argument GenericType="simple" Name="M2_CS_ADC_V" />
  • stm32h7xx_mc_foc_it.c.ftl at ./MCSDK_v6.3.2-Full/MotorControl/templates
    • Added stuff for M2 similar to M1 using ChatGPT and reading it
    • Interrupt handling for current sensing topology
    • Brake Input 2 for M2 (BKIN2), BKIN for M1
    • DMA handler for Motor 2
  • foc_assign.ftl at ./MCSDK_v6.3.2-Full/MotorControl/ftl
    • Added stuff for M2 similar to M1, namely the current sensing topologies for STMH7
Zeno
Associate III

I'll add the whole MCSDK again because I needed to tune even more ftl files.

This seems to be compiling using CMake, I'm gonna go ahead and make the hardware connections now.

First goal is checking if the Motor Pilot can start each motor. 

Gael A
ST Employee

Hello Zeno,

I am sorry, I did not realise it the first time on your previous post, but Dual Drive control is not supported on STM32H7. The only supported MCUs are F3, G4 and F4.

As you may understand, we cannot provide support on such big modifications to our provided tools, although you seem to have understood the functioning of our generation process. Also, don't hesitate to keep posting your advancements on the forum, maybe other users will try to help you, or will benefit from your work. Thank you for your understanding, and good luck in your project.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.
Zeno
Associate III

Hi @Gael A , 

I understand that you guys focus on certain MCU's to get people started. We've selected the H755ZI-Q MCU to make sure we have some headroom for other features. 

Could you guys at least tell me that driving 2 motors with the M4 core on the H755ZI-Q could work? 
Could you check the ADC and timers settings just to give me a better feeling about setting it up as a dual drive (independent motor control)? 

 

At a later stage this would be me not using the Nucleo-H755ZI-Q but our own custom PCB with the H755ZI-Q MCU so my effort in understanding the code generation and what motor features are necessary is mandatory for our design process. 

I'm fairly new to the MCU world.

Zeno
Associate III

I'm getting really close to a working solution but need your input to make it work completely. 

 

The only thing failing now is the WB generating the ADC1 Current Sensing settings. It appears that my configuration would be incompatible because the .ioc.wb file (attached) now has 2 ADC1 current sensing settings and it appears that the entry for M2 wins the config:

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#                                           ADC1 settings for Current Sensing                                          #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
ADC1.EnableInjectedConversion=ENABLE

ADC1.InjectedConvMode=Discontinuous
ADC1.ExternalTrigInjecConv=ADC_EXTERNALTRIGINJEC_T1_TRGO
ADC1.ExternalTrigInjecConvEdge=ADC_EXTERNALTRIGINJECCONV_EDGE_RISING

ADC1.InjNumberOfConversion=2
ADC1.injectedQueueMode=DISABLE
ADC1.LeftBitShift=ADC_LEFTBITSHIFT_2
ADC1.InjectedLeftBitShift=ADC_LEFTBITSHIFT_2

# SAMPLING 1 --> M1 PHASE_U_CURR
ADC1.InjectedRank-1\#ChannelInjectedConversion=1
ADC1.InjectedChannel-1\#ChannelInjectedConversion=ADC_CHANNEL_16
ADC1.InjectedSamplingTime-1\#ChannelInjectedConversion=ADC_SAMPLETIME_8CYCLES_5
ADC1.InjectedOffsetNumber-1\#ChannelInjectedConversion=ADC_OFFSET_NONE
ADC1.InjectedOffset-1\#ChannelInjectedConversion=0

# SAMPLING 2 --> M1 PHASE_V_CURR
ADC1.InjectedRank-2\#ChannelInjectedConversion=2
ADC1.InjectedChannel-2\#ChannelInjectedConversion=ADC_CHANNEL_11
ADC1.InjectedSamplingTime-2\#ChannelInjectedConversion=ADC_SAMPLETIME_8CYCLES_5
ADC1.InjectedOffsetNumber-2\#ChannelInjectedConversion=ADC_OFFSET_NONE
ADC1.InjectedOffset-2\#ChannelInjectedConversion=0

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#                                           ADC1 settings for Current Sensing                                          #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
ADC1.EnableInjectedConversion=ENABLE

ADC1.InjectedConvMode=Discontinuous
ADC1.ExternalTrigInjecConv=ADC_EXTERNALTRIGINJEC_T8_TRGO
ADC1.ExternalTrigInjecConvEdge=ADC_EXTERNALTRIGINJECCONV_EDGE_RISING

ADC1.InjNumberOfConversion=2
ADC1.injectedQueueMode=DISABLE
ADC1.LeftBitShift=ADC_LEFTBITSHIFT_2
ADC1.InjectedLeftBitShift=ADC_LEFTBITSHIFT_2

# SAMPLING 1 --> M2 PHASE_U_CURR
ADC1.InjectedRank-1\#ChannelInjectedConversion=1
ADC1.InjectedChannel-1\#ChannelInjectedConversion=ADC_CHANNEL_2
ADC1.InjectedSamplingTime-1\#ChannelInjectedConversion=ADC_SAMPLETIME_8CYCLES_5
ADC1.InjectedOffsetNumber-1\#ChannelInjectedConversion=ADC_OFFSET_NONE
ADC1.InjectedOffset-1\#ChannelInjectedConversion=0

# SAMPLING 2 --> M2 PHASE_V_CURR
ADC1.InjectedRank-2\#ChannelInjectedConversion=2
ADC1.InjectedChannel-2\#ChannelInjectedConversion=ADC_CHANNEL_15
ADC1.InjectedSamplingTime-2\#ChannelInjectedConversion=ADC_SAMPLETIME_8CYCLES_5
ADC1.InjectedOffsetNumber-2\#ChannelInjectedConversion=ADC_OFFSET_NONE
ADC1.InjectedOffset-2\#ChannelInjectedConversion=0


My problem now is 2-fold: 

  1. Injected Channels ADC_CHANNEL_11 and ADC_CHANNEL_16 are not configured because the config for M2 is last in the file. This causes M1 to malfunction. Manually adjusting the injected channels and ADC1.ExternalTrigInjecConv to  ADC_EXTERNALTRIGINJEC_T1_TRGO makes M1 work.
  2. I wanted to configure TIM1 for M1 PWM + BKIN OCP and TIM8 for M2 PWM + BKIN2 OCP.
    ADC1 needs to sample M1_CURR_AMPL_UM1_CURR_AMPL_VM2_CURR_AMPL_UM2_CURR_AMPL_V. 
    It appears that the current sensing sampling on the injected channels depends on an External Trigger Source. (ADC1ADC_Injected_ConversionModeExternal Trigger Source). 
    And I can only select one trigger source there which is now Timer 1 Trigger Out Event

This works when running 1 motor but I'm afraid that the TIM8 BKIN2 will now never trigger the ADC1 sampling for M2

Is there a way to resolve this issue, manually adding the missing injected channels and perhaps changing the External Trigger Source to Injected Conversion launched by software start