Download Pulse-Width Modulation and Motor feedback systems

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Introduction to Smart Systems
Pulse Width Modulation (PWM)
Motor Feedback - Shaft Encoder
1
(Introduction to) Pulse Width Modulation
PWM means controlling the relative widths of the positive and negative parts
of an output waveform, whilst keeping the pulse frequency constant.
PWM thus controls the amount of energy in the waveform (used to regulate
the speed of a motor, the brightness of a light etc.).
The proportion of time the signal is on is called the ‘duty cycle’:
A duty cycle of 100% means that maximum energy is provided, and a duty
cycle of 0% means that minimum energy is provided to the controlled device.
A square wave has a 50% duty cycle.
Duty Cycle
25%
50%
75%
2
Embedded Systems Programming II
Richard Anthony, Computer Science, The University of Greenwich
Pulse Width Modulation on ATmega1281 using Timer/Counter 0
The Timer/Counters on the ATmega1281 are capable of producing PWM
output pulses. Timer/Counter 0 is used for illustration.
‘Overflow’
Interrupt can be
generated at start
of new pulse
‘Output Compare’
Interrupt can be
generated at the
switchover point
in the pulse
Direct output of
pulse waveform
onto the OC0A pin
(bit 7 of Port B)
3
Embedded Systems Programming II
Richard Anthony, Computer Science, The University of Greenwich
Pulse Width Modulation – LED brightness control
A simple example application of PWM is controlling the brightness of LEDs –
the higher the duty cycle, the brighter the LEDs are.
An example ‘PWM light dimmer’ project has been placed on the course
website.
The application uses Timer/Counter0 in ‘Fast PWM’ mode.
The on-board switches are used control the brightness of the LEDs by reprogramming the timer registers so that different waveforms are produced.
Example LED brightness
levels. Photos are
blurred because these
had to be taken in low
light levels (long
exposures) with a
handheld camera
Duty cycle values
0.5%
2%
12.5%
25%
37.5%
4
Embedded Systems Programming II
Richard Anthony, Computer Science, The University of Greenwich
Rotation Feedback systems - Shaft Encoders (1)
A device to detect the position or angular rotation of a shaft
Typically used in Motor feedback systems (speed control), and devices where
angular position needs to be detected (a good example is a computer
mouse).
Magnetic: a magnet is placed on the edge of a wheel attached to the shaft. A
magnetic switch is placed near the wheel so that the switch activates each
time the magnet passes by.
Pulses
(output
signal to
microco
ntroller)
Magnet
Magnetic
proximity
switch (the
detector)
5
Embedded Systems Programming II
Richard Anthony, Computer Science, The University of Greenwich
Rotation Feedback systems - Shaft Encoders (2)
Detect
Forward / Backward
Movement
Optical:
Mouse Ball sits
under this cover
and rotates the
shafts
A light beam passes through, or
is reflected off of, a disk
attached to the rotating shaft.
The number of received light
pulses indicate the angular
rotation.
Detect
Left / Right
Movement
A ‘Quadrature’ technique is used
in the mechanical ball mice, so
that the direction can be
determined, as well as speed
(see next slide).
6
Embedded Systems Programming II
Richard Anthony, Computer Science, The University of Greenwich
Rotation Feedback systems - Shaft Encoders (3)
Quadrature: Two pulses are
produced on separate output wires.
The outputs are offset by 90
degrees, thus not only enabling the
measurement of speed or distance
(by counting the pulses) but also
determining the direction (by the
relative timing of the two pulses).
A ‘reference’ output is also added on
some devices; this gives an output
pulse once per turn at a precise
position and is used when there is
the need of an absolute reference,
such as positioning systems
(consider a security camera).
The output coding pattern (see above) is called
Gray code and enables the direction to be
determined – based on which signal ‘leads’. The
actual pattern of pulses is shown below (which
way is the shaft rotating?)
Can be mechanical or optical.
Example application: attached to
motors in robots and machinery
where a combination of speed /
rotation angle and direction are all
needed.
Embedded Systems Programming II
Quadrature encoders are used in ball mice to
track whether the mouse is moving to the
right/left or forward/backward.
7
Richard Anthony, Computer Science, The University of Greenwich
Diagrams from Wikipedia