Hardware design (1) - STM32 design inclinometer (a) based on

Open a blog record your own complete set up work.

In this design, we use stm32 as the control and processing core, supplemented by 485, can communicate with the host computer inclinometer function of.

After the design is completed, it will be used in industrial field, the tilt angle measurement basket through 485 to the host computer, the host computer can use the tilt control data accordingly. Meanwhile, we have also developed an inclinometer automatic alarm function, when the angle between the horizontal plane and measured exceeds a certain threshold, the device will issue a warning and the operator can always make changes to this threshold value by the host computer, to meet the needs of different occasions.

First, tell us about the hardware part of the design:

2.1 general framework

This hardware design of the frame mainly consists of the following components: a sensor circuit, a signal conditioning circuit, the processing circuit and the communication circuit microcontroller. In addition, the OLED display circuitry attached, can be displayed in real time on the angle data out. Block diagram shown in Figure 2-1.

                                                               

                                                                            2-1 hardware block diagram of FIG.

When the product is working, the tilt angle sensor signal into an electrical signal output angle, and then filtered and amplified electrical signal generated by the output of the conditioning circuit, the microcontroller so that the signal easily handled, and then the signal is input to the microcontroller port AD. After the microcontroller receives an electrical signal conditioning circuit coming AD processing, and calculates the measured tilt angle of the plane, and the angle signal transmitter 485 in a manner to communicate to the host computer, while taking advantage of the OLED in real time the value represented angle.

 

2.2 Tilt Sensor

After the selection of a tilt sensor, combined with the predecessors of experience and analysis of the various types of sensors, the design selection FXLN8361Q this inclinometer sensor. Freescale FXLN8361Q is based on a differential capacitive MEMS type triaxial acceleration sensor technology research and development, the chip 1.71V ~ 3.76V dc voltage supply may be selected or ± 8g ± 2g range. Internal integration capacitor to a voltage converting circuit, the operational amplifier, the output of the follower unit and the like. [8] Figure 2-2 shows the internal structure:

                                                     

                                                                     2-2 FXLN8361Q internal configuration of FIG.

QFN chip encapsulation, a total of 12 pins. Acceleration value 8 feet and 10 feet to 9 feet output of the sensor, respectively, three output shaft; wherein the pin 2 is VCC; 6 feet to 7 feet and GND; 4 feet to enable pin; select pin for the range 5 feet .

Relationship between the output pin of the acceleration voltage as shown in Table 2-1:

                                                                    Table 2-1 Relationship between the respective axes of the acceleration and the output voltage

mode

-1g

0g

+1g

2g

0.521V

0.750V

0.979V

8g

0.693V

0.750V

0.807V

When the angle between the chip and the horizontal plane is changed, an acceleration value of each axis which will change, thus leading to a change in the output voltage, we can derive the reverse acceleration value of each axis based on the output voltage of the chip, and further by certain mathematical formula can be obtained and the measured angle between the horizontal surface, to achieve the purpose of measuring the inclinometer.

Typical application circuit of the chip shown in Figure 2-3:

                                               

 

                                                                  Design of the sensor circuit of FIG. 2-3 FXLN8361Q

The access circuit in the chip, to note the following:

a.2 two contact feet capacitors C19 and C20 as close as possible to the chip, so that better filtering functions, to prevent noise caused by the power supply.

B.C21 role is to stabilize the output voltage.

c. Enable port must be high in order to set in after the VDD voltage is greater than 1.71V, otherwise may cause the chip can not start work.

D. a capacitor should be connected to each output pin, such play a role in the output filter, so that the output voltage is more stable.

e. In the welding should be such as chip bonded to the circuit board, so that at the same level in order to maintain the chip and the measured plane.

2.3 conditioning circuit

在倾角芯片将倾斜角信号转化为电信号之后,CPU接收电信号之前,我们需要一个调理电路对倾角芯片产生的电信号进行处理,对其进行滤波放大的操作。由于倾角传感器是采用模拟输出,所以不可避免的会产生一定的噪声,为了尽可能减少噪声对测量结果的影响,我们在芯片产生电信号之后接入这个调理电路。经过这个调理电路处理之后,可以使得传入CPU的电压信号更加稳定且易于处理和分析,提高系统的精度。

经过分析和比较,我们选用了二阶压控型低通有源滤波器作为我们调理电路的主体,[9]其电路结构如图2-4所示:

                                              

 

                                                                                图2-4 调理电路

根据运放的知识,在信号频率比较低的时候,各个电容可以视为开路,所以此电路的通带增益为:

Aνp=1+R12R11                            (2-1)

将此电路的输入电压设为Vi,输出电压设为Vo,且令R9=R10=R,C25=C26=C,可以得到如下结论:

V0=AνpV+                              (2-2)

V+=VN11+sCR                            (2-3)

Vi-VNR-VN-V0sC-VN-V+R=0                    (2-4)

联立(1)、(2)和(3)式,我们可以得到此滤波电路的传递函数为:

V0Vi=Aνp1+3-AνpsCR+(sCR)2                        (2-5)

根据电路的传递函数我们可以发现:此电路的通带增益不得大于3,否则电路将会无法稳定工作。在设计时我们令R12=R11,于是根据式(1),我们所设计的电路的通带增益为:

Aνp=1+R12R11=2                         (2-6)

由于设计中FXLN8361Q芯片的输出为0.512V-0.979V,1g的加速度变化对应的是0.229V的电压变化。将此电压作为输入电压输入至此滤波电路,于是此电路的输出为1.024V-1.958V。输出电压的范围符合STM32的AD口识别范围,而且此时加速度每变化1g,CPU所读取的电压变化量为0.458V。在同等加速度变化的情况下,电压变化值翻倍,可以使得我们的计算结果更具分辨力,提高产品的测量精度。

在放大器芯片的选用上,本设计选择的是四路运放LM324。LM324是一款具有真差动输入的四路运算放大器,由四个独立的高增益的运算放大器组成。其封装为14脚的SOIC封装,带宽为1.2MHZ。与单电源应用场合的标准运算放大器相比具有一些显著的优势:此芯片的工作电压范围较普通的运放来说非常宽泛,可以工作在3.0V-32V的电源之下;而且其共模输出范围较大,无需采用外部偏置器件。

在设计完调理电路之后,为验证其正确性,我们在multisim中对此调理电路做了简单的仿真,观察结果是否符合我们的预期。仿真设计如图2-5所示:

                                       

                                                                             图2-5 调理电路仿真电路图

在输入端接上1V的阶跃信号之后,我们可以通过示波器观察到此时的输出信号,如图2-6所示:

                                                         

                                                                            图2-6 调理电路仿真结果

观察仿真结果,我们可以发现此电路可以很好的将输入信号放大两倍之后输出,符合我们的需求。值得一提的是,这个放大电路的通带增益必须小于3,在设计之初由于没有考虑到这一点导致输出电压不稳定,无法读出角度值,至于原因在上文中的公式2-5已经提及,此处就不再赘述。

 

(未完待续)

Guess you like

Origin blog.csdn.net/qq_36631079/article/details/91795523