Complementary output and dead zone insertion of stm32

Publisher:莫愁前路Latest update time:2018-06-29 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

Dead zone, simple explanation: Usually, high-power motors, inverters, etc., are all H-bridges or 3-phase bridges composed of high-power tubes, IGBTs and other components at the end. The upper and lower bridges of each bridge must not be turned on at the same time, but when the high-speed PWM drive signal reaches the control pole of the power component, it often produces a delay effect due to various reasons, causing a half-bridge component to not turn off when it should be turned off, causing the power component to burn out. The dead zone is to delay for a period of time after the upper half bridge is turned off before turning on the lower half bridge, or to delay for a period of time after the lower half bridge is turned off before turning on the upper half bridge, so as to avoid the power component from burning out. This delay time is the dead zone. (That is, the components of the upper and lower half bridges are all turned off) Dead zone time control is not available in the PWM equipped with ordinary low-end microcontrollers.
The transistors of the upper and lower bridge arms of the PWM cannot be turned on at the same time. If they are turned on at the same time, the two ends of the power supply will be short-circuited. Therefore, the two trigger signals must disconnect the transistors for a period of time. This area is called the "dead zone" and the advantages are needless to say. The disadvantage is that the harmonic content increases.

Only the advanced timer of stm32 has the function of dead zone control. For example, the dead zone time can be adjusted when CH1 and CH1N of TIM1 output PWM waves.

2. Dead zone test

Use CH1 and CH1N of TIM1 to output two PWM waves, with a period of 300us, a duty cycle of 1/3, and a dead time of 0xFF. The waveform to be achieved is as shown in the figure below:



3. Implementation method

The configuration process in cube is as follows:




For convenience, set the polarity of the two PWM waves to high.

The code is implemented as follows:

HCLK= 48MHZ

/* TIM1 init function */

static void MX_TIM1_Init(void)

{

 

  TIM_MasterConfigTypeDef sMasterConfig;

  TIM_OC_InitTypeDef sConfigOC;

  TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig;

 

  htim1.Instance = TIM1;

  htim1.Init.Prescaler = 48-1;

  htim1.Init.CounterMode = TIM_COUNTERMODE_UP;

  htim1.Init.Period = 300-1;

  htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

  htim1.Init.RepetitionCounter = 0;

  htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

  if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)

  {

    Error_Handler();

  }

 

  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;

  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;

  if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)

  {

    Error_Handler();

  }

 

  sConfigOC.OCMode = TIM_OCMODE_PWM1;

  sConfigOC.Pulse = 100;

  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;

  sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;

  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;

  sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;

  sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;

  if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)

  {

    Error_Handler();

  }

 

  sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_ENABLE;

  sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_ENABLE;

  sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;

  sBreakDeadTimeConfig.DeadTime = 0xFF;

  sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;

  sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;

  sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_ENABLE;

  if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)

  {

    Error_Handler();

  }

 

  HAL_TIM_MspPostInit(&htim1);

 

}

Turn on complementary PWM wave output in the main function:


HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);



4. Calculation method of dead time

Brake and dead zone dead time control register TIM1->BDTR




8*(1/72M)*(32 + DTG) = 5us

DTG=13

DTG[7:5]=110

DTG[4:0]=01011

DTG[7:0]=11001011=0xCD

The upper three positions can be set according to your needs, and different gears can be selected


Keywords:stm32 Reference address:Complementary output and dead zone insertion of stm32

Previous article:The concept of dead zone in the advanced timer of STM32
Next article:STM32F051 brake function problems and solutions

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号