Content uploaded by Brij Mohan Bhushan
Author content
All content in this area was uploaded by Brij Mohan Bhushan on Jul 07, 2021
Content may be subject to copyright.
OVERSAMPLING AND AVERAGING, NOISE ANALYSIS FOR
IMPROVING CONTROL PERFORMANCE
Brij M. Bhushan1, Allison Lenhard1, David L. Trumper1
1Department of Mechanical Engineering
Massachusetts Institute of Technology
Cambridge, MA, United States of America
INTRODUCTION
Systems with feedback motion control are typically
limited in bandwidth and control performance by the
eect of system parameters which limit the gain of
the controller, such as: (1) sensing noise; (2) plant
dynamics - dominant behavior near crossover, res-
onances, and right-half plane zeros; (3) sampling
time - phase lag due to zero order hold; and, (4)
non-linearities such as amplier saturation and ac-
tuator limits. This paper presents a mechatronic
platform for experiential learning where students can
learn about such issues.
In a teaching environment, students are taught about
all these aspects, but it is more challenging to create
cost-eective labs where students get a feel for the
constraints which dynamics places on feedback con-
trol performance. It is desirable to have a portable,
low-cost setup that enables students to learn these
principles hands-on, even outside dedicated lab facil-
ities. Such a setup, the FlexLab and LevLab printed
circuit board (PCB) has been developed in our lab
for this purpose [1], and has been used successfully in
teaching the Analysis and Design of Feedback Con-
trol Systems (2.14) course at the Massachusetts In-
stitute of Technology (MIT) [2].
We demonstrate a higher control loop performance
and management of dynamics and measurement
noise on the 2-degree of freedom (DOF) FlexLab T-
beam system, achieving a crossover of 100 Hz, with
about 40° phase margin in both the bending and
twisting directions. This is enabled by: (1) imple-
menting high-speed digital control by leveraging the
Field Programmable Gate Array (FPGA) on the NI-
myRIO embedded evaluation board by National In-
struments (NI), and (2) implementing oversampling
and averaging of the sensor measurement signals to
reduce sensing noise within the control bandwidth.
This paper describes the experimental setup, plant
modeling, sensor noise reduction by oversampling
and averaging, and controller design along with its
implementation and achieved performance results.
The paper also describes noise analysis using spec-
T-shaped bronze
beam
Disk-shaped
permanent magnets
Hall effect sensor
pair
Spiral coil using
traces in PCB
Power amplifiers for
coils
Real-time controller:
NI myRIO
FIGURE 1. The experimental setup includes a
FlexLab PCB and an NI-myRIO. Components of in-
terest are labeled accordingly.
tral tools such as power spectral density and cumu-
lative power spectrum, which can be used to identify
areas for improving the control performance. The
approach described in this paper provides a low-cost
way to improve control performance on commonly
available high-speed micro-controllers that usually
have moderately low-resolution analog inputs. We
also provide links to sample open-source LabVIEW
code for implementation using NI hardware.
EXPERIMENTAL SETUP
The experimental setup consists of the
FlexLab/LevLab PCB connected to an NI-myRIO
real-time controller. Fig. 1shows the FlexLab
experimental setup with key components labeled.
The FlexLab conguration is composed of a bronze
T-shaped cantilever beam with two permanent
magnet (PM) pairs on each end of the T. The stem
of the T-beam is bolted to the PCB, while the end
of the beam with the PM pairs is the free end above
two actuating coils printed as spirals on the PCB.
Fig. 2shows a block diagram of the setup. The PM
pairs mounted at the two ends of the T-beam are
used for both sensing and actuation. The PM ux is
measured by the Hall sensors which is correlated to
the beam position above the coils. The Hall sensor
measurement circuit averages and low-pass lters the
outputs from the Hall sensor pair, acting as a rst-
order anti-aliasing lter (AAF) at 20 kHz bandwidth.
Windows
Computer
Real-Time
Hall
sensor
Hall se nsor
Meas. Circuit
(20 kHz LPF)
FPGA
PCB traces
ADC
(250 kHz
Sample rate)
256-pt
Moving A vg.
Filter
Control Loop
(100 kHz
loop rate)
Real-Time
Interface Loop
(5000 Hz
loop rate)
Host PC
UI + Spectral
Analysis
(100 Hz loop rate)
Neodymium magnets
On b ronze beam
NI myRIO-1900
DAC
(100 kHz
output rate)
Push-pull
Linear power
amplifier
PCB Coils
(To actuate
the magnets)
Dynami c Si gnal
Analyzer
(2000 Hz
loop rate)
FIGURE 2. Setup block diagram. Multi-processor architecture enables high speed controller implementation.
The input-output interface and controller is imple-
mented in FPGA on the myRIO. The Hall sensor
signals are read at 250 kHz and low-pass ltered with
a 256-pt. moving average (MA) lter. The control
loop runs at 100 kHz generating a control eort sig-
nal in response to position error. The control eort
signal commands the on-board linear power amplier
to drive current through the PCB coils to actuate the
magnets. The user interface and dynamic signal an-
alyzer enabling measurement of Bode plots run on
the real-time processor, while waveform visualization
and spectral analysis execute on the Host-PC.
PLANT MODELING
The T-beam with a pair of PMs located at each end
of the T as seen in Fig. 1can be most simply modeled
as a fourth-order dynamical system. The plant mod-
eling for the system is described in [1]. The modeling
assumptions and resulting dynamic equations are re-
produced here for completeness.
To simplify the modeling of the system, we make the
following assumptions: the PMs move in the vertical
direction with small displacements relative to their
distance from the coils; the power ampliers driving
the actuator coils are linear and have no signicant
dynamics within position loop bandwidth; the actua-
tor coils have small inductance which has a negligible
eect on the circuit dynamics. Resolving the vertical
PM measurements coil actuation into a transformed
coordinate system of bend and twist makes the rst
two lumped modes at 11 Hz and 32 Hz independent
in each direction.
The dynamic equations resulting from the lumped
parameter model with respect to the decoupled bend
(zc) and twist (θx) coordinates are as follows. Ta-
ble 1denes the modeling parameters used in the
following equations:
¨zc=−kb
2mzc−K2
i
mRc
˙zc+gampKi
2mRc
uz
¨
θx=−kt
Iθx−2K2
iL2
IRc
˙
θx+gampKiL
IRc
uθx
The moment of inertia I, bending stiness kb, and
twisting stiness ktof the T-beam are dened as
I= 2mL2, kb=3E
l3
beam
wt3
12
kt=G
lbeam
wt31
3−0.21 t
w1−t4
12w4
To get the state-space model of the system, de-
ne x= [zc,˙zc, θx,˙
θx]T,u= [uz, uθx]T, and
y= [zc, θx]T, which gives
˙
x=Ax +Bu
y=Cx
where,
A=
0 1 0 0
−kb
2m−K2
i
mRc0 0
0 0 0 1
0 0 −kt
I−
2K2
iL2
IRc
B=
0 0
gampKi
2mRc0
0 0
0gampKiL
IRc
C=1 0 0 0
0 0 1 0
The coordinate transformation matrix used to get
zcand θxfrom the Hall sensor (sensitivity, SHall )
measurements [V] at each PM is:
zc
θx=S−1
Hall 1/2 1/2
−1/2L1/2LVH2
VH3
10-5
100
105
Magnitude [abs]
Bend direction
100101102103
Frequency [Hz]
-600
-400
-200
0
Phase [deg]
plant model
plant meas.
RR model
RR meas.
(a)
100
Magnitude [abs]
Twist direction
100101102103
Frequency [Hz]
-400
-200
0
200
Phase [deg]
plant model
plant meas.
RR model
RR meas.
(b)
FIGURE 3. Measured and modeled Bode plots of plant and loop return-ratio (RR), of the T-beam system driven
in (a) bend, and (b) twist directions. The plant inputs are the decoupled bending and twisting control voltages
[V], and the plant outputs are the decoupled bend [mm] and twist [rad] displacements. The units of the plant
magnitudes are in mm/V and rad/V for bend and twist respectively and RR magnitudes are dimensionless.
Mode 1: 11 Hz
Mode 2: 32 Hz
Mode 3: 154 Hz
Mode 4: 253 Hz
Mode 5: 336 Hz
Mode 6: 428 Hz
FIGURE 4. First 6 exible vibration modes of the FlexLab T-beam, as determined by nite element analysis.
Color gradients represent maximum total displacement from blue (small displacement) to red (large displacement).
TABLE 1. Modeling Parameters
Description Parameter Value Unit
beam length lbeam 65 mm
beam width w9.525 mm
beam thickness t0.25 mm
T end length 2L30 mm
elastic modulus E110.3 GPa
shear modulus G38 GPa
mass of PM pair m1.7 g
amplier gain gamp 2 V/V
coil resistance Rc10.5 Ω
coil force-const. Ki0.055 N/A
Hall-sensor sens. SH all 1.25 V/mm
.
Fig. 3shows the modeled and measured plant and
return-ratio Bode plots in the bend and twist direc-
tions. The delity of the model is limited to 100 Hz
due to only accounting for the rst two lumped ex-
ible modes in the dynamic model. However, there
are higher frequency dynamics present in the system,
which are observable in the measured plant bend and
twist frequency responses. The next four exible vi-
bration modes occur at approximately 154 Hz, 253
Hz, 336 Hz, and 428 Hz. These modes are all a com-
bination of bending, twisting, and sideways motion;
their respective shapes can be seen in Fig. 4. Since
these higher frequency mode shapes do not strictly
fall into the bend or twist category, the vibration
modes are more complex to model, and not amenable
to control from the available inputs. Based on the
plant Bode plot measurements, the high frequency
modes that are problematic to control loop stability
are the 3rd and 5th exible modes. The Controller
Design section discusses the control implications of
these higher order modes.
SENSING NOISE REDUCTION
One of the main contributions of this paper is show-
ing how to use an FPGA to implement high-speed
oversampling, and thereby extend the control loop
bandwidth in the face of sensing noise. In our sys-
tem, the sensing noise is dominated by analog to dig-
ital converter (ADC) quantization. The NI-myRIO
has a 12-bit ADC, with a 0–5 V range on the A,B
fAAF
PSD
fsampling/2
Sensor
Signal noise
ADC
quantization
noise
fLPF
Low-pass
filte r
f
FIGURE 5. Power spectral density (PSD) of sensor
and ADC noise components. Digital low-pass lter
cuts o noise density as shown.
connectors [3]. The corresponding measurement res-
olution is 1.2 mV per least-signicant bit.
Oversampling and averaging [4] helps improve sens-
ing resolution by reducing the eective ADC quan-
tization noise as shown in Fig. 5. The sensor has
an approximately white-noise component from 0 to
fAAF , the anti-aliasing lter cut-o frequency. This
PSD is independent of sampling frequency and de-
pends on many factors such as inherent sensor noise
characteristics, wiring, signal conditioning, and AAF.
On the other hand, ADC quantization noise has ap-
proximately white-noise characteristics from 0 until
fsampling/2, the sampling Nyquist frequency. This
noise has a xed variance and therefore its PSD mag-
nitude reduces with increasing sampling frequency.
Reduction in quantization noise is achieved by:
(1) sampling much faster than the required crossover
frequency, which spreads out the quantization noise
power over a wider range of frequencies up to the
Nyquist frequency (fsampling/2), and (2) implement-
ing a low pass lter at a frequency (fLPF) such that
only noise power up to fLPF remains. These stages
reduce the overall noise variance and thereby improve
the apparent measurement resolution. The sensor
noise, originally appearing up to the anti-aliasing
lter cut-o (fAAF), is also limited by fLPF. All
noise sources are assumed to be Gaussian, which is a
good approximation for commonly available ADCs in
which the quantization non-linearity can be ignored.
FPGA implementation in the NI-myRIO enables 2-
channel sampling rates of up to 250 kHz along with
256-pt. MA lters at this data rate. This high speed
implementation helps in two ways: (1) by oversam-
pling 256-times faster, we can reduce the ADC quan-
tization noise standard deviation approximately by a
factor of 16, which corresponds to an increase in ef-
fective number of bits (ENOB) of 4 [5]. Thus, the
ADC input behaves as a 16-bit ADC up to a band-
width of about 1 kHz; (2) achieve higher sensing
resolution while reducing the accompanying phase
lag in the control loop. The 256-pt. MA lter is a
linear-phase nite impulse response (FIR) lter and
has a phase drop reaching about 18° at the de-
sired crossover of 100 Hz. The control loop run-
ning at 100 kHz loop rate causes negligible phase
drop of 0.18° at 100 Hz due to the zero-order hold
(ZOH). On the other hand, if the controller is im-
plemented on the real-time processor in the NI my-
RIO, the maximum achievable control loop rate is
about 2 kHz, which causes a phase drop of about 9°
at 100 Hz due to the ZOH. Implementing non-linear
phase FIR or Innite Impulse Response (IIR) lters
as the low-pass lter could further help reduce phase
lag due to oversampling and averaging. The value
from the MA lter is placed in a memory location
from which the control-loop reads values at a lower
rate of 100 kHz, which is like the decimation step [6].
Fig. 6shows the measured sensor noise in the bend
and twist directions under closed loop control with
oversampling and averaging. The noise standard de-
viation in both directions is about 60 µV, which cor-
responds to 50 nm and 3.3 µrad (0.2 milli deg) RMS
positioning noise in the bend and twist directions re-
spectively. Frequencies where the CPS plot shows
a large jump correspond to frequencies with high
noise power. For the bend direction, this corresponds
to about 45 Hz which is likely from some external
source such as oor vibration. For the twist direction,
the noise power jumps signicantly at about 154 Hz
corresponding to the 3rd exible mode of vibration.
In contrast, raw measurements have a noise stan-
dard deviation of about 600 µV which corresponds
to 500 nm positioning noise in the bend direction.
The plant requires a gain of about 100 (combination
of proportional gain and lead) from the controller
at 100 Hz for crossover at that frequency (Fig. 3).
This controller gain would increase the control eort
standard deviation to about 60 mV which results in a
peak to peak noise amplitude of about 0.6 V. Thus,
the control eort due to noise becomes a signicant
portion of the amplier range of 5 V making it di-
cult to crossover at 100 Hz with raw measurements.
CONTROLLER DESIGN
Mechanical resonances arising from the exible
modes limit the achievable crossover frequency.
From the measured plant Bode-plots (Fig. 3), it can
be seen that the resonance at 336 Hz limits crossover
for the bend direction and the resonance at 154 Hz
limits the crossover for the twist direction. The
336 Hz resonance in the bend direction is from the
5th exible mode which is both observable and con-
trollable in the bend direction. The impact of this
(a) (b) (c)
(d) (e) (f)
FIGURE 6. Noise measurement of position in closed loop. The top plots (a,b,c) represent the bending direction
and the bottom plots (d,e,f) represent the twisting direction. (a,d) time-waveforms of bend and twist directions
when reference kept at 0. (b,e) probability density of noise. (c,f) The PSD and CPS of the noise waveform.
mode is mitigated by implementing a notch lter at
336 Hz with a quality factor, Qof 10. The notch
lter is of the form:
Hnotch(s) =
s2
ω2
0
+ 2ζzs
ω0+ 1
s2
ω2
0
+ 2ζps
ω0+ 1
with ω0=2090 rad/s, ζz= 0.025, and ζp= 0.25.
The 3rd exible mode corresponding to 154 Hz res-
onance, in which the center of the T-beam oscil-
lates vertically, should in principle be unobservable
in the twist direction. The coupling of this mode
into twist measurements is believed to be due to the
small parasitic motions in the twist direction due to
misalignment of PMs or other asymmetry of the T-
beam mechanism. This same mode should ideally
have a zero in the bend direction which is seen as
an anti-resonance in the bend-direction Bode plot.
This makes the 154 Hz mode observable, but uncon-
trollable in the rotation direction. A notch lter at
154 Hz would make this mode unobservable, but such
a notch lter reduces phase signicantly at 100 Hz
and is therefore not feasible. Due to the parasitic
origin of this mode, the magnitude of resonance is
small and this mode was managed by keeping the
phase above −180° to keep the loop stable. How-
ever, the sensitivity Bode plot of the closed loop in
the twist direction is large at 154Hz and this mode
is easily excited by any jerk in the bending direction
that can excite the 3rd vibration mode. The excited
oscillation slowly dampens out from energy dissipa-
tion in the mounting joints and structural damping
in the T-beam.
With the notch lters in place, a standard PID con-
troller with a low pass lter is used in both bend and
twist directions. The controllers were designed in
continuous time and then mapped into discrete time
using pole-zero matching for implementation as dif-
ference equations in the FPGA at Ts=10 µs loop
time. The controller is of the form:
Gc(s) = Kp1 + Ki
sατ s + 1
s2
ω2
0
+ 2ζs
ω0+ 1
with the values of Kp=31.25 V/mm, Ki=
62 rad/s, α= 20,τ=3.9789 ×10−4s, ω0=
2285 rad/s, and ζ= 0.707 for the bend di-
rection. For the twist direction, the values are
Kp=375 V/rad, Ki=45 rad/s, α= 10,τ=
5.6841 ×10−4s, ω0=1600 rad/s, and ζ= 0.5.
Fig. 3shows the measured decoupled loop return
ratios using the specied controller parameters. As
discussed in the Plant Modeling section, high fre-
quency dynamics are observable in both the bending
and twisting directions.
(a)
(b)
FIGURE 7. Step responses in bend and twist.
RESULTS AND DISCUSSION
With oversampling and averaging, we are able to
achieve a crossover frequency of 100 Hz in both the
bend and twist directions with a phase margin of
about 40° (Fig. 3). Step responses of the system in
bend and twist directions is shown in Fig. 7. The step
responses are consistent with the crossover and phase
margin obtained above. As expected, in the step re-
sponse for the bending direction, the impulse excites
the 3rd exible vibration mode at 154 Hz that shows
up parasitically in the twist direction and rings down
very slowly. Note that this mode is visible because
of the improved sensing resolution. In the raw mea-
surements, this mode gets masked by the ADC noise.
Using the raw ADC measurements we can achieve a
maximum crossover frequency of about 50 Hz in the
bend direction and 65 Hz in the twist direction with
40° phase margin.
The control bandwidth is severely limited by the res-
onance at 154 Hz . The performance of the system
could be improved by increasing damping of the T-
beam or by better alignment of the magnets and
the Hall sensors to decrease the magnitude of the
resonance. Further, the 3rd exible mode could in
principle be actively damped using the 3rd coil at the
center of the long beam - the location at which the
beam has large amplitude in this mode (anti-node).
SUMMARY
In this paper, we presented an example of improv-
ing the control performance enabled by sensing noise
reduction by oversampling and averaging and high-
speed control implementation in FPGA. The control
was implemented in an NI-myRIO for 2-DOF T-beam
control on the Flexlab PCB. We also describe the role
of dynamics in achieving desired control performance
and the use of spectral noise analysis tools. The ap-
proach described in this paper provides a relatively
low-cost way to improve the control performance
on commonly available high-speed micro-controllers
that frequently have low-resolution ADCs.
SOFTWARE
Sample LabVIEW code for implementation of the
controller on the FlexLab hardware using NI-myRIO
is provided at [7]. The design details of the FlexLab
system are open-source and can be found at [8].
REFERENCES
[1] L. Zhou, J. Y. Yoon, A. Andriën, M. I. Ne-
jad, B. T. Allison, and D. L. Trumper, “Flexlab
and levlab: A portable control and mechatron-
ics educational system,” IEEE/ASME Trans. on
Mechatronics, vol. 25, no. 1, pp. 305–315, Feb.
2020. doi:10.1109/TMECH.2019.2951308.
[2] D. Trumper, in 2.14 Analysis and Design of
Feedback Control Systems. Spring 2014, MIT
OpenCourseWare, Cambridge MA, 2014.
[3] User Guide and Specications NI myRIO-1900,
376047C-01, National Instruments Corp., May
2016. [Online]. Available: http : / / www . ni .
com/pdf/manuals/376047c.pdf.
[4] B. Bhushan and D. Trumper, “Low cost, high
dynamic range position sensing enabled by over-
sampling and averaging,” in 2020 ASPE Spring
Topical Meeting – Design and Control of Pre-
cision Mechatronic Systems, May 2020.
[5] “Improving Adc Resolution By Oversampling
and Averaging,” pp. 1–20, 2013. [Online]. Avail-
able: https:/ / www.silabs. com/Support%
20Documents/TechnicalDocs/an118.pdf.
[6] A. V. Oppenheim and R. W. Schafer, Discrete-
Time Signal Processing, 3rd edition. Pearson
Education Limited, 2013, p. 647, isbn: 978-
0131988422.
[7] B. Bhushan, FlexLab. [Online]. Available:
https : / / github . com / mbrijbhushan /
Flexlab.
[8] L. Zhou, FlexLab Design Files. [Online]. Avail-
able: https : / / pmc . mit . edu / projects /
project-flexlab-and-levlab.