当前位置:网站首页>ADC acquisition noise and comparison between RMS filter and Kalman filter
ADC acquisition noise and comparison between RMS filter and Kalman filter
2022-06-26 00:51:00 【To, violet】
For a while, the author was doing a PT100 The conditioning circuit of thermal resistance adopts , Use a constant current source to measure the resistance of the thermal resistance . For the convenience of collection , take 0.3mA The current of is connected PT100 Put... Directly ADC The input terminal is connected to PT100 Both ends . When the temperature is output later, the data is very chaotic . Access to information is inspired , Use to find the effective value of the signal ( Root mean square value ) Method to filter .
ADC sampling 、 Constant current source
ADC It uses STM32F10x Inside the series 12 position ADC. The current value of the constant current source is 0.3mA.
PT100 Thermal resistance
PT100 It's below zero , The resistance value is 100Ω Thermal resistance of , The temperature characteristic curve is shown in the figure 1

chart 1:PT100 Temperature characteristic curve
Basically, in -200—600 There is a linear relationship between temperature and resistance . Therefore, measurement PT100 One way to measure resistance is to give PT100 Connect a constant current source , Then measure the voltage at both ends and then calculate PT100 Resistance value .
Noise analysis
Power on the circuit ( The power supply adopts two sections 18650 Series connection ,AMS1115-3.3V Voltage reduction and stabilization ) Connect both ends of the thermal resistance to the oscilloscope ( Input impedance 1MΩ) Pictured 2.Single once , Then, all the sampling data in the interface are processed FFT( The fast Fourier transform ) Get the picture 3、 chart 4. It is not difficult to see that the noise mainly comes from 1Mhz And some Gaussian white noise .

chart 2: The original signal

chart 3:FFT

chart 4:FFT
Root mean square noise removal

To find the root mean square value of a signal is actually to find the effective value of the signal (RMS) That is, the mean square of the signal is redistributed .ADC Sampling frequency is 10Khz. Every time 100 Data to calculate . The calculated data is output by the serial port , See the picture :6、 chart 7.(C See the program for the code 1)

chart 5: Serial port outputs raw data

chart 6: Filter data

chart 7: to PT100 Heating temperature
First order low pass filter
y(n) = q*x(n) + (1-q)*y(n-1)
in Y(n) For export ,x(n) For input . among Q take 0.5 The input waveform is shown in Figure 8.(C See the program for the code 2)

chart 8: Add the first-order low-pass filter serial port output
kalman wave filtering
The first step is to import the data MATLAB, Draw the raw data curve . See the picture 9.. Make the data as Kalman filter observation matrix . Put the data of t-2 To t The mean value of the time is used as the speculative matrix ( See additional code for details ). Finally, the Kalman output is made into a moving average . Kalman output model ( Blue ) See the picture 10.(matlab See the program for the code 3)

chart 9:MATLAB Import raw data

chart 10: Raw data and filtered data
summary :
A large part of the reason for the noise is that the digital and analog are not separated when drawing the circuit board .Kalman Filtering algorithm is a filtering algorithm based on time domain . The author thinks that the Gaussian white noise in this circuit mainly comes from the interference of power supply and digital signal to analog signal . As far as this circuit is concerned, it is an effective method to find the root mean square value of the signal . The author has limited knowledge , If there are mistakes, please correct them .
Program 1
unsigned int disposePT100v()
{
unsigned char i;
double dData[100];
double dSum;
for(i=0;i<100;i++)
{
dData[i] = g_iADC[0];// obtain ADC data
dSum +=pow(dData[i],2);// Do the sum of squares
delay_us(100);
}
dSum /= 100;// Calculating mean
dSum = sqrt(dSum);// prescribing
return (unsigned int)dSum*3300/4096;//mv Voltage value
}Program 2
unsigned int lowV(unsigned int com)
{
static unsigned int iLastData;
unsigned int iData;
double dPower=0.5;
iData = (com*dPower)+(1-dPower)*iLastData;// Calculation
iLastData = iData;//jilu
return iData;// Return the data
}Program 3
clear
clc
ydata=textread('a123.txt','%s');%% Import data
cData = hex2dec(ydata);% Convert to 10 Hexadecimal data
%t-1 The output of the time is taken as the estimated value of the system at this time Optimal deviation ( initial value )g_zer Speculative error ( initial value )g_ter Measured value deviation ( initial value )g_cer
% Measurement results ( matrix ) ner1 Conjecture ( matrix )ner2 (end)
g_zer = 5;%% Initial value of optimal deviation
g_ter = 3;%% Guess the initial value of deviation
g_cer = 2;%% Measure the initial value of deviation
kdata = 0;
for i=1:5792%% iteration 5000 Time
ner1 = cData(i);
if i>3
ner2 = (cData(i-2)+cData(i-1)+cData(i))/3;%%t-2 Moment to t The average value of time is taken as t The estimated value of time
else
ner2 = kdata;
end
if g_zer>g_ter
g_er = sqrt((g_zer^2)-(g_ter^2));% Calculate this error
else
g_er = sqrt((g_ter^2)-(g_zer^2));% Calculate this error
end
kk = sqrt((g_er^2)/((g_er^2)+(g_cer^2)));% Calculate Kalman gain
kdata = ner1+kk*(ner2-ner1);% Update Kalman output
g_zer = ((1-kk)*g_ter^2)^0.5;% Calculate the optimal deviation
cKdata(i) = kdata;
end
%%%%%%% moving average %%%%%%%%%%
t = 1:5792;
a = 0;
b = 0;
pKdata = zeros(1,5792);
for i=1:5700
for j=1:50
a = a + cKdata(i+j);
end
b = a/50;%% Averaging
a = 0;
pKdata(i)=b;
end
plot(t,cData,'R',t,cKdata,'G',t,pKdata,'B');
边栏推荐
- Idea view unit test coverage
- Law and self-regulation in the meta universe
- Qt之自定义带游标的QSlider
- Qt优秀开源项目之九:qTox
- Comprehensive introduction to Simulink solver
- mtb13_Perform extract_blend_Super{Candidate(PrimaryAlternate)_Unique(可NULL过滤_Foreign_index_granulari
- 认识map
- JS逆向案例:破解登录密码
- Precautions for cleaning PCBA board in SMT chip processing
- [image detection] vascular tracking and diameter estimation based on Gaussian process and Radon transform with matlab code
猜你喜欢

Redis的安装及启动

Research and development practice of Kwai real-time data warehouse support system

Wireshark's analysis of IMAP packet capturing

【图像检测】基于高斯过程和Radon变换实现血管跟踪和直径估计附matlab代码

mtb13_ Perform extract_ blend_ Super{candidate (primaryalternate) \u unique (nullable filtering \foreign\index\granulati

86. (cesium chapter) cesium overlay surface receiving shadow effect (gltf model)

Balanced binary tree AVL

1-11solutions to common problems of VMware virtual machine

leetcode.14 --- 最长公共前缀

Mining pit record of modified field information in Dameng database
随机推荐
Send mail tool class
mysql
论文中英文大小写、数字与标点的正确撰写方式
[TSP problem] solving traveling salesman problem based on Hopfield neural network with matlab code
每日一问:线程和进程的区别
Web学习之TypeScript
“Method Not Allowed“,405问题分析及解决
Summary of common terms and knowledge in SMT chip processing industry
简单 deepclone
Datetimeformatter and localdatetime
Installation and configuration of gradle environment
QT excellent open source project 9: qtox
Understanding of prototypes and prototype chains
Atlas200dk刷机
Wireshark's analysis of IMAP packet capturing
经典面试题之老鼠试药与汉明码
debezium
Dynamic verification code
1-9Vmware中网络配置
PHP performance optimization