b4 Intro All
b4 Intro All
b4 Intro All
Engineering
Stephen Roberts
Lecture 1
A gentle introduction
Aims
• To provide you with an overview of what B4
and information engineering in general is
concerned with
• To make explicit links between information
engineering and the core syllabus especially
A1, A2 and A3
• To give you some sense of how central
information engineering is to the engineer’s
career and to our every day lives.
Course Outcomes
At the end of this 4 lecture course you should
Estimation
Operating System
Sensors Actuators
Real World
The Role of Feedback
• Note the presence of a feedback loop in the previous
architecture.
+ C(s) G(s)
-
H(s)
Issues:
•What does the software of the controller look like?
•What speed must it run at?
•Computers are discrete devices but the world is continuous so how does one
link the two?
•Does using a discrete controller have stability implications?
•What design tools are available for the discrete domain?
•Do familiar continuous domain analysis tools have discrete time duals?
What is H?
+ C G
-
H
Issues:
•How does one sample the plant output ?
•How does one transmit measurements to the CPU running the controller?
•How does one guarantee that measurements will always be processed ?
•What does one do if the sensed output is not what we wish to control e.g sensing
color but wanting to control flow rate?
•How does one deal with noisy sensor data?
•How does one fuse multiple measurements?
Information Systems Exemplar
• The “Segway” robot shown here is a container of
many of the central concerns of the information
engineer (and as it happens, electrical engineers)
• Sensing (accelerometers, gyro)
• Actuation Control (varying payload)
• Computing
– IO from sensors
– Output to actuators
– Controllers in software
– Estimation of state by processing sensor data
Note:
•Duplication of
electronics (safety)
•Requires interfacing of
sensors and motors to
computation
•Requires control to be
implemented on a
computer
•Control laws are non
trivial : to stop you have
to first speed up!
•Requires interpretation
of sensor data
•Requires an internal
model
Info Eng. Components of the Segway
• Sensors - 5 Corriolis (interesting) gyros
Network analysis
National Grid Car design
Complicated non-linear coupled Complex optimisation task
dynamics Active suspension
Traction control, slip estimation
Plant identification
Lecture II –The Role of the Computer
• IO sensor interfaces
– Serial ports
– Ethernet
– PCI
– Firewire
• Microcontrollers
– PICs
– embedded systems,
– pic diagram ref segway
• OS
– device drivers
• Processes and IPC (inter process communication)
Motivation
• If we are to design a complete information
engineering system we may need to consider
of how data is or should be marshalled
• Data transfer technology is ubiquitous and 5*
Engineers should be able to say something
sensible about every day equipment!
Sensor/Actuator Interfacing
• How to get data from sensor to processor? Common choices
– Direct to bus (PCI)
– External serial protocols RS232, firewire, USB
– CAN bus (controller area network)
– All need hardware/software to transport data
Analog/digital data
Control signal
PCI BUS
High power amplifier
Slow speed RS232, RS485, RS422 – the COM Ports on your PC,
long distance, simple hardware, simple data protocol
Image ex -wikepedia
Example PIC16F87 (used in Segway)
The algorithms that support these applications are the domain of the information
engineer.
Why is MAC so Important?
• In B4 and C4 (if you take it) you’ll learn that the continuous transfer
functions you are now familiar with (e.g C(s)) are in reality almost always
implemented in discrete form on a computing device.
• If C(s) is a continuous function you’ll soon learn how to map this to a
discrete time controller C’(z) where z is the discrete time analogue of s
• The upshot of all of this is that time and time again we’ll come across
expressions like:
Constant “filter” coefficients
-50
-100
Magnitude (dB)
-150
-200
-250
-350
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Fraction of nyquist frequency
100
50
Phase (degrees)
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Fraction of nyquist frequency
Micro Processors
• Close approximation to what you’ll find in
your PC – general purpose computation
devices
• No onboard IO like serial ports A2D etc
• Often large word size
• Little speed optimised hardware although
recent x86’s have made in-roads
• Covered in A2
From Hardware to main()
Thread Additional execution
streams
Thread
OS HAL
Driver
hardware
Interlude: Units of Execution -
Processes
• A process is a fundamental concept
to computing.
• It represents a single instance of a
running computer program – a
sequence of serially executing
instructions.
• A process is allocated memory
which is not (generally) seen by
other processes
• The times at which processes are
run are scheduled by the operating
system
Interlude: Units of Execution - Threads
• Threads are independent threads of execution within a
single process.
• Thread scheduling by the OS gives the appearance of
concurrent execution
• All threads within a given process can see (read and
write) the same memory – that owned by the process.
• For example a process might have a user interface
thread (drawing, handling button presses) a
computation thread and a sensor IO thread.
• Operating systems provide system calls that start new
threads from thread[0] (the thread started by the OS
when a process is started.)
The Role of the Operating System
Producer Consumer
We need to consider how data could be shared between producer and consumer
Shared Memory
Process A Process B
Shared Memory
•Processes can make special system calls to the operating system which return a chunk
of memory that can be shared between processes.
•The OS also provides a mechanism by which a process can ask to have already
allocated shared memory inserted into its own address space (Process B needs to be
able to ask to see the shared memory segment already created by Process A)
write read
Shared Memory
write
Marginalisation
If you can remember and use these two rules then so much is
within your reach….(including exams!)
Probabilistic Models
• We can think of sensor measurements, z, as
samples from a conditional distribution
(conditioned on the state of the world, x)
Laser range finder (theodolite)
True distance x
Measured distance z = x + random noise
p(z|x)
x
Sensor Models Cont – Gaussian Noise
p(z|x)
Estimation
Engine
Data Estimate
Prior Beliefs
Maximum Likelihood
p(z|x)
x
xml
A A \B B
Yes, you should be. Bayes’ rule lies at the very heart of
swathes of information engineering:
•Medical imaging
•Tracking
•Estimation
•Sensor processing signal recovery
•Machine learning
p(z|x)
Apply Bayes’ Rule
Mean
Variance
How does the mean change?
Previous state
new state
F
Note that at no point were we restricted by the form of the p.d.f’s or what
the physical interpretation of x,z or u might be.
•x: rate of inflation, z: the price of a car, u: intervention from the world bank
•x: strain on a beam, z: measured voltage
•x: car velocity, z police radar time of flight
•x: sheet metal thickness, z:X-Ray energy, u: roller pressure
•x: tumour state, z: PET scan, u:motion of patients head during scan
Probabilistic methods are a natural way to handle uncertainty in measurement and state evolution.
The techniques they give rise find application across all domains of engineering
The Role of the Gaussian
It is common to find that the functional form of the pdfs in the previous slides is that of
a Gaussian. Of course we may have distribution over a vector (for example position and
velocity). In which case we shall be dealing with the multidimensional Normal
distribution.
.
You can read the marginal distribution variance
off the diagonals of the covariance of the joint
The Gaussian is a common functional
form
If Gaussians are used in the pdfs of the recursive Bayes
formulation and in the equations we derived for propagating
plant uncertainty one ends up with something called a
Kalman Filter (covered in detail in C4)
Flight Parameters
Camera 1 (observer)
Image coordinates
controller plant
r(t) e(t) u(t) y(t)
+ D(s) G(s)
-
1
sensors
In Practice: Using A Digital Computer
• We implement the controller in software running on a digital conputer
• We need to convert twixt digital and analog…
controller plant
y(t)
r(t) Sample & + e(kt) u(kt) DAC & u(t)
ADC
D Hold G(s)
r(kt) -
Sample &
ADC
1
sensors
Digital, sampled system
•The signals e(kT) u(kT) and r(kT) are “discrete”
•T is the sample period,k is an integer
•A discrete signal is constant over the sample period
sample
y(t) y(kT)
Unit circle
[-1]
D(jw)G(jw)
Example Using Simulink
Continuous Controller
Discrete controller
Simulation Results
1.5
80 Hz
Blue: continuous 1
system response
20 Hz
1
Sample rate
0.5
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1.5
10 Hz
0.5
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
4
instability
2
5 Hz
-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time (s)