phd-nass-instrumentation/matlab/detail_instrumentation_2_choice.m

118 lines
6.3 KiB
Matlab

%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
%% Path for functions, data and scripts
addpath('./src/'); % Path for scripts
addpath('./mat/'); % Path for data
addpath('./STEPS/'); % Path for Simscape Model
addpath('./subsystems/'); % Path for Subsystems Simulink files
%% Colors for the figures
colors = colororder;
freqs = logspace(1,4,1000); % Frequency vector [Hz]
%% Load computed requirements
load('instrumentation_requirements.mat')
% Small signal Bandwidth and Output Impedance
% Small signal bandwidth is particularly important for feedback applications as it can limit the overall bandwidth of the complete feedback system.
% A simplified electrical model of a voltage amplifier connected to a piezoelectric stack is shown in Figure ref:fig:detail_instrumentation_amp_output_impedance.
% This model is valid for small signals and provides insight into the small signal bandwidth limitation [[cite:&fleming14_desig_model_contr_nanop_system, chap. 14]].
% In this model, $R_o$ represents the output impedance of the amplifier.
% When combined with the piezoelectric load (represented as a capacitance $C_p$), it forms a first order low pass filter described by eqref:eq:detail_instrumentation_amp_output_impedance.
% \begin{equation}\label{eq:detail_instrumentation_amp_output_impedance}
% \frac{V_a}{V_i}(s) = \frac{1}{1 + \frac{s}{\omega_0}}, \quad \omega_0 = \frac{1}{R_o C_p}
% \end{equation}
% #+name: fig:detail_instrumentation_amp_output_impedance
% #+caption: Electrical model of a voltage amplifier with output impedance $R_0$ connected to a piezoelectric stack with capacitance $C_p$
% [[file:figs/detail_instrumentation_amp_output_impedance.png]]
% Consequently, the small signal bandwidth depends on the load capacitance and decreases as the load capacitance increases.
% For the APA300ML, the capacitive load of the two piezoelectric stacks corresponds to $C_p = 8.8\,\mu F$.
% If a small signal bandwidth of $f_0 = \frac{\omega_0}{2\pi} = 5\,\text{kHz}$ is desired, the voltage amplifier output impedance should be less than $R_0 = 3.6\,\Omega$.
Cp = 8.8e-6; % Capacitive load of the two piezoelectric actuators
f0 = 5e3; % Wanted low signal bandwidth [Hz]
Ro_max = 1/(2*pi*f0 * Cp); % Maximum wanted output impedance [Ohm]
% Large signal Bandwidth
% Large signal bandwidth relates to the maximum output capabilities of the amplifier in terms of amplitude as a function of frequency.
% Since the primary function of the NASS is position stabilization rather than scanning, this specification is less critical than the small signal bandwidth.
% However, considering potential scanning capabilities, a worst-case scenario of a constant velocity scan (triangular reference signal) with a repetition rate of $f_r = 100\,\text{Hz}$ using the full voltage range of the piezoelectric actuator ($V_{pp} = 170\,V$) is considered.
% There are two limiting factors for large signal bandwidth that should be evaluated:
% 1. Slew rate, which should exceed $2 \cdot V_{pp} \cdot f_r = 34\,V/ms$.
% This requirement is typically easily met by commercial voltage amplifiers.
% 2. Current output capabilities: as the capacitive impedance decreases inversely with frequency, it can reach very low values at high frequencies.
% To achieve high voltage at high frequency, the amplifier must therefore provide substantial current.
% The maximum required current can be calculated as $I_{\text{max}} = 2 \cdot V_{pp} \cdot f \cdot C_p = 0.3\,A$.
% Therefore, ideally, a voltage amplifier capable of providing $0.3\,A$ of current would be interesting for scanning applications.
%% Slew-rate specifications - Triangular scan
Vpp = 170; % Full voltage scan [V]
f0 = 100; % Repetition rate of the triangular scan [Hz]
slew_rate = 1e-3*2*Vpp*f0 % Required slew rate [V/ms]
%% Maximum Output Current - Triangular scan
max_current = 2*Vpp*f0*Cp % [A]
% #+name: fig:detail_instrumentation_adc_quantization
% #+caption: Probability density function $p(e)$ of the ADC quantization error $e$
% #+RESULTS:
% [[file:figs/detail_instrumentation_adc_quantization.png]]
% The variance (or time-average power) of the quantization noise is expressed by eqref:eq:detail_instrumentation_quant_power.
% \begin{equation}\label{eq:detail_instrumentation_quant_power}
% P_q = \int_{-q/2}^{q/2} e^2 p(e) de = \frac{q^2}{12}
% \end{equation}
% To compute the power spectral density of the quantization noise, which is defined as the Fourier transform of the noise's autocorrelation function, it is assumed that noise samples are uncorrelated.
% Under this assumption, the autocorrelation function approximates a delta function in the time domain.
% Since the Fourier transform of a delta function equals one, the power spectral density becomes frequency-independent (white noise).
% By Parseval's theorem, the power spectral density of the quantization noise $\Phi_q$ can be linked to the ADC sampling frequency and quantization step size eqref:eq:detail_instrumentation_psd_quant_noise.
% \begin{equation}\label{eq:detail_instrumentation_psd_quant_noise}
% \int_{-F_s/2}^{F_s/2} \Phi_q(f) d f = \int_{-q/2}^{q/2} e^2 p(e) de \quad \Longrightarrow \quad \Phi_q = \frac{q^2}{12 F_s} = \frac{\left(\frac{\Delta V}{2^n}\right)^2}{12 F_s} \quad \text{in } \left[ \frac{V^2}{\text{Hz}} \right]
% \end{equation}
% From a specified noise amplitude spectral density $\Gamma_{\text{max}}$, the minimum number of bits required to keep quantization noise below $\Gamma_{\text{max}}$ is calculated using eqref:eq:detail_instrumentation_min_n.
% \begin{equation}\label{eq:detail_instrumentation_min_n}
% n = \text{log}_2 \left( \frac{\Delta V}{\sqrt{12 F_s} \cdot \Gamma_{\text{max}}} \right)
% \end{equation}
% With a sampling frequency $F_s = 10\,\text{kHz}$, an input range $\Delta V = 20\,V$ and a maximum allowed ASD $\Gamma_{\text{max}} = 11\,\mu V/\sqrt{Hz}$, the minimum number of bits is $n_{\text{min}} = 12.4$, which is readily achievable with commercial ADCs.
delta_V = 20; % +/-10 V
Fs = 10e3; % Sampling Frequency [Hz]
max_adc_asd = 11e-6; % V/sqrt(Hz)
min_n = log2(delta_V/(sqrt(12*Fs)*max_adc_asd))
%% Estimate quantization noise of the ADC
delta_V = 20; % +/-10 V
n = 16; % number of bits
Fs = 10e3; % [Hz]
q = delta_V/2^n; % Quantization in [V]
q_psd = q^2/12/Fs; % Quantization noise Power Spectral Density [V^2/Hz]
q_asd = sqrt(q_psd) % Quantization noise Amplitude Spectral Density [V/sqrt(Hz)]