stm32 Hall sensor interface

Publisher:calmrsLatest update time:2016-09-12 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
13.3.18 Interface with Hall Sensor

When using an advanced control timer (TIM1 or TIM8) to generate a PWM signal to drive a motor, another general TIMx (TIM2, TIM3, TIM4 or TIM5) timer can be used as an "interface timer" to connect the Hall sensor, as shown in Figure 93. The three timer input pins (CC1, CC2, CC3) are connected to the TI1 input channel through an XOR gate (selected by setting the TI1S bit in the TIMx_CR2 register), and the "interface timer" captures this signal.

The slave mode controller is configured in reset mode, the slave input is TI1F_ED. Every time one of the three inputs changes, the counter restarts from 0. This creates a time base that is triggered by any change on the Hall inputs. The capture/compare channel 1 on the "Interface Timer" is configured in capture mode, the capture signal is TRC (see Figure 76). The captured value reflects the time delay between two input changes, giving information about the motor speed. The "Interface Timer" can be used to generate a pulse in output mode, which can be used (by triggering a COM event) to change the properties of the various channels of the Advanced Timer TIM1 or TIM8, while the Advanced Control Timer generates a PWM signal to drive the motor. Therefore the "Interface Timer" channel must be programmed to generate a positive pulse after a specified delay (output compare or PWM mode), which is sent to the Advanced Control Timer TIM1 or TIM8 through the TRGO output. Example: The Hall inputs are connected to the TIMx timers, and it is required to change the PWM configuration of the Advanced Control Timer TIMx at a specified time after each change on any of the Hall inputs.

 ● Set the TI1S bit in the TIMx_CR2 register to '1' to configure the three timer inputs to be logically ORed to the TI1 input.

● Time base programming: Set TIMx_ARR to its maximum value (the counter must be cleared by a change in TI1). Set the prescaler to obtain a maximum counter period that is longer than the time interval between two changes on the sensor.

● Set channel 1 to capture mode (select TRC): Set CC1S=01 in the TIMx_CCMR1 register. If necessary, you can also set the digital filter.

 ● Set channel 2 to PWM2 mode with the required delay: Set OC2M=111 and CC2S=00 in the TIMx_CCMR1 register.

 ● Select OC2REF as the trigger output on TRGO: Set MMS=101 in the TIMx_CR2 register. In the advanced control register TIM1, the correct ITR input must be the trigger input, the timer is programmed to generate PWM signals, the capture/compare control signal is preloaded (CCPC=1 in the TIMx_CR2 register), and the trigger input controls the COM event (CCUS=1 in the TIMx_CR2 register). After a COM event, write the next PWM control bits (CCxE, OCxM), which can be implemented in the interrupt subroutine that handles the rising edge of OC2REF. The figure below shows this example

 

  stm32 Hall sensor interface - liuyunqian@yeah - Embedded Learning

  stm32 Hall sensor interface - liuyunqian@yeah - Embedded Learning
Each time the brushless motor runs a circle, the Hall has six states, and an interrupt will be entered in each state.
When the motor is running normally, it will follow 1, 3, 2, 6, 4, 5

http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=3764371&bbs_page_no=1&search_mode=1&search_text=hall&bbs_id=3020

  stm32 Hall sensor interface - liuyunqian@yeah - Embedded Learning

 

Setting up the system when using Hall-effect sensors
Hall-effect sensors are devices capable of sensing the polarity of the rotor’s magnetic field;
they provide a logic output, which is 0 or 1 depending on the magnetic pole they face and
thus, on the rotor position.
Typically, in a three-phase PM motor three Hall-effect sensors are used to feed back the
rotor position information. They are usually mechanically displaced by either 120° or 60° and
the presented firmware library was designed to support both possibilities. To set up the
PMSM FOC software library for use with three Hall sensors, simply modify the
stm32f10x_MCconf.h and MC_hall_param.h header files according to the indications given
in Section 4.1 and Section 4.4, respectively.
As shown in Figure 30, the typical waveforms can be visualized at the sensor outputs in
case of 60° and 120° displaced Hall sensors. More particularly, Figure 30 refers to an
electrical period (i.e. one mechanical revolution in case of one pole pair motor).
Figure 30. 60° and 120° displaced Hall sensor output waveforms

  stm32 Hall sensor interface - liuyunqian@yeah - Embedded Learning

Since the rotor position information they provide is absolute, there is no need for any initial
rotor prepositioning. Particular attention must be paid, however, when connecting the
sensors to the proper microcontroller inputs.
In fact, as stated in Section 3.11, this software library assumes that the positive rolling
direction is the rolling direction of a machine that is fed with a three-phase system of positive
sequence. In that case to properly work, the software library expects the Hall sensor signal
transitions to be in the sequence shown in Figure 30 for both 60° and 120° displaced Hall
sensors.
For these reasons, it is suggested to follow the instructions given below when connecting a
Hall-sensor equipped PM motor to your board:

1. Turn the rotor by hand in the direction assumed to be positive and look at the B-emf
induced on the three motor phases. For this purpose if the real neutral point is not
available, it can be reconstructed by means of three resistors for instance.
2. Connect the motor phases to the hardware respecting the positive sequence. Let
“Phase A”, “Phase B” and “Phase C” be the motor phases driven by TIM1_CH1,
TIM1_CH2 and TIM1_CH3, respectively (e.g. when using the MB459 board, a positive
sequence of the motor phases could be connected to J5 2,1 and 3).
3. Turn the rotor by hand in the direction assumed to be positive, look at the three Hall
sensor outputs (H1, H2 and H3) and connect them to the selected timer on channels 1,
2 and 3, respectively, making sure that the sequence shown in Figure 30 is respected.
4. Measure the delay in electrical degrees betweenthe maximum of the B-emf induced on
Phase Aandthe first rising edge of signal H1. Enter it in the MC_hall_param.h header
file (HALL_PHASE_SHIFT). For your convenience, an example with
HALL_PHASE_SHIFT equal to –90 °C is illustrated in Figure 31.

  stm32 Hall sensor interface - liuyunqian@yeah - Embedded Learning

Keywords:stm32 Reference address:stm32 Hall sensor interface

Previous article:Understanding of STM32 serial port
Next article:Detailed introduction and technical knowledge of STM32 microcontroller

Recommended ReadingLatest update time:2024-11-17 00:50

STM32 uses SWD default pins PA13 PA14
The day before yesterday, when I was developing a STM32 project, I encountered a problem that I wanted to use the STM32's SWD default pins PA13 or PA14. The MCU model used at the time was STM32F103VET6, which is a 100-pin MCU. So many pins should not be used in general applications. However, when drawing the schematic
[Microcontroller]
STM32 ADC learning
Configuring ADC 1. System clock definition: RCC_Configuration(); Contains:  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMAx, ENABLE); // Enable DMA clock RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADCx , ENABLE); // Enable ADC1 and GPIOC clock 2. Interrupt source configuration: NVIC_Configuration(); Example: { NVIC_InitTypeDef NV
[Microcontroller]
STM32 uses SysTick for accurate timing
SysTick is briefly mentioned in ST's data sheet but not in detail. Let's take a closer look here. Please correct any errors.   SysTick is located in NVIC. It is mainly used in the operating system, so we rarely use it normally, but we can use it to do simple delay, which is relatively accurate.   Then let's take a loo
[Microcontroller]
STM32 uses SysTick for accurate timing
STM32 ILI9341 drives TFTLCD (VII) LCD draws solid triangles, rectangles, circles
The last time we tested the straight line drawing function, we drew a hollow triangle using three straight lines. Today, let’s draw solid ones, namely a solid triangle, a solid rectangle, and a solid circle. 1. Solid triangle For a solid triangle, you can first draw any two sides, then us
[Microcontroller]
STM32 ILI9341 drives TFTLCD (VII) LCD draws solid triangles, rectangles, circles
STM32 Novice Growth Record---System Tick Timer (systick) Application
1. Systick Introduction      Systick is just a timer, but it is placed in NVIC. Its main purpose is to provide a hardware interrupt (called tick interrupt) to the operating system. Tick interrupt? Here is a brief explanation. When the operating system is running, it will also have a "heartbeat". It will work according
[Microcontroller]
STM32 Novice Growth Record---System Tick Timer (systick) Application
What is the difference between STM32 library functions EXTI_GetFlagStatus and EXTI_GetITStatus?
One is for getting status and the other is for getting interrupts. EXTI_GetFlagStatus simply reads the status of the interrupt flag, but does not necessarily respond to the interrupt (the EXT_IMR register masks the interrupt); while EXTI_GetITStatus, in addition to reading the interrupt flag, also checks whether the E
[Microcontroller]
Use Cubemx to port FatFs to stm32
In large storage, it is impossible to have no file system. You can't scan the storage from beginning to end every time you want to open a file. It's OK for a small storage of a few megabytes, but it's impossible to do so for a storage of several gigabytes or even terabytes. And with a file system, you can also manage
[Microcontroller]
Use Cubemx to port FatFs to stm32
STM32 CAN filter settings
It seems that many people still don't know how to set filters. It took me a long time to learn it. Let's first look at a register    CAN_TIxR (x=0~2) Send mailbox identification register Standard frame is 31~21 bits,    a total of 11 bits STID Extended frame is 20~3 bits,     a total of 29 bits EXID +STID 0~
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号