Natcar Design
Jordan Rhee, Team 2, 2010
The goal of the Natcar proj
ect is to build an autonomous
car that can
race around track marked by a
wire carrying a sinusoidal current.
Natcar
is a control system. If we define the error signal as the car’s
distance from the track, then minimizing this value
will keep the car on the track.
A mechatronic control
system interacts with the real world through s
ensing and actuation. Since the
rules r
equire a 1/10 scale
RC car, actuation is already defined for us: steering and acceleration.
For sensing, there are at least two
options for generating a signal proportional to the car’s distance
from the track: 1)
using optics
or 2)
using electromag
neti
s
m
.
Fi gure
1
.
General c
ontrol system
. In Natcar, the system input is the car’
s wheel angle and acceleration. T
he output is the car’
s
position, orientation, and velocity
.
The measured output is a signal pr
oportional to the car’s horizontal displacement from the
track, and the reference is 0 since we want the car to be centered on the track.
Since the course is marked by white tape, an optical approach might use a camera and image processing
to try to “see”
the track and determine the car’s position and orientation relative to the track.
While an
optical approach would allow looking ahead to know the curvature of the track relatively far into the
future, the practical challenges in implementing a real

time vi
deo processing system fast enough be
useful are very hard. One would need a very powerful computer or highly optimized custom hardware
to do video processing that fast. There simply isn’t enough physical space or power for a general
purpose computer, and I
don’t have the time, expertise, or money to desig
n a custom video processing
system.
The electromagnetic approach is much more practical.
This
approach uses Faraday’s law of induction,
which states that t
he induced electromotive force or EMF in any closed
circuit is equal to the time rate
of change of the magnetic flux through the circuit.
We know from the Biot

Savart law that an electric
current generates a magnetic field, so there is a sinusoidally varying magnetic field around the wire
which marks the t
rack. If we place a coil near the track, this
sinusoidally

varying magnetic field will
induce
a sinusoidally

varying
voltage
in the coil. The magnitude of the induced
sin wave
will depend on
the coil’s orientation and distance from the wire.
Therefore, the
error signal (our distance from the
track) is amplitude modulated on a carrier of 75Khz.
If we place two sensors on the front bumper of the
car, we can determine the car’s horizontal displacement relative to the track as the difference of the
sensor value
s.
A system design fo
r Natcar is now becoming clear. One decision we must make is how to implement the
controller. Some Natcar
teams do completely analog implementations, but I will use a general purpose
microcontroller to implement a digital control system. The advantages of digital over analog are
numerous: noise immunity, algorithmic flexibility, reduced power consumption, red
uced cost. The rules
put the following
additional
requirements on our implementation:
T
he entire system must be powered by a single 7.2V standard RC car battery
T
he power supply must be built from ICs and discrete components, i.e. no preassembled
“blocks”
T
he motor driver must be built from ICs and discrete components
From these requirements we can sketch a block diagram of each of the subsystems.
Fi gure
2
. Natcar functional block diagram
.
Now we want to
design and impl
ement each of the blocks. First
we must consider dependencies
between subsystems and come up with a design strategy. The motor driver is dependent on the
electrical characteristics of the motor. Therefore, we must select a chassis and chara
cterize the motor
before designing a driver. The steering servo comes with the chassis, and will be driven by a PWM signal.
To design the sensors, we must first characterize the input signal and know the
input voltage range of
the microcontroller’s ADC. To
select the microcontroller, we must know the required sampling rate and
resolution of the ADC, minimum clock speed of the CPU, number and type of IOs. We must also consider
factors such as processor architecture, quality and availability of development to
ols, and cost. The user
interface will depend on the control algorithm and the IOs of the microcontroller. Finally, we will design
the power supply once we know the voltage and current requirements of each of the subsystems.
The
dependencies in the design
flow are visualized in the following diagram.
Figure
3
. Electronics Design Flow Dependencies
.
Arrow poi nts in direction of dependency.
Work may now proceed on the individual components in any topologi
cally sorted order.
Modeling the Input Signal
Let us define the input path as the system that translates the car’s physical distance from the track to a
digital error signal suitable for input to the controller. The signal originates at the coils, in which
a
voltage is induced proportional to the time rate of change of the magnetic flux through the coils. The
magnitude of the induced voltage depends on the distance and orientation of the coils from the track.
We must now design a system which takes this sig
nal input and translates it into a digital signal suitable
for processing. The system includes analog circuitry, the ADC, and any subsequent digital processing that
we do in the microcontroller.
The analog circuitry needs to amplify the sensed signal, demo
dulate the
75Khz carrier, and low

pass filter the signal to avoid aliasing at the ADC. We
can draw a block diagram of
the
system:
First, we want to characterize the input signal so that we can design the electronics and select
a
sampling frequency.
Let’s do some back of the envelope calculations to get an idea of the magnitude of
the input voltage and the useful frequency content.
First, let’s calculate the magnitude of the induced
voltage versus distance from the track.
To simp
lify our calculations, we’ll assume we’re using square
coils with
turns located in the plane of the track.
We can now formulate the problem into something you might have seen on your high school AP Physics
exam:
A square coi
l
with
turns and
sides o
f length
is placed distance
from an infinitely long wire
carrying current
(
)
(
)
. Derive and expression for
, the voltage measured between two
terminals of the coil.
We’ll use
faraday’s law to calculate the induced EMF in the coil.
(
)
̂
(
)
̂
(
)
(
)
∫
∫
∫
(
)
(
)
[
(
)
(
)
]
∮
(
)
(
)
So the output is a sin wave with magnitude
(
)
.
Let us plot the magnitude of the induced
voltage versus distance for several sizes of the coil.
This will give us an idea of our input voltage range.
√
If we were to place our sensors directly
against the floor, the
input signal range would be about 1

25mV.
Our microcontroller’s ADCs have an input range of 0

3V so we would need a gain of
120. The ADCs have
1
0 bits of resolution, so we would be able to resolve the entire dynamic range of the input signal.
So far our model is not realistic because it is not possible to locate our sensors directly against the floor.
We’ll
leverage the work of UC Berkeley studen
t
Darren Liccardo
in his paper “
Natcar Magnetic Sensor
Modeling
” to model more realistic sensor placement.
We will extend
his model by integrating over the
area of the sensor.
Note that we are NOT using the same coordinate system or direction conventions as
him.
The diagram below is drawn as if you were sitting in the car, looking forward at the track and the
sensors. The sensor is square, extending
units
in the positive y direction (into the page). The wire also
lies along the y axis, and current flows into the page.
We can write the magnetic field as a function of
and
:
(
̂
̂
)
√
The normal vec
tor of the sensor is
̂
̂
̂
The flux through the coil is then
(
)
∫
(
)
(
)
(
)
Where
T
he magnitude of the induced voltage
as a function distance, height, angle, and inductor size is:

(
)

∫
(
)
(
)
Let’s plot voltage versus distance for several sensor angles, choosing a height of 1cm, sensor size of 1cm,
and
.
Left:
Right:
Left:
Right:
Supposing we choose the orientation which has the least dynamic range (
) w
ith a maximum voltage of
about 5mV, we would need a gain of 1000 to
boost the signal up to 5V.
Now that we have an idea of
our input signal voltage range, we want to get an idea of the useful
frequency content so we can select a sampling frequency and design our filters accordingly. The fastest
Natcars travel at around 9m/s, so we’ll assume 10m/s is
the absolute maximum our car would ever go.
Supposing we want 2Khz of frequency content, that means we’re sampling every 0.5cm of linear
distance the car travels. This seems reasonable for now, so we’ll assume the useful frequency content of
our input sig
nal is band

limited to 2Khz.
The slowest part of the system is the steering serv
o, which has a
response time
much greater than 1/2Khz=0.5ms,
so we may need to filter the signal further to avoid
instability, but it is unlikely we will need frequency content
greater
than 2Khz.
We can always implement
further low

pass filtering digitally in the microcontroller.
Our ADC has a maximum sampling rate of
97.4Khz if we use 4 channels at 10bits resolution, so it easily meets the 4Khz Nyquist rate.
The ADC has
an inpu
t voltage range of 0

3V.
Designing the Sensor Circuitry
Now that we’ve characterized our input signal in terms of voltage range and frequency content, we can
design the circuit.
We wish to design a circuit which implements the following block diagram
.
Before we dive into circuit design, let’s first use Simulink to verify the block diagram.
The input signal is modeled as a 2Khz sin wave double sideband
AM
modulated on a 75Khz carrier
superimposed on high frequency white noise.
The analog lowpass filter is a 2
nd
order butterworth filter
with cutoff frequency 2khz. The quantizer
has
and
.
In this simulation
we are using
4x ove
rsampling
.
Simulating the diagram over several periods of the input yields the
following output.
Fi gure
4
. Si mulink output for the i nput path. Top: the i nput signal modulated on a 75Khz carrier with HF noise. Mi ddle: the
amplifie
d, rectified signal and low

pass filtered analog signal. Bottom: the sampled, quantized signal.
We can see from the Simulink output that our
block diagram
is valid. That is, we can recover the original
2khz signal from the modulated, noisy signal.
Now that
we’ve verified the block diagram, we can go
ahead and design the circuit.
We will design everything with a single 5V supply.
I have done the design
on paper, so I will present the results and justify the design.
The first stage accomplishes gain and half

wave rectification.
The gain is achieved in two stages: a fixed
gain of 50 follo
wed by a variable gain of
.
The Texas Instruments INA156 is a rail

to

rail
output CMOS instrumentation amplifier
with a fixed gain of 50.
By referencing the output to ground, we
can also achieve half

wave precision rectification in this stage. When the input goes negative, the output
will saturate at 0V. The requirements on this stage are a closed loop BW > 80Khz, a
nd
slew rate
(
)
(
)
⁄
. The INA156 has
and
, so
it meets the requirements. It also has high input impedance, high common mode rejection, and low
input bias current. Since our sensor (a coil)
can be modeled as a voltage source in series with a very high
resistance, a high input impedance is desirable. Furthermore, the sensors are located several inches
away from the board and will be connect
ed
to the board with wires. The signal will pick up c
ommon
mode noise, so an i
nstrumentation amplifier is
desirable because it
amplifies the difference of the
signals,
reducing
common mode noise.
The variable gain stage is implemented as a non

inverting
amplifier that uses a trimpot for adjusting the gain.
The trimpot can be used to fine

tune the gain after
the circuit is assembled. Thi
s also allows flexibility in
sensor selection and placement.
The
filter
stage is a 2
nd
order low

pass filter created by cascading two 1
st
order RC low

pass filters. From
simul
ations, we saw that the system needed at least a 2
nd
order filter. We could have used the Sallen

Key topology and eliminated one op amp, but the OPA4340 comes
with 4 op

amps, so we might as well
go with the simpler topology and use all four op

amps. The t
ransfer function of the filter stage is
(
)
(
)
⁄
(
)
The transfer function of a 2
nd
order LPF has the general form
(
)
So by matching coefficients we get
We wish to set
, so we choose standard 1% values for R and C:
The last stage is an attenuator and buffer. The signal processing takes place between 0

5V,
and
the input
volta
ge range of the ADC is 0

3V, so
we want to set the voltage divider to have a ratio of
. We select
the following values for the voltage divider:
The unity gain op amp buffers the output of the voltage divide
r and drives the ADC of the
microcontroller. The
series resistance is recommended by the OPA4340 application notes
to
improve stability
when driving capacitive l
oads in unity gain configuration
.
The OPA 4340 is a quad op amp package, so the variable g
ain stage, filter stage, and output buffer can
be implemented with 1 IC. There are 2 ICs per channel (INA156 and OPA4340) and 4 channels, so the
final board will have 8 ICs plus an onboard 5V LDO and decoupling capacitors.
Comments 0
Log in to post a comment