13.3.18 与霍尔传感器的接口
运用高档操控定时器(TIM1或TIM8)发生PWM信号驱动马达时,能够用另一个通用TIMx(TIM2、TIM3、TIM4或TIM5)定时器作为“接口定时器”来衔接霍尔传感器,见图93,3个定时器输入脚(CC1、CC2、CC3)经过一个异或门衔接到TI1输入通道(经过设置TIMx_CR2寄存器中的TI1S位来挑选),“接口定时器”捕获这个信号。
从形式操控器被装备于复位形式,从输入是TI1F_ED。每逢3个输入之一改动时,计数器重新从0开端计数。这样发生一个由霍尔输入端的任何改动而触发的时刻基准。 “接口定时器”上的捕获/比较通道1装备为捕获形式,捕获信号为TRC(见图76)。捕获值反映了两个输入改动间的时刻延迟,给出了马达速度的信息。 “接口定时器”能够用来在输出形式发生一个脉冲,这个脉冲能够(经过触发一个COM事情)用于改动高档定时器TIM1或TIM8各个通道的特点,而高档操控定时器发生PWM信号驱动马达。因而“接口定时器”通道有必要编程为在一个指定的延时(输出比较或PWM形式)之后发生一个正脉冲,这个脉冲经过TRGO输出被送到高档操控定时器TIM1或TIM8。 举例:霍尔输入衔接到TIMx定时器,要求每次任一霍尔输入上发生改动之后的一个指定的时刻,改动高档操控定时器TIMx的PWM装备。
● 置TIMx_CR2寄存器的TI1S位为’1’,装备三个定时器输入逻辑或到TI1输入,
● 时基编程:置TIMx_ARR为其最大值(计数器有必要经过TI1的改动清零)。设置预分频器得到一个最大的计数器周期,它善于传感器上的两次改动的时刻距离。
● 设置通道1为捕获形式(选中TRC):置TIMx_CCMR1寄存器中CC1S=01,假如需求,还能够设置数字滤波器。
● 设置通道2为PWM2形式,并具有要求的延时:置TIMx_CCMR1寄存器中的OC2M=111和CC2S=00。
● 挑选OC2REF作为TRGO上的触发输出:置TIMx_CR2寄存器中的MMS=101。 在高档操控寄存器TIM1中,正确的ITR输入有必要是触发器输入,定时器被编程为发生PWM信号,捕获/比较操控信号为预装载的(TIMx_CR2寄存器中CCPC=1),一起触发输入操控COM事情(TIMx_CR2寄存器中CCUS=1)。在一次COM事情后,写入下一步的PWM操控位(CCxE、OCxM),这能够在处理OC2REF上升沿的中止子程序里完成。 下图显现了这个实例
无刷电机每工作一圈,霍尔有六个状况,在每个状况均会进入一次中止,
正常工作的时分电机是依照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
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
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.