Experimental requirements
In the second question of the first homework, we practiced writing the expression of the corresponding signal based on the waveform of the signal. But in reality, the signal we observe is often the waveform on the oscilloscope. How can we obtain the mathematical expression of these waveforms?
Oscilloscope for measuring waveforms
In essence, real signals are random and have no definite mathematical expression. However, in some cases, we know the type of signal in advance, such as a sine wave, but do not know some of the signal parameters, such as amplitude, frequency, and phase. If these parameters are known, we can write the corresponding signal mathematical expression. In this case, recovering the signal from the observed noisy signal waveform belongs to the content of signal parameter estimation.
Some electronic components
In practical applications, signal parameters are often very important. Here is an example: If you only have a multimeter but no RCL bridge that can measure capacitance and inductance, in order to know the exact capacitance of a capacitor, you can connect the capacitor to be measured in series with a resistor. The resistance value of the resistor can be accurately measured using a multimeter. Use a signal source to generate a sine wave signal and apply it to the RC series circuit. Use an oscilloscope to simultaneously measure the signal of the signal source and the signal after RC voltage division.
Using RC to measure electronic device parameters circuit
According to the circuit principle, we can know that the relationship between the steady-state input and output sinusoidal signals of the above circuit is as follows:
Measured circuit and oscilloscope
Therefore, the ratio of the amplitudes of the input and output sinusoidal signals is:
The phase difference between the input and output sinusoidal signals is: θ
Therefore, as long as the amplitude or phase and frequency of the two sinusoidal signals U and V can be measured, and the resistance value R1 is known, the capacitance of the capacitor to be measured can be calculated.
It is known that the resistance nR1.=1009 ohms in the series circuit above. The value of the waveform displayed by the oscilloscope can be obtained by sampling the value at a time interval of fs=10 microseconds, which has been stored in CH12.MAT.
Numerical waveform collected by oscilloscope
Based on the above analysis, please calculate the capacitance of the capacitor nC1 to be tested.
hint:
Read the data in CH12.MAT through the load() command in MATLAB;
ch12(:,1) is the data of V, and ch12(:,2) is the data of U.
Use the MATLAB fit command to estimate the parameters in the data.
f = fit(x,y,‘fourier1’)
The above fit command outputs f(x)=a0+a1cos(xw)+b1sin(xw)
Parameters such as a0, a1, b1, w, etc.
Problems with using MATLAB calculations
Calculation steps using MATLAB
Import data and draw waveform graph
load ch12'
t = linspace(0, 1400*10e-6,1400)'
plot(t,ch12(:,1), t, ch12(:, 2))'
Waveform diagram of two measurement data channels
(2) Use MATLAB to calculate the parameters of the sine waveform
f1 = fit(t, ch12(:,1), 'fourier1')'
f2 = fit(t, ch12(:,2), 'fourier1')
f1: a0:119.1442, a1:-1.6132, b1:27.3382, pressure:2481
f2: a0:150.0722, a1:64.1255, b1:43.5524, pressure:2481
2. Problems encountered when using MATLAB calculations
Using the above parameters and the two formulas for calculation, there will be a 1.5-fold difference.
The associated vector variance is shown below:
Problems with parameters calculated by MATLAB
Get data from MATLAB through the clipboard
First, use the following command in the MATLAB command window to copy the CH12 data to the WINDOWS clipboard.
cc(ch12)
Then, the following Python program is used to convert the data on the clipboard into two arrays, corresponding to the collected data of the output and input signals respectively.
pastestr = clipboard.paste().strip('[').strip(']').split(';')
data1=[]
data2=[]
for s in pastestr:
ss = s.split(' ')
data1.append(int(ss[0]))
data2.append(int(ss[1]))
plt.plot(data1)
plt.plot(data2)
tspsave('CH12', ch1=data1, ch2=data2)
printf('a')
plt.show()
Perform function fitting and parameter calculation
Two channel sine waves and their FIT curves
The program code is as follows:
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TEST2.PY -- by Dr. ZhuoQing 2020-02-28
#
# Note:
#============================================================
from headm import *
from scipy.optimize import leastsq
ch1, ch2 = tspload('CH12', 'ch1', 'ch2')
#------------------------------------------------------------
def make_sine_graph( params, xData):
"""
take amplitudes A and phases P in form [ C, A0, A1, A2, ..., An, P0, P1,..., Pn ]
and construct function f = C +A0 sin( w t + P0) + A1 sin( 2 w t + Pn ) + ... + An sin( n w t + Pn )
and return f( x )
"""
fr = params[0]
C = params[1]
npara = params[2:]
lp =len (make up)
amps = npara[ : lp //
phases = npara[ lp // 2 : ]
fact = range(1, lp // 2 + 1 )
return [ sum( [ a * sin( 2 * pi * x * f * fr + p ) for a, p, f in zip( amps, phases, fact ) ]) + C for x in xData ]
def sine_residuals( params , xData, yData):
yTh = make_sine_graph( params, xData )
diff = [ y - yt for y, yt in zip( yData, yTh ) ]
return diff
def sine_fit_graph( xData, yData, freqGuess=100., dcGuess=100,sineorder = 3 ):
aStart = sineorder * [ 0 ]
aStart[0] = max( yData )
pStart = sineorder * [ 0 ]
result, _ = leastsq( sine_residuals, [ freqGuess, dcGuess ] + aStart + pStart, args=( xData, yData ) )
return result
#------------------------------------------------------------
if __name__ == '__main__':
ch1 = [c / 255 for c in ch1]
ch2 = [c / 255 for c in ch2]
t = linspace(0, 1400*10e-6, 1400, endpoint=False)
result1 = sine_fit_graph(t, ch1, freqGuess=2481/2/pi, dcGuess=0.5, sineorder=1)
result2 = sine_fit_graph(t, ch2, freqGuess=2481/2/pi, dcGuess=0.5, sineorder=1)
printf(result1, result2)
plt.plot(t, make_sine_graph(result1, t))
plt.plot(t, ch1)
plt.plot(t, make_sine_graph(result2, t))
plt.plot(t, ch2)
tspsave('fitresult', result1=result1, result2=result2)
printf(tan(result2[3] - result1[3]))$$C = {{tan theta } over {2pi f cdot R}} = {{sqrt {1 - alpha ^2 } } over alpha } cdot {1 over {2pi f cdot R}}$$
alpha = result1[2] / result2[2]
printf(sqrt(1-alpha**2)/alpha)
plt.show()
#------------------------------------------------------------
# END OF FILE : TEST2.PY
#============================================================
According to the above PYTHON program, recalculate the sine parameters corresponding to the input and output data. The data is as follows, and the estimated parameters obtained are the same as those in MATLAB.
Output waveform fitting sine parameters:
[ 3.95138209e+02 4.67232082e-01 1.07395207e-01 -5.89407332e-02]
Input waveform data to fit sine parameters:
[3.95096587e+02 5.88518451e-01 3.03988482e-01 9.74184940e-01]
tan(theta)=1.6770990200351208
sqrt(1-a**2)/a=2.6480303891707053
Previous article:Change the image color of the oscilloscope TDS3054D
Next article:Undersampling in the Use of Digital Oscilloscopes
- Popular Resources
- Popular amplifiers
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- What are the application areas of BLE Bluetooth modules?
- 0.9V MSP430L092 MCU makes single-battery powered products lighter and greener
- Import the complete waveform of the oscilloscope signal into advanced data analysis software for calculation
- After GD32F303 SPI is powered on again, the CLK clock signal IO is not output, but the simulation is normal.
- What are the applications of wiring harness testers in the automotive field?
- ESP32-S3 is now available
- DC grounding detection system based on MSP430
- Beautiful Smart NeoPixel LED Cube
- What electrical and electronic engineers must know
- Have you ever used a BP machine? It's 8012, but Japan has just said goodbye to BP machines