CN117909684A - A motor motion direction recognition method based on dual Hall sensors - Google Patents

A motor motion direction recognition method based on dual Hall sensors Download PDF

Info

Publication number
CN117909684A
CN117909684A CN202410046976.6A CN202410046976A CN117909684A CN 117909684 A CN117909684 A CN 117909684A CN 202410046976 A CN202410046976 A CN 202410046976A CN 117909684 A CN117909684 A CN 117909684A
Authority
CN
China
Prior art keywords
motor
value
hall
values
motor speed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410046976.6A
Other languages
Chinese (zh)
Inventor
刘建国
张家毅
陈坤淇
杜丙强
刘玉普
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan University of Technology WUT
Original Assignee
Wuhan University of Technology WUT
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan University of Technology WUT filed Critical Wuhan University of Technology WUT
Priority to CN202410046976.6A priority Critical patent/CN117909684A/en
Publication of CN117909684A publication Critical patent/CN117909684A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01PMEASURING LINEAR OR ANGULAR SPEED, ACCELERATION, DECELERATION, OR SHOCK; INDICATING PRESENCE, ABSENCE, OR DIRECTION, OF MOVEMENT
    • G01P13/00Indicating or recording presence, absence, or direction, of movement
    • G01P13/02Indicating direction only, e.g. by weather vane
    • G01P13/04Indicating positive or negative direction of a linear movement or clockwise or anti-clockwise direction of a rotational movement
    • G01P13/045Indicating positive or negative direction of a linear movement or clockwise or anti-clockwise direction of a rotational movement with speed indication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/213Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2218/00Aspects of pattern recognition specially adapted for signal processing
    • G06F2218/08Feature extraction

Landscapes

  • Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Artificial Intelligence (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Control Of Motors That Do Not Use Commutators (AREA)

Abstract

本发明公开了一种基于双霍尔传感器的电机运动方向识别方法,包括以下步骤:持续读取输入的两路霍尔脉冲信号的方波值,将同一时刻的两路霍尔脉冲信号的方波值按照一定顺序排列和组合,并将组合后的方波值转化为二进制数值;将转化得到的二进制数值记作Hallstate,并引入一个对应a种二进制数值的数组HALLDX[a],该数组长度为a,该数组内包含的a个数值与二进制数值对应;将二进制数值作为下标代入数组中,得到一个数值;将数值减去历史值,并将两者的差值记作temp_hall;根据temp_hall的值判断电机为正转或反转,当电机正常运转且运转方向不变时,电机正转和反转得到的数值temp_hall均预设为个,共计a个数值且数值大小均不相同。本发明精度高具有较强的抗干扰能力、准确性和适应性。

The invention discloses a motor movement direction identification method based on a dual Hall sensor, comprising the following steps: continuously reading square wave values of two Hall pulse signals inputted, arranging and combining the square wave values of the two Hall pulse signals at the same time in a certain order, and converting the combined square wave values into binary values; recording the converted binary values as Hallstate, and introducing an array HALLDX[a] corresponding to a kinds of binary values, the length of the array is a, and the a values contained in the array correspond to the binary values; substituting the binary values into the array as subscripts to obtain a value; subtracting a historical value from the value, and recording the difference between the two as temp_hall; judging whether the motor is forward or reverse according to the value of temp_hall, when the motor is running normally and the running direction remains unchanged, the values temp_hall obtained by the forward and reverse rotation of the motor are both preset as The invention has high precision, strong anti-interference ability, accuracy and adaptability.

Description

一种基于双霍尔传感器的电机运动方向识别方法A method for identifying motor movement direction based on dual Hall sensors

技术领域Technical Field

本发明属于汽车电子领域,具体涉及一种基于双霍尔传感器的电机运动方向识别方法。The invention belongs to the field of automotive electronics, and in particular relates to a method for identifying the movement direction of a motor based on dual Hall sensors.

背景技术Background technique

随着汽车传感器的广泛使用,霍尔传感器也逐渐运用到了汽车上,而霍尔传感器最常见的就是和电机一起使用,搭配成带有霍尔传感器的驱动电机。双霍尔传感器电机作为霍尔电机的一种,具有较好的稳定性,在电机转速过快时也不会丢失信号,因此在汽车上的使用也十分普遍,最常见的就是车上的车窗玻璃和天窗玻璃,大多数都是使用双霍尔传感器电机驱动。在仿真阶段,往往需要对霍尔信号进行处理,来得到电机的转速和运动状态。With the widespread use of automotive sensors, Hall sensors are also gradually used in automobiles. The most common use of Hall sensors is to be used together with motors to form drive motors with Hall sensors. As a type of Hall motor, the dual Hall sensor motor has good stability and will not lose the signal when the motor speed is too fast. Therefore, it is also very common in automobiles. The most common ones are car windows and sunroofs, most of which are driven by dual Hall sensor motors. In the simulation stage, it is often necessary to process the Hall signal to obtain the motor speed and motion state.

目前传统的算法很多都是直接根据电机旋转方向不同,输出的双霍尔信号位置不同来判断电机的运动方向,这种方法优点是算法其抗干扰能力很弱,一旦出现干扰会导致输出的霍尔波形不完整,就会出现判断错误的情况。At present, many traditional algorithms directly judge the direction of movement of the motor based on the different rotation directions of the motor and the different positions of the output dual Hall signals. The advantage of this method is that the algorithm has weak anti-interference ability. Once interference occurs, the output Hall waveform will be incomplete, which will lead to incorrect judgment.

发明内容Summary of the invention

本发明的目的在于,提供一种基于双霍尔传感器的电机运动方向识别方法,不仅考虑到电机特性,还充分发挥了双霍尔传感器的优势,精度高具有较强的抗干扰能力、准确性和适应性,同时可以将此方法拓展到其他领域。The purpose of the present invention is to provide a method for identifying the movement direction of a motor based on a dual Hall sensor, which not only takes into account the characteristics of the motor, but also gives full play to the advantages of the dual Hall sensor, has high precision, strong anti-interference ability, accuracy and adaptability, and can also be expanded to other fields.

为解决上述技术问题,本发明的技术方案为:一种基于双霍尔传感器的电机运动方向识别方法,包括以下步骤:To solve the above technical problems, the technical solution of the present invention is: a method for identifying the movement direction of a motor based on a dual Hall sensor, comprising the following steps:

S100、持续读取输入的两路霍尔脉冲信号的方波值,将同一时刻的两路霍尔脉冲信号的方波值按照一定顺序排列和组合,并将组合后的方波值转化为二进制数值;其中,在一个周期内转化得到的二进制数值为a种,且按照一定规律进行排列循环,a为大于或等于4的正偶数;S100, continuously reading the square wave values of the two Hall pulse signals input, arranging and combining the square wave values of the two Hall pulse signals at the same time in a certain order, and converting the combined square wave values into binary values; wherein the binary values converted in one cycle are a kinds, and are arranged and circulated according to a certain rule, and a is a positive even number greater than or equal to 4;

S200、将转化得到的二进制数值记作Hallstate,并引入一个对应a种二进制数值的数组HALLDX[a],该数组长度为a,该数组内包含的a个数值与二进制数值对应;将二进制数值作为下标代入数组中,得到一个数值记为HALLDX[Hallstate];S200, the converted binary value is recorded as Hallstate, and an array HALLDX[a] corresponding to a binary value is introduced, the length of the array is a, and the a values contained in the array correspond to the binary value; the binary value is substituted into the array as a subscript to obtain a value recorded as HALLDX[Hallstate];

S300、将HALLDX[Hallstate]减去历史值HALLDX[Hallstatelast],并将两者的差值记作temp_hall;其中,历史值HALLDX[Hallstatelast]为上一个周期中计算得到的HALLDX[Hallstate];S300, subtract the historical value HALLDX[Hallstatelast] from HALLDX[Hallstate], and record the difference between the two as temp_hall; wherein the historical value HALLDX[Hallstatelast] is the HALLDX[Hallstate] calculated in the previous cycle;

S400、根据temp_hall的数值判断电机为正转或反转,当电机正常运转且运转方向不变时,电机正转和反转得到的数值temp_hall均预设为个,共计a个数值且数值大小均不相同。S400, judging whether the motor is rotating forward or reverse according to the value of temp_hall. When the motor is running normally and the direction of rotation remains unchanged, the values of temp_hall obtained when the motor is rotating forward and reverse are both preset to There are a total of a values, and the values are all different.

还包括以下步骤:The following steps are also included:

S500、当temp_hall的数值为0时,对预设计时器的计数值进行判断,当计时器的计数值小于预设阈值时,计数值加1,跳转至S700;当计时器的数值大于预设阈值时,判断电机停转,跳转至S700;S500, when the value of temp_hall is 0, the count value of the preset timer is judged. When the count value of the timer is less than the preset threshold, the count value is increased by 1, and the process jumps to S700; when the value of the timer is greater than the preset threshold, the motor is judged to be stopped, and the process jumps to S700;

S600、当temp_hall的数值不为电机正转和反转得到的预设a个数值或0时,对Hallerror值进行判断,当Hallerror值小于预设错误阈值时,Hallerror值加1,并跳转至S700;当Hallerror值大于预设错误阈值时,发送报错信号,结束本方法;其中,Hallerror为Hall错误标志,当判断电机异常状态时对该变量进行调用,根据其值与预设错误阈值进行比较,得到电机是否处于异常状态;S600, when the value of temp_hall is not a preset a value or 0 obtained by the forward and reverse rotation of the motor, the Hallerror value is judged, and when the Hallerror value is less than the preset error threshold, the Hallerror value is increased by 1, and the method is jumped to S700; when the Hallerror value is greater than the preset error threshold, an error signal is sent to end the method; wherein, Hallerror is a Hall error flag, and when it is judged that the motor is in an abnormal state, the variable is called, and its value is compared with the preset error threshold to determine whether the motor is in an abnormal state;

S700、将Hallstate的值赋给Hallstatelast,并跳转至S100进行下一个周期的计算。S700, assign the value of Hallstate to Hallstatelast, and jump to S100 to perform calculation of the next cycle.

还包括以下步骤:The following steps are also included:

S800、根据霍尔脉冲信号计算电机转速,计算方法为:S800, calculate the motor speed according to the Hall pulse signal, the calculation method is:

其中,n为电机转速,t为时间间隔,s为在时间间隔t内读取的霍尔脉冲数量。Where n is the motor speed, t is the time interval, and s is the number of Hall pulses read within the time interval t.

还包括以下步骤:The following steps are also included:

S900、计算电机运行过程中的换向电流,其计算方法为:S900, calculate the commutation current during the operation of the motor, and the calculation method is:

其中,ia为电刷与换向片之间无换向时的电枢电流,t0为进行换向所需时间,Tk为换向时间周期,er为换向元件的电抗电势,ew为换向外界的感应电势,换向元件包括第一换向片和第二换向片,r1、r2分别为第一换向片、第二换向片与电刷的接触电阻。Wherein, ia is the armature current when there is no commutation between the brush and the commutator segment, t0 is the time required for commutation, Tk is the commutation time period, er is the reactance potential of the commutation element, ew is the induced potential of the commutation environment, the commutation element includes the first commutator segment and the second commutator segment, r1 and r2 are the contact resistances of the first commutator segment, the second commutator segment and the brush respectively.

还包括以下步骤:The following steps are also included:

S1000、在电机的电流发生换向时产生一个高频分量称为电流换向脉动频率,电流脉动频率与电机转速存在以下关系:S1000, when the current of the motor is commutated, a high-frequency component is generated, which is called the current commutation pulsation frequency. The current pulsation frequency has the following relationship with the motor speed:

其中,f为电流脉冲频率,k为换向器片数,n为通过霍尔传感器得到的电机转速;Among them, f is the current pulse frequency, k is the number of commutator segments, and n is the motor speed obtained by the Hall sensor;

电流纹波经过调理电路得到类似霍尔脉冲的方波,通过该方波得到电流纹波周期T,并计算得到通过电流纹波计算得到的电机转速w,计算方法为:The current ripple is conditioned by the circuit to obtain a square wave similar to the Hall pulse. The current ripple period T is obtained through the square wave, and the motor speed w calculated by the current ripple is calculated as follows:

还包括以下步骤:The following steps are also included:

S1100、当电机的运转方向改变时,由于电机内部的惯性作用和负载惯性,电机需要一定时间来完成反向转动。S1100: When the running direction of the motor changes, due to the inertia inside the motor and the inertia of the load, the motor needs a certain amount of time to complete the reverse rotation.

还包括以下步骤:The following steps are also included:

S1200、对电机的转速数据进行采集,S1000中通过电流纹波计算得到的电机转速w和通过霍尔传感器得到的电机转速n,两者在实际采集过程中电机最大转速nmax是确定的,根据电机最大转速nmax对两者中的异常数据进行剔除;其中,对电机的转速数据的采集周期与霍尔脉冲信号的采集周期一致。S1200, collecting the speed data of the motor. The motor speed w obtained by current ripple calculation in S1000 and the motor speed n obtained by the Hall sensor, both of which have a maximum motor speed n max determined during the actual collection process, and the abnormal data in the two are eliminated according to the maximum motor speed n max ; wherein, the collection period of the motor speed data is consistent with the collection period of the Hall pulse signal.

还包括以下步骤:The following steps are also included:

S1300、将采集得到的电机转速数据以四个为一组进行存储,并分别计算得到各组数据的电机平均转速值。S1300, storing the collected motor speed data in groups of four, and calculating the average motor speed value of each group of data.

还包括以下步骤:The following steps are also included:

S1400、设置误差阈值,对同一周期内通过电流纹波计算得到的电机转速和通过霍尔传感器得到的电机转速对应的各组数据之间作差并对结果取绝对值,表示为:S1400, setting an error threshold, making a difference between the motor speed calculated by the current ripple and the motor speed obtained by the Hall sensor in the same cycle, and taking the absolute value of the result, expressed as:

np=|n-w|n p =|nw|

其中,n为通过霍尔传感器得到的某组数据的电机平均转速值,w为与n对应的通过电流纹波计算得到的该组数据的电机平均转速值,np为两者作差结果的绝对值;Where n is the average motor speed value of a set of data obtained by the Hall sensor, w is the average motor speed value of the set of data corresponding to n obtained by current ripple calculation, and np is the absolute value of the difference between the two;

根据各组两者作差结果的绝对值与误差阈值进行比较,判断两者的误差大小。The absolute value of the difference between the two groups is compared with the error threshold to determine the size of the error between the two.

一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述任一项所述方法的步骤。A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the methods described above.

与现有技术相比,本发明的有益效果为:Compared with the prior art, the present invention has the following beneficial effects:

本发明在保证较高的准确性且算法结构简单稳定的情况下,具有较强的抗干扰能力,在霍尔信号产生波动时,不会影响算法本身的准确性,提高了系统整体的可靠性与鲁棒性。The present invention has a strong anti-interference ability while ensuring high accuracy and a simple and stable algorithm structure. When the Hall signal fluctuates, it will not affect the accuracy of the algorithm itself, thereby improving the overall reliability and robustness of the system.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本发明实施例的流程示意图;FIG1 is a schematic diagram of a flow chart of an embodiment of the present invention;

图2为本发明实施例中电机顺时针旋转示意简图和对应的双路霍尔信号方波图;FIG2 is a schematic diagram of the clockwise rotation of a motor and a corresponding square wave diagram of a dual-path Hall signal in an embodiment of the present invention;

图3为本发明实施例中电机逆时针旋转示意简图和对应的双路霍尔信号方波图;3 is a schematic diagram of the counterclockwise rotation of the motor and a corresponding square wave diagram of the dual-path Hall signal in an embodiment of the present invention;

图4为本发明实施例中特殊时刻两路霍尔信号方波值和转化成的二进制数图;FIG4 is a diagram showing the square wave values of two Hall signals and the converted binary numbers at a specific moment in an embodiment of the present invention;

图5为本发明实施例中不同时刻的差值temp_hall计算图;FIG5 is a calculation diagram of the difference temp_hall at different times in an embodiment of the present invention;

图6为本发明实施例中电机与换向片连接的结构示意图;6 is a schematic diagram of the structure of the connection between the motor and the commutator segment according to an embodiment of the present invention;

图7为本发明实施例中电机换向电流生成的原理示意图。FIG. 7 is a schematic diagram showing the principle of generating motor commutation current in an embodiment of the present invention.

具体实施方式Detailed ways

为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。此外,下面所描述的本发明各个实施方式中所涉及到的技术特征只要彼此之间未构成冲突就可以相互组合。In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

本发明实施例的技术方案为:一种基于双霍尔传感器的电机运动方向识别方法,包括以下步骤:The technical solution of the embodiment of the present invention is: a method for identifying the movement direction of a motor based on a dual Hall sensor, comprising the following steps:

步骤100,如图1所示,首先持续读取输入的两路霍尔脉冲信号的方波值,将同一时刻的两路霍尔信号的方波值按照一定顺序排列,例如将第一路霍尔信号的方波值排在前面,将第二路霍尔信号的方波值排在后面,例:01并且按照此顺序将值转化成二进制数值,转化后值为1,记为数值b。Step 100, as shown in FIG1, first continuously read the square wave values of the two input Hall pulse signals, and arrange the square wave values of the two Hall signals at the same time in a certain order, such as arranging the square wave value of the first Hall signal in front and the square wave value of the second Hall signal in the back, for example: 01 and convert the values into binary values in this order, the converted value is 1, recorded as value b.

步骤200,将数值b的值赋给Hallstate,本实施例中以数组的长度为4举例,引入一个数组HALLDX[4],长度为4。当电机运动方向不变时,在一个周期内,在步骤100中得到的二进制数只有4种,且按照一定规律排序循环,因此根据需要在数组中设置4个合适的数,将二进制数作为下标带入数组中,得到一个数,HALLDX[Hallstate]。Step 200, assign the value of value b to Hallstate. In this embodiment, an array length of 4 is taken as an example, and an array HALLDX[4] is introduced with a length of 4. When the motor movement direction remains unchanged, in one cycle, there are only 4 kinds of binary numbers obtained in step 100, and they are arranged and circulated according to a certain rule. Therefore, 4 appropriate numbers are set in the array as needed, and the binary number is brought into the array as a subscript to obtain a number, HALLDX[Hallstate].

步骤300,将步骤300中得到的数值HALLDX[Hallstate]减去上一次进入方法的数值HALLDX[Hallstatelast],得到的值赋给temp_hall。Step 300, subtract the value HALLDX[Hallstatelast] obtained in the last method entry from the value HALLDX[Hallstate] obtained in step 300, and assign the obtained value to temp_hall.

步骤400,当电机运动正常运转且方向不变,且数组HALLDX[4]中选择的数值适当时,运用这种方法做差得到的数值temp_hall只有2种情况,即在电机正转时,得到的差值为p或q(分别对应电机正转得到的预设2个数值),在电机反转时得到的差值为m或n(分别对应电机反转得到的预设2个数值)。Step 400, when the motor is running normally and the direction is unchanged, and the value selected in the array HALLDX[4] is appropriate, there are only two cases for the value temp_hall obtained by using this method to make the difference, that is, when the motor is rotating forward, the difference value obtained is p or q (corresponding to the two preset values obtained when the motor is rotating forward), and when the motor is rotating reversely, the difference value obtained is m or n (corresponding to the two preset values obtained when the motor is rotating reversely).

步骤500,当差值为0时,需要继续进行判断,当差值为0时,stop计数加1,当stop超出阈值时,判断电机停转。方法是每64us运行一次,在一段时间内采集的两路霍尔信号值相同,设置一个阈值,当差值temp_hall为0的次数stop没有超过阈值时,stop加1,进行下一步;当stop大于阈值时,则判断电机处于停止状态,继续下一步骤。Step 500, when the difference is 0, it is necessary to continue to judge. When the difference is 0, the stop count is increased by 1. When the stop exceeds the threshold, it is judged that the motor has stopped. The method is to run once every 64us. The two Hall signal values collected within a period of time are the same. A threshold is set. When the number of stop times when the difference temp_hall is 0 does not exceed the threshold, stop is increased by 1 and the next step is performed; when stop is greater than the threshold, it is judged that the motor is in a stopped state and the next step is performed.

步骤600,当得到的差值temp_hall不等于p,q,m,n或0时,则可能是出现霍尔方波错误或者是由于存在信号干扰使方波出现波动,当出现这种情况时,判断Hallerror值是否大于设定的阈值,当小于阈值时,则Hallerror加1,继续下一步骤;当超过阈值时,则发送报错信号,跳出方法。Step 600, when the obtained difference temp_hall is not equal to p, q, m, n or 0, it may be that a Hall square wave error occurs or the square wave fluctuates due to signal interference. When this happens, determine whether the Hallerror value is greater than the set threshold. When it is less than the threshold, Hallerror is increased by 1 and the next step is continued; when it exceeds the threshold, an error signal is sent and the method is exited.

步骤700,当电机没有报错时,将Hallstate的值赋给Hallstatelast,返回步骤100重新进行运算。Step 700, when the motor has no error, assign the value of Hallstate to Hallstatelast, and return to step 100 to perform the calculation again.

当电机正常运转时,如图2和图3所示,图2为电机顺时针转动时的示意简图,图2右侧为两个周期的双霍尔信号方波示意图;图3为电机逆时针转动的示意简图和两个周期的霍尔脉冲信号方波,图2和图3分别截取了两个周期的8个时刻不同的两路霍尔信号方波值,从t1到t8,t1’到t8’。When the motor is operating normally, as shown in Figures 2 and 3, Figure 2 is a schematic diagram of the motor rotating clockwise, and the right side of Figure 2 is a schematic diagram of two cycles of dual Hall signal square waves; Figure 3 is a schematic diagram of the motor rotating counterclockwise and two cycles of Hall pulse signal square waves. Figures 2 and 3 respectively capture two different Hall signal square wave values at 8 moments in two cycles, from t1 to t8 , and t1 ' to t8 '.

根据取得的值转化为二进制数,如图4所示,得到的二进制数按照一定的规律排序,电机顺时针旋转时,二进制数a:0,1,3,2,0,1,3,2;电机逆时针旋转时,二进制数a’:2,3,1,0,2,3,1,0。分别按照两种顺序进行排序。According to the obtained value converted into a binary number, as shown in Figure 4, the obtained binary number is sorted according to a certain rule. When the motor rotates clockwise, the binary number a is: 0, 1, 3, 2, 0, 1, 3, 2; when the motor rotates counterclockwise, the binary number a' is: 2, 3, 1, 0, 2, 3, 1, 0. Sorting is performed in two orders respectively.

此时设置数组HALLDX[4]的数值,每个二进制数对应数组中的一个值,做差后得到需要的temp_hall数值,例如设置数组为HALLDX[4]=[0,1,3,2]。当电机顺时针转动时,将这组二进制数a带入数组,得到的数值为0,1,2,3,0,1,2,3,相邻两数做差,用后一个数减去前一个数,得到的差值temp_hall分别为:1、1、1、-3、1、1、1,得到的数值只有1和-3,之后按照这个规律一直循环。同样,电机逆时针旋转时可以得到,将a’带入数组HALLDX[4],可以得到一组数为:3,2,1,0,3,2,1,0。同样做差可以得到差值temp_hall为-1、-1、-1、3、-1、-1、-1,得到的数值只有-1和3。At this time, set the value of array HALLDX[4], each binary number corresponds to a value in the array, and the required temp_hall value is obtained after subtraction. For example, set the array to HALLDX[4] = [0,1,3,2]. When the motor rotates clockwise, this set of binary numbers a is put into the array, and the values obtained are 0, 1, 2, 3, 0, 1, 2, 3. The difference between two adjacent numbers is subtracted from the previous number by the latter number. The difference temp_hall obtained is: 1, 1, 1, -3, 1, 1, 1. The values obtained are only 1 and -3. Then, it will be cycled according to this rule. Similarly, when the motor rotates counterclockwise, it can be obtained that a' is put into array HALLDX[4], and a set of numbers can be obtained: 3, 2, 1, 0, 3, 2, 1, 0. Similarly, the difference temp_hall can be obtained as -1, -1, -1, 3, -1, -1, -1, and the values obtained are only -1 and 3.

步骤800,读取霍尔脉冲信号,并计算电机转速,计算公式如下:其中n为电机转速,s为在t时间内读取的霍尔脉冲数量,t为时间间隔(单位秒),乘60将转速从每秒的脉冲数转换为每分钟的转速。Step 800, read the Hall pulse signal and calculate the motor speed. The calculation formula is as follows: Where n is the motor speed, s is the number of Hall pulses read in time t, and t is the time interval (in seconds). Multiply by 60 to convert the speed from the number of pulses per second to the speed per minute.

步骤900,针对电机特性计算电机运行过程中的换向电流,当电机转子旋转时,电刷与换向器的换向片接触,导致电路发生变化,从而引起电流的流动,如图6、图7所示。换向电流可以作为电机运行状态参考的重要参数。换向电流计算公式如下:其中ia为电刷与换向片间无换向时电枢电流;t为离进行换向需要时间;Tk为换向时间周期;ew为换向外界的感应电势;r1、r2分别为第一换向片、第二换向片与电刷的接触电阻。Step 900, calculate the commutation current during the operation of the motor according to the motor characteristics. When the motor rotor rotates, the brush contacts the commutator segments of the commutator, causing the circuit to change, thereby causing the current to flow, as shown in Figures 6 and 7. The commutation current can be used as an important parameter for reference of the motor operation status. The commutation current calculation formula is as follows: Wherein, ia is the armature current when there is no commutation between the brush and the commutator segment; t is the time required for commutation; Tk is the commutation time period; ew is the induced potential outside the commutation; r1 and r2 are the contact resistances of the first commutator segment, the second commutator segment and the brush respectively.

步骤1000,电机电流换向产生一个高频分量称为电流换向脉动频率,电流脉动频率与电机转数纯在以下关系:其中f为电流脉冲频率,k为换向器片数,n为电机转数。电流纹波经过调理电路可以得到类似霍尔脉冲的方波,可以通过方波得到电流纹波周期T,计算出电机转速w,公式如下:Step 1000: The motor current commutation generates a high-frequency component called the current commutation pulsation frequency. The current pulsation frequency and the motor speed are in the following relationship: Where f is the current pulse frequency, k is the number of commutator segments, and n is the number of motor revolutions. The current ripple can be conditioned by the circuit to obtain a square wave similar to the Hall pulse. The current ripple period T can be obtained from the square wave, and the motor speed w can be calculated using the following formula:

步骤1100,当电机方向改变时,由于电机内部的惯性作用和负载惯性,电机需要一定的时间来完成反向转动。在这个过程中,电机的输出转矩和转速都会发生变化。具体地说:当电机方向改变时,电机转子需要停止并重新开始旋转。在这个转向的过渡期间,电机的转速将下降,并随着转子重新加速而逐渐恢复。Step 1100, when the direction of the motor changes, due to the inertia inside the motor and the inertia of the load, the motor needs a certain amount of time to complete the reverse rotation. During this process, the output torque and speed of the motor will change. Specifically: when the direction of the motor changes, the motor rotor needs to stop and restart rotation. During this transition period of the direction, the speed of the motor will decrease and gradually recover as the rotor re-accelerates.

步骤1200,为此对电机转速数据进行采集,通过电流纹波计算得到电机转速w和通过霍尔传感器得到的电机转速n,两者在实际采集过程中电机最大转速是确定的,需要对计算出的两个电机转速数据进行异常数据的剔除。Step 1200, for this purpose, the motor speed data is collected, and the motor speed w is calculated by current ripple and the motor speed n is obtained by the Hall sensor. The maximum motor speed of both is determined during the actual collection process, and the abnormal data of the two calculated motor speed data needs to be eliminated.

步骤1300,电机转速采集数据与霍尔脉冲信号采集周期保持一致,为每64us完成一轮数据采样,并在方法中通过设定电机转速阈值nmax完成数据处理,当出现大于阈值的数据进行舍弃。同时将各自计算得到的电机转速数值以四个一组存储在数组中,并求出该数组的电机平均转速通过电流纹波得到的电机平均转速也用同样的方式求得。Step 1300: The motor speed data collection is consistent with the Hall pulse signal collection cycle, and a round of data sampling is completed every 64us. The method completes data processing by setting the motor speed threshold n max . When data greater than the threshold appears, it is discarded. At the same time, the motor speed values calculated are stored in an array in groups of four, and the average motor speed of the array is calculated. The average motor speed obtained by current ripple is also obtained in the same way.

步骤1400,基于霍尔信号采集到的电机转速和基于电流纹波采集到的电机转速在实际过程中存在一定的偏差,需要对二者之间的误差进行定义,设置一个阈值n_dv。以某个对应的数组为例,对两种方法求出的电机平均转速进行求差并对结果取绝对值,得到两者绝对值的差值np=|n-w|。Step 1400: In the actual process, there is a certain deviation between the motor speed collected based on the Hall signal and the motor speed collected based on the current ripple. It is necessary to define the error between the two and set a threshold n_dv. Taking a corresponding array as an example, the difference between the average motor speeds obtained by the two methods is calculated and the absolute value of the result is taken to obtain the difference between the absolute values of the two np = |nw|.

因此,当电机当前时刻的平均转速小于上一时刻平均转速,且电机转速差值小于阈值,可以判断电机运动方向发生了变化,且当差值temp_hall等于1或-3时,可以判断出电机处于顺时针转动状态;当差值temp_hall等于-1或3时,可以判断出电机处于逆时针转动状态。而当电机停转时,两路霍尔信号值都为0,当temp_hall信号为0的次数stop超过阈值,且电机平均转速差值为0,判断电机处于停转状态。Therefore, when the average speed of the motor at the current moment is less than the average speed at the previous moment, and the motor speed difference is less than the threshold, it can be determined that the direction of the motor movement has changed, and when the difference temp_hall is equal to 1 or -3, it can be determined that the motor is rotating clockwise; when the difference temp_hall is equal to -1 or 3, it can be determined that the motor is rotating counterclockwise. When the motor stops, the values of the two Hall signals are both 0. When the number of times the temp_hall signal is 0 exceeds the threshold, and the difference in the average motor speed is 0, it is determined that the motor is stopped.

本领域的技术人员容易理解,以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims (10)

1.一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,包括以下步骤:1. A method for identifying the direction of motor movement based on dual Hall sensors, characterized in that it comprises the following steps: S100、持续读取输入的两路霍尔脉冲信号的方波值,将同一时刻的两路霍尔脉冲信号的方波值按照一定顺序排列和组合,并将组合后的方波值转化为二进制数值;其中,在一个周期内转化得到的二进制数值为a种,且按照一定规律进行排列循环,a为大于或等于4的正偶数;S100, continuously reading the square wave values of the two Hall pulse signals input, arranging and combining the square wave values of the two Hall pulse signals at the same time in a certain order, and converting the combined square wave values into binary values; wherein the binary values converted in one cycle are a kinds, and are arranged and circulated according to a certain rule, and a is a positive even number greater than or equal to 4; S200、将转化得到的二进制数值记作Hallstate,并引入一个对应a种二进制数值的数组HALLDX[a],该数组长度为a,该数组内包含的a个数值与二进制数值对应;将二进制数值作为下标代入数组中,得到一个数值记为HALLDX[Hallstate];S200, the converted binary value is recorded as Hallstate, and an array HALLDX[a] corresponding to a binary value is introduced, the length of the array is a, and the a values contained in the array correspond to the binary value; the binary value is substituted into the array as a subscript to obtain a value recorded as HALLDX[Hallstate]; S300、将HALLDX[Hallstate]减去历史值HALLDX[Hallstatelast],并将两者的差值记作temp_hall;其中,历史值HALLDX[Hallstatelast]为上一个周期中计算得到的HALLDX[Hallstate];S300, subtract the historical value HALLDX[Hallstatelast] from HALLDX[Hallstate], and record the difference between the two as temp_hall; wherein the historical value HALLDX[Hallstatelast] is the HALLDX[Hallstate] calculated in the previous cycle; S400、根据temp_hall的数值判断电机为正转或反转,当电机正常运转且运转方向不变时,电机正转和反转得到的数值temp_hall均预设为个,共计a个数值且数值大小均不相同。S400, judging whether the motor is rotating forward or reverse according to the value of temp_hall. When the motor is running normally and the direction of rotation remains unchanged, the values of temp_hall obtained when the motor is rotating forward and reverse are both preset to There are a total of a values, and the values are all different. 2.根据权利要求1所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:2. The method for identifying the direction of motor movement based on dual Hall sensors according to claim 1, further comprising the following steps: S500、当temp_hall的数值为0时,对预设计时器的计数值进行判断,当计时器的计数值小于预设阈值时,计数值加1,跳转至S700;当计时器的数值大于预设阈值时,判断电机停转,跳转至S700;S500, when the value of temp_hall is 0, the count value of the preset timer is judged. When the count value of the timer is less than the preset threshold, the count value is increased by 1, and the process jumps to S700; when the value of the timer is greater than the preset threshold, the motor is judged to be stopped, and the process jumps to S700; S600、当temp_hall的数值不为电机正转和反转得到的预设a个数值或0时,对Hallerror值进行判断,当Hallerror值小于预设错误阈值时,Hallerror值加1,并跳转至S700;当Hallerror值大于预设错误阈值时,发送报错信号,结束本方法;其中,Hallerror为Hall错误标志,当判断电机异常状态时对该变量进行调用,根据其值与预设错误阈值进行比较,得到电机是否处于异常状态;S600, when the value of temp_hall is not a preset a value or 0 obtained by the forward and reverse rotation of the motor, the Hallerror value is judged, and when the Hallerror value is less than the preset error threshold, the Hallerror value is increased by 1, and the method is jumped to S700; when the Hallerror value is greater than the preset error threshold, an error signal is sent to end the method; wherein, Hallerror is a Hall error flag, and when it is judged that the motor is in an abnormal state, the variable is called, and its value is compared with the preset error threshold to determine whether the motor is in an abnormal state; S700、将Hallstate的值赋给Hallstatelast,并跳转至S100进行下一个周期的计算。S700, assign the value of Hallstate to Hallstatelast, and jump to S100 to perform calculation of the next cycle. 3.根据权利要求1所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:3. The method for identifying the motor movement direction based on dual Hall sensors according to claim 1, further comprising the following steps: S800、根据霍尔脉冲信号计算电机转速,计算方法为:S800, calculate the motor speed according to the Hall pulse signal, the calculation method is: 其中,n为电机转速,t为时间间隔,s为在时间间隔t内读取的霍尔脉冲数量。Where n is the motor speed, t is the time interval, and s is the number of Hall pulses read within the time interval t. 4.根据权利要求1所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:4. The method for identifying the motor movement direction based on dual Hall sensors according to claim 1, further comprising the following steps: S900、计算电机运行过程中的换向电流,其计算方法为:S900, calculate the commutation current during the operation of the motor, and the calculation method is: 其中,ia为电刷与换向片之间无换向时的电枢电流,t0为进行换向所需时间,Tk为换向时间周期,er为换向元件的电抗电势,ew为换向外界的感应电势,换向元件包括第一换向片和第二换向片,r1、r2分别为第一换向片、第二换向片与电刷的接触电阻。Wherein, ia is the armature current when there is no commutation between the brush and the commutator segment, t0 is the time required for commutation, Tk is the commutation time period, er is the reactance potential of the commutation element, ew is the induced potential of the commutation environment, the commutation element includes the first commutator segment and the second commutator segment, r1 and r2 are the contact resistances of the first commutator segment, the second commutator segment and the brush respectively. 5.根据权利要求4所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:5. The method for identifying the motor movement direction based on dual Hall sensors according to claim 4, characterized in that it also includes the following steps: S1000、在电机的电流发生换向时产生一个高频分量称为电流换向脉动频率,电流脉动频率与电机转速存在以下关系:S1000, when the current of the motor is commutated, a high-frequency component is generated, which is called the current commutation pulsation frequency. The current pulsation frequency has the following relationship with the motor speed: 其中,f为电流脉冲频率,k为换向器片数,n为通过霍尔传感器得到的电机转速;Among them, f is the current pulse frequency, k is the number of commutator segments, and n is the motor speed obtained by the Hall sensor; 电流纹波经过调理电路得到类似霍尔脉冲的方波,通过该方波得到电流纹波周期T,并计算得到通过电流纹波计算得到的电机转速w,计算方法为:The current ripple is conditioned by the circuit to obtain a square wave similar to the Hall pulse. The current ripple period T is obtained through the square wave, and the motor speed w calculated by the current ripple is calculated as follows: 6.根据权利要求5所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:6. The method for identifying the motor movement direction based on dual Hall sensors according to claim 5, characterized in that it also includes the following steps: S1100、当电机的运转方向改变时,由于电机内部的惯性作用和负载惯性,电机需要一定时间来完成反向转动。S1100: When the running direction of the motor changes, due to the inertia inside the motor and the inertia of the load, the motor needs a certain amount of time to complete the reverse rotation. 7.根据权利要求5所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:7. The method for identifying the motor movement direction based on dual Hall sensors according to claim 5, characterized in that it also includes the following steps: S1200、对电机的转速数据进行采集,S1000中通过电流纹波计算得到的电机转速w和通过霍尔传感器得到的电机转速n,两者在实际采集过程中电机最大转速nmax是确定的,根据电机最大转速nmax对两者中的异常数据进行剔除;其中,对电机的转速数据的采集周期与霍尔脉冲信号的采集周期一致。S1200, collecting the speed data of the motor. The motor speed w obtained by current ripple calculation in S1000 and the motor speed n obtained by the Hall sensor, both of which have a maximum motor speed n max determined during the actual collection process, and the abnormal data in the two are eliminated according to the maximum motor speed n max ; wherein, the collection period of the motor speed data is consistent with the collection period of the Hall pulse signal. 8.根据权利要求7所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:8. The method for identifying the motor movement direction based on dual Hall sensors according to claim 7, further comprising the following steps: S1300、将采集得到的电机转速数据以四个为一组进行存储,并分别计算得到各组数据的电机平均转速值。S1300, storing the collected motor speed data in groups of four, and calculating the average motor speed value of each group of data. 9.根据权利要求8所述的一种基于双霍尔传感器的电机运动方向识别方法,其特征在于,还包括以下步骤:9. The method for identifying the motor movement direction based on dual Hall sensors according to claim 8, characterized in that it also includes the following steps: S1400、设置误差阈值,对同一周期内通过电流纹波计算得到的电机转速和通过霍尔传感器得到的电机转速对应的各组数据之间作差并对结果取绝对值,表示为:S1400, setting an error threshold, making a difference between the motor speed calculated by the current ripple and the motor speed obtained by the Hall sensor in the same cycle, and taking the absolute value of the result, expressed as: n0=|n-w|n 0 = |nw| 其中,n为通过霍尔传感器得到的某组数据的电机平均转速值,w为与n对应的通过电流纹波计算得到的该组数据的电机平均转速值,np为两者作差结果的绝对值;Where n is the average motor speed value of a set of data obtained by the Hall sensor, w is the average motor speed value of the set of data corresponding to n obtained by current ripple calculation, and np is the absolute value of the difference between the two; 根据各组两者作差结果的绝对值与误差阈值进行比较,判断两者的误差大小。The absolute value of the difference between the two groups is compared with the error threshold to determine the size of the error between the two. 10.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1-9任一项所述方法的步骤。10. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
CN202410046976.6A 2024-01-11 2024-01-11 A motor motion direction recognition method based on dual Hall sensors Pending CN117909684A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410046976.6A CN117909684A (en) 2024-01-11 2024-01-11 A motor motion direction recognition method based on dual Hall sensors

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410046976.6A CN117909684A (en) 2024-01-11 2024-01-11 A motor motion direction recognition method based on dual Hall sensors

Publications (1)

Publication Number Publication Date
CN117909684A true CN117909684A (en) 2024-04-19

Family

ID=90697063

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410046976.6A Pending CN117909684A (en) 2024-01-11 2024-01-11 A motor motion direction recognition method based on dual Hall sensors

Country Status (1)

Country Link
CN (1) CN117909684A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118253080A (en) * 2024-05-27 2024-06-28 深圳市奋达智能技术有限公司 Exercise frequency calculation method and related device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118253080A (en) * 2024-05-27 2024-06-28 深圳市奋达智能技术有限公司 Exercise frequency calculation method and related device
CN118253080B (en) * 2024-05-27 2024-09-17 深圳市奋达智能技术有限公司 Exercise frequency calculation method and related device

Similar Documents

Publication Publication Date Title
CN117909684A (en) A motor motion direction recognition method based on dual Hall sensors
Ertugrul et al. Indirect angle estimation in switched reluctance motor drive using fuzzy logic based motor model
CN107482968B (en) control method for improving motion precision of direct current motor
CN112350626B (en) Method and device for determining the rotational speed and the rotational angle of a motor shaft of a DC motor
CN113437909A (en) Hall position correction method of brushless motor based on Hall sensor
US11509248B2 (en) Position estimation device and position estimation method
US6845337B2 (en) Method for correcting the determination of the rotating position of a drive shaft of a commutated direct current motor
US20210279518A1 (en) Learning method, learning system, and learning program
CN112595971B (en) Locked rotor detection method and controller of direct current brush motor based on FFT technology
CN114337434A (en) An offline parameter identification method of permanent magnet motor considering inductance saturation effect
CN209435138U (en) Counter electromotive force sampling circuit of permanent magnet synchronous motor
CN111478629B (en) Position detection method and device of permanent magnet brushless direct current motor and electrical equipment
US20220014126A1 (en) Position estimation device and position estimation method
CN113824379B (en) Method and device for testing maximum torque angle of unit current of permanent magnet synchronous motor
CN110323975A (en) The control system and control method of hub motor
CN114374345B (en) An improved phase current gradient detection method for switched reluctance motors
CN113391087B (en) Rotation speed detecting device
US11797463B2 (en) Signal generation device
JP3320454B2 (en) Motor position control device and motor position control method
CN113258836B (en) Motor control method and system for vehicle cooling fan based on Kalman filter estimation
CN119335391A (en) Phase loss detection method, device, equipment and computer program for permanent magnet synchronous motor
CN119232004A (en) A permanent magnet synchronous motor rotor position filtering and zero position calibration method and controller
EP1163530A1 (en) Blended velocity estimation
CN118337117A (en) Motor torque zero crossing control method and device, electronic equipment and storage medium
CN115085604A (en) Motor operation detection method and device, computer equipment and motor control device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination