From 0c58d4a3157f2204ab4f21784639f837da11dbad Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 25 May 2020 15:47:29 +0200 Subject: ma: Fix rest of Björn's complaints from 2020-05-13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ma/safety_reset.tex | 99 ++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 50 deletions(-) (limited to 'ma/safety_reset.tex') diff --git a/ma/safety_reset.tex b/ma/safety_reset.tex index a7de6e2..2f57066 100644 --- a/ma/safety_reset.tex +++ b/ma/safety_reset.tex @@ -297,12 +297,38 @@ petersen coil reduces earth fault current to levels low enough to quickly exting \subsubsection{Power factor correction} +Power factor is a power engineering term that is used to describe how close the current waveform of a load is to that of +a purely resistive load. Given sinusoidal input voltage $V(t) = V_\text{pk} \sin \paren{\omega_\text{nom} t}$ with +$\omega_\text{nom} = 2 \pi f_\text{nom} = 2 \pi \cdot \SI{50}{\hertz}$ being the nominal angular frequency, the current +waveform of a resistor with resistance $R \left[\Omega\right]$ according to Ohm's law would be $I(t) = \frac{V(t)}{R} = +\frac{1}{R} V_\text{pk} \sin\paren{\omega_\text{nom} t}$. In this case voltage and current are perfectly in phase, i.e. +the current at time $t$ is linear in voltage at constant factor $\frac{1}{R}$. + +In contrast to this idealized scenario reality provides us with two common issues: One, the load may be reactive. This +means its current waveform is an ideal sinusoid, but there is a phase difference between mains voltage and load current +like so: $I(t) = \frac{V(t)}{R} = \frac{1}{\left|Z\right|} V_\text{pk} \sin\paren{\omega_\text{nom} t + \varphi}$ $Z$ +would be the load's complex impedance combining inductive, capacitive and resistive components and $\varphi$ the phase +difference between the resulting current waveform and the mains voltage waveform. A common case of such loads are motors +and the inductive ballasts in old fluorescent lighting fixtures. + +The second potential issue are loads with non-sinusoidal current waveform. There are many classes of these but the most +common one are switching-mode power supplies. Most SMPS for modern electronic devices have an input stage consisting of +a bridge rectifier followed by a capacitor that provide high-voltage DC power to the following switch-mode convert +circuit. This rectifier-capacitor input stage under normal load draws a high current only at the very peak of the input +voltage sinusoid and draws almost zero current for most of the period. + +These two cases are measured by \emph{displacement power factor} and \emph{distortion power factor} that when combined +yield the overall true power factor. The power factor is a key quantity in the design and operation of the power grid +since a high power factor (close to $1.0$ or an in-phase sinusoidal current waveform) yields lowest transmission and +generation losses. + Reactive power (also referred to as \emph{VAR} after its is unit Volt-Ampère Reactive) an important variable in the operation of electrical grids (see sec.\ \ref{frequency_estimation}). If reactive power generation and consumption are -mismatched, high currents develop that lead to high transmission losses. For this reason grids include circuits to -compensate reactive power imbalances\cite{crastan01}. These circuits can be as simple as inductors or capacitors -connected to a power line but often can be switched to adapt to changing load conditions. Static Var compensators are -particularly fast-acting reactive power compensation devices whose purpose is to maintain bus voltage\cite{rogers01}. +mismatched and power factor is low, high currents develop that lead to high transmission losses. For this reason grids +include circuits to compensate reactive power imbalances\cite{crastan01}. These circuits can be as simple as inductors +or capacitors connected to a power line but often can be switched to adapt to changing load conditions. Static Var +compensators are particularly fast-acting reactive power compensation devices whose purpose is to maintain bus +voltage\cite{rogers01}. \subsubsection{Loads} @@ -756,8 +782,7 @@ by the burden it puts on consumers. The cost of a smart meter is ultimately limi economies of a smart meter rollout\cite{bmwi03}. Cost requirements preclude some hardware features such as the use of a standard hardened software environment on a high-powerded embedded system (such as a hypervirtualized embedded linux setup) that would both increase resilience against attacks and simplify updates. Combined with the small market sizes in -smart grid deployments -\footnote{ +smart grid deployments\footnote{ Most vendors of smart electricity meters only serve a handful of markets. For the most part, smart meter development cost lies in the meter's software % TODO cite? There exist multiple competing standards applicable to various parts of a smart electricity meter. In addition, @@ -1696,37 +1721,11 @@ For this reason all approaches to mains frequency estimation are based on a mode Nominally, this waveform would be a perfect sine at $f=\SI{50}{\hertz}$. In practice it is a sine at $f\approx\SI{50}{\hertz}$ superimposed with some aperiodic noise (e.g. irregular spikes from inductive loads being energized) as well as harmonic distortion that is caused by grid-topologically nearby devices with power factor -\footnote{ - Power factor is a power engineering term that is used to describe how close the current waveform of a load is to - that of a purely resistive load. Given sinusoidal input voltage $V(t) = V_\text{pk} \sin \paren{\omega_\text{nom} - t}$ with $\omega_\text{nom} = 2 \pi f_\text{nom} = 2 \pi \cdot \SI{50}{\hertz}$ being the nominal angular frequency, - the current waveform of a resistor with resistance $R \left[\Omega\right]$ according to Ohm's law would be $I(t) = - \frac{V(t)}{R} = \frac{1}{R} V_\text{pk} \sin\paren{\omega_\text{nom} t}$. In this case voltage and current are - perfectly in phase, i.e. the current at time $t$ is linear in voltage at constant factor $\frac{1}{R}$. - - In contrast to this idealized scenario reality provides us with two common issues: One, the load may be reactive. - This means its current waveform is an ideal sinusoid, but there is a phase difference between mains voltage and load - current like so: $I(t) = \frac{V(t)}{R} = \frac{1}{\left|Z\right|} V_\text{pk} \sin\paren{\omega_\text{nom} t + - \varphi}$ $Z$ would be the load's complex impedance combining inductive, capacitive and resistive components and - $\varphi$ the phase difference between the resulting current waveform and the mains voltage waveform. A common case - of such loads are motors and the inductive ballasts in old fluorescent lighting fixtures. - - The second potential issue are loads with non-sinusoidal current waveform. There are many classes of these but the - most common one are switching-mode power supplies. Most SMPS for modern electronic devices have an input stage - consisting of a bridge rectifier followed by a capacitor that provide high-voltage DC power to the following - switch-mode convert circuit. This rectifier-capacitor input stage under normal load draws a high current only at the - very peak of the input voltage sinusoid and draws almost zero current for most of the period. - - These two cases are measured by \emph{displacement power factor} and \emph{distortion power factor} that when - combined yield the overall true power factor. The power factor is a key quantity in the design and operation of the - power grid since a high power factor (close to $1.0$ or an in-phase sinusoidal current waveform) yields lowest - transmission and generation losses. -} $\cos \theta \neq 1.0$. Under a continous fourier transform over a long period the frequency spectrum of a signal distorted like this will be a low noise floor depending mainly on aperiodic noise on which a comb of harmonics as well as some sub-harmonics of $f \approx f_\text{nom} = \SI{50}{\hertz}$ rides. The main peak at $f \approx f_\text{nom}$ will be very strong with the harmonics being approximately an order of magnitude weaker in energy and the noise floor -being at least another order of magnitude weaker. See figure \ref{mains_voltage_spectrum} for a measured spectrum. This +being at least another order of magnitude weaker. See Figure \ref{mains_voltage_spectrum} for a measured spectrum. This domain knowledge about the expected frequency spectrum of the signal can be employed in a number of interpolation techniques to re-construct the precise frequency of the spectrum's main component despite comparatively coarse STFT resolution and despite numerous distortions. @@ -1796,7 +1795,7 @@ moving most of the signal processing to a regular computer and concentrating our \draw[dashed] (isol.east) -- (isol-right.west); \end{tikzpicture} \end{center} - \caption{Frequency sensor hardware diagram} + \caption{Frequency sensor hardware diagram.} \label{fmeas-sens-diag} \end{figure} @@ -1845,7 +1844,7 @@ of the microcontroller's timer inputs. By connecting a GPS 1pps signal to this p calculate our system's Allan variance\footnote{ Allan variance is a measure of frequency stability between two clocks. }, thereby measuring both clock stability and clock accuracy. -We ran a 4 hour test of our frequency sensor that generated the histogram shown in figure \ref{ocxo_freq_stability}. +We ran a 4 hour test of our frequency sensor that generated the histogram shown in Figure \ref{ocxo_freq_stability}. These results show that while we get a systematic error of about \SI{10}{ppm} due to manufacturing tolerances the random error at less than \SI{10}{ppb} is smaller than that of a room-temperature crystal oscillator by 3-4 orders of magnitude. Since we are interested in grid frequency variations over time but not in the absolute value of grid @@ -1856,7 +1855,7 @@ and ADC resolution. \begin{figure} \centering \includegraphics{../lab-windows/fig_out/ocxo_freq_stability} - \caption{OCXO Frequency derivation from nominal \SI{19.440}{\mega\hertz} measured against GPS 1pps} + \caption{OCXO Frequency derivation from nominal \SI{19.440}{\mega\hertz} measured against GPS 1pps.} \label{ocxo_freq_stability} \end{figure} @@ -1865,8 +1864,8 @@ and ADC resolution. The firmware uses one of the microcontroller's timers clocked from an external crystal oscillator to produce an \SI{1}{\milli\second} tick that the internal ADC is triggered from for a sample rate of \SI{1}{\kilo sps}. Higher sample rates would be possible but reliable data transmission over the opto-isolated serial interface might prove challenging -and \SI{1}{\kilo sps} corresponds to $20$ samples per cycle at $f_\text{nominal}$. This is $10\times$ nyquist and should -be plenty for accurate measurements. +and \SI{1}{\kilo sps} corresponds to $20$ samples per cycle at $f_\text{nominal}$. This figure exceeds the nyquist +criterion by a factor of ten and is be plenty for accurate measurements. The ADC measurements are read using DMA and written into a circular buffer. Using some DMA controller features this circular buffer is split in back and front halves with one being written to and the other being read at the same time. @@ -2165,7 +2164,7 @@ moving the signal band into noisier spectral regions (cf.\ Figure \ref{freq_meas \includegraphics[width=\textwidth]{../lab-windows/fig_out/chip_duration_sensitivity_5} \label{chip_duration_sensitivity_5} \caption{ - 5 bit Gold code + 5 bit Gold code. } \end{subfigure} \end{figure} @@ -2176,7 +2175,7 @@ moving the signal band into noisier spectral regions (cf.\ Figure \ref{freq_meas \includegraphics[width=\textwidth]{../lab-windows/fig_out/chip_duration_sensitivity_6} \label{chip_duration_sensitivity_6} \caption{ - 6 bit Gold code + 6 bit Gold code. } \end{subfigure} \caption{ @@ -2336,17 +2335,17 @@ advertised to support both over-the-air firmware upgrades and a remotely accessi \centering \includegraphics[width=\textwidth]{resources/easymeter_baseboard_channel.jpg} \label{easymeter_channel_xray} - \caption{Microfocus x-ray of one channel's data acquisition circuit} + \caption{Microfocus x-ray of one channel's data acquisition circuit.} \end{subfigure}\hspace*{5mm} \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{resources/easymeter_baseboard_powersupply.jpg} \label{easymeter_powersupply_xray} - \caption{Microfocus x-ray of the auxiliary power supply} + \caption{Microfocus x-ray of the auxiliary power supply.} \end{subfigure} \caption{ - Microfocus x-rays of major sections of the EasyMeter Q3DA1002 measurement board + Microfocus x-rays of major sections of the EasyMeter Q3DA1002 measurement board. } \label{easymeter_detail_xrays} \end{figure} @@ -2359,8 +2358,8 @@ We based our safety reset demonstrator firmware on the grid frequency sensor fir \ref{sec-ch-sim} to embedded C code. After validating the C translation in extensive simulations we integrated our code with a reed-solomon implementation and a libsodium-based implementation of the cryptographic protocol we designed in sec.\ \ref{sec-crypto}. To reprogram the target MSP430 microcontroller we ported over the low-level bitbang JTAG driver -of mspdebug\footnote{\url{https://github.com/dlbeer/mspdebug}}. See Figure \ref{fig_demo_sig_schema} for a schematic -overview of signal processing in our demonstrator. +of \texttt{mspdebug}\footnote{\url{https://github.com/dlbeer/mspdebug}}. See Figure \ref{fig_demo_sig_schema} for a +schematic overview of signal processing in our demonstrator. For all computation-heavy high-level modules of our firmware such as the DSSS demodulator or the grid frequency estimator we wrote test fixtures that allow the same code that runs on the microcontroller to be executed on the host @@ -2402,9 +2401,9 @@ is also galvanically coupled the safety reset controller prototype would also ha pose an electrical safety risk. The second issue we ran into was that the EVM430-F6779 is based around an MSP430F6779 microcontroller. This microcontroller is a rather large part within the MSP430 series and uses a particularly new revision of the CPU core and associated JTAG peripheral that are incompatible with all MSP430 programmers we tried to -use on it. mspdebug does not have support for it and porting TI's own JTAG programmer reference sources did not yield -any results either. Finally we tried an USB-based programmer made by TI themselves that turned out to either have broken -firmware or a hardware defect, leading to it frequently re-enumerating on the USB. +use on it. \texttt{mspdebug} does not have support for it and porting TI's own JTAG programmer reference sources did not +yield any results either. Finally we tried an USB-based programmer made by TI themselves that turned out to either have +broken firmware or a hardware defect, leading to it frequently re-enumerating on the USB. Overall our initial assumption that a development kit would certainly be easier to program than a commercial meter did not prove to be true. Contrary to our expectations the commercial meter had JTAG enabled allowing us to easily read out @@ -2426,12 +2425,12 @@ version's tendency towards incorrect decodings at even very large amplitudes. \begin{subfigure}{\textwidth} \centering \includegraphics[trim={0 4cm 0 0},clip]{../lab-windows/fig_out/dsss_thf_amplitude_56_jupyter_impl} - \caption{Python prototype} + \caption{Python prototype.} \end{subfigure} \begin{subfigure}{\textwidth} \centering \includegraphics[trim={0 4cm 0 0},clip]{../lab-windows/fig_out/dsss_thf_amplitude_56_fw_impl} - \caption{Embedded C implementation} + \caption{Embedded C implementation.} \end{subfigure} \caption{ -- cgit