circuit cellar2004 07

background image

7

9

25274 75349

0 7>

CIRCUIT

CELLAR

®

www.circuitcellar.com

T H E M A G A Z I N E F O R C O M P U T E R A P P L I C AT I O N S

$4.95 U.S. ($5.95 Canada)

#168 July 2004

GRAPHICS & VIDEO

Waveform Monitor

Smart Touchscreen User Interface

Color Video Frame Grabber

Multimedia Thermometer

background image
background image
background image

Digital Oscilloscopes

2 Channel Digital Oscilloscope

100 MSa/s

max single shot rate

32K samples per channel

Advanced Triggering

Only 9 oz and 6.3” x 3.75” x 1.25”

Small, Lightweight, and Portable

Parallel Port

interface to PC

Advanced Math options

FFT Spectrum Analyzer options

DSO-2102S

$525

DSO-2102M

$650

Each includes

Oscilloscope

,

Probes, Interface Cable, Power
Adapter, and software for
Win95/98, WinNT, Win2000
and DOS.

40 to 160 channels

up to 500 MSa/s

Variable Threshold

8 External Clocks

16 Level Triggering

up to 512K samples/ch

Optional Parallel Interface

Optional 100 MSa/s Pattern Generator

LA4240-32K (200MHz, 40CH)

$1350

LA4280-32K (200MHz, 80CH)

$2000

LA4540-128K (500MHz, 40CH)

$1900

LA4580-128K (500MHz, 80CH)

$2800

LA45160-128K (500MHz, 160CH)

$7000

www.LinkIns4.com

Link Instruments

369 Passaic Ave

Suite 100

Fairfield, NJ 07004

(973) 808-8990

Fax (973) 808-8786

Logic Analyzers

• 24 Channel Logic Analyzer
• 100MSa/S max sample rate
• Variable Threshold Voltage
• Large 128k Buffer
• Small, Lightweight and Portable
• Only 4 oz and 4.75” x 2.75” x 1”
• Parallel Port Interface to PC
• Trigger Out
• Windows 95/98 Software

LA2124-128K (100MSa/s, 24CH)
Clips, Wires, Interface Cable, AC
Adapter and Software

$800

All prices include Pods and Software

background image
background image

P

resentation is everything. You don’t have to look any further than

your local mall or supermarket to see the major effect of display.
Manufacturers spend millions creating packages that sell—packages
that clearly and concisely relay essential information about the product
they contain and look good doing it. You might call it user-friendly pack-
aging. The package is an extension of the advertising campaign that has
been painstakingly researched and tested to ensure sales. In fact, the
way in which products are displayed has become so important that col-
leges now offer degrees in supermarket display and packaging.

When designing electronic displays, the same principles apply. The

goal is to create a display that is eye-catching, readable, easy to under-
stand, and most likely easy to program (if you’re making the display for
a client). We have a couple of articles this month that discuss excellent
display projects ideally suited for use by consumers. Alberto Ricci Bitti’s
DVD-Thermometer (p. 12) and Bruce M. Pride’s Smart-E-Touch (p. 56)
are definitely attractive designs that meet the demand for user-friendly
technology. Anyone who followed the Motorola Flash Innovation 2003
Design Contest will be especially interested in these contest winners.

Alberto designed a system to display temperature on a TV with full-

color graphics, which can be still or animated. Graphics that correlate to
various temperatures (for example, a chilly Linux penguin with the back-
drop of snow-capped mountains for 15°F) are stored on a DVD. Alberto
imagines his DVD-Thermometer being used in public spaces like malls
or retail shops, perhaps incorporating advertising. The DVD-
Thermometer’s versatility lends itself to a variety of other uses as well.
You can use the system to gather and display any type of data.

Bruce’s Smart-E-Touch is an intelligent touchscreen user interface

that’s perfect for just about any setting. The design relies on a Motorola
Nitron microcontroller to control and monitor Motorola e-field sensors.
Using the e-field sensors enabled Bruce to build the user interface direct-
ly on the circuit board, which makes the system extremely reliable, not to
mention easy to create.

In addition to these great projects, we have a number of other equal-

ly terrific graphics and display projects. The video frame grabber
designed by Eric Gagnon digitizes a single image of full-field color video
into a field buffer, and offers a cost-effective solution to traditional off-the-
shelf systems (p. 22). The waveform capture and display system creat-
ed by Dick Cappels is designed around three Atmel microcontrollers (p.
42). This simple project, which consists of a graphic display unit and a
capture and control unit, is a great addition to your workbench. Last, but
not least, we have a graphics library written in C for the Zilog Z8 Encore!
family designed by Brian Millier (p. 62). Brian’s library enables Z8 micro-
controllers to utilize the full functionality of graphic LCD panels.

4

Issue 168 July 2004

www.circuitcellar.com

CIRCUIT CELLAR

®

EDITORIAL DIRECTOR/FOUNDER
Steve Ciarcia

MANAGING EDITOR
Jennifer Huber

TECHNICAL EDITOR
C.J. Abate

WEST COAST EDITOR
Tom Cantrell

CONTRIBUTING EDITORS

Ingo Cyliax
Fred Eady
George Martin

George Novacek
Jeff Bachiochi

NEW PRODUCTS EDITOR
John Gorsky

PROJECT EDITORS
Steve Bedford
Ken Davidson
David Tweed

ADVERTISING

PUBLISHER

Dan Rodrigues

E-mail: dan@circuitcellar.com

ASSOCIATE PUBLISHER/DIRECTOR OF SALES

Sean Donnelly

Fax: (860) 871-0411

(860) 872-3064

E-mail: sean@circuitcellar.com

Cell phone: (860) 930-4326

ADVERTISING COORDINATOR

Valerie Luster

Fax: (860) 871-0411

(860) 875-2199

E-mail: val.luster@circuitcellar.com

ADVERTISING ASSISTANT

Deborah Lavoie

Fax: (860) 871-0411

(860) 875-2199

E-mail: debbie.lavoie@circuitcellar.com

CONTACTING CIRCUIT CELLAR

SUBSCRIPTIONS:

INFORMATION: www.circuitcellar.com or subscribe@circuitcellar.com
To Subscribe: (800) 269-6301, www.circuitcellar.com/subscribe.htm, or
subscribe@circuitcellar.com
PROBLEMS: subscribe@circuitcellar.com

GENERAL INFORMATION:

TELEPHONE: (860) 875-2199 Fax: (860) 871-0411
INTERNET: info@circuitcellar.com, editor@circuitcellar.com, or www.circuitcellar.com
EDITORIAL OFFICES: Editor, Circuit Cellar, 4 Park St., Vernon, CT 06066
NEW PRODUCTS: New Products, Circuit Cellar, 4 Park St., Vernon, CT 06066
newproducts@circuitcellar.com

AUTHOR CONTACT:

E-MAIL: Author addresses (when available) are included at the end of each article

CIRCUIT CELLAR®, THE MAGAZINE FOR COMPUTER APPLICATIONS (ISSN 1528-0608) and Circuit Cellar Online are pub-

lished monthly by Circuit Cellar Incorporated, 4 Park Street, Suite 20, Vernon, CT 06066 (860) 875-2751. Periodical rates paid at

Vernon, CT and additional offices. One-year (12 issues) subscription rate USA and possessions $21.95, Canada/Mexico

$31.95, all other countries $49.95. Two-year (24 issues) subscription rate USA and possessions $39.95, Canada/Mexico

$55, all other countries $85. All subscription orders payable in U.S. funds only via VISA, MasterCard, international postal money

order, or check drawn on U.S. bank.

Direct subscription orders and subscription-related questions to Circuit Cellar Subscriptions, P.O. Box 5650, Hanover, NH

03755-5650 or call (800) 269-6301.

Postmaster: Send address changes to Circuit Cellar, Circulation Dept., P.O. Box 5650, Hanover, NH 03755-5650.

For information on authorized reprints of articles,

contact Jeannette Ciarcia (860) 875-2199 or e-mail jciarcia@circuitcellar.com.

Circuit Cellar® makes no warranties and assumes no responsibility or liability of any kind for errors in these programs or schematics or for the
consequences of any such errors. Furthermore, because of possible variation in the quality and condition of materials and workmanship of read-
er-assembled projects, Circuit Cellar® disclaims any responsibility for the safe and proper function of reader-assembled projects based upon or
from plans, descriptions, or information published by Circuit Cellar®.

The information provided by Circuit Cellar® is for educational purposes. Circuit Cellar® makes no claims or warrants that readers have a right to
build things based upon these ideas under patent or other relevant intellectual property law in their jurisdiction, or that readers have a right to
construct or operate any of the devices described herein under the relevant patent or other intellectual property law of the reader’s jurisdiction.
The reader assumes any risk of infringement liability for constructing or operating such devices.

Entire contents copyright © 2004 by Circuit Cellar Incorporated. All rights reserved. Circuit Cellar and Circuit Cellar INK are registered trademarks
of Circuit Cellar Inc. Reproduction of this publication in whole or in part without written consent from Circuit Cellar Inc. is prohibited.

CHIEF FINANCIAL OFFICER

Jeannette Ciarcia

CUSTOMER SERVICE

Elaine Johnston

CONTROLLER

Jeff Yanco

ART DIRECTOR

KC Prescott

GRAPHIC DESIGNER

Mary Turek

STAFF ENGINEER

John Gorsky

QUIZ COORDINATOR

David Tweed

Cover photograph Chris Rakoczy—Rakoczy Photography

PRINTED IN THE UNITED STATES

Presentation is Everything

jennifer.huber@circuitcellar.com

TASK MANAGER

background image

Their boards come with a

packing slip. Ours come

with a

Microsection

Analysis Report

In today’s competitive climate, offering the
best product at a competitive price is a must
to satisfy your customers. Sierra Proto
Express offers the fastest, most reliable, turns
at the highest quality. And we’ll prove it in
every shipment with our unique Evidence of
Quality reports, so you know your board is
right the first time. One proof of quality is
our Microsection Analysis Report, as
featured here, so you can see the quality
inside your board. And that is just part of
our comprehensive quality tests. It’s in our
process, not in our price. In fact, it is our
commitment to total quality that enables us
to run our operation cost effectively. And
that comes back to you in our competitive
price. Talk to a Sierra Proto Express Account
Manager about our commitment to quality,
our range of technology, and our 99%
on-time track record of delivery. Call
1.800.763.7503 from 6 a.m. to 6 p.m. PST
or email your design to
files@protoexpress.com and receive a quote.
Mention code: PPDC00093

For proven quality that never costs
extra, put Sierra Proto Express on
your team today.

14 Layer Board

Microsection

Q u a l i t y O n Ti m e

Learn more about our unique Evidence of

Quality report that comes with every PCB

at www.protoexpress.com

q

u

a l

i t y l e a d

e

r

M

IL

-P-5

5110 ISO

90

0

2

80

0-

76

3-7

503

www.protoex

pre

ss

.c

om

background image

6

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

July 2004: Graphics & Video

4

TASK MANAGER
Presentation is Everything

Jennifer Huber

8

NEW PRODUCT NEWS

edited by

John Gorsky

11

TEST YOUR EQ

edited by

David Tweed

78

SILICON UPDATE

Motoring (Part 1)

Motor Basics
Tom Cantrell

FEATURES

COLUMNS

DEPARTMENTS

94

INDEX OF ADVERTISERS

August Preview

96

PRIORITY INTERRUPT
War Driving

Steve Ciarcia

50

APPLIED PCs

Uncomplicated dsPIC Implementation

Fred Eady

74

FROM THE BENCH

Lose the Crystal

Linear’s LTC6903/4 Programmable Oscillator
Jeff Bachiochi

12

Adaptable Multimedia Thermometer

Alberto Ricci Bitti
Flash Innovation 2003 Design Contest Winner

22

Full-Field Color Video Frame Grabber

Eric Gagnon

32

Easy Reflow

Build an SMT Reflow Oven Controller
Robert Lacoste
Renesas Design 2003 Grand Prize Winner

36

Designing with the Nios (Part 2)

System Enhancement
George Martin

42

Triple AVR Waveform Capture and Display

Three Controllers Make a Waveform Monitor
Dick Cappels

56

Smart-E-Touch

An Intelligent User Interface
Bruce M. Pride
Flash Innovation 2003 Design Contest Winner

62

Graphics LCD Library for the Z8 Encore!

Brian Millier

DVD-Thermometer (p. 12)

Smart User Interface (p. 56)

Waveform Monitor (p. 42)

background image
background image

converts base-band analog video into digital video, sup-
porting up to 10 component video inputs including com-
posite (NTSC, PAL and SECAM), S-Video, and component
(YPbPr) video signals.

The device also includes an analog video output for TV

video out signals and connection to other external devices.
Video signal processing has been optimized to produce high-
quality video from weak broadcast signals or nonstandard
VCR video. Additionally, the decoder outputs ITU-R BT.656
and supports Macrovision copy protection as well as advanced
VBI functionality. The TVP5147 includes two 10-bit, 30-msps
ADCs. Each analog channel contains an analog circuit,
which, prior to each converter, clamps the input to a ref-
erence voltage and applies a programmable gain and off-
set. The TVP5147 digital video decoder includes a 2-D five-
line adaptive comb filter.

Evaluation boards, software tools, and application notes

are available for the TVP5147. The device costs $9 in
1,000-piece quantities.

Texas Instruments, Inc.
www.ti.com

8

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

NEW PRODUCT NEWS

HIGH-QUALITY DIGITAL VIDEO DECODER

The new TVP5147 is a high-performance digital video

decoder (NTSC/PAL/SECAM) that digitizes and decodes
all popular base-band analog video formats into digital
component video. The device is a mixed-signal video
decoder optimized for use in the U.S., Japan, and China. It

Edited by John Gorsky

HIGH-RESOLUTION DISPLAY

Half and full VGA-size LCDs put the power of high-reso-

lution graphics and detailed screen content in the hands
of embedded developers. High-resolution LCDs make the
GUI ideal for developing innovative point-of-sale termi-
nals and introducing unique touchscreens for high-end
consumer electronics.

Creating attractive GUI screen content is as easy and

as time-saving as with the Graphics OS in silicon; how-
ever, the final output can now be more elaborate and
ornate. These higher-resolution displays enable more
content per GUI page as well. This solution comes with
its own microprocessor, graphics library, and LCD con-
troller so that the host microprocessor or microcon-
troller is never burdened by the GUI’s operation.

The half VGA-size LCD is 5.4

with a resolution of 320 ×

480 pixels. The full VGA-size LCD is 7.5

with a 480 ×

680 resolution. The new displays complement a line of
modules that supports a 5.7

QVGA LCD with a resolu-

tion of 240 × 320 pixels.

The half VGA-size LCD is available for $150 each for

production volumes
of 10,000 units or
more. The full-size
VGA LCD is available
for $250 each for pro-
duction volumes of
10,000 units or more.

Amulet Technologies
(408) 244-0363
www.amulet
technologies.com

LOW-CURRENT, SINGLE-DIGIT, SEVEN-SEGMENT

DISPLAYS

The new TDSR family of high-intensity, low-current,

single-digit, seven-segment displays provide excellent read-
ability even in direct sunlight. The displays, which use
AllnGaP technology in the color red, offer high performance
for extremely low-power applications, delivering a typical
luminous intensity of 1,500 µcd while being driven with
just 1 mA of current.

Featuring a wide

viewing angle, the
new displays can be
used in panel meters,
test and measure-
ment equipment,
point-of-sale termi-
nals, control units,
and battery-operated
systems requiring
extremely low-power consumption.

The six TDSR displays offer designers a choice of com-

mon anode (TDSRxx50) or common cathode (TDSRxx60)
versions with minimum and maximum luminous intensity
ratings from 180 to 3,600 µcd, respectively, enabling opera-
tion in direct sunlight or in “black front” designs using
tinted filter glass. A maximum forward current of 10 mA is
allowed for an ambient temperature range of –40° to 85°C
without current derating.

Pricing in 10,000-piece quantities is $60 per 100 pieces.

Vishay Intertechnology, Inc.
(619) 336-0860
www.vishay.com

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

9

NEW PRODUCT NEWS

INDUSTRIAL GRADE FLAT-PANEL DISPLAY INTERFACE

The new industrial grade AD9883A is the industry’s

first fully integrated analog interface to operate over the
industrial temperature range of –40° to 85°C. The device

enables superior image quality in rugged environments
that require wider temperature ranges and robust design
features. The AD9883ABST is ideally suited to automotive
and aerospace applications where displays operate in rigor-
ous, taxing environments and need to withstand extreme
fluctuations in temperature.

The AD988A is optimized for XGA and SXGA LCDs,

HDTV, and Advanced TV applications. The AD9883ABST
features three high-bandwidth, 8-bit, 140-msps ADCs and an
ultralow jitter PLL (less than 500 ps at 140 MHz), ensuring
maximum robustness and image quality. Its architecture is
compatible with LCD, plasma, projection, and other types of
digital display technologies. The IC performs other functions:
composite sync processing, mid-scale clamping, input signal
detection, automatic power-down control, and programmable
gain/offset control—all of which help maximize ease-of-use
and robustness in graphics and video applications.

The AD9883ABST flat-panel interface, which is available

in 80-pin LQFP packaging, is sold in both industrial and
commercial temperature-grade versions.

The part costs $8.50 per unit in 1,000-piece quantities.

Analog Devices, Inc.
(800) 262-5643
www.analog.com

background image
background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

11

What’s your EQ?

The answers are posted at

www.circuitcellar.com/eq.htm

You may contact the quizmasters at eq@circuitcellar.com

CIRCUIT CELLAR

Test Y

Your E

EQ

Problem 3

Each phase of a three-phase power

system is a sine wave displaced by 120° from the pre-
vious one. If you connect a resistor across two of the
phases, what is the waveform of the current that flows
in it?

Problem 4

Demonstrate the answer to Problem 3

mathematically.

Contributed by David Tweed

Edited by David Tweed

Problem 1

A residential power meter contains two

coils that together produce a torque on the rotor disc
that is proportional to the instantaneous power flowing
in the load. The mechanical inertia of the disc aver-
ages this torque over several cycles.

Power factor correction (PFC) circuits come in two

flavors, one that corrects for reactive (inductive or
capacitive) loads, and one that corrects for nonsinu-
soidal current waveforms.

If the load is an inductive load, such as a lightly

loaded motor, what is the effect of adding a PFC of the
first type to it on the power meter reading? In other
words, does the meter run faster, favoring the power
company, or does it run slower, favoring the customer?

Problem 2

If the load is a nonlinear load—such as

a large capacitor-input power supply that draws cur-

rent in relatively narrow spikes at the peaks of the AC
voltage waveform—what is the effect of adding a PFC
of the second type to it on the power meter reading?

background image

mind. As a result, all of the modules
reside in separate files that are ready to
be ported to other applications by chang-
ing only a few

#define commands.

Now I’ll describe how I managed to

transform a DVD player into an eye-
catching video thermometer. Even if you
aren’t interested in taking temperatures,
you can adapt these basic techniques to
display any sort of data. These techniques
are worth adding to your bag of tricks,
just in case. Along the way, you can col-
lect some valuable, reusable software
modules, like a versatile programmable
pulse generator, an I

2

C bus driver, and a

RECS80 remote control transmitter.

SYSTEM BASICS

Let’s examine the building blocks of

the system (see Figure 1). A specialized
digital temperature sensor IC measures
ambient temperature and converts it
into a digital word that can be read by
the microcontroller via the I

2

C bus.

The microcontroller doesn’t have a
hardware I

2

C, so the I

2

C driver is imple-

mented in software. This driver works
as the foundation for the thermometer
chip driver, which is, in turn, required
by the main application firmware.

Another software module makes the

microcontroller’s internal 16-bit timer
work as a programmable pulse generator
(PPG). The RECS-80 remote-control
encoder block assembles these pulses in
order to drive an infrared LED connected
to a port pin. The sleep manager module
ensures that all of the previous blocks

12

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

I

built an innovative multimedia

thermometer that displays tempera-
ture readings on an ordinary TV with
crisp, full-color graphics. To add a lit-
tle magic to a reading, you can ani-
mate pictures and program CD-quality
audio announcements to accompany
each temperature change. The pictures
can vary according to your application.

The system is perfect for a wide range

of settings. If you use it in a retail shop
or mall, you can complement logos and
product advertisements with tempera-
ture information. On the domestic
front, photos of the kids playing at the
beach or, should the temperature drop,
making a snowman are nice gifts for
Grandma. The thermometer would also
work well at hotels, airports, sporting
venues, and tourist sites (see Photo 1).

DVD-THERMOMETER

Despite its rich feature set, my

DVD-Thermometer is an amazingly
simple design that requires few com-
ponents. Another advantage is that it’s
hundreds of dollars cheaper than typi-
cal PC-centric solutions. I made the
DVD-Thermometer at home, just for
the fun it, without special tools. All I
used were a soldering iron, a multime-
ter, a PC with ordinary CD-R burner,
and the Motorola QT demo board.

The circuit, which is battery-operated,

fits comfortably in a small plastic box
that’s located in front of an ordinary DVD
player. A switch and infrared LED peep
out of the box. The DVD player is loaded

Adaptable Multimedia
Thermometer

Alberto’s 68HC908QT4-based multimedia thermometer displays temperature readings in full
color on a TV screen. What’s more, you can add animated pictures along with high-quality
audio to announce each temperature change. If you don’t need a temperature-taking system,
you can use the design techniques described here to display any other type of data.

with a disc that’s prerecorded with pic-
tures that correspond to different temper-
atures. Acting as an intelligent infrared
remote control, the DVD-Thermometer
directs the player by selecting the scene
that matches ambient temperature.

The circuit diagram is embarrassingly

simple: it’s entirely built around an inex-
pensive eight-pin microcontroller, a digi-
tal temperature sensor, and an infrared
LED. All of the hard work has to do with
the software, which is the most impor-
tant ingredient of the project. I wrote the
program in C language, implementing
low-power techniques with code reuse,
portability, and data encapsulation in

FEATURE ARTICLE

by Alberto Ricci Bitti

Photo 1—

One of the great features of this project is

that you can customize the graphics. Here is Tux, the
Linux penguin, commenting on the temperature.

background image

it receives from the circuit.

The adjustment is repeated

until the temperature on the
TV matches ambient temper-
ature. There is no feedback
from the DVD player telling
the microcontroller which
image it’s playing, so the
microcontroller and player
must start from a well-known
temperature/picture pair. To
ensure the DVD player always
starts from the first picture in
the sequence, the microcon-
troller stops and restarts the

disc during start-up.

REMOTE CONTROL HACKING

I started the design process by

reverse-engineering the remote control
that came with my DVD player.

picture on the TV. The DVD driver uses
the RECS-80 embedded remote control
to direct the DVD player to the appro-
priate position. The DVD player cannot
tell the difference between a real
remote control and the infrared stream

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

13

are called in a timely manner
and that power isn’t wasted.

The infrared LED is placed

in front of an ordinary DVD
player connected to a TV. The
DVD player is loaded with a
special disc containing a prere-
corded sequence of pictures,
each of which shows a differ-
ent temperature value. When
played normally, the disc
shows all of the temperatures
in the thermometer range,
from the lowest to the highest.
Refer to the “Disc Production”
sidebar for more information.

When the system runs, the main

program continuously evaluates ambi-
ent temperature. If it differs from the
on-screen temperature, the system
instructs the DVD driver to change the

Temperature

sensor

Microcontroller

Main program

Thermometer

driver

I

2

C Bus

driver

Sleep manager

DVD Driver

RECS-80

Remote

control

Programable

pulse

generator

SDA

SCL

Infrared

LED

DVD Player

DVD Media

(recorded with graphics

and sound)

TV

Figure 1—

One of the building blocks is an entire DVD player that’s used as a

video generator. The remaining hardware consists of a digital temperature sen-
sor, an infrared LED, and a microcontroller. The software is the most important
ingredient because of the many levels of nested drivers.

DISC PRODUCTION

The disc is an essential part of the system because the

images, videos, animations, and sounds are recorded on it.
Skipping the artistic part of the process, let’s focus on the
technical aspects of the procedure.

Of course, you can use your favorite recording and video-

editing software to burn the disc. Strictly speaking, it will
work if it can burn a disc with a sequence of images that your
DVD can browse back and forth through by way of the Next
and Previous keys.

I searched for the easiest way to record a test disc. A DVD

burner is unnecessary. If your thermometer doesn’t require the
DVD player’s full 4.7-GB
capacity, an inexpensive CD-R
burner is sufficient. I used CD-
RW media to perform different
experiments recycling the
same disc. You must ensure
that your DVD player can read
CD-R or CD-RW discs.

I prepared a set of 62 frames,

each of which is stored in a
separate JPG file on the PC
hard drive, representing
temperatures between –10° and 50°C, plus one frame with
the message “battery low” (see Figure 1). Newer DVD
players can automatically play JPG and MP3 files located
in the root directory of a CD-R or CD-RW disc. This is
definitely the easiest way to get started with the DVD-
Thermometer. It’s worth a try.

Unfortunately, my DVD player refused to read such a disc,

so I made a second attempt at recording the CD-RW disc in
the video-CD format. This method worked well.

I prepared my disc with Nero Burning ROM 5.5, a popular

software solution for burning CD-Rs. It features a CD-R
wizard that makes the process a piece of cake.

Click on the File/New menu, and the New Compilation

window will appear. From the left banner, select the Video-
CD format. Don’t touch the defaults (except deselecting
thumbnail generation if it’s enabled. Confirm the new com-
pilation by clicking on the New button. The program contin-
ues with the familiar selection of the files to be included on
the disc, with an Explorer-like directory tree interface. Drag
and drop all of your 62 JPG files on the new project. Pay
attention to the order: the first file you drop must be the first

file that appears in the final
sequence. Multiple selection
and cut and paste work well,
provided that you select the
original files in the right
order. I suggest you give the
files new names so they can
be sorted alphabetically.
Then, sort the folder by file
name and do a multiple
select by dragging the mouse
from top to bottom.

That’s it. If you click on the Burn icon, the program

will format the disc according to the Video-CD specifica-
tions and create all the necessary support files required
by the DVD player. I recommend that you choose the
lowest possible burn speed. When you’re finished, test it
on the DVD player to verify that all of the images are in
the correct sequence, passing from one another, by press-
ing the Next and Previous keys. This is also the best
time to read the user manual in order to discover the pro-
cedure for disabling the on-screen display.

Figure 1—

I implemented readings from –10° to 50°C in 1°C steps. Therefore, I set

DVD_LAST_PICTURE to 61 (62 pictures in total). The last picture appears when the
microcontroller detects an insufficient battery level (approximately 4.3 V on my proto-
type). You may download this sample picture set from the Circuit Cellar ftp site.

background image

14

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

weekend and wasn’t able get one until
the following Monday. So, I used the
PC sound card to analyze the signal.

I connected an infrared LED (the same

one I used in the final circuit) to the mic
input in order to use it as a sort of photo-
voltaic sensor. I placed the remote con-
trol in front of it (as close as possible) and
watched the signal with a sound-editing
program. The waveform suffered because
of the rude measurement technique, but
it was clearly discernible as one of the
popular codes described in Other’s article.

Fortunately, I didn’t need to open it.
All I wanted to know was how it
encodes its various keys. The market
is shared among a handful of different
infrared modulation schemes, but I
was lucky enough to find that the
remote control conformed to one of
the standards whose documentation
was readily available in A. N. Other’s
article “IR Remote Control Codes”
(Elektor Electronics, March/April 2001).

Although an oscilloscope is prefer-

able, I started the design on a rainy

The good news is that the remote control
or my Irradio DVD player conforms to
the RECS80 format. The bad news is that
the RECS80 waveform is difficult to
encode because it involves synthesizing
pulses whose duration spans many orders
of magnitude, from microseconds to
hundreds of milliseconds.

A complete waveform anatomy is doc-

umented in Philips’s “SAA3004 Remote
Control Transmitter” datasheet. In brief,
a RECS80 code word is a sequence of
short pulse bursts. The basic burst
requires six cycles of the 38-kHz carrier
frequency with a 33% duty cycle. This
requires asymmetrical, nail-shaped
pulses just 8.77 µs wide.

Bits are encoded using PPM modula-

tion. In PPM code, the time between
two consecutive bursts represents a sin-
gle bit of a code word. In the case of
RECS80, an interval of 5.06 ms repre-
sents a zero, whereas a 7.6-ms interval
means a one. An entire code word
counts 12 pulses, encoding 11 bits of
information including a bit that toggles
each time a new key is pressed. To
ensure that the code is received without
errors, the same word is repeated many
times, with a repetition period of 0.12 s.
Note that because encoded PPM code
words differ in length, the duration of
the pause between repetitions must
change accordingly to compensate.

As you observe your remote control

waveform, I suggest you take note of
the key codes involved in the DVD
scene selection process. I guess there
are standard tables somewhere, but
because there are only four keys to
use, I found it convenient to transcript
their binary values watching the emit-
ted waveform. After the start pulse,
every short pause means a zero,
whereas a longer one means a one.

Photo 2 highlights the keys of inter-

est. The Next key, which allows you
to skip to the next scene in the DVD
sequence, is opposite the Previous key,
which allows you to go back. The
Next/Previous pair is all you need to
search for a specific picture.

A few other keys are useful during

start-up because the software uses
them as a sort of reset, forcing the
player to always start from the first
scene on DVD disc. In the case of my
DVD player, these keys include Stop,

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

15

which stops disc playing, and Play,
which starts playing the disc from the
beginning after the disc has stopped.

HARDWARE SIMPLICITY

With just eight parts and a battery,

the hardware could not be simpler (see
Figure 2). Circuit optimization is a
corollary coming straight from the level
of integration of its main components.

The temperature sensor IC is either

a DS1621 or DS1631. This eight-pin-
ner includes a complete digital tem-
perature sensor/thermostat with I

2

C

output. With the appropriate com-
mands, the temperature can be read
from the serial interface with a guar-
anteed accuracy of 0.5°C and a resolu-
tion of up to 0.1°C. It does not require
calibration, which is advantageous
because you can trust your ther-
mometer without messing with ice
and boiling water. Pin 3 works as a
thermostat, but this feature is unused
in this application. Pins 5 through 7
determine the low bits of the device’s
I

2

C address. (Up to eight sensors can be

connected in parallel on the same I

2

C

bus.) Setting the connections as shown
in Figure 2 configures the device to
respond at address 0x90.

I used the MC68HC908QT4, a tiny

eight-pin device with 4 KB of flash
memory and 128 bytes of RAM. A
nice characteristic is that all of its
pins (except power) can be used as
I/O, because proper reset is guaran-
teed by means of internal brownout
circuitry and a flash-calibrated inter-
nal oscillator provides a reasonably

stable clock source. Timing precision
is important to get correct remote
control waveforms. The 1% specifica-
tion for the internal oscillator is not
far from the accuracy of ceramic res-
onators, which are commonly
employed in remote controls.

Two I/O pins serve as I

2

C bus data

and clock. All MC68HC908QT4 pins
feature programmable pull-ups, so exter-
nal resistors on the I

2

C bus are unneces-

sary. Another I/O port drives the IR
LED (ports can source up to 25 mA)

through a current-limiting resistor. Peak
current is set to 8 mA—much lower
than a real remote control—because the
device is designed to operate in close
proximity to the DVD player. Excessive

LED power may interfere with other IR
devices in the same location (e.g., air
conditioners, TVs, VCRs, DVD play-
ers, and devices commonly found in
homes, offices, and shops).

The circuit will not add another

cable to your AV tangle: it’s battery
powered. Four AA cells supply a total
of 6 V. A voltage regulator is unneces-
sary; but, if you feel uncomfortable
powering chips close to their maximum
tolerable voltage, you can always add
one. I found that an electrolytic capac-
itor and two filter capacitors are
enough to provide clean power.

An extremely useful feature of the

MC68HC908QT4 is hardware support
for one-pin ICD (in-circuit debug),
which makes an emulator unnecessary
for most developers. An MC68HC908QT4
chip programmed with a tiny user
monitor allows you to load applica-
tion programs, place breakpoints, and
watch variables with almost no over-
head for the program running. ICD
mode requires just one pin (PTA0) for
data transfer, a push button to keep
PTA2 grounded during reset, and a

trivial interface for the PC serial port.
(Refer to the Motorola application
notes listed in the Resources section
of this article for a circuit schematic
that’s compatible with the DVD-
Thermometer and detailed program-
ming explanations.)

If this is your first project with an

HC908 microcontroller, it is simpler
to start with a part with the user mon-
itor already programmed and good
hardware (e.g., the inexpensive
M68DEMO908QT4 starter kit). In
this case, I suggest you replace the
sleep() routine with a classic
“empty-for” delay loop, because the
stop instruction should not be used
with the demo board.

SOFTWARE ESSENTIALS

Because this project requires a mini-

mal amount of hardware, most of the
hard work is done in software. I devel-
oped the software with the free
Metrowerks Codewarrior integrated
development environment. The IDE
includes an assembler, ANSI-C com-
piler, simulator, chip programmer, in-
circuit emulator/debugger, and even
Processor Expert, which is an auto-
matic C code generator.

You may download the code from

the Circuit Cellar ftp site. I selected C
language to make the code reusable
and more flexible. By the way, I had
some I

2

C sources coming from a previ-

ous application on a different micro-
controller.

I have a quite formal program-

ming style. When time allows, I do
my best to write structured code,
using #defines to name every con-
stant, ban global variables, and par-
tition the code in .c modules and .h
header files. Source file names
closely reflect the elements in the

Photo 2—

The microcontroller emulates four remote

control keys: Stop, Play, Next, and Previous. The

RECS80

routine can generate any key code given its

binary value.

Figure 2—

There are eight parts plus the battery. Most of the hard work has to do with the software. The only active

parts are a digital temperature sensor and an 8-bit microcontroller. As long as batteries are used, a power regulator
is unnecessary.

background image

To ensure that disc
playing starts from
the first scene,
DVD_init() stops
and restarts the
player, emulating
the respective
remote control keys.

The distinct

remote.c file imple-
ments the RECS80
remote control
encoder. To make
the IR LED flash the
play command, call
remote_control
(KEY_PLAY).

I defined codes for

the Stop, Play, Next,
and Previous keys.
The routine can gen-
erate any other code
if given its binary
value. It automatical-

ly swaps the toggle bit each time it is
called. Each code is repeated five times
to ensure it is received correctly.

I’m extremely satisfied

by the RECS80 encoder
implementation (see
Listing 1). The secret is
using a programmable
pulse generator (PPG)
that works in the back-
ground under interrupt
control; it does all the
magic transparently and
allows for a straightfor-
ward definition of the
encoding scheme. If your
DVD player uses an
infrared code other than
RECS80, implementing
the new scheme should-
n’t be too difficult. On
the contrary, the PPG
pulse_gen.c file is rather
complex, so I will
describe it separately.

The DS1621.c file,

which is the thermome-
ter driver, is in charge
of initializing the chip
registers and the I

2

C

bus as well as taking
temperature readings. It
carries out these opera-
tions issuing short

16

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

block diagram (see Photo 3).

The main application (main.c) includes

initialization code for port register set up
and void interrupt routines. During the
start-up phase, it calls the initialization
procedures of the DVD driver and ther-
mometer respectively. Each driver han-
dles its initialization hierarchically (e.g.,
after it’s initialized, the thermometer
routine

DS1621_init() calls

I2C_init() to initialize the I

2

C pins).

After the system is up, the main con-

trol loop begins. First, check if the bat-
tery has enough juice by reading the
LVI register. If not, use the remaining
energy to select the “battery low” mes-
sage from the DVD pictures. (I arbi-
trarily placed it as the last image in the
sequence.) Otherwise, obtain the ambi-
ent temperature, subtract the lowest
temperature possible to get an index
that starts from zero, and use the
index to select the image.

DVD.c provides the scene selec-

tion facility. For instance, call
DVD_select( 25 ) to show the twen-
ty-fifth scene. Figure 3 illustrates the
selection algorithm. The DVD module
keeps track of which image is currently
displayed, starting from zero during ini-
tialization. If the image that will be
selected follows or precedes the current
one, the disc is advanced, emulating the
Next or Previous remote control code.

sequences of I

2

C commands. I tried to

make them as easy as possible to read,
but understanding the DS1621/DS1631
datasheet, as well as familiarizing
yourself with I

2

C bus concepts, is defi-

nitely necessary. If you don’t have the
time to read the datasheet, just call
DS1621_temperature() to get the
current temperature (°C). If you need
higher resolution, uncomment the
lines in the code to get 0.1°C readings.
Notably, the software doesn’t need to
convert Celsius to Fahrenheit for use
of the thermometer outside Europe.
All you need is a different DVD on
which Celsius pictures are replaced by
Fahrenheit temperatures!

The software emulates an I

2

C bus tog-

gling two I/O pins. When speed is not a
concern, software implementations like
this one are perfectly adequate. I ported
the I2C.c code from a bigger processor.
All that was required was to provide
methods to set and clear the SDA and
SCL pins, to change data direction, and
to activate the pull-ups. All of this was
done with macros, so I accomplished

Select DVD picture

Picture

greater than

last picture?

Picture

less than

first picture?

Same picture

as currently

on screen?

Picture

greater than

on-screen picture?

Picture

less than

on-screen picture?

Function end

N

N

Y

N

N

N

Y

Transmit “prev” remote

control key

picture = picture –1

Transmit “next” remote

control key

picture = picture + 1

Y

Go in Stop

mode

for 1 s

Picture = last picture

Picture = first picture

Y

Y

Figure 3—

The DVD selection routine operates iteratively. It keeps track of

the image currently on the screen and passes to a new one (one step at a
time). This technique requires the DVD to respond only to two commands,
next and previous.

Photo 3—

The C file names in the Codewarrior project window reflect the blocks

constituting the application. Each module encapsulates a reusable driver for func-
tions like DVD selection, I

2

C bus communication, temperature readout, and

remote control generation. The code compiles in approximately 2 KB and runs in
User Monitor mode.

background image
background image
background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

19

the task in minutes. I didn’t need to
adjust the waiting loop, although you
might have to if you port the code to
fast (or slow!) processors. After it was
recompiled, the driver worked like
magic, providing the I

2

C primitives

for communicating with two-wire
peripherals:

I2C_start, I2C_stop,

I2C_tx_byte, and I2C_rx_byte.

The last file, sleep.c, provides a func-

tion to put the processor in Stop mode for
a given number of seconds. The sleep
function is called from different modules;
therefore, I placed it in a separate file.
Because the delays are based on the wake-
up timer, the times are approximate. To
have the processor take a 1-min., low-
power nap, just call

sleep(60);.

PULSE GENERATOR

The usual way of generating remote-

control pulses with small controllers
is by bit banging (i.e., flipping pins
directly in a carefully timed software
loop). This solution is far from perfect.
The main defects are its poor resolu-
tion and inherent dependency on code.
Even touching a single line of code
inside the loop can completely ruin
the output waveform.

The excellent 16-bit timer module of

the MC68HC908QT4 processor called
for a more elegant solution than crude

bit banging. The result is the versatile
programmable pulse generator (PPG)
contained in the pulse_gen.c source file.
It can generate pulse bursts whose carri-
er frequency and duty cycle are set with
a simple command. The number of puls-
es in a burst can be set as well. This is
ideal for handling the 8.77-µs LED flash-
es. You can disable the output but keep
the timing in order to generate pauses
with the same resolution to handle the
5.06-ms, 7.6-ms, and 0.12-s gaps required
by the RECS80 code.

The PPG is easy to set up and use

(see Listing 2). It is interrupt-based
and synchronizes itself for pending
requests, so it frees the main program
for other tasks while working in the
background. This feature is beneficial
when writing the infrared encoding

routine because it leaves plenty of
time for the processor to compute the
pulses that come next.

I started from a working example

that I created with Processor Expert,
using its PPG component (“bean” in
Processor Expert jargon). I studied the
computer-generated code along with
the datasheets in an effort to get
familiar with the timer module details
before I started writing my own code.

My incarnation of the PPG is

extremely different from the PE code.
First, you must set up the desired fre-
quency and duty cycle with a call to
ppg_set(frequency, duty);. The
purpose of this function is to set the
PWM registers; it does not modify the
PPG output. A call to

ppg_set can be

issued at any time because it automati-

Listing 1—

The PPG works in the background under interrupt control. Calls to

ppg_pulses()

synchronize automatically and return almost immediately to the

caller. As you can see, the implementation of a RECS80 remote control encoder is straightforward.

static void recs80( unsigned int code, unsigned char toggle )

{

unsigned int mask;

unsigned int pause = 4598;

ppg_set( 38000, 33 );

//Prepare PPG for 38 kHz, 33% duty cycle

if (toggle)

code |= (1 << 10);

//Add toggle bit to data word

for( mask= 1<<11; mask!=0; mask>>= 1 ) //Scan all bits in the code word

{

if (mask & code)

//Is data bit = 1?

{

ppg_pulses( 6, PPG_ENABLE_OUT ); //Yes, transmit burst

ppg_pulses( 288,PPG_DISABLE_OUT ); //and a longer silence

pause = pause - 6 - 288; //adjust repetition rate pause to compensate

} //for the time spent

else

{

//No, data bit is 0

ppg_pulses( 6, PPG_ENABLE_OUT ); //transmit burst

ppg_pulses( 192,PPG_DISABLE_OUT ); //and a short silence

pause = pause - 6 - 192; //adjust repetition rate pause to compensate

}; //for the time spent

};

ppg_pulses( pause, PPG_DISABLE_OUT ); //Add the pause to get the 121-ms repetition rate

}

Listing 2—

The programmable pulse generator defined in PPG.C is easy to set up and use. It provides

functionalities for generating square waves of an arbitrary duty cycle with specified duration as well as
pauses. Therefore, the code can be adapted to generate encoding schemes other than

RECS80

.

//Set up PPG for 38-kHz square waves, 33% duty cycle

ppg_set( 38000, 33 );

//Generate six pulses with the current frequency and duty cycle.

ppg_pulses( 6, PPG_ENABLE_OUT );

//Generate a 100-cycle long pause

ppg_pulses( 100, PPG_DISABLE_OUT );

background image

20

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

cally waits for the completion of a pre-
vious cycle if the PPG is running. The
PPG is running whenever

TSC_TSTOP

is zero.

Starting pulse generation requires a

call to

ppg_pulses(count, mode);.

This function triggers the PPG to gener-
ate count pulses (up to 65535). The sec-
ond parameter tells the PPG to toggle
the output if set to one and to leave the
output unchanged if set to zero. Setting
the mode to zero is an effective way to
generate pauses synchronized to the
main PPG frequency. It that case,

count

specifies the pause length expressed as
cycles of the PPG frequency.

It is remarkable that, if no previous

requests are pending,

ppg_pulses

returns to the main application almost
immediately. The purpose of this
function is to load a cache buffer with
the pulse parameters, and to start the
timer if it was not already running. It
then returns to the calling application,
which gets plenty of time to prepare
the next pulse burst. Successive calls
to

ppg_pulses join and synchronize

seamlessly. This feature allows for the
straightforward coding of the remote
control encoding routine in Listing 1.

After the timer runs, waveform gen-

eration is handled by the timer over-
flow interrupt service routine. It’s more
complex than it looks. Timing is crucial
because a 38-kHz pulse takes only 26.3
µs, which leaves little time for counting
pulses and flipping bits. The situation
gets even worse when working in User
Monitor mode because of the overhead
involved with the vector’s redirection.

At every interrupt, the handler checks

the pulse ticks counter to determine if

it is the last pulse. If not, it decrements
the counter and returns. Otherwise, it
checks the cache buffer to see whether
or not more pulses are scheduled. In the
former case, it reloads the tick counter
and sets the mode of operation for the
output pin. In the latter case, it waits for
the current pulse to end, testing the sta-
tus of the output port pin, and resets the
output mode to no-pulse generation. It
finally stops the timer, which stops
overflow interrupts as well. Fortunately,
you don’t have to know all of these
complex details to benefit from the
PPG, which is encapsulated in a C mod-
ule and can be called transparently.

IT’S SHOWTIME

The circuit, which is quick and easy

to assemble on a piece of perf board,
doesn’t require calibration. My proto-
type is shown in Photo 4. The system
begins working immediately after plac-
ing the disc in the player and switching
on the player and the thermometer.

The DVD-Thermometer has superb

multimedia capabilities unparalleled
by current thermometers. It’s inexpen-
sive too. With DVD players starting at
$59.99, using a DVD player as a sort
of graphic front-end is reasonable. An
alternative PC-based solution costs
more, consumes more power, is much
more complex to set up and upgrade,
and is immensely less fun to design!

The basic idea can be adapted to a

variety of practical situations. Clearly,
it’s a great idea for hotels, malls, show-
rooms, stations, airports, and tourist
sites. Thermometers, per se, are unques-
tionably useful, but the multimedia use
and low cost of the DVD-Thermometer
prospects new uses, especially when the
possibility of adding advertisements is
considered. Potential applications
include talking please-take-a-number
displays, interactive product selectors
(e.g., select a certain paint or see how a
new drill works), and colorful, dramatic
displays for any sort of measurement.

You shouldn’t have a problem using

the circuit as a building block for
other projects. The C software is
structured and modular, and the PPG
module performances in particular are
excellent. Its cache-based algorithm
allows for an unusually straightfor-
ward implementation of the remote

Photo 4—

I assembled the DVD-Thermometer prototype

on perf board. The circuit fits a small plastic box, with the
power switch and infrared LED peeping out one side. To
measure the external temperature, separate the LED to be
a few meters apart and connect it with twisted-pair wire.

PROJECT FILES

To download the code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

SOURCES

Nero Burning ROM
Ahead Software
www.ahead.de

68HC908QT4 Microcontroller
Motorola, Inc.
www.motorola.com

DS1621/DS1631 Digital temp sensor
Maxim Integrated Products, Inc.
www.maxim-ic.com

Alberto Ricci Bitti holds a degree in
Computer Science from the University
of Milan. He has more than 10 years of
experience designing and writing soft-
ware for embedded systems. Alberto
currently designs industrial controllers
and instrumentation for Eptar. In his
free time, Alberto enjoys competing in
design contests. He has been awarded
several prizes. You may visit Alberto’s
web site, www.riccibitti.com, or write
him at a.riccibitti@iname.com.

RESOURCES

Philips Semiconductors, “SAA3004
Remote Control Transmitter,” 1982.

J. Sibigtroth, “User Mode Monitor
Access for MC68HC908QY/QT Series
MCUs,” AN2305, 2002.

J. Suchyta, “Reprogramming the
M68DEMO908QT4,” AN2322/D, 2002.

control encoder routine, which you
can adapt to most of the encoding
schemes currently on the market. If
you write a driver for a different DVD
player brand, please contact me so I can
share it with other interested readers.

This design is also a great candidate

for classroom experiments. It’s instruc-
tive for teaching students about micro-
controllers, programming languages,
serial (I

2

C) busses, sensors, remote con-

trols, waveform generation, and the
process of creating and preparing multi-
media content. Young, open-minded stu-
dents working on simple everyday tech-
nologies can generate wonderful
results. I look forward to seeing what
they can get out of a bit of silicon!

I

background image
background image

cameras, digital picture frames, and
photofinish freeze-frame cameras).

More importantly, my goal is to

demonstrate the techniques by which
this is accomplished. This article is
also intended to serve as a starting
point for further exploration.

ANALOG VIDEO BASICS

Since the early 1950s, the National

Television System Committee (NTSC)
color analog video standard has been in
effect for all North American TV broad-
casts. Similar flavors of the standard (i.e.,
PAL and SECAM) also have been devel-
oped in various other parts of the world.

Figure 2 shows the structure of a typi-

cal baseband analog composite video sig-
nal. Essentially, there are four regions of
interest: the sync pulse, which is the
lowest level of the signal; the back porch
(black level) with color burst, which is
used as a synchronization reference
during the color decoding process; the
active video region; and the front porch
(black level).

The luma (Y), or intensity informa-

tion, is encoded as the
average amplitude of the
signal within the active
video portion. In addi-
tion, note that two chro-
ma (Cb/Cr), or color
components, are quadra-
ture-modulated and
added to the luma sig-
nal. In simpler terms,
the two modulated chro-
ma components are
characterized by a super-
imposed sinusoidal sig-
nal, whose phase with
respect to the reference
color burst signal (in the

back porch) represents

22

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

M

y old cell phone had finally

packed it in! That wonder of modern
technology wouldn’t even allow me to
dial out. Instead of having it fixed, I
decided to go shopping for a replace-
ment. I was surprised to find out that a
large number of the newer cell phones
have built-in cameras. Not only can you
talk to your friends, but you can now
see them too. Hmmm.

On the way into the store I also noticed

several closed-circuit TV cameras remind-
ing customers that they should be on
their best behavior. In another corner of
the store, satellite TV products were on
display featuring a personal video recorder
(PVR), which you can use to time-shift
and record whatever TV shows keep you
glued to your seat. Freedom at last!

Essentially, over the past few years,

there has been an explosion in the num-
ber of video-related embedded products
on the market. This has been possible in
large part because of the availability of
inexpensive CMOS imagers, specialized
video compression ICs, and FPGA cores.

Over the years, I’ve designed a number

of embedded products
involving digital video.
These products range in
complexity from a full-
fledged, stand-alone,
FPGA-based multichannel
digital video recorder
(DVR) to a much simpler
video freeze-frame device.
For all of these designs, one
of the key requirements
always has been ultralow
cost. Surprised? In my
experience, “ultralow cost”
is usually a synonym for
“8-bit microcontroller.”

Unfortunately, digitiz-

ing video can be a daunt-

Full-Field Color Video Frame Grabber

ing task because of the volume of data
collected and the rate at which it is
generated (more than enough to choke
the fastest 8-bit microcontrollers on the
market). In this article, I will present
you with a relatively simple and inex-
pensive circuit that allows for the sin-
gle-shot digitization of a full field (720 ×
240) of color video (PAL/NTSC) into a
field buffer. This buffer is accessible by
an Atmel AVR 8-bit microcontroller,
and its contents are sent to a host PC
through the UART (see Figure 1).

Of course, the circuit probably won’t

win any frame-rate contests! Even though
the video acquisition rate supports
60 fields per second, downloading a frozen
full-resolution (720 × 240) color image
over the serial port takes about 30 s at
115.2 kbps. (A download 10 times faster
could be realized over the SPI bus.) If
you sub-sample the image at a fraction
of the resolution during downloading,
expect proportionally better results. In
many applications, acquiring a single
field of video following a trigger is all
that’s required (e.g., motion-triggered

FEATURE ARTICLE

by Eric Gagnon

Eric’s frame grabber enables the single-shot digitization of a full field of color video. Use this
circuit for digital, freeze-frame, and motion-triggered camera design projects.

Video 1

Video 2

Video 3

Video 4

SAA7113

Video

decoder

Video out

Power

regulator

5 to 9 VDC

3.3 V

AL422B

Field

buffer

ATmega8535L

8-bit MCU

4:2:2

(CLK, VS)

WE

HS

4:2:2

(RCK, RE, RRST)

VS

ACQUIRE

(RXD, TXD)

RS-232

Level

shifter

RS-232 Port

(to PC)

I

2

C (SCL, SDA)

Figure 1—

The SAA7113 video decoder digitizes one of the analog input video signals and stores the

samples in a field buffer. The ATmega8535L coordinates the acquisition and download processes.

background image

solid dark lines in
Figure 3) and one of
all the 262.5 even-
numbered lines
(the lighter dashed
lines in Figure 3) in
rapid succession.

Half images, or

fields, are displayed
with a slight verti-
cal offset in rela-
tion to each other
in such a way that
the eye’s retinal
persistence super-
imposes them and
is fooled into see-

ing a 525-line image. Each field is sent
at 60 Hz. This trick is still in use today,
although most PC monitors and TVs
now have video deflection circuits fast
enough to display noninterlaced images

at full video rates.

A field of video is defined as the half

image composed of either the odd or even
262.5 lines of a frame. A frame of video is
defined as a full 525-line image with both

the odd and even fields super-
imposed (interleaved).

One of the problems that

arises when digitizing video of
moving objects is that the odd
and even fields are acquired at
one-sixtieth of a second apart.
When played back on a TV
screen, this is not apparent
because the eye is fooled.
However, if you freeze both
odd and even fields in a frame
buffer and overlay them,

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

23

you’ll notice motion artifacts as shown
in Figure 4. Because the images aren’t
taken at the same point in time, any
moving object in the scene will result
in this slight spatiotemporal mismatch.

There are some deinterlacing tech-

niques aimed at isolating the changes
between both images and applying inter-
polation to infer details in regions of large
motion. However, the most common
approach to the problem is simply to dis-
card one of the fields and use the other
(albeit at half the vertical resolution). If
absolutely necessary, it’s always possible
to interpolate the acquired field vertically
to bring the image back to the original
size. (Although this is artificially inferred
information, it is often adequate.)

Another approach is to copy the data

as-is to the other field. In this article I
simply explain how to acquire one of the
video fields and discard the other.

DIGITIZING VIDEO SIGNALS

The digital revolution has taken the

world by storm, and video is no excep-
tion. With the creation of two standards,
ITU-R BT601 and ITU-R BT656, a new
digital video format has been estab-
lished. The former describes the essen-
tials of the video digitization process
such as minimum/maximum, reserved
values, sample rates, etc. The latter
specifies both a parallel and a serial elec-
trical interface for digital video transfer.
The parallel interface supports an 8-bit-
wide datastream (10-bit is also support-
ed) with embedded codes representing
timing and ancillary information.

Both standards apply to component

4:2:2 digital video. The 4:2:2 ratio ter-

the hue, and whose amplitude repre-
sents the saturation of the color.

FRAMES VERSUS FIELDS

Encoding the information contained

in an entire image requires the con-
catenation in time of a series of sin-
gle-line video signals. In fact, there is
one for every active video line and
also some for additional timing infor-
mation (the first 21 lines per field).
Figure 3 illustrates the scanning pat-
tern used to encode the information
contained in a typical image.

The NTSC composite video standard

calls for 525 total lines of video per
frame at 30 frames per second. In order
to reduce image flicker and increase the
refresh rate without changing the overall
video signal bandwidth or needing faster
deflection circuitry in TV receivers,
engineers came up with the interlaced
video technique. This technique doubles
the image refresh rate to 60 Hz (while
maintaining the perceived vertical reso-
lution of 525 lines) by quickly alternat-
ing between a half image composed of
all the 262.5 odd-numbered lines (the

Y component (luma) = average signal offset

1 V

Back

porch

Active video

Cb, Cr components

(chroma)

= superimposed

quadrature-

modulated

sinusoids

63.555

µ

s

Color burst
(reference)

Front porch

Sync pulse

Figure 2—

Study the structure of an analog composite NTSC video signal. The main

sections include the sync pulse, the back porch, the active video, and the front
porch. The average signal offset represents the luma (Y) and the superimposed
quadrature-modulated sinusoid, the chroma (Cb and Cr) components.

Even field
(lines 264–525)

Line 285

Line 286

Line 287

Line 288

Line 524

Line 525

Odd field

(Lines 1–263)

Line 22

The first 21 video lines

of each field

contain no active

video information

(not shown)

Vertical spatial
offset between

odd and even fields

Typical scan line

consists of a

single-line

video signal

Line 263

Line 23

Line 262

Line 261

Figure 3—

The NTSC image scanning pattern is for full video frame. The odd field scan lines are shown in solid

dark, and the even field scan lines in the light dashed pattern. Both fields are scanned in rapid succession from top
to bottom, left to right with a slight vertical offset to each other.

Figure 4—

The motion artifacts are obtained when simultaneously

displaying both the odd and even fields captured from a moving
object. Because the fields were acquired one-sixtieth a second apart
by the camera, the image of the moving van appears jagged
because of the spatiotemporal mismatch.

Vehicle at time T2

Vehicle at time T1

Even field

lines sampled

at time T2

Odd field lines

sampled

at time T1

Direction of

vehicle motion

background image

much more familiar with the R, G, B
color space where a pixel has three sam-
ples corresponding to its red, green, and
blue color components. Fortunately,
converting between the two involves a
simple matrix operation. To transform a
YCbCr triplet to a corresponding RGB
triplet, use the following YCbCr-to-
RGB transformation equations:

[1,2]

R, G, and B are gamma-corrected val-
ues ranging between zero and 255.

SAA7113 VIDEO DECODER IC

Converting an analog video signal

into the digital domain requires an
ADC. About 5 to 10 years ago, many
semiconductor manufacturers offered
digital video decoder integrated cir-
cuits. A video decoder is essentially a
specialized ADC with a front-end used
to condition and synchronize to an
analog video signal. In recent years,
however, only a few of the dominant
players have remained and continued
to offer a good selection of parts.
Among these is Philips Semiconductor,
whose SAA7113 is truly a lean-and-
mean video decoder IC. Its ancestor is
the venerable SAA7111 known by
many in the field.

The SAA7113 is housed in a com-

pact 44-pin TQFP package and oper-
ates at 3.3 V. It accepts up to four
video input channels that are internal-
ly multiplexed to a single video ADC.
A convenient analog video output pin
buffers the currently selected analog
video channel for viewing. The video
ADC outputs data in 8-bit, multi-
plexed, 27-MHz (BT656) format on its
data bus pins. It also provides addi-
tional signal outputs such as vertical
sync, horizontal sync, and odd/even
field detect on two programmable pins.
This makes it convenient to interface
to external circuitry without needing
to recover the synchronization infor-
mation from the datastream itself.

The SAA7113 has a built-in phase-

locked loop (PLL) circuit, which enables
it to lock its on-board oscillator clock
to the incoming video signal. This pro-
vides an accurate pixel clock (27 MHz

R

G

= 1.164 Y 16 + 1.596 Cr 128

= 1.164 Y 1

×

(

)

×

(

)

×

6

6

0.392

Cb

128

0.813

Cr

128

= 1.164

(

)

×

(

)

×

(

)

×

B

Y

Y 16 + 2.017 Cb 128

(

)

×

(

)

24

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

Y sample (see Figure 5). The (Cb,Y,Cr)
triplets are cosited in space, and each
second Y sample is alone because of the
dropped Cb and Cr samples. The result-
ing aggregate sample rate, 27 MHz, is
calculated by adding the 13.5-MHz Y
component as well as both the 6.75-MHz
Cb and Cr components.

COLOR SPACES

The 8-bit Y, Cb, and Cr sample values

are used to represent a pixel in color
space. In the computer world, we are

minology simply means that during
the video sampling, the luma informa-
tion (Y) is sampled at every pixel posi-
tion (13.5-MHz sample rate), and the
chroma (Cb, Cr) components are sub-
sampled by a factor of two (6.75 MHz
each). This decimation is possible
because the eye is less sensitive to spa-
tial color resolution than spatial intensi-
ty resolution. In a BT656 4:2:2 digital
video stream, one 8-bit sample of Cb is
followed by a Y sample and then a Cr
sample, which is followed by the next

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

25

nominal) with respect to the video sig-
nal timing and tracks any signal jitter.

I should also mention that besides

video decoders used to digitize legacy
analog video signals, there are also new
video imagers based on CMOS technol-
ogy that directly output BT656. (The
video ADC is internal to the IC.)
Therefore, in theory, you could directly
replace the video ADC front end of this
circuit and substitute a CMOS imager
if you want to build a small camera.

KEEPING PACE

As I mentioned earlier, the funda-

mental problem in capturing digital
video is the rate at which it is generat-
ed and the volume of the generated
data. A typical 8-bit MCU would not
have the SRAM resources required to
directly store a single color field of
video (300 KB) or even the processing
speed to read the data at 27 MHz. The
solution to this problem lies in buffer-
ing the video field into a field buffer.
This can be implemented in a number
of different ways. Figure 6 shows a
few possible system architectures.

For optimal performance, an FPGA-

based (or CPLD-based) external mem-
ory buffer is the architecture of
choice, especially when the FPGA is
otherwise needed in the circuit (see
Figure 6a). As such, its incremental
duties as the field buffer can be rela-
tively inexpensive. The circuitry
inside the FPGA typically includes a

counter that cycles the external mem-
ory in sync with the incoming video
data samples and writes the values at
each memory location. The vertical
and horizontal sync pulses are used to
gate (enable/disable) the clocking of
the SRAM addresses to ensure that
data is only written to memory during
valid video data sampling (and not

720 sampled pixels per video line (at 13.5 MHz)

720

Pixel 720

Y720

Cb720

Cr720

Pixel

1

Chroma components

are sampled at 8 bits after

quadrature demodulation

1

Each sampled pixel

has a [Y, Cb, Cr] triplet

4:2:2 Digital video stream (at 27 MHz)
from video decoder

Every second, Cb/Cr chroma samples
(shaded) are dropped

Y720

Cb1 Y1 Cr1 Y2 Cb3 Y3 Cr3 Y4

Y1

Y2 Y3

Y4

Cb1

Cr1

Cb2 Cb3 Cb4

Cr2 Cr3 Cr4

Pixel

2

Pixel

3

Pixel

4

8-bit

Sampling range

(for luma)

0

255

Figure 5—

Here you see the ITU-R BT656 4:2:2 digital video stream. The 27-MHz digital datastream is mainly

composed of a succession of Cb, Y, and Cr samples. Each component sample value of the (Cb, Y, Cr) triplets are
cosited in space. Because of the 4:2:2 decimation, each second Y value has no associated chroma information
(shown shaded). Embedded sync codes are also added throughout the digital stream.

background image

26

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

needs to be transferred to the main
processor for processing, communica-
tion, or storage. This operation can be
accomplished by implementing a DMA
controller inside the FPGA or simply by
having the FPGA switch over all the

control and data lines of the memory
to the MCU during the entire transfer.
(This is done to the detriment of the
overall system frame rate because no
new fields of video can be acquired
while the SRAM is under MCU control.)

Another way to accomplish the data

transfer is to use dual-ported memory
(see Figure 6b). The video frame grab-
ber writes to the memory on one port,
and the system can read the data from
the other port. However, full-field,
dual-ported SRAM memories are
extremely expensive. It is often more
economical to use smaller dual-ported
SRAM as single-line buffers.

If you have the luxury of a DSP or

extremely fast processor with an
external memory bus, you can simply
use DMA transfers. Assuming the
processor can read out one line of
stored video data at a faster average
rate than it’s generated, all you need is
a single-line video FIFO or dual-ported
SRAM (see Figure 6c). The video
decoder simply fills the FIFO with
data at the video rate, and it interrupts
the main processor when the buffer is

outside these bounds). At the same
time, the circuit can separate the Y,
Cb, and Cr components into different
memory destinations if desired.

After the digital video field data is

collected in the field buffer, it usually

SRAM or SDRAM

(full frame/field)

ADDR, CTRL

FPGA

or

CPLD

DATA

4:2:2

HS, VS, CLK

ADDR

DATA

MCU

FPGA

or CPLD

Dual-ported

memory

MCU

(external

memory bus)

ADDR

4:2:2

DATA

ADDR

DATA

Single-line

FIFO

4:2:2

HS, VS, CLK

DATA

CTRL

Fast MCU

or DSP

ADDR

DATA

Main memor

y

Full-field

FIFO

MCU

DATA

CTRL

4:2:2

HS, VS, CLK

HS, VS, CLK

Figure 6—

There are a few possible field buffer architectures: an FPGA managing memory buffer

(a)

, a dual-ported

memory

(b)

, a single-line FIFO

(c)

, and a full-field FIFO

(d)

.

a)

b)

c)

d)

background image
background image

28

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

half full or at the end of each line. The
processor then immediately bursts out
the data from the buffer in less time
then it took to fill it, preferably much
faster. The data is transferred to the
processor’s main memory space,
which has to be large enough to hold
a complete field.

In this project, you don’t have access

to an FPGA or DSP, or even enough
internal memory to buffer a field.
Therefore, you need a full-field FIFO
with an interface simple enough for
the MCU (see Figure 6d). The video
decoder will fill the FIFO using the
write port. Then, the MCU will inde-
pendently read out the data from the
read port after it detects that a com-
plete field has been stored.

AL422B FIELD BUFFER FIFO

Averlogic’s AL422B is a popular

full-field FIFO. This IC is implement-
ed internally as dynamic RAM, so it
costs less than a comparable SRAM-
based product. It has a convenient and
simple FIFO interface with one input
write port and one output read port.

On the input port, the write enable

signal is used to gate the main clock,
which must be present for the DRAM
cells to get refreshed internally. The
write reset pin resets the internal write
address generator counter to zero. At
every write clock pulse, the address
generator is automatically incremented.
On the read side, the same idea
applies, but from the read perspective.

PUTTING IT TOGETHER

The circuit is shown in Figures 7

and 8. The SAA7113 is used to digitize
one of four possible analog video input
channels. The buffered analog video out-

put allows for the live viewing of the
selected video channel. The BT656-for-
mat digital output of the video decoder
is wired to the input port of the FIFO.

The SAA7113 is programmed to

output an odd/even field signal
switching after line 21 (start of active
video lines) on its RTS1 pin. This signal
goes high for the duration of an odd
field, and then goes low for the even
field. It is tied directly to the write
reset pin (*WRST) and holds the write
counter in its reset state, except when
an odd video field is present.
Remember, you only want to sample
one field to eliminate motion artifacts.

Furthermore, the SAA7113’s other pin

(RTS0) is programmed to output a hori-
zontal reference (HREF) signal, which
goes high and stays high for the duration
of the active video data portion of every
video line. Connected to the *WE pin

Figure 7—

U1 digitizes one of the four video input signals from BNC connectors J2–J6. The digitized samples are stored in U4, a full-field FIFO memory. All of the operations

of the frame grabber, as well as download functions, are coordinated by U5, an 8-bit Atmel AVR MCU.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

29

through an inversion, it is used
to gate the main pixel clock,
which is connected to WCK. It
simply enables the writing of
valid video data values to the
FIFO at the appropriate times.

The microcontroller also has

access to the write enable line
through a NAND gate. This
allows for the acquisition of a
single field and then the ability
to stop under MCU control.
(Otherwise, the video fields will
be continuously overwritten
before you have the chance to
read out the data.) The MCU
has full access to the FIFO’s
output port. After detecting that
a frame grab is complete, the MCU
waits for the appropriate serial port
command before reading out the video
data from the FIFO for transmission.

The fully assembled circuit board is

shown in Photo 1. Note that the design
was separated into two modular parts:
a stand-alone daughter card, which
contains the entire frame grabber cir-
cuit, and a larger motherboard that
holds the various connectors as well as
the RS-232 level shifter circuitry.

FIRMWARE AND SOFTWARE

The firmware for this project was

developed in C using ImageCraft’s
ICCAVR compiler. The MCU’s main
roles involve running a serial command
server, initializing the SAA7113 through
the I

2

C bus, and managing the field

acquisition process. The serial com-
mands are sent in plain ASCII format.

The basic ASCII frame grabber

command set includes the following:
VER returns firmware version number;
GRAB grabs a field into the field buffer;
CHAN n selects video channel n; RRST
resets the FIFO read pointer; and

SEND

sends the next n bytes of video data
from the FIFO in binary format.

A variation of the

SEND com-

mand could allow decimation of
the image to speed up the transfer
(Thumbnail mode). Additional
commands allow for board config-
uration and extra features.

The SAA7113 is a highly config-

urable part that contains a large
number of registers. At power-up,
each register must be set up cor-
rectly through I

2

C before the part

can be used. Just remember to pro-
gram the unused registers to zero
as indicated in the datasheets; oth-
erwise, it won’t work. After ini-
tialization, the desired channel is
selected and the digital video
comes spewing out!

At this point, the frame grabber is

capable of digitizing a full-color video
field and transmitting the data over a
standard RS-232 serial port in
response to simple ASCII commands.
This offers great flexibility for use in
generic embedded systems. In order
to allow for simple user experimenta-
tion, a Windows-based command and
viewing utility was developed using
Visual C++ 6.0. This utility commu-
nicates with the frame grabber
through the PC’s serial port. It can
send all the commands used to con-
trol the frame grabber as well as

Figure 8—

The live video output BNC connector J7 allows for a live preview of the currently selected video input. An RS-232 level shifter (U2) provides the required signal lev-

els for interfacing to a PC. U3 is a 3.3-V LDO regulator providing local regulation of the input voltage.

Photo 1—

This is the microcontroller frame grabber (uCFG) prototype.

The small daughter card on top contains the entire frame grabber cir-
cuitry, and the larger motherboard on the bottom contains the various
connectors as well as the RS-232 level shifter circuitry.

background image

30

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

download the image data for viewing.

The downloaded YCbCr data has to

be reconstructed into an RGB array
for display on the computer screen.
To perform this reconstruction, the
decimated Cb and Cr samples are first
regenerated through interpolation.
The YCbCr-to-RGB matrix transform
is then applied to convert image data
to the RGB color space. Because the
captured video field is 720 × 240,
merely displaying it 1:1 on a PC mon-
itor results in a vertically squashed
image. In order to compensate, verti-
cal interpolation of the missing field
is performed before displaying the
image. A high-resolution mode could
be implemented that would capture
the odd field, the even field of a static
scene (eliminates motion artifacts), and
provide an actual 720 × 480 resolution
image. The software can also save the
uploaded image in the .bmp format.

FIRST LIGHT

Well, enough theory. It’s time to get

your hands dirty! After building the
frame grabber circuit, I used my cam-
corder as a color video source. I sent
the command to acquire the video
field from the Windows-based GUI
application and downloaded the image.
Photo 2 shows the PC control software
in action. You can see the downloaded
image of the frame grabber taking a
picture of the frame grabber, taking a

PROJECT FILES

To download the viewing software and
programming files, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

REFERENCES

[1] K. Jack, Video Demystified, LLH

Publications, 2001, www.video-
demystified.com.

[2] C. A. Poynton, A Technical

Introduction to Digital Video

, John

Wiley & Sons, Hoboken, NJ, 1996.

RESOURCES

International Telecommunication
Union, ITU-R series standards,
www.itu.int/home/index.html.

NTSC standard information, www.ntsc-
tv.com.

SOURCES

ATmega8535L Microcontroller
Atmel Corp.
www.atmel.com

AL422B Full-field FIFO
Averlogic Technologies, Inc.
www.averlogic.com

Stand-alone OEM frame grabber
boards, evaluation kit
Digital Creation Labs, Inc.
(905) 793-3603
www.digitalcreationlabs.com

C Compiler
ImageCraft
www.imagecraft.com

CMOS Imagers
OmniVision
www.ovt.com

SAA7113 Video decoder
Philips Semiconductor
www.semiconductors.philips.com

Eric Gagnon, M.A.Sc., P.E., has more
than 10 years of embedded design
experience. He currently runs Digital
Creation Labs, Inc. (www.digitalcreation
labs.com). Eric has worked on projects
pertaining to the International Space
Station, industrial robotics, 3-D
machine vision, and embedded video
products. You can contact him at
egagnon@digitalcreationlabs.com.

picture of the frame
grabber… Well, you
get the picture (no pun
intended)!

LOOKING AHEAD

I’m sure you are

already thinking ahead.
How can you integrate
this simple frame grab-
ber into a product?
What about adding an
SPI-based secure digital
(SD) flash card on the
SPI interface of the
Atmel MCU and turn-
ing this into a simple
digital camera? You
could save a large num-
ber of images in raw
format to the flash card
(or with a file system).

How about implementing a simple

video compression algorithm inside
the microcontroller and sending the
image to a remote observation host
using a wireless RS-232 module? Maybe
you could implement a photo finish
freeze-frame module to take a single
picture of athletes crossing the finish
line. Or what about a motion-triggered
camera taking a snapshot of the last
person entering the premises? Using the
Cypress wireless USB chipset (wireless
SPI), you can build an all-digital wire-
less camera. Let your imagination run
wild! If you come up with some neat
ideas, I would love to hear from you.

Hopefully this article has provided

you with some useful background on
digital video as well as some hints on
how to implement a basic video frame
grabber. By extending this basic sys-
tem, it’s possible to implement high-
er-performance video capture circuits,
and perhaps combine them with some
simple image-processing algorithms. If
you’re interested in hands-on experi-
mentation, take a look at my full
evaluation kit and individual OEM
frame grabber modules (www.digital-
creationlabs.com).

Anyhow, back to my story. After

waiting in line at the store (for longer
than I should have), I ended up purchas-
ing a replacement cell phone, but not
one with a video camera. I guess I’m
cheap. Some things never change!

I

Photo 2—

The frame grabber circuit acquired this image. Also shown is a

screen capture of the Windows-based PC control and viewing software. All
communications occur over a standard RS-232 serial port.

background image
background image

REFLOW OVEN

The key to good reflow is a precise

multistep thermal profile, as illustrat-
ed in Figure 1. The preheating profile
allows you to slowly bring the PCB to
a temperature high enough to dry the
solder paste (approximately 100°C)
while minimizing the risk of thermal
stress on the components in the reflow
phase. After thermal stabilization, the
board is heated as quickly as possible to
the reflow temperature (approximately
250°C). The board stays above the
reflow temperature for a set period of
time (usually around 30 s) before it’s
cooled down in a controlled fashion.

What are the key characteristics of

an industrial reflow oven? Quick heat-
ing and cooling is important (the
quicker the better) in order to reduce
the thermal stress on the components.
(The pads and solder paste have a
lower thermal latency than the com-

32

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

F

or years surface-mount technology

(SMT) has been the manufacturing
technology of choice, particularly
because it’s less expensive than classic
through-hole processes and because of
the reduction in board size. I’m sure
you have noticed that SMT is now
mandatory for prototypes, even if a
project isn’t space-constrained. Many
new and exciting components are only
available in SMT packages. High-
speed designs (using high-speed digital
or radio frequencies) won’t work using
large through-hole packages.

It’s possible to solder the majority of

SMT components by hand, but it’s
painful and time-consuming. The
components must be soldered individ-
ually with either a small soldering
iron or a hot-air pencil. But small

Easy Reflow

When designing high-speed applications, working with SMT components and soldering by
hand can be tedious. Robert’s H8/3687-based SMT Reflow Oven Controller transforms a
conventional infrared toaster oven into an effective reflow oven that ensures thermal control.

packages like 0603 resistors are likely
to fly away when soldered with hot air
and stick to the soldering iron at the
worst time.

A solution to this problem is to use

reflow oven technology just like the
manufacturers do. A reflow oven is a
well-controlled oven that allows to
you cook a PCB with its components
and solder all of the pads simultane-
ously with solder paste. Great! The
only issue is that reflow ovens cost a
fortune, ranging from $2,000 to $1
million. The ovens cost so much
because they need strictly controlled
thermal profiles to ensure good solder-
ing and also to limit the thermal
stress on the components.

In this article I’ll show you how a

homemade controller built around a

Renesas evaluation
board can transform
an inexpensive toaster
oven into a reflow
oven. First, I’ll cover
how reflow ovens
work and explain
which toasters on the
market are best suited
to mimic them. Then,
I’ll describe my con-
troller’s hardware and
software. I’ll finish up
with some tips on
how to assemble your
own SMT boards
using the reflow oven.
Let’s get hot.

FEATURE ARTICLE

by Robert Lacoste

Preheating,

1° to 4°C/s

Heating, 2° to 4°C/s

Maximum temperature =
reflow temperature + 20°C,
or around 250°C, depending
on the solder paste.

Drying, 100° to 150°C,
1 min., 30 s to 3 min.

Cooling,

–2° to –4°C/s

Reflow

Figure 1

In order to achieve reliable solders and to minimize thermal stress on

components, a precise thermal profile must be used with four successive steps.

Build an SMT Reflow Oven Controller

GRAND PRIZE WINNER

Photo 1—

You must choose an appropriate toaster

oven. For the best results, find one with infrared
heaters on top that allow for a quick temperature rise.
This one, which was made in France, costs less than
$150. The thermocouple wire is on the left.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

33

you to select either Configuration
mode or Run mode.

In Configuration mode, the LCD

successively displays each of the nine
key profile parameters (preheating slope,
drying temperature, drying duration,
heating slope, reflow temperature,
reflow duration, cooling slope, thermal
hysteresis, and differential coefficient).
It also allows you to modify the profile
parameters with the plus and minus
buttons. (It’s easy to store these values
in EEPROM, but it isn’t done in the cur-
rent version of the firmware.) In Run
mode, the LCD shows the current actu-
al and preset temperature, as well as the
current state and the remaining time to
be spent in the state (see Photo 3).

Seven steps are managed by the

state machine in order to achieve a
thermal profile that’s as close as possi-
ble to the theoretical one. The first
step involves preheating. The preset
temperature is linearly increased from
the ambient temperature up to the
drying temperature. Next, the con-
troller waits for the actual tempera-

ponents themselves.) Maintaining a
homogeneous temperature inside the
oven is also important, especially when
you’re working with large PCBs. And,
last but not least, regulation is a must
in order to guarantee that successive
reflows follow the exact same profile.
As you can imagine, I will handle the
regulation with a microcontroller-
based solution, so let’s focus on the
low-cost oven you’ll use to replace a
real reflow oven.

In order to have a quick heating

time, some industrial reflow ovens
use infrared heaters. Why not just buy
an infrared-based toaster oven like the
one shown in Photo 1? I bought mine
on the ’Net for less than $150. It has
two quartz heating elements on the
top and a classic resistor on the bot-
tom (a total of 1,100 W).

I used a thermocouple affixed on a

small PCB to take the first measure-
ments. The temperature got up to
250°C in less than 4 min., which is
definitely enough for this application.
The only real drawback was the lack
of a cooling system. I decided to use a
manual cooling method: I open the
door when the controller asks.

HOME-BUILT CONTROLLER

As for building the controller, I used

the Basic Micro EVB87 Renesas evalu-
ation board, which is fitted with an
H8/3687 microcontroller (see Figure 2).
This inexpensive microcontroller is
exactly what I needed for this project.
It has a low pin count, high RAM and
program memory for using a simple
high-level language like BASIC, and
on-chip ADC. The evaluation board
already provides an LCD and push but-

tons, so all I had to do was add two small
circuits using the prototyping area. The
first was a thermocouple interface. I used
a K-type thermocouple and an Analog
Devices AD595 monolithic thermocou-
ple amplifier with on-board cold-junction
compensation directly connected to the
H8/3687’s ADC. More than simple, isn’t
it? Lastly, I needed a way to drive an
external relay to switch the oven on and

off. It took nothing more than a BD235
transistor and a free-running diode. Of
course, you could use your favorite
microcontroller (e.g., Basic Stamp’s) for
this design, but this evaluation kit

speeds up the process (see Photo 2).

On the firmware side, I decided to

try to the BasicATOM programming
language because this application isn’t
managing microseconds. This was
easy thanks to the user-friendly devel-
opment environment provided by the
board in addition to the resident boot-
loader. It took only 4 h to write and
debug the full software, even though I
wasn’t able to use the debugger for
some reason.

The application, for which the

source code is available on the Circuit
Cellar

ftp site, is extremely easy to

read. It is structured into two inde-
pendent sections: a configuration sec-
tion and a state machine section. The
former allows you to manually modify
all profile parameters with the LCD
and a couple of push buttons. The lat-
ter manages all of the successive steps
of the thermal profile and reads the
actual oven temperature in real time.
Let’s look at the details.

First, a welcome screen is displayed.

Then, a static screen displays the cur-
rent temperature in real time and allows

Figure 2—

The reflow oven controller is simple. There are only six components in addition to the Renesas EVM87

evaluation board.

Photo 2—

The oven controller includes a Renesas

evaluation board with thermocouple and relay inter-
faces in the breadboard area.

Photo 3—

When it’s running, the controller shows the

current phase (“UpDry,” meaning “up to drying tempera-
ture”), and the preset and actual temperatures, as well
as the remaining time to spend in this phase.

background image

34

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

ture to be equal to the drying tempera-
ture. The third step involves drying.
The preset temperature stays constant
during the drying time.

Heating follows this. Basically, the

preset temperature is linearly
increased from the drying to the
reflow temperature. Then, the con-
troller waits for the actual tempera-
ture to be equal to the reflow tempera-
ture. Next, the preset temperature
stays constant during the reflow time.
Finally, the preset temperature moves
linearly down to the initial ambient
temperature, and you open the oven
door to help the process.

In addition to state

machine management, a
thermal control loop is
implemented in the soft-
ware using a PD-like algo-
rithm. An estimated future temperature
is calculated using the actual tempera-
ture plus a multiple of the differential of
the temperature. The estimated future
temperature is compared to the preset
temperature in order to switch the
heater elements on or off. This allows
you to account for the thermal latency
of the captors and heaters and to get a
more stable temperature. A small hys-
teresis factor is also used in the compar-
isons in order to extend the life of the
heater. Figure 3 shows the actual ther-
mal profile compared to the preset val-
ues generated by the controller.

OVEN IN USE

Now that you know why you need a

reflow oven and how to build one,
how will you use it? First, you need to
get some additional equipment. You’ll
need a good magnifier (a video magni-
fier would be best) and a syringe of
solder paste. It’s easier if you have a

pneumatic fluid dispenser
(which is easy to find on
the ’Net, but you will
also need shop air)
because using the syringe
can be difficult. You will
also need a flux cleaning
spray, a small classic iron
(15 W or less), and, ideal-
ly, a hot-air iron for
repairs. Don’t worry, the
Internet is a good source
for low-cost equipment.

Even if you don’t have a video magni-
fier, you can be successful if you have
a good optical lens and good eyes!

A clean blank PCB is extremely

important. I know from experience
that it’s nearly impossible to achieve
good reflow results with home-etched
PCBs. Solder masks are really helpful
in keeping the solder paste on the
pads. I don’t know how to get solder
masks on home-etched PCBs, so find
a good PCB manufacturer and order
your PCB with solder masks.

You have to put solder paste on the

pads with the syringe either manually
or with the fluid dispenser. Then, you

must place each component on the
PCB on the solder paste spots. These
two steps are time-consuming, but
things speed up with experience!
Remember that it is far quicker to use
solder paste than to try to solder by
hand. After all of components are
placed, you can put the board in your
reflow oven and press the Start but-
ton. After 10 min. or so, your PCB
will be cooked. Beware, it can still be
quite hot. Use flux removal fluid and
a toothbrush to clean the board (see
Photo 4). Refer to the Circuit Cellar
ftp site for a detailed illustration of
the process.

By the way, you can use this process

for boards with components on both
sides if you put light components on
one side. Reflow only that side first,
and then flip the board and repeat the
process: apply solder paste, place the
components, and then reflow. The
components on the bottom side will

300

250

200

150

100

50

0

0

100

200

300

400

500

600

Thermal profile

T

e

mper

ature (

°C)

Time (s)

t

SET

t

ACTUAL

Figure 3—

The red curve is the set point defined by the software, where-

as the yellow curve shows the actual temperature as measured inside
the oven. The full cycle takes around 10 min.

With a $150 toaster oven and a

low-cost controller, you can

achieve reflows with good results.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

35

usually stay soldered thanks to the
surface tension of the solder.

Finally, you should check the elec-

trical connections and make the neces-
sary repairs. If you follow the process
closely, you shouldn’t have too much
trouble. My last 160 mm × 100 mm
board had more than 300 fine-pitch
components on both sides, but I had
only a couple of bad joints and one
solder bridge on a 0.65-mm pitch IC.

THREE-DAY SOLUTION

This project proves that SMT tech-

nology is neither boring nor too expen-
sive for the occasional prototype circuit
maker. With a $150 toaster oven and a
low-cost controller, you can achieve
reflows with good results. The only
other things you need are a good lens
and some basic equipment that’s readily
available on the used market. And, yes,
you’ll need some patience too.

This project also shows that BASIC

is efficient language for low-speed,
real-time applications, especially those
that are associated with microcon-
trollers with plenty of RAM and pro-
gram memory in order to fully use the
power of such languages (e.g., the
Renesas H8/3687).

Last but not least, this project

demonstrates that embedded develop-
ment doesn’t necessarily have to be a
huge undertaking to give good results.
It took me only three days to finish
this project. I spent one day drawing
the concept and algorithms on paper.
The last two days were spent building
the prototype, writing the software,
and optimizing it.

The next step will be to experiment

with BGA packages, but that should
work too. Happy reflowing!

I

RESOURCES

Analog Devices, Inc., “Monolithic
Thermocouple Amplifiers with Cold
Junction Compensation: AS594/
AD595,” rev. C, 1999.

Basic Micro, “Renesas 3687 Tiny
Series Starter Kit User Manual,” ver. 2.1,
2003, www.basicmicro.com/downloads/
Renesas/3687/3687RSKUsersManual.pdf.

———“3687 Starter Kit: Quick Start
Guide,” 2003, www.basicmicro.com/
downloads/Renesas/3687/QStart.pdf.

D. Kubin, 3687 Evaluation board
schematic, 2003, www.basicmicro.com/
downloads/Renesas/3687/Schematics.pdf.

Research International, “Reflow
Technology Handbook,” www.research
-intl.com/reflowtechbook.htm.

SOURCES

AD594/AD595 Thermocouple ampli-
fiers
Analog Devices, Inc.
(800) 262-5643
www.analog.com

EVB87 Renesas evaluation board
Basic Micro, Inc.
(248) 427-0400
ww.basicmicro.com

H8/3687 Microcontroller
Renesas Technology Corp.
(408) 382-7500
www.renesas.com

PROJECT FILES

To download the code and additional
photos, go to ftp.circuitcellar.com/pub
/Circuit_Cellar/2004/168.

Photo 4—

Here’s an example of a cooked PCB after

reflow and cleaning. Not too bad, huh?

Robert Lacoste lives near Paris,
France. He has 15 years of experience
working on innovative real-time soft-
ware and embedded systems.
Specialized in cost-optimized mixed
signal designs, he has won more than
a dozen international design con-
tests. Robert currently manages his
own design and consulting company.
You can reach him at rlacoste@
alciom.com and visit his web site at
www.alciom.com.

background image

and detailed in Figure 2. Its purpose is
to limit the system’s maximum veloci-
ty. The velocity is calculated and then
subtracted from the error signal. When
the error signal is at its 2047-count
limit, the motion speeds up until the
velocity reaches a large enough value
to limit additional speed increases.

If you recall, velocity is change in

position divided by change in time. The
velocity feedback design has P0 to latch
the present position and P1 to latch the
previous position. The latching is per-
formed by counting 4,096 clock ticks
(4,096 × 50 ns = 0.203450 ms). A little
state machine transfers the position data
into the appropriate registers and the
proper times using states S0, S1, and S3.
Note that S2 is not used, so don’t look too

36

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

L

ast month I started describing a

two-axis motion control system featur-
ing an Altera Nios embedded CPU. In
fact, I put the entire system inside one
of Altera’s FPGA devices. I left off with
V00-00. I had the CPU and one axis
designed. Also, I did an initial placement
and achieved my design goal of 20-MHz
operation. This month I’ll explain how
to enhance the axis component by
adding velocity feedback and building a
two-axis system. I’ll also detail the
software you’ll need to run the design.

Well, I was extremely pleased with

the V00-00 version of this project.
Typically, you would review this with
all the interested parties in your organ-
ization (a design review). And out of
that hypothetical meeting, suppose
service said that you need to monitor
the temperatures of motors and other
circuitry, and that marketing is really
close to having an answer about the
network requirements. What to do?

I found Analog Device’s AD7476/7/6

serial A/D converters, which have 8, 10,
or 12 bits, respectively, of resolution at a
1-msps rate. So, I added a four-device SPI
serial interface to the Nios processor. And
for the network requirements, I added an
interface to the LAN91C111 on an Altera
development board. So, now I have a
schematic and software, if marketing is
ever able to firm up their requirements.

Photo 1 shows the new SOPC builder.

Note that the SPI interface requires
seven pins, three of which are shared
for data in, data out, and clock, and
four of which are chip selects, one for
each device. The LAN91C11 interface
requires just three additional pins
because there is already a bus for off-

Designing with the Nios (Part 2)

Last month, George laid the groundwork for a Nios-based two-axis motion control system.
Now he discusses velocity feedback and preps you on the software you’ll need to drive it.

chip memory. The pin count can be a
limiting factor in any FPGA design.
Having too many pins pushes you into
a larger, more expensive package.

The place and route achieved 31.02

MHz in the selected device. The maxi-
mum clock frequency times got better
even though I added more logic ele-
ments. Don’t count on this to be the
norm. By looking at the timing reports
I see that the longest path is in the
axis-error calculation, which isn’t sur-
prising. I could speed up this path and
increase the maximum clock frequen-
cy by adding registers in the path. But,
as it stands, I’ve met the design goal.

I also added a velocity feedback ele-

ment to the design. The velocity feed-
back block diagram is shown in Figure 1

FEATURE ARTICLE

by George Martin

System Enhancement

Photo 1—

This screen shot of the SOPC builder shows the CPU configuration details. Screen peripherals are

added to the CPU from this. The implementation details of the peripherals are also defined.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

37

quencies. If the resonant point in your
mechanical system is below the high-fre-
quency cut off defined by the output driv-
ers, then the mechanics will oscillate
whenever the offending frequency is out-
put. And because the step output contains
all frequencies, your system will oscillate.

After you know the resonant fre-

quency, you could define a digital fil-
ter to remove it from the output sig-
nal. The great part about this solution
is that each system probably has a
slightly different resonant point, and
you can tune the digital filters for each
system. Production will love that.

SOFTWARE

I built a set of software routines to

help you understand the Nios design.

long for that reference. I was planning to
add registers for settling time on the cal-
culations, and S2 provides another 50 ns
of delay for the calculations to complete.

So, I have

P over

T, and that’s

available on the output pins. This num-
ber needs to be scaled. I could scale it by
changing the 4096 clock divider in the
velocity feedback count block. I could
increase or decrease the time period for
the measurement. If that’s not suffi-
cient, I could change the type of counter
to a count down and achieve any time
period. If that still isn’t enough, I could
add a multiplier to the VEL[31..0] sig-
nal to scale it to the appropriate value.

Figure 1 shows an optional filter

block just before the output signal. I
didn’t include this as part of my design.

This would be a great place to add a digi-
tal filter to attenuate any unwanted fre-
quencies in the output signal. Most sys-
tems have resonant frequencies. The
mechanical designers try to eliminate
them, but you usually will be faced with
working around them. If you need a visu-
al example, imagine a fly fishing rod. As
you slowly move your arm and the rod,
the tip of the rod exhibits no lag in its
positioning. But, as you start accelerating
you arm and the rod, the rod’s tip starts
to lag. If you move your arm back and
forth at just the correct frequency, the tip
of the rod will be moving in the opposite
direction of your arm.

You’ve just found the system’s resonant

frequency. The controller’s output can be
thought of as a step, containing all the fre-

Figure 1—

Aiming for single-axis control with velocity feedback? The A and B inputs derive the current position. The CPU sets the target position register. The errout output is

used to drive the servo motors.

Figure 2—

For the velocity feedback circuit, the positions are captured in latches P0 and P1. The difference is latched and represents the velocity. The up-counter determines

the rate of position sampling.

background image

38

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

I know I’ve got some explaining to do.

First, let’s take a look at the constants
__TURBOC__ and RUNNING_IN_NIOS.
When the Turbo C compiler is
invoked,

__TURBOC__ is defined and

RUNNING_IN_NIOS is not defined. If
__TURBOC__ is not defined, then
RUNNING_IN_NIOS is defined.

Look at the beginning of

CCCONST.h, which you may down-
load from the Circuit Cellar ftp site.
This file enables code to run in Turbo
C or any other compiler, without writ-
ing to an address that will cause prob-
lems on the PC.

uart0 is defined at

some constant address in excalibur.h,
so accessing it in Turbo C will probably
crash the PC’s operating system. I know
this because I’ve done it by accident.

Next, the

BYTE keyword is defined

in CCCONST.h. When different com-
pilers and CPUs are used, the value of
definitions such as

int can change.

So, I created keywords including

BYTE,

These routines create a test bed for code
development and will actually run the
hardware. I used Turbo C++ V. 3.0 in a
DOS window to write, compile, and
debug code. I know this is an old
method, but it’s great for getting start-
ed, especially when the hardware
doesn’t exist yet. Eventually, you will
use the GNU tool chain to build the
software for the Nios CPU.

UART

The interface to each of the periph-

erals selected for the design is generat-
ed as a set of registers. Take the UART
for example. The register set for the
UART is defined as a structure in the
excalibur.h file (see Listing 1).

The structure

np_uart (“np” stands

for Nios peripheral) has six 32-bit registers
that interface to the hardware. These reg-
isters are memory-mapped I/O. The first
register is

np_uartrxdata, which con-

tains the data received in the UART. The
actual data is only 8 bits, but 32 bits are
reserved for this and every register. Other
symbols are defined too:

na_uart_0 is a

pointer to an

np_uart located at the

0x00040000 address;

na_uart_0_base is

the base address value for the UART 0
register set; and

na_uart_0_irq is

the interrupt request number.

The excalibur.h file also contains bit

definitions for the UART and all periph-
eral control purposes. So, the software
can be completely written using the
excalibur.h file. To make hardware
design changes, all you need is the latest
copy of excalibur.h. If you’ve ever bought
a C compiler dedicated to a microproces-
sor, it probably came with a header file
that described the CPU; those header
files look a lot like excalibur.h.

In the ARMCOM.c file posted on the

Circuit Cellar

ftp site, you will find the

routines that directly touch the Nios
hardware as opposed to transferring
data in and out of the serial buffers in
memory (CCCOM.c and CCCOM1.c).
The

PutCom0(BYTE c) routine puts a

BYTE (8-bit entity) in the UART’s
transmit buffer (see Listing 2). First, a
pointer to the UART register structure
is declared (

np_uart *uart), and then

the pointer is set to point to the
uart_0 register set in memory-mapped
I/O. And finally, the data is placed in
the Tx register (see Listing 2).

INT16, INT32, and UINT8 to define
what I intend to do.

If I use a different CPU or compiler,

I will redefine these values for each
new implementation. Take a look at
the

INT16 for the Turbo C (16-bit) com-

piler versus the Nios (32-bit) compiler.
Lastly, note that if you are compiling
for Turbo C and running in a DOS win-
dow, the output for

Com0 goes to the

stdout, which is the console on the PC.

The serial communications routines

are in the ARMCOM1.c, CCCOM.c,
and CCCOM1.c files. The incoming
characters generate an interrupt in
which characters are read from the
hardware and placed in a buffer. Input
line-feed characters are ignored. I’ve
had trouble when systems send a car-
riage return and then line feed while
others send a line-feed followed by a
carriage return. So, I just started ignor-
ing line feeds and life became simpler.

Also, I processed complete lines of

Listing 1—

The NIOS UART data structure is defined by

np_uart

. The hardware mapping of the UART is

defined by the

(np_uart *)

construct.

// UART Registers

typedef volatile struct {

int np_uartrxdata; // Read-only, 8 bits

int np_uarttxdata; // Write-only, 8 bits

int np_uartstatus; // Read-only, 8 bits

int np_uartcontrol; // Read/Write, 9 bits

int np_uartdivisor; // Read/Write, 16 bits, optional

int np_uartendofpacket; // Read/Write, end-of-packet character

} np_uart

#define na_uart_0 ((np_uart *) 0x00040000) // altera_avalon_uart

#define na_uart_0_base 0x00040000

#define na_uart_0_irq 16

Listing 2—

This

Put_Com

example will run a PC and Nios. If compiled with

__TURBOC__

defined, then

the character goes to the PC’s console device. If compiled with

RUNNINGIN_NIOS

defined, then the

character is placed in the UART buffer at location 0x40000 (see Listing 1).

// This routine puts a character into Nios Com0: port

void PutCom0(BYTE c) {

np_uart *uart;

// Create a ptr to a Nios UART

// data structure

uart = (np_uart *)na_uart_0; // Set that pointer to Com0 hardware

// Output the data

#ifdef RUNNING_IN_NIOS

uart->np_uarttxdata = c;

#endif

#ifdef __TURBOC__

// put_com(c);

#endif

} /* end of void PutCom0(BYTE) */

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

39

could just write to a memo-
ry-mapped register offset
from some base address. My
approach takes a couple of
extra instructions for each
operation, but it works
without any hassle.

In the CCPOS.C file, I

defined the bit functions for
the Read_Status[15..0] inputs
and the CTRL[15..0] outputs.
On the input side, I have Loop
Status (OK/fault), Home,

Limit, and Fault indicators for each axis.
On the output side, I have Latch
Position, Clear Position, Set Position,
Clear Target, Latch Target, and Close
Loop for each axis. I don’t use every one
of these bits because several are redun-
dant. I included all of them to show you
what’s possible in this type of design.

The

SetTarget, GetPosition,

and

SetPosition routines are fairly

self-explanatory. These are used to
clear control bits, output/input the
data, and then set any control bits
(see Figure 3). The control bits are
positive-edge active.

data as they were received. I
define an end-of-line charac-
ter for each serial port. When
that character is received, a
line counter is incremented.
All the main routine looks at
is that line counter. When
the input line counter does
not match the output line
counter, I know a complete
line has been received and I
start to process that line.

I selected a Nios UART

with a fixed data rate and other param-
eters. If you look through these serial
routines, you’ll see how to interface to
the Nios UART hardware. You can
then extrapolate to other variations
you might add to the CPU. Altera also
provides documents and code examples
for the peripherals.

TIMER

The CCTIM1.c file contains the

timer routines. You can set the timer
period and install the timer interrupt.
The timer variables are incremented for
each interrupt. If you have a timer inter-

rupt period of 1 ms, every 1,000 inter-
rupts are equal to 1 s in the real world.

I created a timer test option in the

main program loop. With this option,
you can install and remove the timer
interrupt, and set the interrupt period.

PIO INPUT AND OUTPUT

I used a parallel I/O scheme to inter-

face to each axis. Basically, I set a value
for the Nios PIO and that worked its
way down through the hardware. This
is the safest approach I could think of.
It’s slower than designing each axis as a
device, like the UART, for which you

Figure 3—

This circuit is looking for a change from zero to one. After the change

occurs, the circuit’s output goes to a one for one clock period.

background image

George Martin began his career in the
aerospace industry in 1969. After five
years at a real job, he set out on his own
and cofounded a design and manufactur-
ing firm (www.embedded-designer.com).
George’s typical designs include servo-
motion control, graphical input and
output, data acquisition, and remote
control systems. He’s a charter member
of the Ciarcia Design Works Team. He’s
currently working on a mobile commu-
nications system for the military. In his
spare time, George has become a nation-
ally ranked revolver shooter. Contact
him at george.martin@worldnet.att.net.

RESOURCES

Altera Corp., “Nios UART,” DS-NIO-
SUART-3.0, 2003.

Nios peripheral library, www.altera.com/
products/devices/nios/features/nio-
peripherals.html.

SOURCES

Nios embedded processor, SOPC
Builder, QuartusII design software
Altera Corp.
www.altera.com

40

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

an

int, which is a 32-bit entity. You

need to test this assumption when
you’re debugging the hardware.

You now have an axis and a step size.

The motion system should be resting,
and the position and target registers
should be equal values. However, note
that the target register is constant, and
the position register varies slightly
because outside disturbances cause the
mechanism to move.

I have defined target registers for each

axis. You need to add the step to the tar-
get register and set that new value in the
hardware. This causes the hardware to
generate an error signal that drives the
axis motor in a direction to reduce the
error. You can monitor the position until
the motor stops and its close enough
to the target. If all is well, you’re done.

A word of caution here: Lots of things

can go wrong. The mechanism could
run into something and never get to the
target position. The step size could be
inacurate and you might move too far
past your limit. The move could be so
slow that you timeout before reaching
your goal. The motor could overheat
and shut down. Furthermore, you could
reach your goal but be unstable, oscillat-
ing back and forth across the target. I
didn’t consider this when I wrote the
code. I just looked for a way to reach the
target. This gets you started on the right
foot. You also might want to modify the
design to address the potential problems.

You’ll notice that the

RunMotion rou-

tine assumed the axis was at some sort
of acceptable, stable position. How did
you get there? Well, you went through a
zeroing process, which moved the axis to
the home position, which was zeroed
along with the target registers. Actually,
each axis has a home, zero, and limit
position defined by its construction.

Home is a position that you can move

to rapidly. Some overshooting is permit-
ted. Zero is a position found under stable,
repeatable conditions. For example, mov-
ing to zero occurs at a rate until an opti-
cal sensor is tripped. Limit is a fault-type
condition that indicates you’ve gone too
far. Sometimes software reacts to the
limit condition, and sometimes the hard-
ware takes over and shorts the motor,
causing the axis to stop abruptly. You can
recover from a limit condition by moving
the axis by hand. If you try to move

quickly, the motor will act as a generator
and the short will act like a brake.

A

ZeroAxis() routine takes care of

this homing operation. Its implementa-
tion requires information from outside
sensors. Keep in mind that I used hypo-
thetical data for this article rather than
gathering data from sensors. Therefore,
you’ll want to pay more attention to
the comments than the actual code. I
suggest adding a

GoHome(INT16 Axis)

routine that would close the loop and
start stepping relatively small amounts
toward the home direction until the
home sensor is activated.

NEXT

Next month I’d like to show you a

complete system with... Wait a minute.
Why don’t you take over? It doesn’t
have to be a Nios; any FPGA vendor’s
system would be good. Come on, show
us where you’re going today.

I

The

InitAxis routine opens the

control loop for the axis. Then, it sets
both the position and target registers
to zero and closes the loop.

I left out looking for errors in the

control loop. Potential errors include a
high motor temperature reading, detec-
tion of limit input, or a timeout on a
move command. Each system is so dif-
ferent that showing one implementa-
tion is a waste of ink.

Another feature of the Nios PIO input

registers is that an interrupt can be gen-
erated for an event on any input bit. If a
safety interlock is activated, you might
want to open the loop immediately.

MOTION CONTROL

You have two options for motion test-

ing in the main control loop. The first is
to zero both axes. The second is to move
one of them a predetermined distance.

Let’s start with the second command.

The format is as follows: G n dddd<CR>.
“G” is the unique command prefix,
“n” is the axis, “dddd” is the command
amount, and “<CR>” is the end-of-com-
mand character. This data is entered
into the serial port and processed using
the call

count = ReadLineCom1(buf).

The return value is the number of
characters returned in

buf. If there are

any, the main loop attempts to process
the returned characters. The first char-
acter is the test option selected. If that
first character is “G” or “g,” then con-
trol is transferred to

RunMotion and

that routine is passed a pointer to the
rest of the command line.

The

RunMotion routine takes the

pointer and extracts the axis number
and the size of the step. It does so by
first ignoring (skipping over) spaces in
the command string. Then, a call goes
to the C

atoi() routine, which returns

the integer value of the characters start-
ing at the pointer value passed to it.
That return value is the axis number.

Skipping over the axis number and

any subsequent spaces places the point-
er at the start of the step size. The
atol() function is used to extract the
value. Be careful here. You need to rep-
resent position and step sizes in 32-bit
entities. In Turbo C,

atol is used to

get a 32-bit return value. In Nios, I
selected a 32-bit CPU, so I expect the
compiler to interpret

atoi() to return

PROJECT FILES

To download the code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

background image
background image

DS requires only approximately

60 words of program memory. It was
designed for this kind of interface, but
my only debugging tool is awkward to
use, and I was more interested in see-
ing waveforms than writing another
debugging tool. If one or more of the
processors had been tied up in a time-
intensive task while needing to attend
to the firmware-only communications
channel, I would have used this one.

The serial peripheral interface (SPI)

does not require any critical timing. It
only needs a small amount of code, and
would have been a good candidate,
except that it would have required a
third wire, which is undesirable for the
interface between the graphic display
unit and the capture and control unit
because of the cable between them.

When it came time to actually write

the code, I settled on asynchronous
serial ASCII for all the communica-
tions channels, including the one that
was to be implemented in firmware.
The second serial channel in the
waveform capture controller is easy to
implement using the compact code I
found on the ’Net. As for a debugging
tool, I realized that if I would stick to

printable ASCII codes, I could use
the terminal program on my PC
and directly interact with the con-
trollers. And that’s what I did.

DISPLAY MODULE

The graphic display unit’s inputs

are power and asynchronous serial
data. Its output is handshake data
to its host, and it displays informa-
tion by writing black dots on a

42

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

A

fter building the minimum mass

waveform capture circuit that I
described last October (“Minimum Mass
Waveform Capture,” Circuit Cellar,
issue 159, 2003), I couldn’t resist the
urge to build an oscilloscope-like instru-
ment with it. The waveform capture
engine was already designed, so all I
needed were a little analog processing, a
simple graphic display, a user interface,
and some interchip communications to
tie it all together.

My waveform capture and display sys-

tem is composed of two circuit assemblies
incorporating a total of three Atmel
AT90S2313 microcontrollers (see Figure 1).
One assembly is the graphic display
unit, which includes a Seiko-Epson
G1216B1N000 64 × 128 graphic LCD, an
adjustable negative bias supply for the
display, and a microcontroller-based seri-
al interface. I put the graphic display unit
in a separate clear plastic box so I could
position it for easy viewing; it’s inde-
pendent of the rest of the electronics.
Because the unit is in its own box, I can
use it with other projects. The display
and control panel are shown in Photo 1.

The other assembly is the capture

and control unit, which includes the
waveform capture electronics that
supply the waveform and trigger
signals to the waveform capture
controller. It also has all of the user
controls, including those for signal
gain and offset, triggering, timebase
adjustments, a four-digit LED time-
base display, and a trigger indicator
LED, all of which are minded by the
user I/O controller. All the commu-
nication between the capture con-

Triple AVR Waveform Capture and Display

Dick built a simple waveform capture and display system around three AT90S2313 micro-
controllers. Although it’s not a replacement for a real-time oscilloscope, he relies on the sys-
tem for a variety of tasks such as monitoring the I/O on a microcontroller.

trol unit and the other two controllers
is 0- to 5-V asynchronous serial.

WHY ASYNC SERIAL?

Each of the three controllers has a

hardware UART on it, but the wave-
form capture controller has to support
two bidirectional communications chan-
nels (one to the graphic display unit and
the other to the user I/O controller), and
that means one or more of the commu-
nications channels must be imple-
mented in firmware only. I looked at
Philips’s I

2

C protocol a couple of times.

It’s certainly well proven and designed
for exactly this kind of interchip com-
munication. But, I was concerned about
the amount of code space a firmware
implementation would take and the
severe demands on the slave controller’s
response time. Most of all, I dreaded the
hassle of debugging something I had
little experience with and no tools for.

The DS protocol turned out to be a

better choice for this project than I

2

C.

It’s a two-wire serial protocol that I
wrote for some earlier projects in
which I

2

C wasn’t suitable because of

its demands on the slave controller’s
response time.

FEATURE ARTICLE

by Dick Cappels

Photo 1

It works! I removed the display from its plastic box for

this picture. The controls are arranged in a manner similar to
that found on old Tektronix analog oscilloscopes. The red light
below the timebase display is the trigger signal indicator.

Three Controllers Make a Waveform Monitor

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

43

ASCII Input mode.

$82 switches to

Binary Input mode, and

$83 restarts

the firmware and controller.

The controller’s main loop watches

for data coming into the UART. When
two successive address bytes are
received, they are used as x,y coordi-
nates and a dot is written at that
point. Then, it sends an ASCII asterisk
character back to the host to indicate
that the operation has completed. Any
byte received with a value higher than
127 is interpreted as a command, and
then the execution jumps back to the
start of the main loop. If an unsupport-
ed command is received, it sends an
ASCII exclamation point before return-
ing to the main loop. The acknowledge
(ACK,

$06) and negative-acknowledge

(NAK,

$15) are traditionally used as

handshakes, but I used the asterisk and
exclamation points to make sure they
would print on all ASCII terminals.

CAPTURE AND CONTROL

Two circuit boards are inside the cap-

ture and control unit’s plastic enclosure.
The main board holds two microcon-
trollers: the waveform capture controller
that digitizes the analog waveforms and
the user interface controller that attends
to the user input buttons and the LED
timebase display. Analog circuitry pro-
vides minimal signal processing for the
analog waveform and triggering. The
other board is the control panel board
on which the user controls are mount-

ed. The circuitry for
both boards is shown
in Figure 3.

Early in the project,

I decided to use two
separate controllers
for the waveform cap-
ture and user I/O
functions so I could
put them at opposite
ends of the circuit
board to minimize the
noise pickup by the
analog circuits (see
Photo 2). As it turned
out, using two sepa-
rate controllers also
helped simplify the
development process;
it forced me to use
small modular pro-

light background at locations speci-
fied by the host.

The power for the graphic display

unit comes through a 7805 regulator
in a TO-220 package. The 7805 supplies
5 V to the Seiko module, the microcon-
troller, and a voltage multiplier and
adjustable regulator that provides the
negative bias for the display. To make
the negative supply, the buffered output
of an NE555 oscillator is passed through
a five-stage, capacitor-diode, half-wave
voltage multiplier to provide a negative
power supply for the op-amp, which
provides a regulated bias supply that is
adjusted with a contrast potentiometer.

As for the original breadboard, I was

disappointed to see that the NE555’s
output dropped to less than 3 V

PP

under load. The datasheet confirmed
that this is expected, so I added a two-
transistor saturating buffer so I could
get the necessary negative voltage
with the minimum of multiplier stages.
The transistors in the buffer saturate,
causing the voltage multiplier to be
driven within a couple hundred milli-
volts of ground and the 5-V line.

The inverting serial interface is a

clever circuit that I first saw in
Atmel’s AVR910 application note. It
takes its negative power supply from
its host, which makes it well suited
for projects like this. The interface’s
output swings negative if it’s connect-
ed to my PC’s EIA-232 port for debug-
ging with the terminal program. It
safely swings down to
only a little above
ground if it’s connect-
ed to the 0- to 5-V
COMS input on the
waveform capture con-
troller. There are no
switches, jumpers, or
fancy sensing circuits;
it just works that way!

The interface firm-

ware for Seiko’s 64 ×
128 LCD was compli-
cated because the dis-
play appears as two 64 ×
64 displays side by side,
while the interface was
to make it appear as a
single continuous dis-
play. There are separate
chip-select pins for the

two halves, and the AT90S2313 con-
troller was a pin short, so an inverter
was added to make two chip-select lines
out of one (see Q3 in Figure 2).

When power is first applied, the

AT90S2313 LCD interface controller
resets the LCD, erases the screen, and
draws a line from the upper-left corner
to the middle of the bottom edge and
then another to the upper-right corner,
which looks similar to a large V span-
ning the display. This is a visual indica-
tion that the power supply, display
module, and serial controller are up and
running. At that point, the graphic
interface controller enters its main loop
where it waits for data from its host.

Data from the host is either com-

mands or parts of the x,y screen
address at which a dot is written. An
internal flag tells the UART character
receive routine whether to receive
data in 2-byte ASCII hex format,
which is useful for debugging, or in
single-byte binary format, which
needs only 2 bytes for a dot address
instead of 4 and doubles throughput
when writing to the screen.

Because the highest dot address is

127, I was able to reserve those values
with the most significant bit set (cor-
responding to decimal values of 128 or
higher) as commands, while values of
127 or lower were treated as x,y
address data. As for the command
codes,

$80 erases the display and

sends an asterisk, and

$81 switches to

8 to 14 VDC

Power
return

5-V

Regulator

A

T

90S2313

Microcontroller

Signal

Attenuator

A

T

90S2313

Microcontroller

Serial ASCII

Ser

ial ASCII

Amplifier

Signal

Ground

External

trigger

Trigger

circuit

Waveform capture

controller

User interface

controller

4 × 7

LED display

8 8 8 8

User input buttons

Capture and control unit

AT90S2313

Microcontroller

Adjustable

negative

supply

64 × 128

LCD Module

LCD Interface

controller

Graphic display unit

5-V

Regulator

Figure 1

The waveform capture and control system is composed of a capture and control unit and a

graphic display unit connected to each other with a 50-cm, five-conductor flat cable.

background image

44

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

small capacitor should be selected and
placed in position C1 or C2 to compen-
sate for the differences in capacitance,
which include wiring capacitances and
the input capacitance of the FET buffer
following it. With my layout, I needed
5 pf for C2 and C1 was not used.

Source follower Q1 provides high-

input impedance to the attenuator and
shifts the signal to positive so that sig-
nals below ground are within the

grams rather than one large,
complex one.

The unregulated 8 to 14 VDC

coming into the assembly is
shunted by a 14-V varistor to
protect against line transients.
After passing through an on/off
switch, the unregulated voltage
directly powers the op-amps and
the 78L05 voltage regulator.
Then, it’s sent off the board
through the display connector to
the graphic display unit.

The input waveform is capaci-

tively coupled to the top of a
10:1 attenuator. The waveform
capture controller’s full-scale input is
1 V, so the 10: attenuator raised the
full screen sensitivity to 10 V, which
is more than enough for most of my
needs. Closing the switch across the
coupling capacitors makes the input
direct coupled. The ratio of the capaci-
tive reactance across each of the atten-
uator resistors should be the same
ratio as the resistance values in order
to make square waves look square. A

input range of the waveform
capture CPU. Either the indi-
vidual FET used for Q1, the
value of R1, or both may have
to be selected to obtain the nec-
essary 1.5- to 3.5-V gate to
source voltage. A gain stage
made with A1A and A1B allows
for the selection of a bandwidth-
limited version of the signal to
give 10× gain for the full-screen
sensitivity of 100 mV. The fine
and coarse offset potentiometers
are adjusted so that the 0-VDC
point on the displayed waveform
doesn’t shift when the gain

stage is switched in or out. The
2N2907 on the output of A1A protects
the comparator input of the waveform
capture CPU from excessive voltage.

Trigger signals, whether they’re from

the separate trigger input or the incom-
ing waveform, can be either AC or DC
coupled; they are compared in compara-
tor A2A with the trigger level set by the
trigger-level potentiometer. The result-
ing pulses are applied to the trigger input

Photo 2

The main board is at the top. The control board is at the bot-

tom. The waveform capture controller is on the right-hand end of the
main board, and the user I/O controller and the LED timebase display are
at the left-hand end. The analog circuitry is in the middle.

Figure 2—

The op-amp regulates the contrast voltage at –2.2 times the voltage set on the wiper of the contrast potentiometer. The NPN and PNP transistors can be 2N2222

and 2N2907 (or similar devices), respectively.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

45

of the waveform capture controller and
to a simple one-shot made with com-
parator A2B, which drives the trigger
signal indicator LED with voltage fol-
lower A1C. As a result, the LED is illu-
minated whenever triggering signals are
sent to the waveform capture controller.

The waveform is digitized by suc-

cessively comparing the input wave-
form at specific time intervals relative
to the trigger signal with a reference
voltage that is stepped from 1 V to
nearly ground. Vertical centering of
the waveform in the display is accom-
plished by changing the reference volt-
age by adding current from Q1 (which
is set by the vertical centering poten-
tiometer) to the resistor divider on the
controller’s PWM output. The PWM
output divides the PWM signal down
to 1-V full-scale.

WAVEFORM CAPTURE CONTROLLER

The firmware for the waveform cap-

ture controller is a modified version of
the firmware posted on the Circuit
Cellar

ftp site for my October 2003

article (ftp.circuitcellar.com/pub/
Circuit_Cellar/2003/159.). During
power-up initialization, the waveform
capture controller’s firmware waits
until the serial data line from the
graphic display unit goes high, which
indicates that the LCD interface con-
troller is ready to receive data. This
keeps the system start-up synchro-
nized when the graphic display unit has
a separate power supply. After that, it
sends an erase command to the dis-
play and waits for an acknowledgment
before sending a “Switch to ASCII
data” command to the graphic display
unit. It then sends a character to the

user interface controller to display the
default timebase setting.

Having set up the system, it goes

into its main loop where it continu-
ously cycles through the process of
collecting a waveform, sending the
waveform data to the graphic display
unit, and checking to see if a character
from the user I/O controller was
received by the UART. In each meas-
urement cycle, 100 waveform samples
are collected at 6-bit resolution to cor-
respond to the 64 × 128 display for-
mat. Some of the extra columns are
used as vertical scale markers, which
are written to the display each meas-
urement cycle.

Captured waveforms are sent to the

graphic control unit. The handshakes
are received at 19,200 bps, 0 to 5 V with
EIA-232 polarity on regular I/O pins, by

Figure 3

Take a look at the circuitry on the front panel board and the main circuit board. CPDNG is a special ground bus on the front panel board. The 39-k

resistor on the

base of Q2 was added to stop RF oscillations.

background image

46

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

firmware asynchronous serial commu-
nications routines. Communication
with the user interface controller
occurs at 9,600 bps, 0 to 5 V with the
signal polarity inverted from EIA-232
and uses the hardware UART. The
hardware UART is used for user I/O
to make sure user input is not missed,
even during the time-intensive tasks
of capturing waveforms and sending
them to the graphic control unit.

When the waveform capture con-

troller receives a button code from the
user interface controller, it performs
the indicated internal functions, such
as adjusting the timebase, and returns
one or two characters depending on the
button code. If the timebase changes, it
sends a symbol corresponding to the
current timebase setting. If the button
code is a toggle, such as the one to tog-
gle trigger polarity between positive
and negative edges, it also sends back
the four status flags that show the
states of the four toggle controls.

Although the status flags weren’t

used by the current version of the
user interface controller, they were

handy when debugging with the termi-
nal program. I can use them to update

status LEDs if I update the user inter-
face controller code in the future. The

ASCII Character

Waveform capture unit

Internal action taken when

Action taken when received

response

received by waveform

by user I/O controller

capture unit

Function code

0

Timebase value

Set sampling to 1 µs

Display “1–6”

1

Timebase value

Set sampling to 2 µs

Display “2–6”

2

Timebase value

Set sampling to 5 µs

Display “5–6”

3

Timebase value

Set sampling to 10 µs

Display “10–6”

4

Timebase value

Set sampling to 20 µs

Display “20–6”

5

Timebase value

Set sampling to 50 µs

Display “50–6”

6

Timebase value

Set sampling to 100 µs

Display “1–4”

7

Timebase value

Set sampling to 200 µs

Display “2–4”

8

Timebase value

Set sampling to 500 µs

Display “5–4”

9

Timebase value

Set sampling to 1,000 µs

Display “1–3”

:

Timebase value

Set sampling to 2,000 µs

Display “2–3”

;

Timebase value

Set sampling to 5,000 µs

Display “5–3”

<

Timebase value

Set sampling to 10,000 µs

Display “10–3”

Button code

A,a

Status flags

Toggle triggered/free run

None

C,c

Status flags

Toggle capture enable on/off None

D,d

Status flags, Timebase value Decrement timebase

None

E,e

Status flags

Toggle auto erase

None

F,f

Status flags

Toggle trigger polarity

None

I,i

Status flags, Timebase value Increment timebase

None

Table 1—

These ASCII codes can be received by either the waveform capture controller to set capture parameters

or by the user interface controller to set the timebase display. The user interface controller can only generate the A,
C, D, E, I, and F characters. It does not use the status flags, but characters “0” through “<” and the status flags are
helpful for debugging the waveform capture controller using a serial terminal.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

47

functions and button codes are shown
in Table 1.

The status flags returned by the

waveform capture controller are gen-
erated by masking off the irrelevant
bits in the register that the flags are
stored in and adding the

$50 hex

value to it. None of the button or func-
tion codes have values higher than
the

$50 hex value, so any byte with a

hex value of

$50 or higher can be inter-

preted either on an ASCII terminal or
by the user interface controller (if I
add features) as containing flags.

The flags have significance when

they are set: flag 0 indicates that eras-
ing the display before rewriting is
enabled; flag 1 indicates that trigger-
ing is enabled; flag 2 indicates that
triggering occurs on the positive edge;
and flag 3 indicates that the timebase
is in free-run mode.

USER INTERFACE CONTROLLER

The last and easiest part to design

was the user interface controller.
Having thoroughly worked out and
tested the interface to the waveform
capture controller using a terminal,
designing the user I/O controller and
circuitry, as well as writing and
debugging the firmware, was a piece
of cake.

Inside the user interface controller,

a round-robin multitasker, triggered
by Timer0 interrupts, refreshes one of
the four LED characters or checks the
input buttons at each interrupt so
that all four characters are displayed
and the buttons are checked every
five interrupts. The controller’s main
loop continuously checks for a char-
acter arriving in the UART’s receive
buffer. After a character is received, it
checks the character against charac-
ters corresponding to the 13 possible
timebase settings. When a match
occurs, the appropriate bit patterns
are loaded into registers that hold
refresh data for the LED display.

Using this technique, everything

other than the characters relating to
the timebase settings are ignored.
Thus, the status flags are ignored
when they are sent from the wave-
form capture controller. The timebase
display shows the selected waveform
sample rate in a 1-2-5 sequence from

1–6 to 10–3, which represent 1 µs and
10 ms per sample, respectively. The
display codes are shown in Table 1.

Updating the timebase display in

response to data returned from the
waveform capture controller instead
of directly from the user-control but-
tons causes a perceptible lag between
pressing a timebase button and seeing
the display change. That’s because
the waveform capture controller does-
n’t send the updated timebase value
until after the completion of the
waveform capture cycle in which the
character has been received. I had to
do it this way. When I tried setting
the display according to the button
codes sent to the waveform capture
unit, the display was hopelessly out
of sync as soon as the waveform cap-
ture controller missed a button code.

The LED is a common cathode.

The anodes are driven by the user
input controller’s I/O port B through
1-k

current-setting resistors. When

the multitasker gets to the time slot
assigned to sensing the input buttons,
port B changes to inputs, the buttons’
states are read, and then the port pins
turn back to outputs. An additional
1-k

resistor between the buttons

and ground protects port B from
over-current when a button is
pressed while its corresponding I/O
pin is driven high.

The user input buttons include the

following: Triggered/Free-Run Toggle,
which enables you to vertically center
and measure DC voltages, even if no
trigger signal is available; Positive
Transition/Negative Transition
Triggering Toggle; Capture Enable/
Disable Toggle, which stops sampling
and freezes the display; and Erase
Before Write Toggle, which keeps the
display from erasing a captured wave-
form before writing the new one. This
last feature makes the display look
more solid because the display doesn’t
disappear before it’s rewritten in each
waveform capture cycle.

BUTTONING UP

The graphic display unit resides in

a clear plastic box with one 50-cm
flat cable that carries serial data and
power to connect it to the outside
world. The waveform capture unit is

background image

48

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

mounted in a clear plastic pencil box
that’s the same color as the LEDs,
which can be seen through the top of
the box. Note that the user controls
are mounted on the top of the box.

Along with a ground lead, the trig-

ger and signal inputs exit the side of
the case close to where the flat cable
to the graphic display unit and the
power cable to the 12-V wall wart
transformer exit the case. Captive
micrograbbers and a subminiature
alligator clip enable you to attach the
signal, trigger, and ground leads. All
of the cables plug into the main
board. Note that when the top of the
pencil box is closed, all of the cables
are captive.

Since building this little waveform

monitor, I have come to rely on it for
a variety of indication and measure-
ment tasks. Although it isn’t a sub-
stitute for a real-time oscilloscope,
it’s just fine for things like seeing
what the I/O on a microcontroller is
really doing, and even sorting through
a bag of mystery inductors from the
surplus store.

I

National Semiconductor Corp., “LM124/
LM224/LM324/LM2902 Low Power
Quad Operational Amplifiers,”
SA009299, 2000.

———“LM193/LM293/LM393/LM2903
Low Power Low Offset Voltage Dual
Comparators,” DS005709, 2000.

Philips, “I

2

C Bus Specification Version

2.1,” 9398 393 40011, 2000.

Seiko Instruments, “Liquid Crystal
Display Module G1216B100N,”
MG1216B1N000-002, 1993.

Dick Cappels enjoys tinkering with
and writing about analog circuits and
microcontrollers. He has published
several papers on the topic of elec-
tronic displays in computer systems
and is currently active in the Society
for Information Display. Dick holds
18 U.S. patents in areas including dis-
play technology, color management,
and capacitive proximity sensing. You
may reach him at projects@cappels.org.

PROJECT FILES

To download the code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

RESOURCES

Atmel Corp., “AVR910: In-System
Programming,” rev. 0943C, 2000.

———“8-bit AVR Microcontroller
with 2K Bytes of In-System Program-
mable Flash: AT90S2313,” 0839I, 2002.

D. Cappels, “DS Two-Wire Protocol,”
users.cableaz.com/~cappels/dproj/
dspage/ds.htm.

SOURCES

AT90S2313 Microcontroller
Atmel Corp.
(408) 441-0311
www.atmel.com

LM324 Op-amp, LM3939 Comparator
National Semiconductor Corp.
www.national.com

G1216B1N000 LCD
Seiko Instruments, Inc.
(310) 517-7771
www.siielectroniccomponents.com

background image
background image

50

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

I

speak regularly with the electrical

and application engineers that support
the ICs and modules that I talk about
in my columns. The reason for this is
simple: I get into their heads. As a
result, I have a better understanding
as to how to work the ICs and elec-
tronic modules into applications that
may interest and help you. Getting
freaky with an application doesn’t
always make sense for you, the reader.
So, I always try to use a device for its
intended purpose. I’ll do that this time
around, but with a slight twist.

dsPICDEM (BEFORE)

As you can see in Photo 1, I have a

Microchip dsPICDEM 28-pin demo
board loaded with a dsPIC30F2010 engi-
neering sample. Engineering samples are
like rental cars: you get one, run the
heck out of it, and buy your own if the
experience is positive. I tend to work on
the bleeding edge of most demo boards,
so I took this one for a test drive. Now

troller communications channel, I con-
nected the dsPIC30F2010 and the
PIC18F452 coprocessor serially, using
the dsPIC30F2010’s UART interface and
the PIC18F452’s USART interface. By
directly connecting the USARTs, I pro-
duced a simple and relatively high-speed
communications link with a minimum
of hardware and firmware effort.

Next, I added a NICholas 10/100

microcontroller NIC, which is solely
supported by the PIC18F452. The idea
here is to provide a fast Ethernet
interface to the motor control func-
tionality of the dsPIC30F2010 on
the dsPICDEM demo board. After the
Ethernet interface is established, you
can get at the dsPIC30F2010 and its
internal organs in all sorts of ways.

dsPICDEM (AFTER)

Photo 2 is a view of the modified

dsPICDEM 28-pin demo board. The
NICholas Ethernet NIC stacked on
the dsPICDEM is based on the ASIX
AX88796L 10/100 Ethernet engine IC,
which does all of the work that makes
Ethernet things go.

Uncomplicated dsPIC
Implementation

APPLIED PCs

by Fred Eady

I’ll let you know how it felt because
you’ll probably get the real thing on
your dsPICDEM 28-pin demo board.

At first glance, the dsPIC30F2010

datasheet gave me the impression that
the dsPIC30F2010 was designed to be
an integral part of a motor control or
power control system. The six PWM
output channels can go either way,
while the quadrature encoder interface
supports the motor control side of my
datasheet interpretation. Although the
dsPIC30F2010 sports an internal DSP
engine, its pins are heavily multiplexed
to incorporate all of the motor control-
oriented functionality. That’s a good
thing if all you want to do is dictate the
actions of a motor or supply numerous
PWM signals to a power controller/
voltage regulator subsystem.

No matter what, you still have to be

able to talk to the dsPIC30F2010 to con-
trol it dynamically. The dsPIC30F2010
is capable of communicating with its
three-wire SPI module, I

2

C, or serially

using its internal UART module. The
downside of taking the dsPIC30F2010
out of solitary confinement is that
you’ll either have to give up some
motor control pins to the communi-
cations interface of your choice or
bring in some help.

There isn’t much on the dsPICDEM,

but considering all of the stuff inside
the dsPIC30F2010, not much else is
required if motor control is your goal.
Just add an H-Bridge, tie in your
encoder, and write some PWM driver
code. That’s nice, but I had something
else in mind (see Figure 1). First, I
added a coprocessor to the dsPICDEM
in the form of a PIC18F452. To facili-

tate a microcontroller-to-microcon-

As soon as Fred got his hands on a Microchip dsPICDEM 28-pin demo board, he modified it.
This month he proves that you don’t have to be a DSP wiz to get started with the dsPIC.

Photo 1—

This is one unassuming development board,

but don’t let the lack of componentry fool you. There’s a
lot of bang in this little package.

Photo 2—

Check out my dsPICDEM 28-pin demo board

after a trip to the Florida room chop shop.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

51

The AX88796L is an NE2000 regis-

ter-compatible, local CPU bus
Ethernet controller with an embedded
10/100-Mbps PHY transceiver. Using
the IEEE802.3 and IEEE802.3u stan-
dards, the AX88796L provides 10- and
100-Mbps Ethernet functionality in
full- or half-duplex operation.

Note that 8 KB of 16-bit SRAM is

included on the AX88796L, as is an 8-
or 16-bit local CPU interface that can
accommodate a wide range of micro-
controllers. The AX88796L can be
configured to run in either 8- or 16-bit
mode by simply setting a bit in its
data configuration register (DCR).
Specifying the CPU interface is just as
easy. The AX88796L can be config-
ured to run in one of four local bus
CPU modes by jumpering pins CPU[0]
and CPU[1] to logic levels that
instruct it to interface to one of the
following environments: an ISA, an
80186, a 68000, or an 805X. The
NICholas loaded on the dsPICDEM

demo board is jumpered for ISA opera-
tion, which equates to both CPU[0]
and CPU[1] being pulled low.

The AX88796L, which is housed in

a 128-pin LQFP low-profile package,
typically consumes less than 100 mA
from a 3.3-V power source. In addition
to smashing packets through a wire,
the AX88796L’s I/O is 5-V tolerant,
which means you really don’t have to
convert the dsPICDEM’s 5-VDC
power supply to 3.3 VDC to accom-
modate the Ethernet controller. The
AX88796 L’s clock lines are the only
I/O lines that are not 5-V tolerant. A
25-MHz crystal or oscillator can be
used as the AX88796L’s clock source.

To keep the part count down and

maintain the smallest footprint possi-
ble, the AX88796L development board’s
Ethernet magnetics are contained with-
in a single LAN Mate unit. The LAN
Mate NU1S041C-434 complies with
the IEEE 802.3u standards. The module
used on the NICholas is a 1:1 center-

tapped configuration that contains all
of the necessary electronics needed to
interface to standard Cat 5 twisted-pair
media. Three-link activity and speed
status LEDs are also incorporated in
the LAN Mate module.

The NICholas’s dual-row header

pins out five of the AX88796L’s address
lines that I used to gain access to the
AX88796L’s internal NE2000 (MAC)
register set (SA0–SA4). The remaining
address lines are hard-wired at the
dsPICDEM’s dual-row female NIC sock-
et to select a base address of 0x200,
which is the default base address for
the AX88796L. By using the default
address, the three base address pins—
I/O_BASE[0], I/O_BASE[1], and
I/O_BASE[2]—can be left in a disconnect-
ed state. This allows the AX88796L’s
base address pins to follow their internal
pull-up and pull-down circuitry and
select the base addresses of 0x200
(I/O_BASE[0]=0, I/O_BASE[1]=1 and
I/O_BASE[2]=1). I hand-wired this

Figure 1—

No surprises here. Imagine what you can do with six remotely controlled PWM outputs.

background image

52

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

baby in, so every extra pin I don’t
have to connect a wire to is goodness.

In terms of raw processing power,

the dsPIC30F2010’s MIP rate falls
with the voltage, which gave me one
more reason not to rip up the
dsPICDEM and modify the on-board,
5-V power supply just to accommo-
date the NICholas. So, to keep the
AX88796L 3.3-VDC power supply cir-
cuitry as simple as possible, and to
keep the dsPIC30F2010’s performance
potential high, I powered the
NICholas using a Zetex ZSR330 volt-
age regulator, which is fed by the
dsPICDEM’s 5-VDC power supply.
The ZSR330 doesn’t require any exter-
nal components for stability.

The DPDT switch you see mounted

on the dsPICDEM in Photo 2 is there
in place of the jumpers and shorting
blocks you see there in Photo 1. I
used the MPLAB ICD 2 as the
dsPIC30F2010 debugging tool. After
some initial serial routine failures
with BASIC code that executed in the
debugger correctly, I finally figured
out that the UART transmit and
receive lines are doing double-duty as
the MPLAB ICD 2 debugger commu-
nication lines. To circumvent this sit-
uation, I used a dsPIC30F2010 config-
uration fuse setting that shifted the
MPLAB ICD 2 debugger lines to an
alternate set of MPLAB ICD 2 com-
munication pins.

The dsPIC30F2010 has four sets of

alternate MPLAB ICD 2 interface
pins. The primary set of pins, EMUC
and EMUD, is multiplexed with the
primary UART transmit and receive
pin pair. The EMUC1 and EMUD1
pins are positioned on the alternate
UART transmit and receive pair locat-
ed on port C. The third pair of pins,
EMUC2 and EMUD2, is found on port
D, and the final pair of pins, EMUC3
and EMUD3, resides on port B.

Having a MPLAB ICD 2 interfaces

on different ports gives you the flexi-
bility to hang an MPLAB ICD 2
debugger on pins that you aren’t try-
ing to use in the debugging process. In
this case, the jumpers and the configu-
ration fuse setting switched the
MPLAB ICD 2 from EMUD and
EMUC to EMUD1 and EMUC1 to
allow the serial port pins originally

assigned to the MPLAB ICD 2 to be
used as transmit and receive lines in
the debug process. I added the DPDT
switch because the MPLAB ICD 2
must use the EMUD and EMUC inter-
face to initially load the compiled
code and debug executive with the
alternate MPLAB ICD 2 interface fuse
setting into the dsPIC30F2010.

After the debugger load is complete,

the jumpers have to be moved to con-
nect the MPLAB ICD 2 to the
EMUD1 and EMUC1 interface pair
and free the EMUD and EMUC pins
to be used as the UART transmit and
receive pins. I moved the jumpers
back and forth once before deciding to
mount the DPDT switch in their
place. Another way to avoid moving
jumpers or adding switches is to code
the dsPIC30F2010 to use the alternate
UART transmit and receive pins. To
do that with the dsPICDEM requires
custom trace cutting and rewiring.
Adding the DPDT switch is the easi-
est way out.

dsPIC30F2010 CODING

I always like to start out with a new

microcontroller by conquering the
serial interface. After I get the serial
port of that microcontroller working,
other things just seem to fall into
place. My first experiences with the
dsPIC30F2010 UART were unhappy

ones because I didn’t realize that the
MPLAB ICD 2 was messing up the
outgoing data. However, after I finally
caught on to what was transpiring,
using the dsPIC30F2010’s UART was
as simple as Listing 1 shows it to be.

Although simple, the code in

Listing 1 is instrumental in that this
is the way the dsPIC30F2010 and the
PIC18F452 communicate. Taking the
code line by line, the dsPIC30F2010’s
UART is enabled by setting the most
significant bit of the U1MODE register.
The dsPIC30F2010’s UART data rate is
calculated with the following formula:

F

CY

is the instruction clock rate. BRG

is the value to load into

U1BRG for

data rate clock generation.

The U1BRG statement in Listing 1

solves for BRG and loads the data rate
generator value in the

U1BRG register.

The last action performed before turn-
ing the UART loose involves enabling
the UART transmitter by setting the
UTXEN bit in the U1STA register.
The code between the

while(1)

braces is a simple serial echo mecha-
nism. The dsPIC30F2010 UART has
its own 4-byte receive-and-transmit
buffer. When a character enters the
receive buffer, the URXDA bit is set.
If there is no transmission in progress,

Data

F

CY

rate =

BRG

+

1

16

×

(

)

Listing 1—

After I got this little piece of code working, I was on my way to bigger and better things.

main(void)

{

U1MODE |= 0x8000;

U1BRG = (((7372800/9600) /16) - 1);

U1STA |= 0x0400;

while(1){

while(!U1STAbits.URXDA);

while(!U1STAbits.TRMT);

U1TXREG = U1RXREG;

}

}

Listing 2—

I really had to dig to get enough information to make this little code snippet work correctly.

main(void)

{

int x;

PTPER = 0x1FFF;

PDC1 = 0x1FFF;

PTCON = 0x8000;

while(1){

++x;}

}

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

53

the TRMT bit is clear. The code waits
for a character to enter the receive
buffer, and when all is clear on the
transmit side, it moves the incoming
character from the receive buffer into
the transmit buffer for transmission.

The dsPIC30F2010 has an extensive

PWM module. The dsPIC30F2010
datasheet provides information about
how to set up the PWM registers, so I
turned to Microchip’s “dsPIC30F Family
Reference Manual” for the scoop on
the bits inside the dsPIC30F2010’s PWM
register set. As you can see in Listing 2,
the PWM module is just as easy to set
up and use as the UART.

The PWM operation is based on a

15-bit up/down counter, or PWM time
base, implemented by the PTMR spe-
cial function register. The most signif-
icant bit of the PTMR is read-only and
indicates the direction of the timebase
count (up or down). Using the PWM
timebase to count up and down allows
for the generation of center-aligned
PWM signals. To set the PWM period,
a 15-bit value is written to the PTPER
special function register. When the
count in the PTMR reaches the count
established by the PTPER, the PWM
timebase either resets to zero or starts
counting in the reverse direction.

In Listing 2, PWM1 is set to run

in Free-Running mode. The
dsPIC30F2010’s PWM running in Free-
Running mode produces an edge-
aligned PWM signal, which means the
PTMR value counts up to the PTPER
value and resets the timebase to zero.
The time it takes for the PTMR value
to reach the PTPER value is the period
of the PWM signal. It’s computed as
follows:

where T

PWM

is the PWM period, and T

CY

is the dsPIC30F2010 clock cycle time.

T

CY

in Listing 2 is the reciprocal of

the crystal, or clock frequency, multi-
plied by four:

With a value of 0x1FFF (8191 decimal)
and a PTMR prescale value of one, the
PWM period is 4.44 ms, which results
in a PWM frequency of 225 Hz.

1

7.37 MHz

4

×

T

PTPER

PWM

=

T

PTPER + 1

prescale value

CY

×

(

)

produce PWM signals, the rest of the
code for the dsPIC30F2010 calls on
the serial routine to receive a PWM
period or duty cycle value from the
PIC18F452 coprocessor, as well as
some auxiliary code to apply the
received data to the appropriate PWM
special function register. Listing 3 is a
way of routing the data to the correct
special function register to implement
the change in the requested PWM sig-
nal. As you can see, the ASCII charac-
ter P or D, followed by 2 bytes of spe-

The PDC1 special function register

determines the duty cycle of the
dsPIC30F2010’s PWM1 signal. The
value in the PDC1 special function
register determines how long the PWM
signal will remain high during each
cycle. The value of PDC1 in Listing 2
sets a 50% duty cycle. Figure 2 is a
graphical interpretation of how
PTPER, PTMR, and PDC1 interplay to
form a PWM signal.

With some dsPIC30F2010 code to

communicate with the PIC18F452 and

background image

PROJECT FILES

To download the code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

Fred Eady has more than 20 years of
experience as a systems engineer. He
has worked with computers and com-
munication systems large and small,
simple and complex. His forte is
embedded-systems design and com-
munications. Fred may be reached at
fred@edtp.com.

SOURCES

NICholas
EDTP Electronics
www.edtp.com

dsPICDEM 28-pin demo board,
dsPIC30F2010, and PIC18F452
Microcontroller
Microchip Technology, Inc.
(480) 792-7200
www.microchip.com

ZSR330 Voltage regulator
Zetex
(+44) 161 622 4444
www.zetex.com

54

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

cial function register data
received from the PIC18F452
coprocessor via the asynchro-
nous serial link, can be used
to modify the dsPIC30F2010’s
PWM output signal.

CODING THE PIC18F452

The PIC18F452’s job is to

initialize the AX88796L and
perform the interface func-
tion between the
dsPIC30F2010 and the
Ethernet link. If the
PIC18F452’s code is written
in a modular fashion, it really
doesn’t matter how you
decide to encode the messages
that ultimately will be delivered to the
dsPIC30F2010. For instance, Visual Basic
allows you to put together a quick and
nasty UDP engine. The UDP code mod-
ule contained within the PIC18F452
picks up the UDP data, performs the
necessary data conversions, and passes
the message to the dsPIC30F2010 via
the serial link established between the
two microcontrollers.

If Visual Basic isn’t your thing, you

can code a Telnet module for the
PIC18F452 that essentially does the
same thing as the UDP module. The
basic idea is to capture the data using
the AX88796L Ethernet interface,
process it, and pass it to the

dsPIC30F2010 via the PIC18F452’s seri-
al port. Doing so simply entails gather-
ing data from one code module inside
the PIC18F452 and passing it to anoth-
er code module that either prepares the
data for output or sends it on its way.

MELDING MODULES

The AX88796L is NE2000-compati-

ble, which means you can reuse (with
minor modifications) code written for
other NE2000-compatible Ethernet
controllers such as the Realtek
RTL8019AS. Visual Basic, which pro-
vides plenty of space when it comes
to Internet protocols, is a fast and
easy way to build a useful user inter-

RESOURCES

Microchip Technology, Inc.,
“dsPIC30F Family Reference Manual,”
DS80169C, 2004.

face. Even though I didn’t do
any deep DSP stuff, I’ve
shown you just how easy it
is to get started with the
dsPIC using the dsPICDEM
28-pin demo board.

I want you to have as

much fun as I did. So, I bun-
dled up all of the dsPICDEM
Ethernet, Visual Basic, and
dsPIC30F2010 code that I
wrote so you can download it
from the Circuit Cellar ftp
site and use it in a project of
your own. The dsPIC is
much like the PICs you’re
used to, but some of the
newer features will have you

digging into the datasheets. After you
get familiar with the differences,
you’ll find that dsPIC stuff isn’t com-
plicated, it’s embedded.

I

Listing 3—

You can build on this to include changing just about any special function register-related

dsPIC30F2010 function.

#define make16(varhigh,varlow) ((varhigh & 0xFF)* 0x100) +

(varlow & 0xFF)

switch (recvchar)

{

case ‘P’:

//Change PWM period

while(!U1STAbits.URXDA);

low_byte = U1RXREG;

while(!U1STAbits.URXDA);

high_byte = U1RXREG;

PTPER = make16(high_byte,low_byte);

break;

case ‘D’:

//Change PWM duty cycle

while(!U1STAbits.URXDA);

low_byte = U1RXREG;

while(!U1STAbits.URXDA);

high_byte = U1RXREG;

PDC1 = make16(high_byte,low_byte);

break;

default:

break;

}

PTPER

PDC1

PDC2

0

PWM1H

PWM2H

Duty cycle

Period

PTMR value

New duty cycle loaded from PDCX

Figure 2—

After all that reading, I see this. Bing!

background image

Schematic and PCB Layout

• Powerful and flexible schematic capture.
• Auto-component placement.
• Rip/entry PCB routing.
• Polygonal gridless ground planes.
• Library of over 8000 schematic and 1000 PCB foot prints.
• Bill of materials, DRC reports and more.

Mixed Mode SPICE Circuit Simulation

• Berkeley SPICE3F5 simulator with custom extensions for

true mixed mode and interactive simulation.

• Six virtual instruments and 14 graph based analysis types.
• 6,000 models including TTL, CMOS and PLD digital parts.
• Fully compatible with manufacturers’ SPICE models.

Proteus VSM - Co-simulation and debugging for

popular Micro-Controllers

• Supports PIC16 & PIC12, AVR, 8051, HC11 and ARM micro-

controllers.

• Co-simulate target firmware with your hardware design.
• Includes interactive peripheral models for LED and LCD

displays, switches, keypads, virtual terminal and much,
much more.

• Provides source level debugging for popular compilers

and assemblers from HiTech PICC, Crownhill, IAR, Keil
and others.

R4

www.labcenter-electronics.com

EASY TO USE CAD TOOLS AT FANTASTIC PRICES

MicroChip PIC 18

• Supported models of the PIC 18 includes PIC18F242,

PIC18F252, PIC18F442, PIC18F452, PIC18F248, PIC18F258,
PIC18F448 and PIC18F458.

Basic Stamp BS1 and BS2

• Proteus VSM for BASIC Stamp contains everything you

need to develop and simulate designs based around the
BASIC Stamp.

• See examples in downloadable Demo at

www.labcenter-electronics.com

“I finished my first design, schematic and PCB in one day.”
“What a great tool! I love it.”

DAN GILL

“For the cost of the software compared to the productivity gains,

I consider Proteus to be pivotal in the commercial viability

of my company and by far represents the best value for money
of anything Tempus possesses.”

ROB YOUNGS, Tempus Consulting

“PROTEUS stands out as the best all-round program in this review.

Other programs reviewed have strengths in the pcb design process,
Proteus maintains a constant high level of capability throughout.
Whether a schematic, user-friendly interactive routing, config-
urable autoplacing, competent autorouteing, or a combination
of the above, PROTEUS handles everything very well.”

Electronic & Wireless World CAD Review Roundup

FREE

DOWNLOADABLE

DEMO

Save Time. Save Money.

Proteus Starter Kit – $199 • Complete Systems from $449

“This is clearly superior in every respect.”

Virtual System Modelling

SYSTEMS
INC

.

Tel: 905•898•0665 info@r4systems.com

background image

As the design concept evolved, I

realized that I could actually design
the entire UI right on a PCB with the
e-field circuitry. There are no unwant-
ed or flimsy connections (e.g., a touch-
screen flex connector), and the PCB
traces are my electrodes. This keeps
the manufacturing simple and it
enhances reliability.

The design uses two e-field sensors

to form an XY grid on both sides of the
board. A custom user interface template
(or overlay) is placed on the back of the
board and exposed through the enclo-
sure for interaction. When you touch
the overlay, the capacitance changes
on various e-field electrode XY points
underneath, which are then deciphered
by the Nitron. The final result is my
Smart-E-Touch, which is a simple, com-
pact design that has many possibilities.
Now I’ll cover the technical details.

SYSTEM OVERVIEW

The Smart-E-Touch is an intelligent,

touchscreen-based UI design that uses
a Nitron microcontroller to control
and monitor a pair of e-field sensors.
The sensors, in turn, monitor an XY
grid on the PCB for the actual capaci-
tive sensing of the touchscreen
through a custom UI overlay. After
the Nitron has translated a touch from
the e-field sensor data, it then outputs
an XY coordinate to its RS-232 serial
port. A main system controller, PC,
PLC, or microboard then receives the
coordinates and can act upon them.

The unique thing about this touch-

screen is that it’s built right on the
actual circuit board where the touch-

56

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

U

ser interface (UI) designs are a

critical part of a system’s design.
Having worked on a variety of UI
designs, I’ve seen the simplest LCD
and keypad overlay combo all the way
up to the extreme of a full-blown
WebPAD that harvested more process-
ing power than my last desktop PC.
The front end of the system is what
you use to interact with your product
or device. For this reason, it must be
carefully tailored toward the applica-
tion for which the device will be used.
If you make it too simple or too com-
plex, your device may not get used to
its fullest potential.

As technology improves, UIs will

evolve. For example, an LCD with a
touchscreen bolted on top is a com-
mon alternative for custom keypad
switch overlays and LEDs, which can
give your product more pizzazz and
flexibility but bring inherent complex-
ity and cost. Once again, it comes
down to the level of complexity need-
ed to interface with your product, and
whether you can take the inherent
cost burden.

E-FIELD FOR UI DESIGN

Technological improvements can

provide the catalyst for new design
ideas. It was definitely the case when I
was introduced to the new Motorola
MC33794 e-field sensor. Since then,
the sensor has garnered a lot of public-
ity. It also has appeared in several
Circuit Cellar

articles, so I won’t go

into too much depth about how it
works. Let’s focus on the basics. You
can connect up to nine electrodes (e.g.,

Smart-E-Touch

wire and PCB trace) to one chip and
sense a change in capacitance on each
individual line. Touching one elec-
trode with your finger drastically
affects the capacitance measurement,
and the chip easily senses it.

At the time of the Motorola Flash

Innovation 2003 Design Contest, I
knew that hooking up an e-field sen-
sor to a Nitron microcontroller would
result in a really cool project, especial-
ly if it had something to do with sens-
ing human touch. So, how does all of
this tie into UI design? Well, given my
love (or lack thereof) for UI designs, I
thought it would be interesting to
design a simple, low-cost UI based on
e-field technology. I decided that the
design’s main focus would be on the
simplicity of interfacing and placing
low burden on the system controller
monitoring the UI.

FEATURE ARTICLE

by Bruce M. Pride

Bruce’s Smart-E-Touch is an intelligent, touchscreen-based UI design in which a
68HC908QY4 microcontroller controls a pair of Motorola e-field sensors. This inexpen-
sive system is the perfect alternative to the pricier touchscreen UIs on the market.

Photo 1—

The Smart-E-Touch design is entirely inte-

grated on the PCB, so you can easily bolt it into an
enclosure. Use custom PCB form factors to accommo-
date the enclosure for a perfect fit.

An Intelligent User Interface

background image

Photo 2b, a 9 × 9 XY electrode grid was
created on the back of the circuit board
to provide the UI sensing. The grid was
also brought through to the front of the
board with vias so as to increase the
amount of copper for each electrode. As
you can see in Photo 2c, I shined a light
through the board to show you the UI
and the XY grid together. This should
give you an idea of the UI’s resolution.

Although the grid resolution is

coarse and only provides 81 total sens-
ing points, it was just fine for this UI
design. Most of the buttons on my UI
overlay have at least four XY intersec-
tion points on or near them that pro-
vide ample sensing capabilities for the
buttons. These 18 PCB trace elec-
trodes are then hooked up to the two
MC33794 e-field sensors. Nine elec-
trodes go to the X e-field sensor and
nine go to the Y e-field sensor.

The e-field sensors require little

external circuitry to operate. All you
need is power and a few discrete resis-
tors and capacitors (see Figure 2). By
connecting your microcontroller to the
e-field’s 4-bit logic input, you can select
which of the nine e-field channels you
want to measure. After a selection is

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

57

made, the electrode voltage is output
on the e-field sensor’s LEVEL pin for
easy reading by an A/D converter.

The e-field sensor provides other

features that I didn’t use for this proj-
ect. The internal lamp driver and ISO
communications interface could prove
handy for some designs.

Now that I’ve covered the UI, elec-

trodes, and e-field sensors, let’s take a
look at the processing power behind the
design. I used a Nitron 68HC908QY4
8-bit flash memory microcontroller in
a 16-pin TSSOP SMT package.
Although a TSSOP is tricky to solder,
I needed a small device package given
the size constraints. The Nitron pro-
vides the 100-ms sample interrupt via
its internal timer, the selection inter-
face for selecting which electrode to
measure, and uses its A/D converter
to measure the current selected elec-
trode. The Nitron then converts the
analog electrode voltage data to a
coordinate representing a specific loca-
tion on the UI. After X and Y coordi-
nates have been put together, it out-
puts them to its bit-banged RS-232 port
at 19.2 kbps via a MAX232 transceiver.
This gives the Smart-E-Touch a fairly
high-speed serial port from a low-cost
microcontroller.

The Nitron provides 4 KB of flash

memory and 128 bytes of RAM, which
was more than enough for the Smart-
E-Touch code. The Nitron doesn’t
require an external crystal because it
has a built-in digitally controlled
oscillator. I used it for this project and
programmed it to 10 MHz.

The Nitron is programmed via the

16-pin MONO8 port, which allows for
a direct connection to a P&E
Microcomputer Systems Cyclone pro-
grammer. Reset is provided via the

control circuitry is located. An interest-
ing option for this concept is that rather
than integrating a separate touch-
screen assembly into a design, you can
design the touchscreen on the main
system controller board. This makes
for a more cost-effective, reliable, and
adaptable user interface design.

So, given the Smart-E-Touch’s capa-

bilities, how can it be used in system
development? Depending on the appli-
cation, the Smart-E-Touch is a natural
replacement for touchscreens and cus-
tom-made switch overlays. A simple UI,
like the one shown in Photo 1, could be
used with or without an LCD and pro-
vide a great deal of functionality. Now
let’s look at the various pieces of the
design so you can see just how simple
and elegant the Smart-E-Touch really is.

SYSTEM BLOCKS

To keep things simple and the cost

down, the Smart-E-Touch is made up
of a minimal number of components
(see Figure 1). Starting with the user
interface, note that you interface with
the Smart-E-Touch via an overlay
placed on the back of its board. I
designed a simple UI in Excel, printed
it on paper, and then cut it to fit.
Although this wasn’t a production solu-
tion, it was the simplest way to come
up with a nonconductive overlay with-
out breaking the bank. I’m sure there
are many more durable materials out
there that can be placed over an e-field
electrode that would allow a change of
capacitance to occur when touched.

Next, the overlay is placed over the

XY electrode matrix (see Photo 2a).
Underneath the overlay is the key to
the entire system. As you can see in

Y Electrodes

Motorola

MC33794

e-field

sensor

E-field interface

X Electrodes

STOP

GO

Smart-E-Touch

Motorola MC33794

e-field sensor

E-field

interface

Motorola

Nitron

microcontroller

ASCII

Serial data

Maxim

RS-232

transceiver

RS-232 ASCII

Serial data

PCB

PC

or

XY PCB

touch panel

RS-232-enabled

monitoring device

Figure 1—

The Nitron microcontroller lies at the heart of the design, controlling the e-field sensors and sending

ASCII “touch” data out through the RS-232 transceiver.

Photo 2a—

The user overlay on the back of the board forced the requirement of having no circuitry on the back,

and it mandated that I use surface-mount components.

b—

The XY electrodes were designed right on the PCB as

rectangular strips of copper. Each electrode is isolated from the others because only one electrode is read at a time
and the others are grounded.

c—

With the overlay on the back of the board, you can see the XY points by shining

light through the board. There are 81 possible data points, or coordinates, on the board.

a)

b)

c)

background image
background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

59

CodeWarrior IDE for the 68HC08 with
Processor Expert using the C program-
ming language.

There are several benefits to using

this IDE. Because it supports C lan-
guage, learning the processor’s native
assembly language isn’t required. This
saved time and made developing the
Smart-E-Touch easier because I was
able to use various C modules from
previous projects. The built-in
Processor Expert program saved an
enormous amount of time given that
this point-and-click GUI automatical-
ly implemented all of the Nitron’s
peripheral drivers in C language! It
also provides boot-up code for the
chip, which lets you concentrate more
on your application than on manually
setting up the microcontroller.

LT1117CM-5 voltage regulator, further
reducing the Smart-E-Touch’s cost!

The PCB, which is a single-sided,

mixed-technology (surface-mount and
through-hole) circuit board, was devel-
oped using the ExpressPCB software
package. The board was designed so
that no components are located on the
back because the user interface overlay
must be attached to the back of the
board, which then sticks out through
the enclosure or machine panel open-
ing. The board routing is dense, given
the surface-mount components, but is
required because of size constraints.

FIRMWARE

Before covering the Smart-E-Touch’s

software design, I’ll describe how the
software was developed in the

Nitron’s internal power-on-reset circuit.
This eliminates the need for an external
reset circuit. The debug LED, which is
attached to a Nitron port bit, proved
extremely useful during debugging for
watching the scan interrupt occur.

Powering the system is straightfor-

ward. You must supply 12 VDC to the
power input connector, which is used
by the e-field sensors and also convert-
ed to 5 VDC by the LT1117CM-5 low-
dropout voltage regulator. The Nitron
and the MAX232 require the 5 VDC.
The e-field sensors also convert the
12 VDC input to 5 VDC internally,
and output it to one of their pins. I
accounted for this and added a few 0-

resistors to the board to provide for
access to this feature in the future.
This eliminates the need for the

Figure 2—

As you can see, the circuitry is straightforward. The Nitron has just enough I/O pins to hook to both e-field four-input selects, both e-field analog level pins, the

MAX232, and the infamous debug LED!

background image

60

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

The overall goal of the firmware is

to control the e-field sensors, scan
them at a timed interval, translate the
sensor data into XY coordinates, and
then send the ASCII XY coordinate
data out the serial port. As you can
see in Figure 3, after the Nitron boots
up and is initialized, the 100-ms peri-
odic interrupt timer is enabled, which
then gives the firmware a timed inter-
val, or heartbeat, to perform the
required operations. Inside this heart-
beat interrupt, the Nitron scans the
two XY matrix e-field sensors via its
A/D converter inside every heartbeat
interrupt and figures out the XY coor-
dinate of any touch sensed by an X or
Y electrode (see Listing 1).

A valid touch is defined by any

value below the analog-to-digital
MaxTouchLevel threshold, which is
110 for this setup. When an electrode
isn’t touched, the 8-bit analog-to-digi-
tal value sits at approximately 255, or
a high. When a PCB metal electrode is
directly touched, the value goes down
close to zero. This value is much
higher, around 100, when touching
through the user interface overlay.

When no electrode has been sensed

on either the X or Y matrix, the coordi-
nate is marked with an asterisk. This
tells the host connected to the Smart-
E-Touch serial port that no valid coor-
dinate has been sensed. After the scan-
ning is done, the Nitron converts the
coordinates to ASCII and sends them
out the serial port at 19.2 kbps (e.g.,
X3, Y4 or X*,Y7 or X*,Y*). Refer to
Photo 3 for a real data set sample taken
from HyperTerminal. This entire
process happens every 100 ms. The
Smart-E-Touch software framework
allows for plenty of future expansion
and features

.

SYSTEM TEST AND RESULTS

I compiled the code, downloaded it

to the board, and verified the e-field
sensor’s functionality. Valid X and Y
coordinates were successfully sensed
when I touched the PCB electrodes.
When X or Y electrodes weren’t
touched, the Smart-E-Touch correctly
interpreted these as “no touches,”
which were then assigned an asterisk.

The X and Y coordinates were suc-

cessfully sent out of the serial port to

Listing 1—

The Nitron C code selects an e-field electrode, reads the analog value of it, and then compares it

to the maximum touch threshold. This straightforward code comprises the bulk of the Nitron code, showing

just how easy it is to interface to an e-field sensor.

//Check each E-field sensor electrode, 18 total electrodes

**********************************************************************

PTB = ELECTRODE_1;

//Select e-field electrode

Delay1mS();

//Wait 1 ms after selecting new electrode

ReadAdcValue (&Xsensor, &Ysensor); //Read electrode analog value

ElectrodeX1 = Xsensor;

//Save A to D value of electrode X-1

ElectrodeY1 = Ysensor;

//Save A to D value of electrode X-1

.

.

//Duplicate code for electrodes 2

.

//through 8

PTB = ELECTRODE_9;

Delay1mS();

//Wait 1 ms after selecting new electrode

ReadAdcValue (&Xsensor, &Ysensor); //Read electrode analog value

ElectrodeX9 = Xsensor;

//Save A to D value of electrode Y-9

ElectrodeY9 = Ysensor;

//Save A to D value of electrode Y-9

**********************************************************************

//Find the X position

**********************************************************************

if (ElectrodeX1 < MaxTouchLevel)

//Electrode X-1 AtoD value <

//touch max value?

{

Xcoordinate = ‘1’;

//Yes, X-coordinate 1 has sensed a touch

}

else

//No, look at next X-coordinate electrode

if (ElectrodeX2 < MaxTouchLevel)

//Electrode X-1 AtoD value <

//touch setpoint?

{

Xcoordinate = ‘2’;

//Yes, X-coordinate 2 has sensed a touch

}

.

//Duplicate code for Electrodes 3

.

//through 8

.

else

//No, look at next X-coordinate electrode

if (ElectrodeX9 < MaxTouchLevel)

//Electrode X-9 AtoD value <

//touch setpoint?

{

Xcoordinate = ‘9’;

//Yes, X-coordinate 9 has sensed a touch

}

else

//No valid touch has been sensed

{

Xcoordinate = ‘*’;

//X-coordinate set to none

}

**********************************************************************

// Find the Y position

**********************************************************************

if (ElectrodeY1 < MaxTouchLevel)

//Electrode Y-1 AtoD value

//touch max value?

{

Ycoordinate = ‘1’;

//Yes, Y-coordinate 1 has sensed a touch

}

else

//No, look at next Y-coordinate electrode

if (ElectrodeY2 < MaxTouchLevel)

//Electrode Y-1 AtoD value <

//touch setpoint?

{

Ycoordinate = ‘2’;

//Yes, Y-coordinate 2 has sensed a touch

}

.

//Duplicate code for Electrodes 3

.

//through 8

.

else

//No, look at next Y-coordinate electrode

if (ElectrodeY9 < MaxTouchLevel)

//Electrode Y-9 AtoD value <

//touch setpoint?

{

Ycoordinate = ‘9’;

//Yes, Y-coordinate 9 has sensed a touch

}

else

// No valid touch has been sensed

{

Ycoordinate = ‘*’;

//Y-coordinate set to none

}

**********************************************************************

//Output X,Y coordinates to host via 19.2-kbps RS-232 port connection.

//9 × 9 electrode matrix gives a total of 81 possible points.

**********************************************************************

DebugPortTxData(‘X’);

//Send an “X” out the serial port

DebugPortTxData(Xcoordinate);

//Send the X-coordinate

DebugPortTxData(‘,’);

//Send a “,”

DebugPortTxData(‘Y’);

//Send a “Y”

DebugPortTxData(Ycoordinate);

//Send the Y-coordinate

}

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

61

as the user interface. This would
allow the Smart-E-Touch to be used as
a real system user interface.

Another option is to refine the e-

field sensor’s scanning algorithm to
achieve better sensitivity. You also
might need to modify the e-field’s
minimum and maximum reference
capacitors to get better sensitivity.

Adding a wireless transmitter to the

Smart-E-Touch would remove the need
for a serial port. You’ll find this valuable
if you design a remote user interface.

You also could provide more detailed

data out of the serial port. The new
data can be the actual analog-to-digital
reading and the values of the e-field ref-
erence capacitors, which are the mini-
mum and maximum e-field values.

Finally, consider writing a Visual

Basic application (or something equiv-
alent) that you can use instead of a
terminal emulator. This would make
the user interface more flexible. The
program would actually do something
on the screen when a Smart-E-Touch
button is pressed.

SMART ALTERNATIVE

The Smart-E-Touch is an intelligent,

touchscreen-based UI design that’s a
great alternative to current UI options
currently on the market. In addition

HyperTerminal at 19.2 kbps (see
Photo 3). When you look at the data
set, start at the top of the Hyper-
Terminal screen shot. Note that the
first XY coordinate is X1,Y1. This
coordinate is followed by others, from
X2,Y2 all the way down to X9,Y9. I got
this pattern by placing my finger on the
bottom corner of the XY matrix and
then slowly moving it diagonally up to
the top corner of the screen. This is
why both coordinates increment
together. It proves just how well the
Smart-E-Touch tracks a moving finger!

You’ll also notice the asterisk

mixed in with the Y coordinates. This
happened when my finger crossed
over to the next Y electrode; there
was a point where no electrode was
being touched. When this occurs, it’s
detected as a “no touch,” which is
exactly how the system should work.
This proves that the sampling rate for
the system is sampling more than
enough data points. The Smart-E-
Touch concept is now a proven success!

SYSTEM ENHANCEMENTS

The Smart-E-Touch has a lot of

potential. You could change the cir-
cuit board form factor to fit nicely
inside an off-the-shelf enclosure simi-
lar to Photo 1 with a durable overlay

PROJECT FILES

To download the code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

Editor’s note: Bruce’s Smart-E-Touch
project won Grand Prize in the 2003
Motorola E-Field Sensor Contest and
First Prize in the Motorola Flash
Innovation 2003 Design Contest.

Bruce M. Pride holds an A.S. and B.S.
in electronics and currently works as
a Senior Electrical Engineer. He enjoys
all aspects of embedded system hard-
ware and software design, particular-
ly designs with 32-bit microproces-
sors, FPGAs, and various microcon-
trollers. In his spare time, he enjoys
spending time with his family, playing
acoustic guitar, competing in

Circuit

Cellar design contests, and consulting
via his side business, Pride Embedded
LLC. You may reach him at
BrucePride@PridEEmbedded.com.

Start

Reset and initialization

Enable the 100-ms touch

scan interrupt timer

100-ms touch

scan timer

interrupt?

Scan X e-field sensor,

scan Y e-field sensor

Translate data into XY

coordinates if less than

threshold voltage set point,

or else coordinate equal “*”.

Convert XY coordinates to

ASCII data

Send data out serial port

at 19.2 kbps

N

Y

Figure 3—

As you study the system’s firmware flow dia-

gram, keep in mind that the code doesn’t execute until
a timer interrupt or heartbeat has occurred.

SOURCES

PCB Design tool
ExpressPCB
www.expresspcb.com

LT1117CM-5 Regulator
Linear Technology
(408) 432-1900
www.linear-tech.com

MC33794 E-field sensor,
68HC908QY4 Nitron microcontroller
Motorola, Inc.
(847) 576-5000
www.motorola.com

Cyclone programmer
P&E Microcomputer Systems, Inc.
(617) 353-9206
www.pemicro.com

Photo 3—

Take a look at the HyperTerminal snapshot

showing the XY coordinate data from the serial port. If
you notice the incrementing coordinates, you’ll realize
that the data is a result of dragging a finger diagonally
across one side of the board to the other.

to its reliability, the Smart-E-Touch is
inexpensive to build and easy to use.

Given the design’s adaptability, you

can use it in applications to replace
mechanical switches, touchscreens,
membrane keypads, and entire switch
panels. To my knowledge, there aren’t
any touchscreen designs currently on
the market similar to the Smart-E-
Touch. This truly proves that the
Nitron-controlled, e-field sensor-enabled
Smart-E-Touch is a unique design.

I

background image

For a 128 × 240 screen with a font size
of 6, the RAM needed is 40 columns by
16 rows, or 640 bytes. The third region
is the user-defined character font. Each
user-defined character requires 8 bytes.
A maximum of 128 characters can be
defined for a total of 1024 bytes.
Unless you use custom-defined char-
acters, this buffer space is not needed,
of course. The sum of the three afore-
mentioned values is 6784 bytes,
which is less than the 8 KB mounted
on the LCD panels.

Initializing the T6963 controller

requires you to first define the starting
RAM locations for each bitmap area
being used. Thus, if you are using
both text and graphics, you must
define starting addresses in RAM for
each of those areas. Further initializa-
tion chores consist of setting up a
graphics-size parameter as well as the
number of text columns on the screen.

Although I mentioned that the text

and graphics bitmaps are independent,
there can be some interaction between
them, if desired. You do this by select-
ing various values with the mode set
command. The different modes are
shown in Table 1.

If you use either the XOR or the

AND modes, then pixels placed on
the screen by text fonts will interact

62

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

I

recently spent a considerable amount

of time becoming familiar with Zilog’s
new Z8 Encore! family. I was impressed
with several unique features of the
chip’s hardware, and the development
kit that I received worked right out of
the box, with an extremely short learn-
ing curve. I decided to port some of the
BASCOM/assembly language peripheral
driver routines, which I routinely use
with Atmel’s AVR family, over to Z8
Encore! C libraries. I often use graphic
LCDs in my projects, so these drivers
seemed like a good place to start.

With the proliferation of Palm Pilots

and fancy cell phones, there is certainly
no shortage of small graphic LCD pan-
els available, many of them in color.
Although quite nice, they tend to be
somewhat small and require tiny inter-
face connectors. The panels themselves
are often sub-VGA resolution, requiring
a relatively complex controller ASIC to
drive them and involving strict timing
issues that must be carefully addressed.

In the past, considering the above com-

plications, I’ve settled on LCD panels that
incorporate at least a low-level controller.
I normally choose those incorporating the
common Toshiba T6963 controller,
because it has a good architecture and is
found in reasonably priced LCD panels
having screen resolutions up to 128 × 240.

In this article I’ll briefly describe the

capabilities of LCD panels containing this
controller. I’ll also show you a text/graph-
ics library, which I wrote in C language,
that gives Z8 Encore! programs access to
the full functionality of the graphic LCD
panels. Photo 1 shows my prototype con-
troller along with its LCD panel.

T6963 LCD PANEL

The T6963 LCD controller’s most

Graphics LCD Library for the Z8 Encore!

Brian has created a graphics library you can use for your future projects. It provides access
for Encore! programs to graphics LCD panels driven by the T6963 LCD driver chip.

important feature, in my opinion, is that
it implements text and bitmap graphics
functions concurrently and independent-
ly. Text mode contains a complete ready-
to-use, ROM-based character set. (You
don’t have to download your own bitmap
images for each of the ASCII characters.)
Text characters placed on the screen
reside on their own bit plane. This means
they can coexist on the screen with any
graphics images, without any interference
between them). To put it another way,
you perform separate “text clear screen”
and “graphics clear screen” operations to
selectively erase text and graphics content
independently. This greatly simplifies
operations such as plotting dynamic
graphs with fixed, labeled axes.

The T6963 controller can handle up

to 64 KB of static RAM, but the LCD
panels that I’ve used have only 8 KB
mounted, which is sufficient for a
screen resolution up to 128 × 240. You
must partition this RAM memory space
as needed into three distinct regions.

The first region is the graphics bit

plane. When using the 6 × 8 font size,
the maximum RAM space needed to
handle a 128 × 240 screen is:

The second region is the text bit plane.

128

240

= 5,120 bytes

×

6

FEATURE ARTICLE

by Brian Millier

1

0

0

0

CG

MD2

MD1

MD0

Mode description

1

0

0

0

X

0

0

0

OR text and graphics pixels

1

0

0

0

X

0

0

1

XOR text and graphics pixels

1

0

0

0

X

0

1

1

AND text and graphics pixels

1

0

0

0

X

1

0

0

Text Attribute mode

1

0

0

0

0

X

X

X

Internal ROM character generator

1

0

0

0

1

X

X

X

RAM character generator

Table 1—

The way in which the text and graphics bit planes interact is defined by three bits in the Mode Set com-

mand: MD0–MD2. As well, the choice of the internal character generator ROM, or a RAM-based character genera-
tor, is determined by the CG bit.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

63

cellaneous characters consisting of
vowels with various accents and a few
currency symbols.

Although it’s possible to replace the

entire ROM-based font with user-
defined characters, it makes sense for
most users to use the ROM-based font
for the standard ASCII characters and
to define only the extra characters
needed. These get mapped to charac-
ters represented by byte values of
0x80 and higher.

Each custom character is represent-

ed by 8 bytes, 1 byte per row of pixels
in the font, starting at the top. The
most significant bit of the byte repre-
sents the leftmost pixel. My utility
application also contains a routine to
assist in generating the 8 bytes needed
to represent any given bit pattern. It
allows you to download this pattern
into the T6963 CGRam for testing.

To define a custom character from a

Z8 Encore! user program and load it
into the T6963 CGRam area, call the
LoadCGRam library routine. This pass-
es it the byte value that will subse-
quently represent that character (these
user-defined characters start at 0x80),
followed by a pointer to a character
string containing the 8 bytes needed to
represent the desired pattern. To display
a custom character on the LCD panel,
simply place the byte plus 32 into any
string that you send to the display.

Why “plus 32”? It turns out that the

T6963 defines all of its ROM-based
characters as their normal ASCII value
minus 32. Basically, this removes the
32 ASCII control characters normally
residing in characters 0 through 31.
This allows room for those 32 miscel-
laneous characters to reside in charac-
ter positions 96 through 127. As a
result of this anomaly, the

PrintChar

routine in the library must subtract 32
from the ASCII values passed to it,
before displaying them, if you are to

with graphics pixels located in the
same position. For example, if you use
AND mode, only those pixels lit by
both a text operation and a graphics
operation will show up on the screen. I
wanted completely independent text and
graphics, so I used the OR mode in my
initialization routine. I won’t describe
Text Attribute mode because it pre-
cludes the use of the graphics functions
and instead uses the graphics bit plane to
set text attributes on a character-by-
character basis. The next operation in
initializing the controller is to issue a
Display Mode command with the
desired parameters, as shown in Table 2.

Finally, you can set up the shape of

the text cursor, if you want to use it,
by issuing the Cursor Pattern Select
command. This command is made up
of an upper nibble (1010) and the
lower nibble containing a value denot-
ing the number of lines needed in the
cursor pattern (from one to eight).

All of the required T6963 initializa-

tion is performed by the

InitScreen

library routine. It’s well commented,
and you can make changes to the
display configuration by changing
the parameters.

In general, all commands sent to the

T6963 follow the following format:
LSB of parameter, MSB of parameter,
and the actual command itself. The
first 2 bytes must be sent to the
T6963’s data register and the last to its
command register. The only difference
between these two operations is in the
level set on the T6963’s C/*D line.

All such operations are performed by

the C library routines

T6963dat and

T6963cmd respectively. A third rou-
tine,

T6963WaitReady, which is called

by both of the aforementioned routines,
is needed to monitor the busy status of
the T6863 (i.e., waiting until it’s ready
before sending data/commands). An
additional routine,

T6963adt, also sends

data to the T6963’s data register; it han-
dles the special case in which large
blocks of data must be sent sequentially,
without intervening commands.

Only these four routines and the

init_port routine contain references
to the actual port pins used on the Z8
Encore!. If you were to use different
ports, or even a different microcontroller,
these routines would be the only ones

associated with the T6963 that you’d
need to modify to match your hardware.
The PWM routine that generates the
drive signal for the V

EE

generator would

need to be modified too, but that’s not
strictly a T6963-related routine.

TEXT FUNCTIONS

The library’s text functions are fairly

basic.

ClrText() clears all text from

the LCD screen (without disturbing any
graphics) and locates the character point-
er position to row one, column one.

Locate (Row,column) places the text

position pointer to the row and column
passed. These parameters are “1” based
(i.e., the “home” position is row one, col-
umn one).

PrintChar(char) places the

character passed to it on the screen at
the current text pointer position.
WriteStr(*str) writes an ASCIIZ
string on the display, starting at the cur-
rent text pointer position. The pointer
to that string is passed to this routine.

TEXT FONT CHARACTERS

Like many LCD panel controllers,

the T6963 allows you to define your
own character font to supplement its
128-character, ROM-based font. The
ROM-based font contains the standard
ASCII 96 characters as well as 32 mis-

Photo 1—

I built my unit on a vector board. There’s

plenty of free space for circuitry beyond what’s needed
for the LCD controller itself. I left Zilog’s smart cable
hooked up so you can see how the Z8 Encore! is pro-
grammed/debugged.

Bit 7

Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

Bit 0

Description

1

0

0

1

0

0

0

0

Display off

1

0

0

1

X

X

1

0

Cursor on, no blink

1

0

0

1

X

X

1

1

Cursor on, blink on

1

0

0

1

0

1

X

X

Text on, graphics off

1

0

0

1

1

0

X

X

Text off, graphics on

1

0

0

1

1

1

X

X

Text on, graphics on

Table 2—

Text, graphics, or both bit planes can be enabled by setting the proper bits in the Display Mode com-

mand. Also, the cursor can be turned on and off, and the blink attribute set here as well.

background image

64

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

the display without disturbing the text
that’s being displayed.

Pset(X,Y,color)

places a dark pixel on the screen at x, y
if the color parameter is one; otherwise,
it erases that pixel.

DrawLine(X

0

,Y

0

,X

1

,

Y

1

,color)draws the line (X

0

,Y

0

) – (X

1

,Y

1

)

if color is one; otherwise, it erases the
pixels between the two coordinates.
DrawRectangle(X

0

,Y

0

,X

1

,Y

1

,color)

draws a rectangle with opposing corners
at (X

0

,Y

0

,X

1

,Y

1

) if the color parameter is

one; otherwise, it erases such a rectan-
gle.

DrawCircle(X

C

,Y

C

,rad)draws a

circle centered at (X

C

, Y

C

) with a

radius of

rad.

There are more specialized graphics

routines. I’ll describe them in the fol-
lowing sections.

BITMAP IMAGES

Working with instrumentation in the

Chemistry Department at Dalhousie
University, I primarily need for a
graphics display to show plots of data
being collected. However, I know that
many people need to be able to display
pictures in the form of bitmap images,
so I’ve written routines to handle this.

see what’s expected. However, in the
case of the user-defined characters,
you must add 32 to the character you
pass the

PrintChar routine in order to

end up displaying the character with
the code you’ve already predefined with
a given character value.

I think Toshiba screwed up by organ-

izing things this way. It would have
made more sense to place the miscella-
neous accented vowels and currency
symbols in ASCII codes 0 through 31
and leave the normal ASCII 96 charac-
ters alone with their standard values.

BASIC GRAPHICS FUNCTIONS

The basic graphics functions include

the point, line, and circle drawing rou-
tines as well as a screen clear func-
tion. My earlier AVR assembly lan-
guage T6963 graphics routines used
my own custom line-drawing algo-
rithm, but it seemed more sensible
here to use Bresenham’s line and circle
algorithms, which are readily available
as C routines.

There are four basic functions.

ClrGraph() clears all graphics from

The first thing to consider is where

to store the bitmap images. Zilog’s
Z8F6401 contains 64 KB of flash memo-
ry, much more than the microcontrollers
I’ve used in the past. The assembly lan-
guage graphics library, which I had writ-
ten for the ’8515 AVR device, takes up
less than half of the 8-KB flash memo-
ry in that device. However, this graph-
ics library, written in C for the Z8
Encore!, is approximately 28 KB long.
Allowing additional space for a reason-
ably sophisticated program meant plac-
ing the bitmap images somewhere else.

The obvious choice is to use some

form of serial flash memory, because
it can be connected to the Z8 Encore!
using only a few lines. This is impor-
tant, given that the T6963 display
interface already consumes 12 I/O
lines. Earlier, I had used Atmel 32-KB
SPI flash memory devices for this pur-
pose, but this time around I went with
Microchip’s 24LC256 I

2

C flash memo-

ry device (also 32K × 8). Although
accessing this I

2

C memory device is

slower than a comparable SPI memory
chip, there are advantages. It requires
only two I/O lines, and you can easily
connect other I

2

C peripherals with the

same lines. Additionally, the Z8
Encore! C compiler library contains
I

2

C routines, and the 24LC256 is inex-

pensive and readily available.

To compensate for the limited space

available in the 24LC256 I

2

C flash

memory device, as well as its less-
than-stellar access speed, I decided to
use data compression prior to storing
the bitmap images. Because the dis-
play is only monochrome, it’s possible
to achieve a high data compression
ratio (from two to 10 times) of the
image using only a simple run-length
encoding scheme. You can easily store
30 full-screen images (on a 128 × 240
display) in the 24LC256, and these
images are painted on the screen in a
fraction of a second.

The images are stored in the I

2

C

flash memory by way of a simple file
organization scheme. A number refer-
ences each image, and there is a small
directory maintained in the I

2

C flash

memory that points to the starting
address of each image, as well as its
size. In addition, this directory con-
tains an eight-character name to iden-

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

65

rows starting from the bottom
and going toward the top of the
screen (i.e., they follow the
standard Cartesian coordinate
convention). The T6963 starts
at the top of the LCD panel
and works down.

Bitmap images generally

have a white background
with a black image. Zeros rep-

resent black areas. LCD panels are usu-
ally viewed with the background unlit
and the image itself lit. A lit pixel is
black (or blue, etc.) and, in terms of the
T6963 controller, is represented by a
one. Therefore, bitmap pixel data must
be inverted before being sent to the
T6963 controller.

Given the need for the aforemen-

tioned data manipulation, as well as
the decision to run-length encode the
data, I wrote a PC utility application
that performs the data conversion. It
then downloads the compressed
image data to the Z8 Encore! via an
RS-232 serial data link. A routine in
the Z8 Encore! graphics library
receives this serial datastream and

tify that particular I

2

C flash

memory chip. The bitmap
image file utility program uses
it to identify which memory
chip is currently being pro-
grammed with image data.

How do you generate these

bitmap images in the first
place? I decided that the easiest
method was to use standard PC
drawing programs that can output
Windows bitmap (.BMP) files. The
Windows bitmap format contains a sig-
nificant amount of information in its
header, most of which is unnecessary in
this context and can be ignored.
However, the parameters that are
important here are shown in Table 3.

There are a number of differences in

the way in which bitmap files are
organized in comparison to the way in
which the data must be presented to
the T6963 controller. Bitmap images are
stored as groups of 4 bytes (long inte-
gers) representing image pixels horizon-
tally from left to right. For images that
are not a multiple of 32 pixels horizon-
tally, this long integer is zero-padded to

allow for the smaller number of pixels
in the source image.

Depending on the font size selected

in the T6963 controller, you have to
break up the packets into either 8- or
6-bit groups before sending them to
the controller. You also have to pad
your own pixel data when the hori-
zontal pixel size of the image is not a
multiple of either eight or six pixels.

Because of the significant differences

in handling the bitmap image function
for the 6 × 8 font size mode versus the
8 × 8 font size, I chose to implement
only the bitmap function for the 6 × 8
font size. I decided this presented the
most useful display option.

Bitmap images store the pixels in

Offset

Size

Type

Description of the variable

1

2

Character

“BM” to indicate that the file is a bitmap

11

4

Long integers

Pointer to start of bitmap data

19

4

Long integers

Width of the image in pixels

23

4

Long integers

Height of the image in pixels

Table 3—

Although most of the header information contained in a Windows

bitmap file is not needed in order to convert it to a file format that the T6963 can
use, the locations of the few necessary parameters are shown in this table.

background image
background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

67

library that performs this function. In
operation, you first fill the ScopeCurrent
array with up to 240 data points. You
then call the ScopeDraw procedure with
the following parameters: horizontal off-
set (in pixels), vertical offset (in pixels),
horizontal size (number of data points),
vertical clipping size (in pixels), and
erase flag (set to one if you want to
erase the previously plotted data set).

This routine allows you to present a

dynamic data plot positioned any-
where on the screen with a defined ver-
tical and horizontal size. Although the
timing is dependent on the actual data
being plotted, the routine takes less
than 1 s to plot a full screen. The rou-
tine requires 480 bytes of RAM for a
full 240-pixel display, but it can be
reduced if a narrower display is all
that’s needed (by defining smaller
arrays for ScopeCurrent and ScopeLast).

This procedure is fairly straightfor-

ward. For each data point (n), the line-
draw routine is called using n,Y(n) and
n + 1,Y(n + 1) for the endpoints (plus
horizontal and vertical offsets speci-
fied). If necessary, the Y values are
clipped at the vertical clipping size
before plotting. If the erase flag is set
to one, on a sample-to-sample basis,
the line-draw routine is first called
with a color of zero to erase the old
line (using the data from the previous-
ly plotted screen and stored in the
ScopeLast array). Then, the line-draw
routine is called with a color of one to
plot the line segment corresponding to
the new sample. After each new line
segment is plotted, the current sam-
ple’s Y value is transferred, in prepara-
tion for the next plot, into the corre-
sponding index position in the
ScopeLast array. This provides a dis-
play that remains on the screen, with

the erasure of the old
data occurring only in
the small area of the
screen where the data is
actively being plotted. In
use, it is extremely
smooth, like that of an
oscilloscope display.

Some of my earlier

projects involving the
T6963-based LCD panel
used the AT90S8515
microcontroller, which

has only 512 bytes of RAM, much less
than the 4 KB present in the Z8F6401.
To achieve this function without eating
up virtually all of the ’8515’s RAM, I
used a more efficient raster-based algo-
rithm, which is coded in assembly lan-
guage, rather than the sequential line
erase/draw routines that I chose for
this library. However, given the
greater RAM resources and Z8 Encore!
execution speed, and wishing to use C,
the more straightforward algorithm
seemed appropriate.

WIRE IT UP

T6963-based LCD panels interface

to their host via an 8-bit, bidirectional
data bus using the Intel standard *RD,
*WR, and CS control signals. This is
generally implemented using a dual
10-pin connection, which allows the
use of standard ribbon-cable and IDC
header connectors.

Although the T6963 LCD controller

can control up to 64 KB of static RAM
for the text and graphics display
buffers, this memory is not randomly
accessible by the host, because the
interface does not include an address
bus per se. Instead, there is a single
C/*D line which steers the data from
the host into either a control register
or a data register. In terms of hard-
ware, the eight data lines and a few
control lines are all that the host
microcontroller has to actively han-
dle. There are a few additional config-
uration control lines that I generally
choose to handle with jumpers.

The T6963 controller chip’s bidirec-

tional data bus is meant for a micro-
processor featuring a full bus for exter-
nal memory, peripherals, and so on. In
earlier T6963-based LCD projects, I
used an AT90S8515 microcontroller,

stores it in the I

2

C flash

memory. Other routines
read/maintain the image
file directory, which is also
contained in the I

2

C flash

memory.

Although the text/graph-

ics routines reside in a
stand-alone library
(T6963.c), the sample pro-
gram that I’ve included
with this article contains
code in the main section,
which interfaces directly with the PC
utility program via the COMM port.
This allows you to initially download
bitmap images into the flash memory,
as well as a few other useful functions.
After the images are stored in the non-
volatile flash memory, the PC utility
program is no longer needed.

StoreBitmap() and DrawBitmap(

image#,Xoffset,Yoffset) are the
two library routines used for the
bitmap functions. The former is specif-
ically meant to work in conjunction
with the PC utility program I wrote.
It’s used to initially store compressed
bitmap images in the 24LC256 I

2

C

flash memory device. The routine is
called from the main section in the
sample program after receiving a 0xFE
command from the serial port (issued
by the PC utility program). The
DrawBitmap(image#,Xoffset,Yoff
set) routine draws a bitmap image
specified by an image number at the
specified screen offset. Don’t call this
with a nonexistent image number or
the results will be unpredictable!

Photo 2 is a screen shot of the utility

program. Note that the program can
also act as an exerciser to test the opera-
tion of the various library routines.

OSCILLOSCOPE DISPLAY

For my purposes, it’s essential to be

able to quickly plot a set of data
points on the screen. For data that
changes quickly, the ideal solution is
the left-to-right painting of data points
on the screen without an intervening
full-screen erasure. (CRT-based oscillo-
scopes do this.) Intelligent graphics
controller assemblies with serial data
links are available commercially, but I
have not seen any with this capability.

I included a routine in this graphics

Photo 2—

I wrote the PC utility program so you can download bitmap images to the flash

memory.

background image

68

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

which contains a full bus. I wasn’t able
to get the LCD panel to work properly
with the ’8515 using Bus mode, even
after calling for the insertion of wait
states. It appears that the T6963’s
access time is too slow to use with
most current microprocessor buses.

In my experience, it seems that the

best way to control the T6963 is with
a simple port access. You allocate one
of the microcontroller’s 8-bit ports for
the data lines and connect lines of a
second port up to the T6963’s control
lines. The latter lines are toggled up
and down in software to read and
write to the T6963 controller. This
works fine, although it takes a bit more
code to implement. Because the T6963
controller is a low-speed CMOS device,
the time it takes to perform the various
graphics commands is much greater
than the time spent doing either port or
bus access, so this is moot. Assuming
that the microcontroller port pins that
connect to the LCD panel’s *RD and
*WR lines are not shared by other
devices, the *CS line on the LCD panel
can be permanently tied low, thereby
saving one microcontroller I/O port pin.

The host program must be able to

interrogate the T6963 controller to
determine when it has finished per-
forming the last command it received.
Note that this is done by reading a
T6963 status register and examining
two individual busy bits (which
depend on the type of command opera-
tion being performed). It would have
been nicer if the interface had includ-
ed a dedicated ready line that could be
tied to a host IRQ line, freeing up the
host to perform other tasks while the
LCD panel was busy drawing. However,
the T6963 is not designed that way.
Status checking is handled by the
T6963WaitReady library function.

Unlike the AVR microcontroller

chip, which I’ve used with these LCD
panels, the Z8 Encore! runs off a 3.3-V
power source, whereas T6963-based
LCD panels require a 5-V source. I
anticipated some problems here given
the different logic levels involved.
Actually, things worked out well. The
Z8 Encore! has 5-V tolerant inputs on
its port pins, which means that the 5-V
logic signals that the T6963 outputs
on its data lines during a read opera-

tion can be handled directly by the Z8
Encore!. Checking out the T6963 con-
troller’s datasheet, I found that it
requires a minimum of 2.7 V for a
logic-high signal and a maximum of
0.8 V for a logic low, both of which are
provided by the Z8 Encore! ports.
Therefore, the two devices can be
interconnected without any glue logic.

The T6963 controller itself is capa-

ble of generating character fonts in
widths of five, six, seven, or eight pixels
via two font-select lines (FS0 and FS1).
However, many LCD panels, including
the one that I used, tie the FS0 line low,
and bring only the FS1 line out to the
20-pin I/O header. This limits the font
selection to six or eight pixels wide.

Deciding which font width to use is a

trade-off. Regardless of your choice, the
actual pattern used to generate the char-
acters is the same. The 8 × 8 font just
has more space between the characters,
which means it’s not any clearer or well
formed. Therefore, it seems logical to
use the 6 × 8 font exclusively because it
yields, for example, 40 columns of text
rather than 30 on a 128 × 240 display.

I should note that the choice of the

text font size also affects the operation
of the graphics part of the display.
Briefly, when selecting the 8 × 8 font
size, the organization of the graphics
bitmap divides the horizontal pixels into
byte-sized groups of eight. However, in
the case of the 6 × 8 font, the horizontal
pixels are grouped by six. In practice,
this means that if you use the 8 × 8 font
exclusively, the graphics routines
could be streamlined by taking advan-
tage of simple shift instructions rather
than multiply/divide instructions.

For versatility, my graphics library rou-

tines handle both font sizes. Thus, they
must use the multiply/divide instruc-
tions rather than streamlined routines
using the shift instructions. However,
you must choose one specific font size
for a given project. Given that, you then
set the font size jumper properly and also
set the variables

Fontsize, LcdRows,

and

LcdCols accordingly (in statements

found at the start of the Main procedure).
The bitmap image routine, however, is
implemented for the 6 × 8 font size only,
as I mentioned earlier.

All graphic LCD panels require a

negative voltage (V

EE

) in addition to

the 5-V logic power supply. Although
some models include this V

EE

supply on

the controller PCB itself, the more com-
mon ones, including the one I use, don’t.

The V

EE

supply must be approxi-

mately –7 (for a 64 × 240) to –16 V (for
a 128 × 240). Check your panel’s
datasheet for its exact requirements.

The current requirement for this

supply is extremely modest—only
about 2 mA. However, this voltage
must be stable and adjustable (using a
potentiometer and software) in order
to change the contrast of the display.
The voltage needed to provide opti-
mum contrast is temperature-depend-
ent. In an environment where the
LCD panel is exposed to wide temper-
ature variations, the controller must
adjust the V

EE

supply automatically in

response to temperature changes, or
the display will be hard, if not impos-
sible, to read. I didn’t make
allowances for automatic contrast
control over wide temperature swings.

I’ve handled the V

EE

power supply in

several different ways in past projects.
I started by using Maxim’s MAX749
digitally adjustable LCD bias supply
chip, which works well but is expen-
sive. I later designed my own clone of
this with a Tiny AVR microcontroller
(“Build a Graphics LCD Bias Supply,”
Circuit Cellar

, issue 144, 2002). For

this project, I retained the analog
charge-pump components of the afore-
mentioned circuit, but let the Z8
Encore! provide the PWM signal that
the Tiny AVR microcontroller had pro-
vided. This design is beneficial because
it allows for software control of con-
trast, requiring only a single Z8 Encore!
I/O pin (a PWM output). In contrast,
both the MAX749 and my Tiny AVR
design required two I/O lines from the
host micrcontroller to control contrast.

In operation, the Z8 Encore! generates

an active-low PWM signal with a period
of 100 µs and a pulse width that varies
from about 35% to 55% depending on
the 8-bit contrast parameter. This active-
low signal drives a 2N3906 PNP transis-
tor with its emitter connected to V

CC

and forces current to flow through a 100-
µH inductor to ground. During the time
that this transistor is shut off, the mag-
netic field in the inductor collapses and
generates a negative potential across C8

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

69

(which must be a tantalum capacitor).
An 18-V Zener diode connected across
this supply limits the maximum voltage
developed to a safe value. A 50-k

trim-

ming potentiometer and an PNP emit-
ter-follower provide for the coarse con-
trast control. The software adjustment
of the PWM duty-cycle provides fine
contrast adjustment.

Depending on your LCD panel’s V

EE

voltage and current requirements, you
might have to adjust the PWM’s peri-
od and width range by changing some
constants in the firmware itself. My
code is optimized for the AZ Displays
AGM2412B 128 × 240 panel, which
requires about –14 V. The software
adjustment of contrast is performed by
the

VeeGen(period,width) proce-

dure in the library.

I used the AGM2412B-NC-BTD

LCD panel for this project. It’s a 128 ×
240 panel with a CCFL backlight. For
any panel with a CCFL backlight, you
need a high-voltage supply. I’ve seen
surplus modules advertised for approx-
imately $5, but I used a standard Digi-
Key JKL BXA-501/KIT module, which
takes a 5-V input and produces approx-
imately 600 V to fire the cold cathode
fluorescent tube used as the backlight.
The module is extremely efficient,
requiring only a few hundred milliamps
of current at 5 V to light the tube.

Figure 1 shows both the CCFL back-

light power supply and R7 connected up
to pin 9 of JP1 plus a ground on pin 20.
R7 is a current-limit resistor for pow-
ering an LED backlight like those
found on some displays. You need only
one of these two circuits, depending
on the backlight used in your display.

I used a Microchip 24LC256 I

2

C

flash memory device (U3) to take
advantage of the Z8 Encore!’s built-in
I

2

C port. This stores bitmap images.

Downloading required bitmap images

from the PC, which is where they are
generated, is done via an RS-232 serial
data link operating at 19,200 bps. The
level-shifting between the Z8 Encore!’s
3.3-V and RS-232 levels is done by U2,
which is a Maxim MAX232. Although
Maxim makes level-shifters specifical-
ly designed for 3.3-V logic microcon-
trollers, I had only MAX232 devices
on hand. They interfaced well with
the Z8 Encore! without causing any

problems, but I had to power them
from the 5-V logic supply. Because I
used both 3.3- and 5-V devices in this
project, I had to use two regulators—a
7805 and an LM1086-3.3—to provide
regulated power.

I built my circuit on a vector board

(see Figure 1). As you can see in Photo 1,
there’s plenty of space left for other
circuitry. Just before I finished writing
this article, I found an inexpensive Z8
Encore! trainer board from Futurlec,
which includes all of the components

in my circuit except the few passive
components that make up the LCD
V

EE

generator. If you want to try out a

graphics display on a Z8 Encore!, take
a look at this option.

UTILITY PROGRAM

To use bitmap images with this proj-

ect, you must generate them on a PC
in Windows bitmap format and then
use the T6963Z8 utility application
that I wrote. This program allows you
to choose a PC bitmap image, which

background image

70

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

Brian Millier is an instrumentation
engineer in the Chemistry Department
at Dalhousie University in Halifax,

PROJECT FILES

To download the code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

SOURCES

AGM2412B-NC-BTD LCD panel
AZ Displays, Inc.
www.azdisplays.com

JKL BXA-501/KIT Module
Digi-Key Corp.
www.digikey.com

Z8F6401 Microcontroller
Zilog, Inc.
www.zilog.com

24LC256 Flash EEPROM
Microchip Technology, Inc
www.microchip.com

Z8 Encore! trainer board
Futurlec, Inc.
www.futurlec.com

T6963 LCD Controller
Toshiba
www.semicon.toshiba.co.jp

must be black and white and small
enough to fit the display, and down-
load it to the 24LC256 I

2

C flash mem-

ory device.

When using a brand-new 24LC256 I

2

C

flash memory device, you first must use
the initialize flash memory function.
This puts a known signature pattern in
the flash memory and stores a user-
selected, eight-character name. It also
zeroes out the entire flash memory chip,
which takes approximately 5 min. If you
attempt to initialize a flash memory
device that already has image data
stored in it, the program will notify you
and give the flash ID name. Then, you
will have the option to abort or proceed,
thereby erasing the existing image data
stored in the flash memory device.

After this, you can select bitmap

images that you’ve prepared, and then
download them to the flash memory.
After each image is downloaded, a
window indicates the number of the
next free image. The utility program
generates a map file, which has the
same name as the one you gave the
flash memory chip during the initial-
ization procedure, and a .MAP exten-
sion. This text file contains the PC’s

bitmap file name and image number
associated with each image stored in
flash memory.

The utility program also contains a

matrix where you can draw custom-
defined characters for downloading to
the T6963’s CGRam. This is only
temporary, of course, because they
will disappear when the LCD panel’s
power is removed. However, the utili-
ty program also displays the list of 8
bytes needed to produce that custom
character, and those values can be
hard-coded into your program for per-
manent access to that character.

A NEW OPTION

Although I still intend to use the

Atmel AVR chips for most of my proj-
ects, I do like many aspects of the Z8
Encore! family. Now that I can con-
nect it up to a graphics LCD panel, I’ll
probably find a place for it in some
future projects. I hope that you can
make use of the graphics library in
your own projects.

I

Figure 1—

This is the complete schematic of my LCD panel controller. The RS-232 link is needed only for initially downloading bitmap images, if used.

Canada. He also runs Computer
Interface Consultants. You may reach
him at brian.millier@dal.ca.

background image
background image
background image
background image

74

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

O

ne of my more memorable excur-

sions back in my college days was to
Herkimer, New York. My buddies and I
had been traveling for a number of hours
and needed to stretch. Pulling off the
road next to an abandoned railroad tres-
tle, one of the guys got excited when he
saw the rock layers exposed in the exca-
vated underpass. We spent hours looking
through the sedimentary layers for fos-
sils until we were asked to leave by the
landowner. I still treasure a trilobite—a
worthless ugly hunk of rock from the
Paleozoic era (543–248 mya)some-
where amongst my cache of things.

Herkimer is known for its diamonds,

not fossils. Yep, you can still prospect for
Herkimer diamonds. Seeing dollar signs?
Well, hold on, a Herkimer diamond is
actually quartz. If you choose your claim
wisely, you can still find some sizable
hunks of quartz crystals buried in the
ground (see Photo 1). As you can see,
these are considerably more attractive
than what you would see if you popped
the can off of a microprocessor’s crystal.
But, where would we be today if it was-
n’t for the crystal? Don’t look now, but
soon the crystal might be just a
thing of the past.

Linear Technology has

released a programmable oscil-
lator that covers a frequency
range of 1 kHz to 68 MHz using
no external components. It is
available with either an SPI
(LTC6903) or an I

2

C (LTC6904)

interface, and needs only a sin-
gle supply from 3 to 5.5 V. The
clock output is available as nor-
mal and/or inverted output, and
it can be externally controlled
using the output enable (OE)

for the feedback loop to stabilize. (You
can prevent frequency overshoot when
changing frequencies by always chang-
ing the DAC values first.)

SERIAL DATA CONNECTION

The device powers up using a default

of OCT=0 and DAC=0 (1.039 kHz). To
change values in the device, write a
16-bit data word to its serial interface.
The LTC6903 uses SPI, and the LTC6904
uses I

2

C. Both devices are write-only

because neither have the circuitry for
returning data. The SPI device requires
only the data word to be transmitted
(maximum 20-MHz clock). The I

2

C

device, which requires an addi-
tional address byte (maximum
100-kHz clock), would be slow-
er even if the clocks were equal.
But, in this case, you can see
that the SPI device is orders of
magnitude faster to begin with.

The data word comprises

the 4-bit OCT value, the
10-bit DAC value, and the
2-bit CFG value. The config-
uration value determines the

state of an output enabled by
the OE input pin. Table 2
defines the choices. Figure 2

Lose the Crystal

FROM THE BENCH by Jeff

Bachiochi

control input. Output selection also can
be controlled via the 2 least significant
bits of the 16-bit serial data word,
where the upper 14 bits are for fre-
quency selection.

Refer to the LTC6903/4 innards in

Figure 1, and you can see a master VCO
(34 to 68 MHz), which receives its drive
from a 10-bit DAC. The DAC is part of
the closed-loop feedback to keep the
VCO stable. The VCO and DAC are
designed to run over a single octave fre-
quency range, 1–2x (frequency mini-
mum, x, to frequency maximum, 2x).
This gives a fine frequency control of
better than 0.1% between the minimum
and maximum frequency (approximately
34 kHz steps between 34 and 68 MHz).
The VCO output goes through a pro-
grammable divider. The 4-bit octave
(OCT) data controls the divider. This is
the coarse frequency control; it doesn’t
affect the VCO frequency.

Table 1 shows ranges selected using

the 4-bit OCT data. Changes in the
OCT data provide instantaneous CLK
output changes, whereas changes in
the DAC data may take up to 100 µs

There are many different silicon oscillators out there, but Jeff thinks the LTC6903 is a stand-
out. Read on to learn how he used it with a microcontroller to control a four-digit LED.

Linear’s LTC6903/4 Programmable Oscillator

Photo 1—

This exotic Herkimer diamond shows off its

crystalline structure thanks to Mother Nature.

8

+

Master

oscillator

f

M0

= 68 MHz × k

I

SET

V

+

– V

SET

I

SET

+

A1

V

SET

Serial port

1

2

3

4

GND

SDI

SCK

*SEN (LTC6903)
ADR (LTC6904)

DAC

V

+

7

OE

CLK

*CLK

Programmable

divider

6

5

OCT

6903 BD

Figure 1—

This eight-pin device has circuitry to create a master VCO. The output

can be divided for a wide range of user-controlled frequencies via an SPI
(LTC6903) or I

2

C (LTC6904) interface.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

75

a good alternative where reduced accura-
cy can be tolerated. Besides its small
size, the digital programmable oscillator
(DPO) has other advantages when used
as an input clock for a processor or
microcontroller. At power-up, it defaults
to its lowest frequency 1.039 kHz. This
allows a processor to begin executing
code. The processor can reprogram the
DPO on the fly, thus speeding up its
execution for normal operation. When
the circuit needs to save energy, it can
throttle back to a comfortable speed
to reduce the required circuit current.
It can even turn off the oscillator com-
pletely, although this is a death sentence
until power is recycled.

Frequency error is approximately

0.5%, while maximum error over the
entire output range at 5 V is approxi-
mately

±

2.25%. The VCO used in the

actual frequency generation has some
jitter associated with it, which can con-
tribute approximately 0.5% (at mini-
mum undivided frequency, 34 MHz) to
3% (at maximum undivided frequency,
64 MHz). Other lower ranges reduce jit-
ter because of averaging inherent
in dividing the frequency.

PROJECT TIME

I’m always looking for ways

to create test equipment. The
LTC6903 seemed like it has great
potential: it is no problem to get
a microcontroller to set any
desired output frequency using
this device. However, without a
user interface inputting the

appropriate value for the desired
frequency, it is next to impossible.
Oh sure, you can watch the output
with a oscilloscope and have
Up/Down buttons increment
through the 2

14

codes, if you can

wait all day. So, to make the circuit
portable, a user-friendly interface is
important. And, because the device
doesn’t have infinite resolution,
you also need feedback on what fre-
quency is actually obtainable.

This project uses a microprocessor

to control a four-digit LED using
three push buttons to set a frequency
value. The value is converted to the
closest OCT (4-bit coarse) and DAC
(10-bit fine) control values. The
LTC6903 is updated with these, and

the LED is updated with the frequency
produced using the OCT and DAC val-
ues. This value can be different from
the input values. Figure 3 shows the cir-
cuit I used to support the LED, push
buttons, and LTC6903 DPO.

WHO’S GOT THE BUTTON?

I wanted to give you an easy way to

change frequency values without sim-
ply incrementing or decrementing the
14-bit DPO value with two push but-
tons. I added a third button as a mode
control. I created seven modes:
change digit1, digit2, digit3, digit4,
decimal point, multiplier, and
LTC6903 (Run mode). You can tell
which mode you are in via a flashing
display. Depending on the mode, the
Up and Down buttons will increment
and decrement a digit, move the deci-
mal point (around to one of the four
digits), or change the multiplier (alter-
nate between megahertz and kilo-
hertz, one of the two colon dots).

In LTC6903 mode, the display val-

ues are read and a frequency value is

defines the bit placement of the
OCT, DAC, and CFG values.

SPI communication begins when

the device is enabled (*SEN). The
LTC6903 is then ready for the most
significant bit of the 16-bit data
word. Data bits are clocked into
the device on the rising edge of the
clock line. After the first 8 bits of
data are received, they are trans-
ferred into an internal register. The
second 8 bits received are trans-
ferred internally as well after com-
pletion. You can choose to end the
transmission by raising *SEN after
only 8 bits if the lower 8 bits of
the DAC and the 2 bits of configu-
ration do not change.

I

2

C communication does not

require a chip enable (*SEN). The
LTC6904 defines this pin as an address
selection input. Thus, you can have two
I

2

C devices connected to the I

2

C bus and

control them independently. An I

2

C

transmission begins with a start bit.
(It’s defined as a lowering of the data
line, SDA, while the clock line, SCL, is
in a high state.) Data is considered good
during the high period of the clock line.
A transmission consists of 3 data bytes,
the device address, the most significant
data byte, and the least significant data
byte. After each of the 8 bits, the
device responds with an acknowledge
bit (ninth bit time) as an assurance that
the data was received. Failure to
acknowledge aborts the transmission.
As with the SPI device, the I

2

C com-

munication may end after the most sig-
nificant data byte has been sent if the
lower 8-bits of the DAC and the 2 bits
of configuration do not change.

REPLACING CRYSTAL

We all have been content with using

crystals for a long time. Although
they’ve been reduced in size, they still
are susceptible to shock. Resonators are

Minimum frequency (

≥≥

) Maximum frequency (

<<

)

Octave

34.05 MHz

68.03 MHz

15

17.02 MHz

34.01 MHz

14

8.511 MHz

17.01 MHz

13

4.256 MHz

8.503 MHz

12

2.128 MHz

4.252 MHz

11

1.064 MHz

2.126 MHz

10

532 kHz

1063 kHz

9

266 kHz

531.4 kHz

8

133 kHz

265.7 kHz

7

66.5 kHz

132.9 kHz

6

33.25 kHz

66.43 kHz

5

16.62 kHz

33.22 kHz

4

8.312 kHz

16.61 kHz

3

4.156 kHz

8.304 kHz

2

2.078 kHz

4.152 kHz

1

1.039 kHz

2.076 kHz

0

Table 1—

The frequency resolution is approximately 0.001 × f. The

minimum frequency of an OCT is with the DAC=0x00, and the
maximum frequency is with the DAC=0x3FF.

Figure 2—

The 16-bit data word value comprises the 4-bit OCT

value, the 10-bit DAC value, and the 2-bit CFG value. The data
is sent most significant bit first. All three values can be changed
with a single transmission.

D15

D14

OCT.3

D13

D12

D11

D10

D9

D8

OCT.2

OCT.1

OCT.0

DAC.9

DAC.8

DAC.7

DAC.6

D7

D6

DAC.5

D5

D4

D3

D2

D1

D0

DAC.4

DAC.3

DAC.2

DAC.1

DAC.0

CFG.1

CFG.0

CFG1

CFG0

CLK

*CLK

0

0

On

CLK + 180°

0

1

Off

On

1

0

On

Off

1

1

Powered down

Table 2—

The 2-bit configuration value determines how

the outputs CLK and *CLK are treated as well as the
power-saving circuitry.

background image

76

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

calculated. OCT and DAC values are
determined and sent to the LTC6903.
Finally, the OCT and DAC values are
used to calculate a frequency and the
LED display is updated with the actu-
al frequency produced.

OCT & DAC

Although the LTC6903 uses a 14-bit

value to set a frequency, the OCT and
DAC variables differ in function. The
basic VCO circuit is designed to oper-
ate at the 34- to 68-MHz octave. An
octave, as in music, is a doubling of fre-
quency (i.e., the range of the VCO). The
VCO operates within an octave’s range
based on a 10-bit resistor DAC within
the loop. A constant current feeds the
DAC resistor, creating a voltage used to
set the VCO frequency. Think of the
DAC as a control that sets a frequency
between 0.5 and full scale, or 68 MHz.
Or, you can think of the 10-bit DAC
value as always adding an offset to the
VCO’s lower frequency (34 MHz).

Using the latter line of thought, the

output frequency is made up of two
components: the DAC (offset or fine
tuning) and the OCT (base frequency

tines—one for multiplication and one
for division—cut down on the code
space required for the math routines.

The code is based on the flow chart in

Figure 4. The execution spends most of
its time in the main loop; periodically, it’s
in the interrupt routine. There are two
interrupt routines. The first is a CCP1IF
interrupt. The CCP1 module takes input
from the LTC6903 and counts edges.
When the count matches 50, the CCP1
interrupt is generated and the count is
cleared. By using this interrupt to toggle
an output pin, a frequency of one one-
hundredth of the LTC6903 is created.

I plan to add a MAX7400 eighth-order,

low-pass filter to the circuit using this
output as the filter input and the
LTC6903 output as a clock into the fil-
ter. The filter’s output will be a sine
wave equal in frequency to the input.
This will give both sine and square wave
outputs of one one-hundredth of the
LTC6903’s frequency (10 Hz to 680 kHz).
Note that this interrupt is unnecessary
for this stage of the project.

The second interrupt, which is from

timer2, is set for approximately 3 ms.
The LED display is in the form of four

or coarse tuning):

where

and

The DAC fraction normally would be

a number between zero and one. I avoid-
ed using the large floating-point routines
by carefully rearranging the equation to
keep the numbers large but less than
4,294,967,295, which is the maximum
limit of a 32-bit integer. This keeps
rounding errors mostly insignificant.

I started using a number of multipli-

cation and division routines (8 × 8, 8 ×
16, 16 ×16, 8 × 24, etc.) and rapidly ran
out of programming space. So, I decid-
ed to use 32-bit math for almost every
situation. Although it was not the
fastest execution when I only needed
the product of two 8-bit numbers, speed
was not critical. Having only two rou-

fine setting = coarse setting DAC fraction

or

fine setting

×

= 2

1,039

OCT

×

× 






DAC
1024

coarse setting = 2

1,039

OCT

×

f = coarse setting + fine setting

Figure 3—

This project uses drive transistors to provide adequate column current for a port to sink a single digit (seven segments and a DP). The frequency displayed is trans-

lated into commands to set the appropriate frequency on the LTC6903 output.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

77

multiplexed digits. Each digit plus the
colon has a column drive transistor to
supply approximately 100 mA for each
row of LED segments. The seven seg-
ments plus DP of each digit share the
eight rows of the display. A digit’s seg-
ment is enabled whenever data placed
on a display row is low and its associat-
ed column has been enabled by the col-
umn-drive transistor. Each time a
TMR2IF interrupt occurs, the last LED
column driver is disabled, data for the
next digit is placed on the display rows,
and the new digit’s column is enabled.

The five columns get updated every

15 ms (5 × 3 ms), which is about 60
Hz. Indication of which mode you’re in
is handled by the interrupt routine as
well. After you press the Mode button,
the mode variable is incremented (0–6).
Mode 0 is the Run mode in which the

display does not flash. All of the other
modes flash various parts of the display.

Modes 1 through 4 flash one of the four

digits. Mode 5 flashes the DP. Mode 6
flashes one of the two colon dots (upper
equals megahertz, lower equals kilohertz).
A variable blink is incremented each time
through the interrupt. During a column
update, the mode is checked. If there is
a match, the column is enabled only if
blink is greater than 128. This flashes the
proper segments at approximately 1 Hz.

SETTING THE LTC6903

When the mode is less or greater than

zero (editing the display), none of the
calculation routines are being executed.
This happens only after you have incre-
mented through the editing modes (1–6).

After leaving mode 6, you are forced

back into mode 0. As you can see in

Figure 4, a number of calls
are made to determine
which value to send to the
LCT6903 based on what you
have set on the LED display
(using modes 1 through 6).
The microcontroller has
synchronous serial port
hardware and can communi-
cate with the LTC6903 by
simply placing bytes in the
SSPBUF register. (Note that
this microcontroller also has
support for I

2

C, and this

could be used to talk with
an LTC6904.) After the
LTC6903 has been updated,
additional calculations are
made to determine the actu-
al frequency based on the
OCT and DAC. This is done
so the display can be updat-
ed with new values that are
closer to what is being pro-
duced as opposed to what
has been asked for.

MSOP8

The LTC6903 is only

available in the SMT ver-
sion. Obviously, Linear
wants the footprint to be
less than that of a crystal so
you can eliminate your

crystal without changing
the PCB space requirement.
I often mount these devices

in a DIP header so I can easily plug them
into a DIP socket (see Photo 2). After
bending the tiny leads up and down, I
was able to tack on short lengths of
bare wire wrap wire to each leg using
a regular soldering iron. It takes more
patience than skill to do this. If you get
this far, use a small clip as a heatsink
on each wire as you solder the eight
wires to a DIP header. This allows the
initial joint to remain cool.

Many companies have introduced sili-

con oscillators, but the LTC6903/4 has
innovations that make it stand out from
the crowd. Linear might intend to replace
the crystal in many microprocessor appli-
cations, but I think this device will find
its way into a number of unusual designs.

Are those little wheels in your head

spinning yet? Got any use for a large
quartz crystal?

I

Initialization

Main

Up button

pushed?

Down button

pushed?

Mode button

pushed?

N

N

N

Y

Y

Y

Increment digit,

DP, or multiplier

Decrement digit,

DP, or multiplier

Increment mode

(0-1-2-3-4-5-6-0)

Go to

display

Interrupts

Exit

interrupts

CCP1 Count

reached?

Timer2

overflow?

Toggle DIV100

output bit

Turn off last column.

Update next column’s row data.

Turn on next column or skip based

on mode (flashing display).

N

N

Y

Y

Display

Mode = 0?

Call

Digits2Freq

Call

Freq20CTDAC

Call

Set6903

Call

OCTDAC2Freq

Call

Freq2Digits

Call

Digits2Display

Go to

Main

N

Y

Figure 4—

The main loop consists of the UI (buttons) and calculations. The

interrupt routine displays the frequency using a four-digit LED display.

Photo 2—

The LTC6903 is hand-wired to an eight-pin

DIP header for easy removal. Three of the four push
buttons are used as a user interface for editing the dis-
play and ultimately the LTC6903.

Jeff Bachiochi (pronounced BAH-key-
AH-key) has been writing for

Circuit

Cellar since 1988. His background
includes product design and manu-
facturing. He may be reached at
jeff.bachiochi@circuitcellar.com.

SOURCES

LTC6903/4 Digital programmable
oscillator
Linear Technology Corp.
www.linear.com

PIC16F873 Microcontroller
Microchip Technology, Inc.
www.microchip.com

PROJECT FILES

To download the code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/2004/168.

background image

tricity and magnetism as discovered
centuries ago by household names like
Oerstad, Ampere, and Faraday.

Keeping things real simple, here are

some electromotive force (EMF) basics.
A current passing through a conductor
generates a magnetic field surround-
ing the conductor. That’s what Hans
Oersted (1777-1851) discovered almost
200 years ago when he noticed that a
compass needle would move under
the influence of the magnetic field sur-
rounding a current-carrying wire. In
essence, Oersted’s moving compass
needle was the first electric motor.

Nature tends to balance things out,

so the opposite is true, as Michael
Faraday (1791-1867) discovered.

78

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

A

ccording to the market statistics,

something on the order of 5 billion
electric motors are shipped each year.
It’s enough to make your head—and a
lot of other stuff—spin (see Photo 1).
The fact that the number of motors
shipped is roughly equal to the num-
ber of MCUs inspires contemplation
of an underlying convergence of both
technical and societal factors.

As you’ll see, the inexorable march

of MCUs finds our little friends push-
ing their way into ever-lower cost and
higher-volume motor control applica-
tions. One driving force is a desire to
conserve precious energy resources.
That’s more than an abstract concern
here in California, where some resi-
dents are wondering when the lights
will go out again, and others are wor-
rying about the new power plant being
built in their backyard.

Of course, the more that motors do

the heavy lifting, the less we the
couch potato-inclined populace have
to. Whether it’s an escalator, Segway, or
even the power windows in your car,
motors make life easier, although some
decry the fact that we seemingly bank
the calories saved on our waistlines.

Whether you’re going green or getting

lazy, motor control is increasingly a
topic of interest to engineers across a
broad range of fields. Let’s see what’s up.

I’M AMPED

When it comes to selecting an electric

motor for a particular application, there
are myriad of choices (see Figure 1).
Despite the various bells and whistles,
they all rely on basic concepts of elec-

Change the magnetic field around a
conductor (i.e., pass a wire near a mag-
net), and a current is induced. That’s
how a transformer works, and it also
explains why a motor can be a genera-
tor and vice versa.

As enunciated by Andre Ampere

(1775-1836), the magnitude of the
effect (i.e., power of a motor) depends
on the length of the wire within that
field and the amount of current pass-
ing through the wire. His original defi-
nition (although subsequently
replaced with a slightly different inter-
national standard) defined an ampere
as follows: the amount of current in
two straight parallel

conductors

of infi-

nite length a meter apart that gener-
ates a magnetic attraction between
the

conductors

with a force of 2 × 10

–7

newtons per meter.

Another key factor is the orienta-

tion relative to the magnetic field,
namely the force (torque) is maximized
when the wire is perpendicular to the
magnetic field and minimized (zero)
when aligned. This is simple enough to
see with a compass by forcing the nee-
dle due east or west and releasing it.
The needle accelerates quickly (maxi-
mum torque) toward north, overshoots
(mechanical inertia), and slowly (mini-
mum torque) settles back to proper ori-
entation. The exact amount of force at
any particular point is related to the
sine of the angle (i.e., 1 at 90° and 0 at
0°). Dust off your old math book
because such trig relationships are, as
you’ll see, at the heart of motor control.

Thus, motor control basically boils

down to the interaction between two

Motoring (Part 1)

SILICON UPDATE

by Tom Cantrell

Intelligent motor control should be the only kind of motor control you design into your proj-
ects. But before you start sketching your next design, take some time to learn about the elec-
tric motors at your disposal. Tom covers them all, from brush to brushless.

a)

Photo 1—

Motors come in all sizes, from 1000-plus-hp

behemoths (Photo 1a courtesy of www.hampton-
power.com/products.html) to tiny MEMS motors built
using semiconductor manufacturing techniques
(Photo 1b courtesy of www.sarcos.com/memsspec_
wobble.html).

b)

Motor Basics

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

79

magnetic fields, one in the sta-
tionary part of the motor (sta-
tor) and one the rotating part
(rotor). By rotating one of the
magnetic fields relative to the
other, work is performed as the
rotor moves in a continual effort
to restore magnetic alignment.
The analogy that comes to mind
is a dog chasing its tail, with a
big dish of dog food serving as
the power supply.

With the previous discussion

in mind, a few observations
become apparent. First, one of
the magnetic fields can be cre-
ated by permanent magnets;
but at least one must (and both
can) be created by electromag-
nets in order to allow electrical cir-
cuits to generate and control the rotat-
ing magnetic field.

Going further, it’s apparent that the

performance characteristics of the
motor (speed, torque, smoothness,
efficiency, etc.) are vitally dependent
on the ability to precisely control the
rotating magnetic field in the opti-
mum manner for the task at hand.
But, the task at hand varies greatly
(i.e., there’s no single right way when
it comes to choosing or controlling a
motor). Some applications are laugh-
ably simple, such as a fixed-speed fan.
Others, such as the motor in an elec-

tric vehicle, require infinitely variable
speed control. An application such as
a conveyor belt that carries different
size boxes (i.e., varying load) may
require constant speed, but variable
torque. Other applications call for just
the opposite—constant torque at vari-
able speed (e.g., a stepper motor).

Many applications have start-up

issues. Often, more torque is initially
needed to overcome the inertia of the
load (including the motor and related
mechanical apparatus itself) than is
required after steady-state operation is
achieved (e.g., disk drive spindle
motor). But sometimes it’s desirable

to limit torque at start-up to
minimize mechanical shock
(or whiplash for passengers in
an elevator).

Another factor to consider is

duty cycle, which encompasses
a spectrum of time- and load-
varying scenarios (see Table 1).
It’s just this variability in appli-
cations that explains why there
are so many different kinds of
motors, and why the ability to
exploit MCUs for intelligent
motor control is such a big deal.

KEEP IT SIMPLE

To find out how we got

where we are, let’s take a brief
look at where we came from by

starting with the brushed DC motor.
The common permanent magnet (PM)
version relies on magnets mounted on
the stator with coils of wire wrapped
around poles on the rotor.

Operation is conceptually simple: pass

current through the rotor coils, which
creates an electromagnet whose field
interacts with that of the permanent
magnets, generating torque that causes
the rotor to turn. Conductive brushes
rubbing against a rotor-mounted slip
ring provide the connection between
the power supply and the coils.

Great, so now you’ve got a motor

that will turn a bit and then, like a

Electrical

motor

Brush
motor

DC motor

Universal motor

Brushless

motor

Synchronous motor

(permanent magnets)

Asynchronous motor

(induction)

DC motor

Switched

reluctance motor

Stepper motor

Figure 1—

Designers have a number of options when it comes to choosing

the appropriate motor for a particular application.

Duty cycle type

Description

Continuous running

Operation at constant load of sufficient duration to reach thermal equilibrium.

Short-time duty

Operation at constant load during a given time, less than required to reach thermal equilibrium, followed by a rest enabling the machine
to reach a temperature similar to that of the coolant (2°K tolerance).

Intermittent periodic duty

A sequence of identical duty cycles, each including a period of operation at constant load and a rest (without connection to the mains). For
this type of duty, the starting current does not significantly affect the temperature rise.

Intermittent periodic duty

A sequence of identical duty cycles, each consisting of a significant period of starting, a period under constant load, and a rest period.

Intermittent periodic duty

A sequence of identical cycles, each consisting of a period of starting, a period of operation at constant load, followed by rapid electric

with electric braking

braking and a rest period.

Continuous operation

A sequence of identical duty cycles, each consisting of a period of operation at constant load and a period of operation at no load. There is

periodic duty

no rest period.

Continuous operation

A sequence of identical duty cycles, each consisting of a period of starting, a period of operation at constant load, followed by an electric

periodic duty with

braking. There is no rest period.

electric braking

Continuous operation

A sequence of identical duty cycles, each consisting of a period of operation at constant load corresponding to a predetermined speed of

periodic duty with related

rotation, followed by one or more periods of operation at another constant load corresponding to the different speeds of rotation (e.g., duty).

load and speed changes

There is no rest period. The period of duty is too short to reach thermal equilibrium.

Duty with nonperiodic

Duty in which the load and the speed generally vary nonperiodically within the permissible range. This duty includes frequent overloads

load and speed variations

that may exceed the full loads.

Table 1—

International standards bodies establish motor specifications based on a number of factors, including duty cycle, as defined here by the International Electrotechnical

Commission (IEC).

background image

80

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

compass, come to rest. The clever
solution is to split the brush connec-
tion and coil wiring so that, just as the
rotor nears alignment with the perma-
nent magnets, the current flow is
reversed—a process known as commu-
tation. Like our easily entertained dog,
just when he’s almost got his tail, it
moves out of reach and round and
round he goes.

The PM DC motor is pretty cool.

The torque is constant across the
speed range, making for reliable start-
ing and smooth operation. A brushed
motor doesn’t need an MCU because
the control (i.e., pole sequencing) is
built into the mechanics of the motor
itself. However, the clever mechanics
are also the downside because brushes

have wear-out and maintenance
issues. And don’t forget that sparks
tend to fly when the current is
reversed at the commutator, which
not only creates electrical noise but,
in fact, can be a showstopper in safety-
critical applications (e.g., a fuel pump).

Variations on the DC brush motor

theme include those that replace the
permanent magnets on the stator with
electromagnets using either a single
power supply for both stator and rotor
(series wound) or dual supplies (sepa-
rately wound). The latter is well suit-
ed for high-starting torque applica-
tions (e.g., scooters, golf carts, etc.). A
“universal” brushed motor is so-
named because it’s wired in such a
way that it will work on either AC or

DC. It isn’t easily reversible, but that’s
not a problem for a lot of applications
(e.g., fans and kitchen appliances).

BRUSH OFF

Because of its simplicity, and thus

low cost and reliability, the AC induc-
tion motor is probably the single most
widely used type of motor. Alternating
current passing through coils on the
stator induces a magnetic field on the
rotor (either wound or the affection-
ately named “squirrel cage”), thereby
eliminating the need for brushes and
their maintenance, electrical noise,
and safety issues.

The good news is that a single-phase

AC induction motor is not only
mechanically simpler than a brushed

DC motor, but it’s also conceptually
simpler. By virtue of the fact that the
current is alternating, the power sup-
ply itself performs the commutation
(i.e., the pole polarity switches along
with the phase of the supply).

The bad news is that there are a few

possible gotchas to watch out for. The
biggest one is that the starting torque
is low. In fact, the motor may not
start at all, but just sit there vibrating.
There are a number of jump-start
schemes that all generally boil down
to mixing and matching three differ-
ent add-ons. First is the addition of a
separate start winding that’s designed
so that it generates a field at a differ-
ent angle than the main winding,
thereby giving the motor a directional

bias at power-up. A start capacitor is
usually thrown in to boost the current
available for starting to many times
the rated continuous current. After
the motor reaches a speed at which
the main winding torque is sufficient
(e.g., 75%), a centrifugal switch cuts
the start winding out of the circuit.
Variations include using permanent
capacitors (eliminating the need for
the centrifugal switch) or separate
start and run capacitors.

A so-called shaded pole single-phase

AC induction motor gets rid of the
starting add-ons altogether by shield-
ing poles to induce relative lags in the
magnetic fields in such a way that the
motor starts turning. It’s simple and
cheap, but the downside is low start-

ing torque and low efficiency. That’s
OK for something like a household
fan where the starting torque required
is low and the motor doesn’t go
through a lot of start/stop cycles, but
that’s about it.

Stepping up to a multiphase motor

addresses the starting problem direct-
ly because the geometry of three sepa-
rate coils in a triangle arrangement
allows for the establishment of a clear
directional bias from the get-go. This
is helpful for applications that need
more starting torque or go through a
lot of start/stop cycles. Of course, the
downside is the higher cost of both
the motor itself and the control elec-
tronics needed to juggle a three-phase
power supply.

Slip is an inherent factor for all AC

induction motors (see Figure 2).
Normally, you would expect the speed
of the motor simply to be determined
by the frequency of the alternating
current (i.e., rate of rotation of the
magnetic field in the stator), but
because the field in the rotor must be
induced, there’s always some lag. Put
another way, if the rotor catches up to
the rotating magnetic field, there is
zero torque. But because the motor
has inherent electrical and mechanical
losses that require some torque to
overcome, the rotor can never catch
up. As a result, the actual motor speed
is slightly (e.g., 5%) less than the base
speed of the rotating magnetic field,
and the amount of slip varies with the
load changes.

10% 20%

30%

40%

50%

60%

70% 80% 90% 100%

Rotor speed (percentage of full speed)

Sample load torque curve

Pull-up torque

Full-voltage start torque

Full-voltage stator current

Pull-out torque

7 × FLC

LRC

6 × FLC

5 × FLC

4 × FLC

3 × FLC

LRT

2 × FLC

1 × FLC

Current (percentage of

motor full-load current)

2 × FLT

1 × FLT

Torque (percentage of
motor full-load torque)

Figure 2—

At start-up, a three-phase AC induction motor draws a huge amount of locked rotor current (LRC) until

the motor reaches 80% of full speed. At that point both current and torque drop quickly as the motor approaches
95% of full speed, where it delivers full load torque (FLT) with high efficiency (i.e., low current).

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

81

POWERFULLY CORRECT

Any talk about AC and induc-

tive loads has to include discus-
sion of power factor correction
(PFC). The topic goes beyond
motors (it relates to all AC pow-
ered devices), and the effect is
felt mostly by large generators
(utilities) and users (e.g., com-
mercial and industrial plants).
Nevertheless, here goes.

Let’s start with the simple

example of an AC supply driv-
ing a resistive load (e.g., a light
bulb). If you hook up an oscillo-
scope, you’d see that the voltage
and current remain in phase
(i.e., the sine waves are aligned),
as you can see in Figure 3. In
this case, the familiar watts =
volts × amps equation holds.
Notice that the power consumed
(watts) is always positive (i.e., the
voltage and current are always either
both positive or both negative).

But if you replace the resistor with

an inductor that draws the same
amount of current, look what hap-
pens. Now the voltage and current are
no longer in phase: the current flow
lags by 90°, and there are regions of
both positive power (positive voltage
and current) and negative power (posi-
tive voltage and negative current or
negative voltage and positive cur-
rent). This seems odd. There is volt-
age present and current flowing, but
there is no power!

Put more formally, the power factor

of a circuit is defined as the cosine of
the phase angle (one for perfectly
aligned voltage and current wave-
forms, and zero for waveforms 90° out
of phase). Because real-world circuits
comprise a mix of resistive and induc-
tive loads, the line current is a com-
posite of the two. For example, a cir-
cuit containing equal resistive and
inductive loads would have a phase
angle of 45° and, thus, a power factor
of 0.71 (cosine of 45°).

This is more than a numbers game.

A lower power factor translates into a
direct loss of efficiency (i.e., watts in
versus work out), so a motor’s actual
work output is derated, depending on
its power factor. It also means generat-
ing and distribution facilities must be

upsized to overcome the difference.
With the emphasis on energy conser-
vation (and the fact that nobody likes
paying higher energy bills), it’s no
wonder there’s been a big push to
improve power factors with regula-
tions (and utility imposed price penal-
ties) pushing for at least 0.9 and
beyond. A classic solution is to add
capacitors because capacitance causes
a leading (versus an inductor’s lagging)
phase angle.

Another often overlooked power

factor, harmonics, comes into play
any time the voltage and current
waveforms deviate from a pure sine
wave. For instance, a square wave
approximation generates many higher-
frequency harmonics that cause an
increase in true versus apparent power
consumption. Harmonics not only
represent an additional power factor
loss, but also can damage other equip-
ment sharing the same line or even
the power source itself. The push to
improve power factors includes the
explicit consideration of harmonics
(see IEEE, Recommended Practices
and Requirements for Harmonic
Control in Electrical Power Systems

,

519, 1992).

BEST OF BOTH WORLDS

Wouldn’t it be nice to have a motor

with the performance advantages of a
brushed DC motor and the mechani-
cal simplicity (no brushes) of an AC

Power

Average

0

Average

Power

0

Voltage

Current

0

0

Voltage

Current

Figure 3—

As shown here, a purely inductive load exhibits a

power factor of zero as measured by the sine of the phase
angle between voltage and current. Fortunately, this isn’t the
case for real-world circuits, but so-called wattless power (i.e.,
power factor less than one) represents a loss of efficiency that
calls for a power factor correction (PFC).

background image

Hot Chips 16 brings together designers and architects of high-performance chips, software, and systems. Presentations focus
on up-to-the-minute real developments. This symposium is the primary forum for engineers and researchers to highlight
their leading-edge designs. Three full days of tutorials and technical sessions will keep you on top of the industry.

SundaSundaSundaSundaSunda

yyyyy

August

22

August

22

August

22

August

22

August

22

MondaMondaMondaMondaMonda

yyyyy

August

23

August

23

August

23

August

23

August

23

TTTTT

uesdauesdauesdauesdauesda

yyyyy

August

24

August

24

August

24

August

24

August

24

A Symposium on High-Performance Chips
August 22-24, 2004, Memorial Auditorium,
Stanford University, Palo Alto, California

This is a preliminary program; changes may occur. For the most up-to-the-minute details on
presentations and schedules, and for registration information, please visit our web site

http://www

http://www

http://www

http://www

http://www.hotchips.org

.hotchips.org

.hotchips.org

.hotchips.org

.hotchips.org

..... For general information please contact

inf

inf

inf

inf

info@hotchips.org

o@hotchips.org

o@hotchips.org

o@hotchips.org

o@hotchips.org

.....

Please also check out HOT Interconnects 12 (another HOT Symposium being held following
HOTChips 16) on their website

http://www

http://www

http://www

http://www

http://www.hoti.org

.hoti.org

.hoti.org

.hoti.org

.hoti.org

.....

Sponsor

Sponsor

Sponsor

Sponsor

Sponsored b

ed b

ed b

ed b

ed by the

y the

y the

y the

y the T

T

T

T

Technical Committee on Micr

echnical Committee on Micr

echnical Committee on Micr

echnical Committee on Micr

echnical Committee on Micropr

opr

opr

opr

oprocessors and Micr

ocessors and Micr

ocessors and Micr

ocessors and Micr

ocessors and Microcomputers of the IEEE Computer Society

ocomputers of the IEEE Computer Society

ocomputers of the IEEE Computer Society

ocomputers of the IEEE Computer Society

ocomputers of the IEEE Computer Society

HO

HO

HO

HO

HOT Chips 16

T Chips 16

T Chips 16

T Chips 16

T Chips 16

1

1

1

1

16

6

6

6

6

ADVANCE PROGRAM

Organizing Committee

Organizing Committee

Organizing Committee

Organizing Committee

Organizing Committee

Chair

Chair

Chair

Chair

Chair
Bob Lashley Sun
Vice Chair

Vice Chair

Vice Chair

Vice Chair

Vice Chair
Pradeep Dubey Intel

Finance

Finance

Finance

Finance

Finance
Angela Lee HP

Publicity

Publicity

Publicity

Publicity

Publicity
Donna Wilson
Adv

Adv

Adv

Adv

Adver

er

er

er

ertising

tising

tising

tising

tising

Stephan Mueller Sun
Publications

Publications

Publications

Publications

Publications
Tiziana Perinotti

Sponsorship

Sponsorship

Sponsorship

Sponsorship

Sponsorship
Amr Zaky Qualcomm
Registration

Registration

Registration

Registration

Registration
Yusuf Abdulghani Apple
Local

Local

Local

Local

Local Ar

Ar

Ar

Ar

Arrangements

rangements

rangements

rangements

rangements

Allen J. Baum Intel

W

W

W

W

Webmaster

ebmaster

ebmaster

ebmaster

ebmaster

Ranganathan Sudhakar AMD
Bill Humphries Apple

At Large

At Large

At Large

At Large

At Large
Lily Jow HP
Howard Sachs Telairity
Gail Sachs
Alan Jay Smith Berkeley
Bob Stewart SRE

Program Committee

Program Committee

Program Committee

Program Committee

Program Committee

Program Co-Chairs

Program Co-Chairs

Program Co-Chairs

Program Co-Chairs

Program Co-Chairs
Bill Dally Stanford
Keith Diefendorff MemoryLogix
Program Committee

Program Committee

Program Committee

Program Committee

Program Committee
Forest Baskett NEA
Allen J. Baum Intel
Pradeep Dubey Intel
Norm Jouppi HP
Christos Kozyrakis Stanford
John Nicholls NVIDIA
Tom Petersen MIPS
Chris Rowen Tensilica
Mitsuo Saito Toshiba
John Sell AMD
Alan Jay Smith Berkeley
Mateo Valero Catalonia

Morning Tutorial

Ultra

Ultra

Ultra

Ultra

Ultrawideband;

wideband;

wideband;

wideband;

wideband; T

T

T

T

Technolog

echnolog

echnolog

echnolog

echnology and Issues

y and Issues

y and Issues

y and Issues

y and Issues

Afternoon Tutorial

J.

J.

J.

J.

J. Thomas Pa

Thomas Pa

Thomas Pa

Thomas Pa

Thomas Pawlo

wlo

wlo

wlo

wlowski

wski

wski

wski

wski

Micron

Micron

Micron

Micron

Micron

P

P

P

P

Perf

erf

erf

erf

erformance Comparison of State-of-the-Ar

ormance Comparison of State-of-the-Ar

ormance Comparison of State-of-the-Ar

ormance Comparison of State-of-the-Ar

ormance Comparison of State-of-the-Art

t

t

t

t V

V

V

V

Volatile and

olatile and

olatile and

olatile and

olatile and

Non-V

Non-V

Non-V

Non-V

Non-Volatile Memor

olatile Memor

olatile Memor

olatile Memor

olatile Memory De

y De

y De

y De

y Devices

vices

vices

vices

vices

Mobile Processing

• Bulv

• Bulv

• Bulv

• Bulv

• Bulver

er

er

er

erde -

de -

de -

de -

de - An

An

An

An

An Applications Pr

Applications Pr

Applications Pr

Applications Pr

Applications Processor f

ocessor f

ocessor f

ocessor f

ocessor for Phone and PD

or Phone and PD

or Phone and PD

or Phone and PD

or Phone and PDA

A

A

A

A Applications

Applications

Applications

Applications

Applications

Intel

Intel

Intel

Intel

Intel

• SC10:

• SC10:

• SC10:

• SC10:

• SC10: A

A

A

A

A Video Pr

Video Pr

Video Pr

Video Pr

Video Processor and Pix

ocessor and Pix

ocessor and Pix

ocessor and Pix

ocessor and Pixel Shading GPU F

el Shading GPU F

el Shading GPU F

el Shading GPU F

el Shading GPU For Handheld De

or Handheld De

or Handheld De

or Handheld De

or Handheld Devices

vices

vices

vices

vices NVIDIA

NVIDIA

NVIDIA

NVIDIA

NVIDIA

• SH-Mobile3:

• SH-Mobile3:

• SH-Mobile3:

• SH-Mobile3:

• SH-Mobile3: Application Pr

Application Pr

Application Pr

Application Pr

Application Processor f

ocessor f

ocessor f

ocessor f

ocessor for 3G Cellular Phones on a

or 3G Cellular Phones on a

or 3G Cellular Phones on a

or 3G Cellular Phones on a

or 3G Cellular Phones on a

Lo

Lo

Lo

Lo

Low-P

w-P

w-P

w-P

w-Po

o

o

o

ow

w

w

w

wer SoC Design Platf

er SoC Design Platf

er SoC Design Platf

er SoC Design Platf

er SoC Design Platform

orm

orm

orm

orm

Hitachi

Hitachi

Hitachi

Hitachi

Hitachi

Keynote

Rober

Rober

Rober

Rober

Robert Denise

t Denise

t Denise

t Denise

t Denise

JPL

JPL

JPL

JPL

JPL

Mars Exploration Ro

Mars Exploration Ro

Mars Exploration Ro

Mars Exploration Ro

Mars Exploration Rov

vv

vvers — a

ers — a

ers — a

ers — a

ers — a Vie

Vie

Vie

Vie

View fr

w fr

w fr

w fr

w from the Inside

om the Inside

om the Inside

om the Inside

om the Inside

High-End Audio and Video

• Quar

• Quar

• Quar

• Quar

• Quartet:

tet:

tet:

tet:

tet: A Pipeline-Interlea

A Pipeline-Interlea

A Pipeline-Interlea

A Pipeline-Interlea

A Pipeline-Interleav

vv

vved Multithr

ed Multithr

ed Multithr

ed Multithr

ed Multithreaded

eaded

eaded

eaded

eaded Audio DSP

Audio DSP

Audio DSP

Audio DSP

Audio DSP

Cr

Cr

Cr

Cr

Creativ

eativ

eativ

eativ

eative Labs

e Labs

e Labs

e Labs

e Labs

• CS7050 High P

• CS7050 High P

• CS7050 High P

• CS7050 High P

• CS7050 High Perf

erf

erf

erf

erformance H.264/A

ormance H.264/A

ormance H.264/A

ormance H.264/A

ormance H.264/AVC Har

VC Har

VC Har

VC Har

VC Hardwar

dwar

dwar

dwar

dware

e

e

e

e Video Decoder

Video Decoder

Video Decoder

Video Decoder

Video Decoder

Cor

Cor

Cor

Cor

Core f

e f

e f

e f

e for Multimedia SOC’

or Multimedia SOC’

or Multimedia SOC’

or Multimedia SOC’

or Multimedia SOC’sssss

Amphion

Amphion

Amphion

Amphion

Amphion

Wireless Communication

• IEEE802.11a Based

• IEEE802.11a Based

• IEEE802.11a Based

• IEEE802.11a Based

• IEEE802.11a Based Wir

Wir

Wir

Wir

Wireless

eless

eless

eless

eless A

A

A

A

AV Module with Digital

V Module with Digital

V Module with Digital

V Module with Digital

V Module with Digital A

A

A

A

AV Interface

V Interface

V Interface

V Interface

V Interface

T

T

T

T

Toshiba

oshiba

oshiba

oshiba

oshiba

• Single Chip CMOS Dir

• Single Chip CMOS Dir

• Single Chip CMOS Dir

• Single Chip CMOS Dir

• Single Chip CMOS Direct Con

ect Con

ect Con

ect Con

ect Conv

vv

vversion

ersion

ersion

ersion

ersion T

T

T

T

Transceiv

ransceiv

ransceiv

ransceiv

ransceivers f

ers f

ers f

ers f

ers for

or

or

or

or WW

WW

WW

WW

WWAN &

AN &

AN &

AN &

AN & WLAN

WLAN

WLAN

WLAN

WLAN Sirific

Sirific

Sirific

Sirific

Sirific

Media and Graphics Processing

• The GeF

The GeF

The GeF

The GeF

The GeFor

or

or

or

orce 6800 GPU

ce 6800 GPU

ce 6800 GPU

ce 6800 GPU

ce 6800 GPU

NVIDIA

NVIDIA

NVIDIA

NVIDIA

NVIDIA

• Ne

• Ne

• Ne

• Ne

• New Media

w Media

w Media

w Media

w Media Ar

Ar

Ar

Ar

Architectur

chitectur

chitectur

chitectur

chitecture f

e f

e f

e f

e for Next Generation

or Next Generation

or Next Generation

or Next Generation

or Next Generation Application Pr

Application Pr

Application Pr

Application Pr

Application Processors

ocessors

ocessors

ocessors

ocessors

ARM

ARM

ARM

ARM

ARM

• The MXP5800 Media Pr

The MXP5800 Media Pr

The MXP5800 Media Pr

The MXP5800 Media Pr

The MXP5800 Media Processor

ocessor

ocessor

ocessor

ocessor

Intel

Intel

Intel

Intel

Intel

Enabling Technology

• SimNo

• SimNo

• SimNo

• SimNo

• SimNow:

w:

w:

w:

w: An Extr

An Extr

An Extr

An Extr

An Extremel

emel

emel

emel

emely Fast &

y Fast &

y Fast &

y Fast &

y Fast & Accurate Platf

Accurate Platf

Accurate Platf

Accurate Platf

Accurate Platform & Pr

orm & Pr

orm & Pr

orm & Pr

orm & Processor Sim

ocessor Sim

ocessor Sim

ocessor Sim

ocessor Simulator

ulator

ulator

ulator

ulator AMD

AMD

AMD

AMD

AMD

• Microchannel Liquid Cooling Solutions

• Microchannel Liquid Cooling Solutions

• Microchannel Liquid Cooling Solutions

• Microchannel Liquid Cooling Solutions

• Microchannel Liquid Cooling Solutions

Coolig

Coolig

Coolig

Coolig

Cooligy

yy

yy

• A Ne

A Ne

A Ne

A Ne

A New System-On-Chip Bus

w System-On-Chip Bus

w System-On-Chip Bus

w System-On-Chip Bus

w System-On-Chip Bus Ar

Ar

Ar

Ar

Arch.

ch.

ch.

ch.

ch. Optimized f

Optimized f

Optimized f

Optimized f

Optimized for 1GHz MIPS Pr

or 1GHz MIPS Pr

or 1GHz MIPS Pr

or 1GHz MIPS Pr

or 1GHz MIPS Processors

ocessors

ocessors

ocessors

ocessors PMC-Sier

PMC-Sier

PMC-Sier

PMC-Sier

PMC-Sierra

ra

ra

ra

ra

Panel

Moderated b

Moderated b

Moderated b

Moderated b

Moderated by J

y J

y J

y J

y John Nick

ohn Nick

ohn Nick

ohn Nick

ohn Nickolls

olls

olls

olls

olls NVIDIA

NVIDIA

NVIDIA

NVIDIA

NVIDIA

Outsour

Outsour

Outsour

Outsour

Outsourcing Engineering De

cing Engineering De

cing Engineering De

cing Engineering De

cing Engineering Dev

vv

vvelopment Offshor

elopment Offshor

elopment Offshor

elopment Offshor

elopment Offshore

ee

e

e

Potpourri

• MDGRAPE-3 chip:

MDGRAPE-3 chip:

MDGRAPE-3 chip:

MDGRAPE-3 chip:

MDGRAPE-3 chip: A 165-Gflops

A 165-Gflops

A 165-Gflops

A 165-Gflops

A 165-Gflops ASIC f

ASIC f

ASIC f

ASIC f

ASIC for molecular dynamics sim

or molecular dynamics sim

or molecular dynamics sim

or molecular dynamics sim

or molecular dynamics simulations

ulations

ulations

ulations

ulations Genomic

Genomic

Genomic

Genomic

Genomic

• Accelerating Next-Generation Public-k

Accelerating Next-Generation Public-k

Accelerating Next-Generation Public-k

Accelerating Next-Generation Public-k

Accelerating Next-Generation Public-ke

ee

e

ey Cr

y Cr

y Cr

y Cr

y Cryptogra

yptogra

yptogra

yptogra

yptograph

ph

ph

ph

phy on

y on

y on

y on

y on

General-Purpose CPUs

General-Purpose CPUs

General-Purpose CPUs

General-Purpose CPUs

General-Purpose CPUs

Sun

Sun

Sun

Sun

Sun

• Ho

• Ho

• Ho

• Ho

• How SolarFlar

w SolarFlar

w SolarFlar

w SolarFlar

w SolarFlare Comm

e Comm

e Comm

e Comm

e Communications br

unications br

unications br

unications br

unications brok

ok

ok

ok

oke the 10Gbps on UTP bar

e the 10Gbps on UTP bar

e the 10Gbps on UTP bar

e the 10Gbps on UTP bar

e the 10Gbps on UTP barrier

rier

rier

rier

rier

SolarFlar

SolarFlar

SolarFlar

SolarFlar

SolarFlare

ee

e

e

Keynote

Ste

Ste

Ste

Ste

Stev

vv

vve J

e J

e J

e J

e Jur

ur

ur

ur

urv

vv

vvetson

etson

etson

etson

etson

DFJ

DFJ

DFJ

DFJ

DFJ

Nanotech and the Futur

Nanotech and the Futur

Nanotech and the Futur

Nanotech and the Futur

Nanotech and the Future of Moor

e of Moor

e of Moor

e of Moor

e of Moore’

e’

e’

e’

e’s La

s La

s La

s La

s Law

w

w

w

w

Embedded Systems

• A Fast P

A Fast P

A Fast P

A Fast P

A Fast Po

o

o

o

ow

w

w

w

wer

er

er

er

ertrain Micr

train Micr

train Micr

train Micr

train Microcontr

ocontr

ocontr

ocontr

ocontroller

oller

oller

oller

oller

Infineon

Infineon

Infineon

Infineon

Infineon

• The Mote Re

The Mote Re

The Mote Re

The Mote Re

The Mote Rev

vv

vvolution:

olution:

olution:

olution:

olution: Lo

Lo

Lo

Lo

Low P

w P

w P

w P

w Po

o

o

o

ow

w

w

w

wer

er

er

er

er Wir

Wir

Wir

Wir

Wireless Sensor Netw

eless Sensor Netw

eless Sensor Netw

eless Sensor Netw

eless Sensor Network De

ork De

ork De

ork De

ork Devices

vices

vices

vices

vices

UC Berk

UC Berk

UC Berk

UC Berk

UC Berkele

ele

ele

ele

eley

yy

yy

Low-Power Processors

• A 90nm embed

A 90nm embed

A 90nm embed

A 90nm embed

A 90nm embedded DRAM single chip LSI with a 3D gra

ded DRAM single chip LSI with a 3D gra

ded DRAM single chip LSI with a 3D gra

ded DRAM single chip LSI with a 3D gra

ded DRAM single chip LSI with a 3D graphics,

phics,

phics,

phics,

phics,

H.264 codec engine

H.264 codec engine

H.264 codec engine

H.264 codec engine

H.264 codec engine,,,,, and a r

and a r

and a r

and a r

and a reconfigurable pr

econfigurable pr

econfigurable pr

econfigurable pr

econfigurable processor

ocessor

ocessor

ocessor

ocessor

Son

Son

Son

Son

Sony

yy

yy

• A Lo

A Lo

A Lo

A Lo

A Low-P

w-P

w-P

w-P

w-Po

o

o

o

ow

w

w

w

wer Opter

er Opter

er Opter

er Opter

er Opteron Pr

on Pr

on Pr

on Pr

on Processor

ocessor

ocessor

ocessor

ocessor

AMD

AMD

AMD

AMD

AMD

Instruction Set Automation

• The End of ISA Design:

The End of ISA Design:

The End of ISA Design:

The End of ISA Design:

The End of ISA Design: P

P

P

P

Po

o

o

o

ow

w

w

w

wer

er

er

er

er T

T

T

T

Tools f

ools f

ools f

ools f

ools for Optimal Pr

or Optimal Pr

or Optimal Pr

or Optimal Pr

or Optimal Processor Generation

ocessor Generation

ocessor Generation

ocessor Generation

ocessor Generation T

T

T

T

Tensilica

ensilica

ensilica

ensilica

ensilica

• Long

• Long

• Long

• Long

• Long W

W

W

W

Wor

or

or

or

ords and

ds and

ds and

ds and

ds and Wide P

Wide P

Wide P

Wide P

Wide Por

or

or

or

orts:

ts:

ts:

ts:

ts: Rein

Rein

Rein

Rein

Reinv

vv

vventing the Configurable Pr

enting the Configurable Pr

enting the Configurable Pr

enting the Configurable Pr

enting the Configurable Processor

ocessor

ocessor

ocessor

ocessor

T

T

T

T

Tensilica

ensilica

ensilica

ensilica

ensilica

• OptimoDE

• OptimoDE

• OptimoDE

• OptimoDE

• OptimoDE

ARM

ARM

ARM

ARM

ARM

High-End Processors

• The Montecito Pr

The Montecito Pr

The Montecito Pr

The Montecito Pr

The Montecito Processor

ocessor

ocessor

ocessor

ocessor

Intel

Intel

Intel

Intel

Intel

• A 32-wa

A 32-wa

A 32-wa

A 32-wa

A 32-way Multithr

y Multithr

y Multithr

y Multithr

y Multithreaded SP

eaded SP

eaded SP

eaded SP

eaded SPARC Pr

ARC Pr

ARC Pr

ARC Pr

ARC Processor

ocessor

ocessor

ocessor

ocessor

Sun

Sun

Sun

Sun

Sun

• Intel P

• Intel P

• Intel P

• Intel P

• Intel Pentium 4 Pr

entium 4 Pr

entium 4 Pr

entium 4 Pr

entium 4 Processor on 90nm

ocessor on 90nm

ocessor on 90nm

ocessor on 90nm

ocessor on 90nm T

T

T

T

Technolog

echnolog

echnolog

echnolog

echnology

yy

yy

Intel

Intel

Intel

Intel

Intel

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

83

induction motor? Yes, it would, which
is why brushless DC (BLDC) motors
are such hot items, especially under
the hood of the latest-and-greatest
hybrid vehicles (see Photo 2).

Conceptually, a BLDC motor is a

permanent magnet brushed DC motor
turned inside out: the magnets are
mounted on the rotor, and the coils
are on the stator. Because the coils no
longer rotate, there’s no need for
brushes to make the power connec-
tion (see Figure 4).

Of course, without brushes, another

way must be found to switch the pole
polarity at the proper time. The solu-
tion is to determine the rotor’s posi-
tion in some way and to control the
coil drive in real time, a process
known as “electronic commutation.”
Traditionally, BLDC motors include
sensors, such as Hall effect, to deliver
rotor position information to the
motor controller. More recently, how-
ever, sensorless BLDC motors have
become all the rage.

As the name implies, these motors

dispense with the need for separate
rotor position sensors. Instead, they
exploit a phenomenon known as back
EMF. As I described earlier, current
passing through the stator coil gener-
ates a field that interacts with the
rotor’s permanent magnet field to
cause the motor to turn. But also
recall from EMF 101 that a conductor
passing through a magnetic field gen-
erates current. So, as the rotor (mag-
net) is flying past the coil (conductor),
a small amount of EMF is generated
counter to the EMF that’s causing the
motor to turn in the first place.

By monitoring the back EMF, you

can determine the speed and position
of the rotor without needing any extra
sensors, wires, or I/O ports. However,
the relative magnitude of back EMF
can be small relative to forward EMF,
and it also varies with the speed. That
makes low-speed back EMF detection
(and thus precise control) especially
difficult. Of course, in general, there’s
plenty of electrical noise to cut
through as well. Fortunately, today’s
MCUs and motor-control chips are
increasingly up to the task, allowing
sensorless BLDC motors to make sig-
nificant inroads against both brushed
DC and AC induction motors.

Fulfillment of the promise offered

by intelligent MCU-based motor con-
trols is found in the switched-reluc-
tance (SR) motor, arguably the sim-
plest of all. It’s somewhat similar to a
BLDC, except the rotor has formed
poles (looks like a gear) and is made of

Rotor magnet N

Hall effect sensors

Accessory shaft

Hall effect sensor magnets

Stator windings

Stator windings

Rotor magnet S

Driving end of the shaft

Figure 4—

Brushless DC motors are popular because they combine the performance (e.g., flat torque curve) of

brushed DC motors with the mechanical simplicity and reliability of an induction motor. In order to perform electron-
ic commutation, the motor controller monitors the rotor position using traditional sensors (e.g., Hall effect) and,
more recently, sensorless (e.g., back EMF) techniques.

Photo 2—

Advanced electric motors and their controls

are sparking the emergence of next-generation hybrid
gas and electric engines such as this one from Honda.
Only 60-mm thick, the 144-V BLDC motor boosts
horsepower by 10% and torque by 20% (photo cour-
tesy of Green Car Group, www.greencars.com).

background image

positioning errors (e.g., stalls, external
disturbances, loss of power, or con-
troller errors). Using a stepper motor
open loop (i.e., no external position
detection) versus a conventional DC
motor with position sensors running
closed loop remains an interesting
choice for designers.

The fine positioning resolution and

smoothness of rotation can be further
enhanced with half-stepping, as
shown in Figure 5. Instead of fully
activating a set of coils (as in full-
stepping), partial coil activation caus-
es the rotor to move to an intermedi-
ate position between steps. However,
because partial activation reduces the
overall current, the holding torque at
the half-step position is reduced. To
compensate, a technique known as
current profiling increases the current
through the active coil so that the
total current at all (full- and half-step)
positions is the same.

Microstepping takes the current-

profiling trick further. Instead of just
full- or half-activation, the coils are
driven with much finer granularity
capable of achieving fractional degree
accuracy with tens or even hundreds
of microsteps per full step. Although
it’s a DC motor, the coil drive wave-

84

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

forms for microstepping start
to look like overlapping sine
waves, little different from
those that drive an AC motor.

CONTROL FREQ

Whew. I have to confess

that even this brief examina-
tion of the various types of
electric motors went on
longer than expected.
Originally, I’d intended to
combine the motor and con-
trols discussion in one arti-
cle, but as I got into it, I real-
ized each topic has more than
enough meat to justify its
own article. This month I
talked about iron, copper, and
magnets. Next month I’ll talk
about silicon and software.

Everyone knows motors are

here to stay and new applica-
tions continue to emerge.
The real story is that even for
traditional applications, the

desire to go green and cut our energy
bills along with the march of silicon
means the subject of motor controls is
far from old hat. As they say in poli-
tics, the spinning is just beginning!

I

a magnetically permeable
material (something a mag-
net will attract, like iron)
rather than having it’s own
(permanent or induced) mag-
netic field.

When opposing pairs of

coils on the stator are ener-
gized, the nearby poles on
the rotor attempt to align. If
the number of coils and
poles are equal (or integral
multiple), the rotor moves to
a stable position and then
stops. But by using fraction-
ally less poles on the rotor
(say, six) compared to the
number of coils (say, eight),
a coil/pole pair that’s
aligned during one phase is
slightly out of alignment for
the next phase.

Precise control is required

to overcome the main chal-
lenge posed by SR motors,
torque ripple. In essence, the
motor wants to move in steps equal to
360° divided by the number of coils
(e.g., 45° steps for an eight-coil
motor). This can cause vibration,
mechanical stress on the bearings,
and audible noise.

STEP LIGHTLY

Speaking of steps, let’s finish up this

month with the aptly named stepper
motor. It’s kind of like a BLDC on
steroids, one that divides a single rev-
olution of the rotor into, for example,
200 discrete steps (1.8° per step).
Furthermore, as long as the coils
remain energized, the motor will
exhibit strong holding torque at each
step position. Torque is further
enhanced for bipolar stepper motors in
which the coils are driven with cur-
rent in both directions.

With precise stepping angles and

strong holding torque, the stepping
motor is uniquely well suited for posi-
tioning applications. As a practical
matter, all other motors require
closed-loop control for anything
approaching precision positioning. By
contrast, a stepper motor can be, and
usually is, run open loop with perhaps
a limit switch or intermittent calibra-
tion as the only concession to possible

RESOURCES

K. Berringer, “Motor Control
Tutorial,” 2000, e-www.motorola.com/
files/ microcontrollers/doc/train_ref_
material/MOTORTUT.html.

R. Parekh, “

AC Induction Motor

Fundamentals

,” Microchip Technology,

DS00887A, www.microchip.com/1010/
suppdoc/appnote/all/an887/index.htm.

STMicroelectronics, “A Tutorial On
Electrical Motors,” www.st.com/
stonline/products/support/motor/
tutorial/tutorial.htm.

P.

Yedamale, “

Brushless DC (BLDC)

Motor Fundamentals,” Microchip
Technology, DS00885A, 2003,

www.microchip.com/1010/suppdoc/ap
pnote/all/an885/index.htm.

Tom Cantrell has been working on
chip, board, and systems design and
marketing for several years. You may
reach him by e-mail at tom.cantrell@
circuitcellar.com.

1

2

3

4

Full-step current

two-phase “on”

Phase 1

Phase 2

+I

1

–I

1

–I

2

+I

2

1

2

3

4

5

6

7

8

1

2

3

4

5

6

7

8

Half-step current

Phase 1

Phase 2

+I

1

–I

1

–I

2

+I

2

Half-step current

profiled

Phase 1

Phase 2

+I

1

–I

1

–I

2

+I

2

Figure 5—

Controlling a stepper motor’s winding currents with finer granularity can

boost the positioning resolution to hundreds (half-stepping) and even thousands
(micro-stepping) of steps per revolution.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

85

IDEA BOX

THE

DIRECTORY

OF

PRODUCTS AND

SERVICES

AD FORMAT

: Advertisers must furnish digital submission sheet and digital files that meet the specifications on the digital submission sheet.

ALL TEXT AND OTHER ELEMENTS MUST FIT WITHIN A 2

″″ ××

3

″″

FORMAT

. Call for current rate and deadline information. Send your disk and digital submis-

sion sheet to: IDEA BOX, Circuit Cellar, 4 Park Street, Vernon, CT 06066 or e-mail kc@circuitcellar.com. For more information call Sean Donnelly at (860) 872-3064.

The Suppliers Directory at www.circuitcellar.com/suppliers_dir/

is your guide to a variety of engineering products and services.

experience xBOB

turn serial data into video text

w w w.decadenet.com

D

ECADE

E

NGINEERING

503-743-3194 Turner, OR, USA

Insert-ready Single Board Computer modules in sub-miniature

dimensions (as small as 47x55 mm) populated by:

8-bit:

ADuC812

,

AT89C51CC01

,

DS80C390

,

P87C591

,

P89C51Rx2

,

P89C66x

,

P89C51MX

16-bit:

C167CR

,

C167CS

,

XC161CJ

,

XC167CI

,

PXAC3

,

PXAG49

,

ST10F168

,

ST10F269

32-bit:

AT91M55800A (ARM7TDMI core)

,

Elan SC520

,

MPC555

,

MPC565

applicable controller signals extend to standard pin header (2.54

mm) or high-density Molex (0.625 mm) connectors, enabling SBC

to be plugged like a “big chip” into OEM targets

Low EMI design

achieved via GND circuitry, multi-layer PCB, by-

pass capacitor grid and short signal traces achieved via small

footprint and use of 0402 SMD passive components

32 KB to 64 MB external SRAM and Flash (controller-dependent)

CAN, Ethernet, RS-232 and RS-485 interfaces; ADC, DAC

(controller-dependent); freely-available /CS and I/O lines

available in

Rapid Development Kit

including Development Board,

AC adapter, serial cable and SPECTRUM CD with eval software

tools, electronic documentation and demos

Stick It In!

: insert-ready PHYTEC SBC modules accompany you

from evaluation through protyping to end production...

accelerating your design cycle and reducing your time-to-market

www.phytec.com

phyCORE

®

New Generation
Single Board Computer

(800) 278-9913

PHYTEC America, LLC

203 Parfitt Way SW, G100

Bainbridge Island, WA 98110 USA

background image

86

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

PC KEYBOARD EMULATION

Interface Keypads, Switches, or RS-232 to your PC Keyboard Input

MODEL KE24

ONLY $

99

95

• Up to 12 x 12 matrix • Programmable • RS-232 Port • Macro Capability

The KE24 is the ultimate in flexibility. Inputs or serial data can

emulate any of the 101 keys from a standard keyboard.

MODEL KE18

ONLY $

44

95

• Up to 9 x 9 matrix • 2.5" x 3.0" Size • PC Keyboard Port • PCXT, AT Compatible

The KE18 combines a multitude of features with small size at an

economical price. Custom units available.

HAGSTROM

ELECTRONICS

11 Fiddlers Green

Lansing, NY 14882

Toll Free: 888-690-9080

Phone: 607-533-4441 Fax: 607-533-4443

www.hagstromelectronics.com

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

87

background image

88

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

89

AT-XTR-903

RF MODULES

www.abacom-tech.com

Tel: (416)236-3858 Fax: (416)236-8866

x Multi-Channel Intelligent

Wireless Transceiver

x 3V operation
x 9600 to 38.4Kbps
x Virtual Wire Operation
x Wafer Thin, Tiny Footprint
x Low Current
x 433, 868 & 900MHz versions
x Standard serial I/O
x Programmable TX Power
x Programmable Frequency
x User Customizable Features

1.5 mm

2.5 mm

5.5 mm

Pins

0.6mm x 0.6mm

30.48 mm

(1.2 in.)

Intro

ducin

g th

e

background image

90

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

Email: sales@picofab.net

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

91

Got Dial Tone?

R

ING

-I

T

!

T

ELCO

S

IMULATOR

Caller-ID

LED display

Audio Output Jack

Real 20Hz Ring

$325 Sale $299.95

Telecom Hardware/Software Developers

STOP using your phone lines to test and demonstrate
your telecom devices. Our affordable telephone line
simulators offer authentic USA dial tone, busy signals
and ringing. Supports high speed analog modems too!

P

ARTY

-L

INE

T

ELCO

S

IMULATOR

Six Extensions

Caller-ID

Distinctive Ringing

CPC Disconnect

$425 Sale $399

Digital Products

Company

134 Windstar Circle

Folsom, CA 95630 USA

Tel: 916-985-7219

Fax: 916-985-8460

http://www.digitalproductsco.com

background image

92

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 168 July 2004

93

background image

Understanding Embedded Security

Closed-Loop Motion Control for Mobile Robots

PICs, DRAMs, and Graphics Displays: Build a Graphics LCD Driver

E-Field Sensor-Based Monitoring System

Ham Radio Repeater Locator

ABOVE THE GROUND PLANE

Stepper Drive (Part 1): Analog

APPLIED PCs

PSoC 101

FROM THE BENCH

Is There a Robot in Your Future?: Emerging Robot Technologies

SILICON UPDATE

Motoring (Part 2): Motor Control Chips and Software

94

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

89

Abacom Technologies

89

ActiveWire, Inc.

93

All Electronics Corp.

93

Amazon Electronics

81

AP Circuits

7

Atmel

91

Bagotronix, Inc.

81

Bellin Dynamic Systems, Inc.

39

Belsoft

18

Beta Layout Ltd.

49

Bitscope Designs

14

CadSoft Computer, Inc.

87

Carl’s Electronics

88

CCS-Custom Computer Services

92

Conitec

85

Cyberpak Co.

1

Cypress MicroSystems

65

CWAV

91

DataRescue

85

Decade Engineering

85

Digital Creation Labs Inc.

91

Digital Products

85

DLP Design

25

Earth Computer Technologies

90

EE Tools

(Electronic Engineering Tools)

26

EMAC, Inc.

35

Entrelogic Corporation

The Index of Advertisers with links to their web sites is located at www.circuitcellar.com under the current issue.

Page

71

ESC Boston

24

ExpressPCB

85

FDI-Future Designs, Inc.

87

Fitzhugh & Waggoner, Inc.

92

Front Panel Express

86

Hagstrom Electronics

21

HI-TECH Software, LLC

82

HOTChips 16 Symposium

48

ICOP Technology, Inc.

89

IMAGEcraft

31

Imagine Tools

86

Intec Automation, Inc

93

Integrated Knowledge Systems

91

Intrepid Control Systems

90

Intronics, Inc.

17

Jameco

64, 86

JK microsystems, Inc.

81

JR Kerr Automation & Engineering

9

Kg Systems, Inc.

83

LabJack Corp.

83

Lakeview Research

89

Lawicel HB

53

Lemos International

2

Link Instruments

69

Linx Technologies

34

MaxStream

88

MCC (Micro Computer Control)

11

Microchip

92

MicroControls

90

Microcontroller Services

95

Micromint

93

Micro Digital

92

microEngineering Labs, Inc.

88

MJS Consulting

90

Mosaic Industries, Inc.

41

Mouser Electronics

66

MVS

86

Mylydia, Inc.

C2

NetBurner

88

OKW Electronics, Inc.

92

Ontrak Control Systems

26

PCBpro

10

PCBexpress

87

PCB Fab Express

C4 Parallax, Inc.

85

Phytec America LLC

87

Phyton, Inc.

90

Picofab, Inc.

93

Pulsar, Inc.

88

Quality Kits & Devices

86

Quantum Composers, Inc.

87

R2 Controls

55

R4 Systems, Inc.

27

Rabbit Semiconductor

Page

Page

Page

11

Reach Technology, Inc.

25

Remote Processing

58

RoboNexus Conf. & Expo

93

Rogue Robotics Corp.

3

Scott Edwards Electronics, Inc.

88

Sealevel Systems

5

Sierra Proto Express

91

Softools

46

Syspec, Inc.

83

Systronix

89

TareTronics, Inc.

90

TAL Technologies

C3

Tech Tools

72, 73

Technologic Systems

87

Technological Arts

90

Tern, Inc.

86

Trace Systems, Inc.

91

Triangle Research Int’l, Inc.

46

Trilogy Design

47

Velocity Semiconductor

93

Weeder Technologies

91

Zanthic Technologies, Inc.

89

Z-World

September Issue 170

Deadlines

Space Close: July 9

Material Due Date: July 20

Theme:

Signal Processing

Bonus Distribution:

Embedded Systems Conference

Boston 2004

Wescon North America

A

TTENTION

A

DVERTISERS

Call Sean Donnelly now to

reserve your space!

860.872.3064

e-mail: sean@circuitcellar.com

INDEX OF ADVERTISERS

Preview of August Issue 169

Theme: Embedded Programming

background image

background image

W

hen something works so well for business it is only natural to assume that it can apply to vacations too. After all, if you take your laptop and stay

in touch with the office, you aren’t really running away on vacation. You’re merely changing the initiation point of your office e-mails. Of course, this pre-
sumes that the Internet exists where you are going.

Last month I spent a week vacationing near Manchester, Vermont. To make a long story short, I knew I was in trouble when the innkeeper said,

“Wideband what?” when I asked about connecting to the Internet. It was either make a long-distance telephone call to New York for the nearest IP, or
hunt for one of the few local businesses with a cable modem connection. None of these included the hotels. Evidently the leaf peepers who overwhelm
Vermont every year prefer low-tech entertainment like beer and brat. According to the innkeeper, the first communication priority, if any, would be to
add some cell phone service. Welcome to a black hole.

The search wasn’t going to be easy and it called for desperate measures. From everything I could tell, the only pastimes in Manchester are either

shopping in one of the local factory outlets or hanging out at one of the many restaurants and cafes while waiting for the next factory outlet to open. If
there is a hip cafe with Internet service, no one seemed to know where it is. I decided the only way to find an Internet connection in this town was to
take PC in hand and go war driving.

War driving is when you go driving through a neighborhood with a wireless-enabled notebook computer and map houses and businesses that have

wireless access points. War driving comes from a play on the older term “war dialing.” Film buffs should recognize war dialing from the 1983 movie
War Games with Matthew Broderick, in which his character uses an IMSAI computer to automatically call telephone numbers looking for any modem-
connected games and bulletin-board systems. He inadvertently ends up with a direct connection to a high-level military computer that gives him con-
trol over the U.S. nuclear arsenal. Obviously, everything hits the fan after that.

If there was a coffee house with Wi-Fi, I could simply tell by turning on my laptop and driving down the street. So, with my trusty Sony TR3A (3

lbs, 10.6² screen) on the dashboard, I drove through Manchester’s two main streets and looked for traces of 802.11b. To my amazement, I picked up
seven different signals in 2 miles. None were encrypted!

I got a signal outside one cafe in the center of town. As I walked in with my computer, the screen popped up with a little notice saying that Internet

service was $6.95 per day and I should sign up now. I noted the location as a backup in case I couldn’t find free service someplace else. About 10¢
out the cafe door, I picked up a much stronger Wi-Fi signal with a random-looking alphanumeric ID. There wasn’t any commercial business that looked
like it could be the source. Curious, I clicked on Internet Explorer and instantly my home page appeared. I had no idea whose Wi-Fi it was, but what
the heck, it worked. I got back in my car and downloaded my e-mail.

After my quick unofficial access, I decided to see whether or not the other five signals I had picked up could be accessed as easily. It turned out

that three allowed me to connect with no trouble. The other two did not register as encrypted, but they did not allow me access for some reason, which
I did not pursue. Certainly, if I had made a directional antenna out of a coffee can like most war drivers, I might have picked up many more signals,
but my exercise was to get a quick e-mail fix, not hijack all the Wi-Fi hot spots in Vermont.

The best news was that I did indeed find a free Internet cafe among the seven signals I trapped. One of the great attractions in Manchester is the Northshire

Bookstore. Recently they added a large cafe that includes free Wi-Fi along with a computer for public use. Thanks to Northshire, now it’s cappuccino with Wi-Fi.

Of course, this discussion can’t help but bring up the question of Wi-Fi connection legality. Unfortunately, every government entity has an opinion

and an equally ridiculous unenforceable consequence to go along with it. The all too typical pattern of legal thought these days is to presume that the
guy who installs the unencrypted, publicly placed so everyone can trip over it, omnidirectional broadband transceiver has no responsibility. It’s the
unfortunate sop with a laptop who happens to walk within range of this transmission who is the bad guy. Come on now.

The age of passing the buck has to stop. If we are going to have laws governing Wi-Fi and similar wireless technologies, it should be presumed

that anything with public access is fair game if it isn’t encrypted or otherwise encoded to prohibit access. Instead of blaming the guy sitting in a coffee
shop picking up a signal with his laptop, people should be forced to take responsibility for their Wi-Fi transmission when they install it. If they don’t want
it to be public, they should turn on the safeguards. Accessing a public signal should not trigger legal consequences. But, hacking a signal when some-
one has taken pains to tell you that it isn’t public should.

War Driving

steve.ciarcia@circuitcellar.com

96

Issue 168 July 2004

CIRCUIT CELLAR

®

www.circuitcellar.com

by Steve Ciarcia, Founder and Editorial Director

PRIORITY INTERRUPT

background image
background image

Wyszukiwarka

Podobne podstrony:
circuit cellar2001 07
circuit cellar2000 07
circuit cellar1995 07
circuit cellar2002 07
circuit cellar1993 07
circuit cellar1994 07
circuit cellar1996 07
circuit cellar1997 07
circuit cellar2004 07
circuit cellar1994 07
circuit cellar1996 07
circuit cellar1995 07
circuit cellar1997 07
circuit cellar1993 07

więcej podobnych podstron