circuit cellar2003 02

background image

7

9

25274 75349

0 2>

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)

COMMUNICATIONS

GPS-GSM Navigator

DIY Parallel Port Solution

Network Enabling

Wireless Humidity Meter

#151 February 2003

background image
background image

SK-78ST

is a new 7.8", color, touch LCD. Each

kit includes PCI controller, touch controller,
inverter and adaptor cable. The SK-78ST is a
great low-cost alternative to interface with SBC
computers, in just about any embedded
application. Over 95,000 in stock!!

The picL is a PIC 16F877

microcontroller based development

board with a 240x480 graphical that

comes programmed to be used as a

serial RS-232 LCD. It features-

multiprotocol and complete

reprogrammability.

The EG9013 is a 6.3" monochrome LCD.
With an inventory of over 25,000 pieces,
these LCDs are priced to sell!

The mARMalade is a low-cost 720T
ARM, single board computer module for
LCD devices utilizing from QVGA mono-
chrome to SVGA color TFT. The
LH79520 combines a 32-bit ARM7TDMI
RISC, 8KB Cache, MMU, color LCD
controller, and local SRAM.

Touch Screens

High Bright LCD Monitors

LCD Televisions

Controllers

Backlight Assemblies

SBC Kits

Microcontroller Boards

Panel Mount LCDs

Character Displays

Replacement LCDs for

Laptops

Serial Displays

Video Compatible LCDs

Customization

Portable Monitors

www.earthlcd.com

Phone 949.248.2333 ext 233
Fax 949.248.2392

32701 Calle Perfecto
San Juan Capistrano, CA 92675
sales@earthlcd.com

GOT EMBEDDED?

Made in the USA

The World Wide

LCD Source

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

e’re one month into the new year. For all the

hard-working, disciplined engineers who read this

magazine, I hope that means a renewed dedication to

designing that next must-have device. I, on the other

hand, never aspire to accomplish anything so productive with my New
Year’s resolution, and I count that as a success.

February used to be when I accepted defeat over fulfilling a New Year’s

resolution. After years of traumatic failures (e.g., not becoming the first
teenage astronaut), I no longer bother drumming up anything special to be
disappointed about after I lose interest in bettering myself. Who needs the
stress? In recent years, I’ve stuck to ineffectual promises to do things like
stop eating cheese. Then, I’d bargain with myself to simply eat less cheese.
My doctor told me that I’m lactose-intolerant about a decade ago, so really,
this is just a reaffirmation of my typical diet. Nevertheless, I usually break
the resolution immediately because there’s always a Brie tray out on New
Year’s Eve. But, you see, the vitamin D and calcium in the cheese mitigate
my inhaling of a quarter-pound of lactose. So, in the end, I default on my
resolution; but have I actually failed? I think not. With the rest of the dairy
products I’m missing out on, I need that Brie to fend off osteoporosis. The
same goes for feta.

I make resolutions I can handle by setting the bar low. Cheese depriva-

tion doesn’t exactly qualify as a life-altering feat, so failing causes minimal
guilt. For a successful triumph over the dreaded New Year’s resolution, you
have to put a positive spin on things. Choose words like “less” instead of
“no,” and stress the good (e.g., vital nutrients) in that decision.

A simple stress-free resolution to start off the new year works for me.

Maybe you would like to set the bar slightly higher than doing something like
avoiding dairy products. If you haven’t already come up with a resolution for
yourself, I have a suggestion. Become an author. You probably have plenty
of ideas for dynamic projects and compelling articles, so sending in a pro-
posal shouldn’t be too difficult. As you’re heading back to your workbench,
you might want to keep our upcoming themes in mind. Issues fill up quickly,
so it’s a good idea to send in your proposals about a month before the
deadlines. For more information, please read the Author’s Guide on our web
site at www.circuitcellar.com/authors.

Theme

Article Deadline

Analog Techniques

Feb. 3, 2003

Measurement & Sensors

Mar. 3, 2003

Embedded Programming

Apr. 1, 2003

Wireless Communication

May 1, 2003

Internet & Connectivity

June 2, 2003

Data Acquisition

July 1, 2003

Embedded Development

Aug. 1, 2003

Graphics & Video

Sept. 1, 2003

4

Issue 151 February 2003

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

ADVERTISING SALES MANAGER

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 © 2001 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

ACCOUNTANT

Jeff Yanco

ART DIRECTOR

KC Prescott

GRAPHIC DESIGNER

Mary Turek

STAFF ENGINEER

John Gorsky

QUIZ COORDINATOR

David Tweed

TASK

MANAGER

Cover photograph Ron Meadows—Meadows Marketing

PRINTED IN THE UNITED STATES

w

Triumph Over New Year’s Resolution

jennifer.huber@circuitcellar.com

background image

CANbus

Starter Packs

PCI/ISA/PCMCIA/PC104/

VME/cPCI format boards.

Software drivers for most OS’s.
CAN/Ethernet bridges, etc.

Saelig Company

brings you unique,

easy-to-use control and instrumentation
products to USA, mostly from Europe,
but now from worldwide. (Need USA
sales help - overseas companies?)

Our customers comment
on our unrivalled FREE
after-sales support.

“Hi - I’m Alan

- you can email me at
saelig@aol.com for free
advice for your control or
measurement problem.”

Saelig

C

o. Inc.

585-425-3753 • Fax: -3835

www.saelig.com • saelig@aol.com

• Plug directly into PC

self powered!

• Drive any RS422

or RS485 devices.

• Send control and data

100s of feet!

K422/K485, 25pin > 9pin . . .

$

69

K2 9pin > 9pin . . . . . . . . . .

$

69

Isolate RS232/422/485 signals

K4xx-ISOL 25pin

self-powered . . . . . . . .

$

139

NEW! 9p-9p K3-ISOL - $129!

Make PCs

talk I

2

C

easily!

RS232 to RS422/485

self-pwrd converters

• Store analog/digital

/GPS or CANbus data
on FlashATA cards -
read on your own PC!

• > 100 customizable

software modules—
finish REALLY quickly.

• 8ch 10bit A/D, 33 I/Os, I

2

C, 2 x

RS232, interrupts, sleepmode,
pre-emptive multitasking, easy to
attach LCD or keypad.

• CANbus adapter—recompile or log

data over huge network!

PCMCIA

Datalogger TDS2020

lowpower PCcard logging

PC-based

Instruments

ADC-10

8-bit

$

85

through

ADC-216

16-bit

$

799

—display

scope, spectrum and meter

simultaneously. Connect to PC

parallel

port

and

start

gathering/displaying

data

immediately!

• EnviroMon

temperature

logging/alarm system
standalone or with PC.

TH-03

thermistor-

to-PC converter

TC-08

8x thermocouples

N

O

W

!

G

P

S

L

o

g

g

i n

g

check out what’s new at www.saelig.com!

Industry-standard card for PC’s
ISA/P-port/PCI versions
2-6V I2C bus versions

• Master, Slave or Bus monitor

• Control or program I

2

C devices

ICA90/93LV - PICA90/93LV PCI90/93LV

- from

$299!

USB ic’s

USB <> RS232 easily!!

US232: USB <> RS232 cable

$35

SMD PCB adapters

for prototyping

“How

to I

2

C”

www.saelig.com

by

Janz

for

all

com

puters

DrDAQ plugs into a PC for useful
datalogging at school, college,
industry. Built-in sensors for light,
sound, temp. or add pH sensor and
run one of the many

suggested

science experiments!

- only $99!

DrDAQ

Educational

Datalogger

with built-in

sensors!

www.drdaq.com

Customer list inc: Intel,
Compaq, Philips, NEC,
Kodak, Nokia, US Military,
Microsoft, Dell, Xerox,
Universities, T.I., Dalsa,
Harris, Litton, Sony, J&J,
Thomson, H-P, Agilent, etc.

NEW!!

12-bit

100Ms/S

dual-ch

scope

adapter

ADC-212/100

$1015!!

WILKE TIGER MODULES

multitasking powerful BASIC building blocks

BASIC Tigers

are

tiny multitasking
computer systems

for quick project

d e v e l o p m e n t .

Powerful features and low

prices make Tigers a number

one choice for developers: super-fast

development cycle, high reliability products,
>100,000 instructions/s, up to 38 I/O lines,
A/D, D/A, I2C, SPI, , text/graphic LCD inter-
face, up to 50,000 lines of BASIC, RTC/watch-
dog timer. Easy connection and software for

Expansion Modules

for CANbus, TCP/IP for

net-access, opto-I/O, 64 analog inputs, 64 dig-
ital outputs, high-current outputs, etc.

TIGER Starter Kits start from $159!

NEW!

Euroquartz filters/crystals!

Remote control & data acquisition

BIT

link

®

power & data

on two-wire

control network

2-year

self-contained

DATALOGGERS for volts, switch-

closures, events, flow, pressure, etc.

See www.abidata.be for details

background image

6

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

USB Parallel Port

Jan van de Kamer

MCS-51 SBC for the Classroom
Part 1: Hardware

Praveen Deshpande, Prajakta Deshpande, & Viraj Bhanage

GPS-GSM Mobile Navigator

Ma Chao & Lin Ming

A Wireless Indoor/Outdoor Humidity Meter

Ken Macleish

Short Solutions
Simple EL-Lamp Driver

D

.

Prabakaran

I

ROBOTICS CORNER
Easy Image Processing
Camera Interfacing for Robotics

Daniel Herrington

I

APPLIED PCs
A P89C668 Development Board for 8051Fans

Fred Eady

I

ABOVE THE GROUND PLANE
Nonlinear Mixing

Ed Nisley

I

I

FROM THE BENCH
Newcomer Nitron
Motorola’s Leading 8/16-Pin MCUs

Jeff Bachiochi

I

SILICON UPDATE
Working the Net’

Tom Cantrell

COLUMNS

ISSUE

Task Manager
Jennifer Huber
Triumph Over New Year’s
Resolution

New Product News
edited by John Gorsky

Test Your EQ
edited by Dave Tweed

Advertiser’s Index
March Preview

Priority Interrupt
Steve Ciarcia
Real People

4

8

11

94

96

151

12

20

38

30

FEA

TURES

Contest-Related Articles

62

78

76

54

68

44

background image

Check out AVR today at www.atmel.com/ad/fastavr

Introducing the Atmel AVR

®

. An 8-bit MCU that

can help you beat the pants off your competition.

AVR is a RISC CPU running single cycle instructions.

With its rich, CISC-like instruction set and 32 working registers,

it has very high code density and searingly fast execution–up to
16 MIPS. That’s 12 times faster than conventional 8-bit micros.
We like to think of it as 16-bit performance at an 8-bit price.

With up to 128 Kbytes of programmable Flash and EEPROM,

AVR is not only up to 12 times faster than the MCU you’re using
now. It’s probably 12 times smarter, too.

And when you consider that it can help slash months off your

development schedule and save thousands of dollars in project
cost, it could make you look pretty smart, too.

AVR comes in a wide range of package and performance

options covering a huge number of consumer and industrial
applications. And it’s supported by some of the best development
tools in the business.

So get your project started right. Check out AVR today at

www.atmel.com/ad/fastavr. Then register to qualify for your free
evaluation kit and bumper sticker. And get ready to take on the world.

Our AVR microcontroller is
probably 12 times faster than
the one you’re using now.

(It’s also smarter.)

AVR 8-bit RISC Microcontrollers

Memory Configurations (Bytes)

Debug and

Processor

Package

Flash

EEPROM

RAM

Development Tools

tinyAVR

8-32 pin

1-2K

up to128

up to128

Available Now

low power AVR

8-44 pin

1-8K

up to 512

up to1K

Available Now

megaAVR®

32-64 pin

8-128K

up to 4K

up to 4K

Available Now

© 2002 Atmel Corporation. Atmel and the Atmel logo are registered trademarks of Atmel Corporation.

R

background image

LOW-COST RF TRANSCEIVER

The TRF6901 is intended for use as a low-cost FSK or

OOK transceiver to establish a frequency-programmable,
half-duplex, bidirectional radio frequency (RF) link in the
860- to 930-MHz band. The single-chip transceiver oper-
ates down to 1.8 V with an on-board DC/DC converter
and is designed for low-power consumption. The synthe-
sizer has a typical frequency resolution of approximate-
ly 200 kHz and features a fully integrat-
ed voltage-controlled oscillator
(VCO). There is also code available from
TI’s MSP430 microcontroller family to
program this device.

Typical uses include applications in

wireless data communications, PDAs,
remote sensors, wireless metering, secu-
rity systems, keyless entry, home
automation, and garage door openers.
Products employing this device can

NEWS

8

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

NEW PRODUCT

Edited by John Gorsky

wirelessly transmit and/or receive up to 64 Kbps of
information at distances greater than 200 m.

The chip features programmable crystal frequency trim-

ming, programmable brownout detection, 9-dBm typical
output power, and an integer-N synthesizer with fully
integrated VCO. Also featured is an on-chip reference
oscillator and PLL, a linear receive strength signal indi-

cator (RSSI), and a three-wire serial port
interface. Minimal external components
are required for this 48-pin, low-profile
plastic quad flat package (PQFP) device.

The TRF6901 is priced at $2.75 in

quantities of 1000.

Texas Instruments, Inc.
(972) 644-5580
www.ti.com

LOW-COST 8051 CONTROLLER

The VERSA 1000 (VRS1000-40) is a low-cost, 8-bit,

8051-based microcontroller with in-system program-
ming (ISP) capability.

With its hardware features and powerful instruction

set, the VRS1000-40 can easily serve as a versatile and
cost-effective controller for applications that require up
to 36 I/O pins and 64-KB flash memory for either pro-
gram, data, or both. To program the on-chip flash mem-
ory, a commercial writer is available. The flash memory
can be programmed in either serial or parallel interface
with the ISP feature. The VRS1000-40’s ISP capability
makes it easy to program via an RS-232
transceiver/level shifter.

The VRS1000-40 is available in 44-PLCC and 44-QFP

packages, and it’s pin compatible with other 8051-based
microcontrollers. Key fea-
tures include: three 16-bit
timers/counters, a watchdog
timer, and four 8-bit I/O
ports plus one 4-bit I/O port
for PLCC or QFP packages.
The device also features a
full-duplex serial channel,
nested interrupts, two priori-
ty level interrupts, power save modes, and a code pro-
tection function.

The VRS1000-40 is supported by a demo system, and

it’s compatible with Keil compilers and the Raisonance
IDE/Compiler/Assembler, the latter of which is freely
available from Goal.

The price for the VERSA 1000 in quantities of 1000 is

$3.40.

GOAL Semiconductors, Inc.
(514) 871-2447
www.goalsemi.com

68HC9S12DP256 DEVELOPMENT BOARD

The EVBplus9S12DP256 board is a low-cost, feature-

packed development board for the new Motorola HCS12
microcontroller family. It’s compatible with the
Motorola 9S12DP256EVB board and other similar devel-
opment boards from Axiom and TechnologicalArts, but
it also incorporates many on-board peripherals that
make this board a better value for users.

The state-of-the-art MC9S12DP256 controller is the

most powerful chip in the family, and it’s loaded with
hardware features, such as 25-MHz bus speed, 256-KB
flash memory, 12-KB SRAM, and 4-KB EEPROM. On-
chip peripherals include dual SCIs, triple SPIs, I

2

C, five

CAN modules, two 10-bit eight-channel ADCs, eight
PWMs, and eight 16-bit timers. It can also be used in
evaluation and development of all the other family
members, such as A series and D series.

The on-board hardware includes BDM in and BDM

out ports, a solderless breadboard, four robot servo out-
puts, a 2 × 16 LCD module, a 4 × 4 keypad connector, a
fast SPI expansion port, a speaker, a four-digit seven-seg-
ment LED display, eight data-LED indicators, and four
mode-LED indicators. Also included is a DIP switch,
four push buttons, IR and RF transceivers, an RS-485
interface, three CAN ports, and dual SCI DB9 connec-
tors. All I/O lines in the 112-pin male header and female
receptacle provide easy access for your experiments on
the breadboard.

Supplied with an RS-232 cable, which is used for con-

necting to a PC serial port and
an AC adapter to power the
board, the board is priced
starting at $145.

EVBplus.com
(630) 894-1440
www.evbplus.com

background image

Use the Cypress PSoC

instead of an MCU for

more flexibility, fewer parts and lower cost.

The versatile PSoC

Programmable System-on-Chip

is

the world’s first mixed signal array that lets you custom
configure the exact functions you need. And it has an
on-chip controller to manage your application and run
the configuration process.

Graphically select, place, and interconnect
the peripherals you want and adapt the
architecture with PSoC Designer

software

Dynamically reconfigure a single PSoC
chip multiple times—changing functionality
on the fly in any application

Reduce BOM cost by reducing the number
of external components

MCU

later.

Cypress,

PSoC,

Programmable-System-on-Chip

and

PSoC

Designer

are

trademarks

of

Cypress

Semiconductor

Corporation.

©2002

Cypress

Semiconductor

Corporation.

All

other

Trademarks

are

the

property

of

their

respective

owners.

There are many more blocks to work with—

and thousands of configurations to choose from.

PSoC Designer

software is free for download, with

full-featured emulation hardware starting at $248.

Option #8926

8-bit PWM

Inverting Amplifier

IrDA

Transmitter

11-bit

Delta Sigma A/D

Band Pass Filter

Analog

Comparator

8-bit Counter

8-bit DAC

24-bit Timer

Low Pass Filter

Option #1530

Analog

Comparator

Instrumentation

Amplifier

12-bit

Incremental A/D

Notch Filter

16-bit CRC

Option #625

Analog

Comparator

16-bit PWM

Programmable

Gain Amplifier

Instrumentation

Amplifier

IrDA

Transmitter

11-bit

Delta Sigma A/D

8-bit DAC

12-bit

Incremental A/D

Band Pass Filter

8-bit Counter

Option #4237

CPU

Analog

Comparator

Your Customized Mixed Signal

platform in 60 minutes or less

Build your custom PSoC

with programmable analog

and digital functions from our extensive library.

To learn more about our innovative PSoC solutions

and to enter a drawing to win a PSoC Development

Kit, visit www.cypress.com/ad/mcu

.

background image

10

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

NEW PRODUCT

NEW PRODUCT

ROBOT BASE

The Blue Robot Base now includes additional micro

controller support. This new version allows the follow-
ing boards to be mounted to the robot: Basic Board Jr,
JStamp development board, Adapt12 system, OOPIC 1
and 2, Mini Robomind, Parallax Board of Education,
ISOPOD development board, Dontronics DT005
Passive motherboard, and the Rogue Robotics SIMM-
BOT system.

The Rogue Blue Robot Base is an 8

round base with

three high levels, two central 3

servo-driven wheels,

and sensor mount mounting holes on the first and sec-
ond levels for greater flexibility and ease of installation.
The base is a highly stable platform for smooth surface
experimentation and research. It’s ideal for hobbyists,

educators, researchers, and robot enthusiasts.

The Rogue Blue robot base sells for $119. It is also

available as a full robot kit bundled with the Parallax
Board of Education ($219) or as a Rogue Robotics SIMM-
BOT ($219). And for as little
as $79, a Parallax BOE-BOT
can be upgraded to a Rogue
Blue robot with the Rogue
Blue BOE expansion pack.

Rogue Robotics
(416) 707-3745
www.roguerobotics.com

COST-EFFECTIVE 14-PIN FLASH MEMORY PIC

The PIC16F630 and PIC16F676 are new 14-pin, flash

memory microcontrollers that feature an integrated ana-
log-to-digital converter, precision internal oscillator, and
quick start-up.

The PIC16F630 and PIC16F676 microcontrollers are

code-compatible with Microchip’s current PIC12F629
and PIC12F675 eight-pin flash memory devices, allow-
ing designers to reuse software and hardware in existing
platforms, thus lowering overall development costs and
time-to-market concerns. The devices offer a typical
standby current of 100 nA at 2 V and a wide operating
voltage range from 2 to 5.5 V.

A quick start-up of 2 ms, and the ability to run a timer

from an external crystal while in Sleep mode make the
devices ideal for applications requiring low-power opera-
tion. Additionally, the peripheral features can be enabled
by individual on/off controls to conserve power.

The PIC16F630 and PIC16F676 offer 1792 bytes of

flash program memory, 64 bytes of RAM, and 128 bytes
of EEPROM with one million erase/write cycles. The
PIC16F676 features a 10-bit analog-to-digital converter
with eight channels that can use either VDD or an
external voltage reference. Additional peripherals avail-
able on both devices include a precision internal oscilla-
tor that is ±2% stable over a wide temperature and volt-
age range, a comparator with an internal voltage refer-
ence with 32 selectable voltage levels, and brownout

reset (BOR).

Pricing in high vol-

ume is $0.79 each for
the PIC16F630, and
$0.91 each for the
PIC16F676.

Microchip Technology Inc.
(480) 792-7668
www.microchip.com

MINIATURE FOUR-DIGIT LCD

The LCD-S401M14TF is a new miniature four-digit

LCD with characters only 0.174

high. It incorporates

three decimal points, allowing numbers ranging from
0.001 to 9999 to be displayed. It also incudes units of
measure for pressure indication in PSIA, Mpa, and kPa.
The display is available with customer-specified features
in production quantities as small as 1000 units. This
LCD is ideal for equipment or instruments where a
miniature pressure display is required, or in any applica-
tion requiring a compact, four-digit display with
extremely low power consumption.

The transflective LCD utilizes twisted nematic (TN)

LCD fluid against a gray background for good readability.
An optional backlight is also available, allowing use in
environments with low—or even zero—ambient light.

The LCD is housed in a single in-line package with

thirteen 0.25

-long leads on 0.06

centers. The total

package footprint size is 0.8

× 0.4

. Package thickness is

0.11

maximum. The device operates from a 5-VAC sup-

ply over a temperature range of 0 to 50°C. The storage
temperature range is –20° to 70°C.

Typical pricing for the standard configuration is $0.32

in quantities of 5000.

Lumex, Inc.
(800) 278-5666
www.lumex.com

NEWS

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

11

Problem 5

Can an induction motor (e.g., squirrel-

cage type) be used as a generator?

Contributed by Dave Tweed

Problem 6

What is "lithotripsy"? What is the

shape of the sound reflector and why?

Contributed by Dave Tweed

Problem 7

Why does this reconstruction of a

20-kHz sine wave sampled at 44.1 kHz show ripple in

its amplitude?

Contributed by Dave Tweed

Problem 8

Assume you can make a cigarette out

of six cigarette stubs. If you are given 36 cigarettes,

how many can you smoke?

Contributed by Naveen PN

Problem 1

Which of the following are legiti-

mate parts of a URL?

• protocol

• username

• password

• host

• port

• path

• parameter

• query

• fragment

Contributed by David Tweed

Problem 2

Which parts of a URL are used

by the client (browser), and which parts are

used by the server?

Contributed by Dave Tweed

Problem 3

An analog signal channel car-

ries frequencies from 1 to 11 kHz. What is the

minimum frequency at which signals from this

channel must be sampled? What is the sam-

pling interval,

T

, in this case?

Contributed by Naveen PN

Problem 4

Suppose that the SNR of this

channel is 8:1. What is the maximum number of

bits per second that this channel can theoreti-

cally carry?

Contributed by Naveen PN

What’s your EQ?

—The answers and 4 additional

questions and answers are posted at

www.circuitcellar.com/eq.htm

You may contact the quizmasters at

eq@circuitcellar.com

Te s t Yo u r E Q

CIR

CUIT

CELLAR

Edited by Dave Tweed

background image

12

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ife is becoming

more and more dif-

ficult for the electron-

ic enthusiast who wants

to connect his own hardware to a PC.
In the old days, a handful of standard
logic chips, a parallel printer port, and
a simple DOS program would do the
job. Nowadays you need knowledge
of microcontrollers, Windows device
drivers, and hardware protocols like
USB. Windows 98 still allows direct
access to the registers on the printer
port hardware, but newer versions of
Windows such as Windows 2000
strictly forbid this. Even worse, there
are plans to declare parallel and seri-
al ports obsolete!

Of course, it is always possible to

resist the new generations of PC hard-
ware and operating systems by using
the Pentium 233-MHz machine run-
ning Windows 95. But eventually there
will come a time when new software
releases of your favorite CAD systems
will not run on the old machine. Sure, a
new PC is quickly bought, but what
do you do with your hardware projects
that took many hours of time to build?

One possible solution is a USB-to-

standard parallel port adapter that
doesn’t use a microcontroller or other
programmable logic. Although there is

no need to develop a Windows device
driver for this adapter, it is unfortu-
nately necessary to modify your proj-
ect software. There is no way around
this. On the bright side, you get some-
thing back for this effort: now multi-
ple adapters can be connected to the
PC simultaneously. Note also that
this adapter cannot be used to drive an
actual printer with standard printer
drivers; the reasons for this will
become clear shortly.

PARALLEL PORT EMULATION

If you ignore bidirectional modes

(e.g., EPP and ECP), a standard parallel
port has 12 outputs and five inputs
that all operate at TTL levels, as
shown in Figure 1. Reproducing this
pinout is not difficult. Two 74HCT273
chips provide 16 outputs, and eight
inputs can be generated by using a
74HCT541. The problem now becomes
a question of connecting the resulting
8-bit bus to the serial USB interface. It
seems Future Technology Devices
International (FTDI) considered this
question as well, and its answer was
to develop the versatile FT8U245AM
USB-to-parallel interface chip.

The FT8U245AM is a full USB

V.1.1-to-parallel converter that con-
tains all of the logic required to identi-
fy itself as a USB device, to initialize
the interface, and handle all USB com-
munication. Your project hardware
has two buffers that it can access, one
of 384 bytes for sending data to the PC
and one of 128 bytes that contains the
data received from the PC. As a bonus,
FTDI supplies a free Windows device
driver that can be downloaded from
the company’s web site.

Unfortunately, the FT8U245AM is

available only in a QFP package.
There are no sockets for this package
and it’s difficult to solder by hand.
However, it can be done and you
need to build the interface only once.
Figure 2 lists the pinout of the chip.
I’ll discuss the main signals, but for
the full details, download the
datasheet from the FTDI web site.

USB OPERATION

The USB hardware and driver soft-

ware on the PC work together to cre-
ate virtual bidirectional pipelines for

USB Parallel Port

l

With each passing
generation of PC and
OS technology, it’s
becoming harder for
you to connect your
home-built hardware
to your computer.
However, with Jan’s
USB-to-standard par-
allel port adapter, you
will have no problem
connecting your own
hardware.

Jan van de Kamer

FEATURE
ARTICLE

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

13

ated as output Q1 of the state
machine goes low and Q2
goes high. This could be inter-
preted by the FT8U245AM
as the next read pulse.
Fortunately, the parasitic
capacitance of the outputs of
the 74HCT4017 results in a
small overlap of the output
signals, and the measure-
ments show no spikes in the
decoded signals.

A full cycle of the state

machine requires 10 clock
pulses. If at that time there is
more data in the receive
buffer, then a second cycle
will follow immediately. This

can be used to boost the speed of the
interface significantly. The maximum
speed of the USB interface is 12 Mbps.
And, when the overhead of addresses
and checksums are subtracted, this
results in an effective data transfer
rate of 1 MBps. The FT8U245AM is
capable of handling this data rate, so
the USB Parallel Port’s hardware must
be able to keep up. Because two bytes
are read per cycle, the state machine
must be able to execute 524,288 cycles
per second. Each cycle requires 10 clock
pulses, so an oscillator frequency of a
little less than 6 MHz is sufficient.
The values of R10 and C4 are selected
to produce this frequency.

To put the outputs into known

states after a power-up cycle, a reset
circuit is incorporated using R12
through R14, Q1, and C8. A NAND

data flowing between an appli-
cation program and a particular
USB device. When an applica-
tion writes a byte via the driv-
er API, that byte eventually
appears in the receive FIFO of
the FT8U245AM. Similarly,
when a byte is written by the
hardware to the chip’s transmit
FIFO, it becomes available to
the software a short time later.

This project takes advantage

of that in the simplest possible
way by requiring that the
application send data 2 bytes at
a time, representing the 16 out-
puts. For every 2 bytes sent,
the hardware returns 1 byte
representing the eight inputs. This
means that the software must always
execute a read function after every
2-byte write function in order to pre-
vent the incoming pipeline from over-
flowing. These simple rules mean that
the hardware can be nothing more
than a simple state machine that gen-
erates a series of signals that will
always be the same. A GAL or PAL
would be ideal for this job, but either
would require access to a specialized
programmer, and I want to avoid that.

Figure 3 shows the order in which

the different signals need to be gener-
ated to latch the output data into
two 74HCT273 8-bit latches for the
16 outputs and to read one 74HCT541
buffer for the eight inputs. The *RXF
signal from the FT8U245AM is used
as a trigger for the state machine. The
first step is to lower the *RD signal
releasing the first byte for the outputs,
which are clocked into the first
74HCT273 by pulsing its clock sig-
nal (CP1). Both CP1 and *RD can be
unasserted at the same time.

Another lowering of *RD releases the

second byte of outputs that get clocked
in the second 74HCT273 by a pulse on
CP2. After unasserting *RD the second
time, the *RXF signal should be at a
high level because all of the data has
been read from the receive buffer. The
next step is to drive the inputs onto the
data bus by lowering the *OE signal of
the 74HCT541, clocking the current
state of the inputs into the transmit
buffer of the FT8U245AM on the
falling edge of the WR signal. When

this sequence is completed, the state
machine will stop in state 0 until
new data is received.

THE SCHEMATICS

Figure 4 presents the schematics for

my USB Parallel Port (see Photo 1),
including the FT8U245AM (U1) along
with the input and output buffers U3
through U5. The resistor array R9
makes sure the inputs are always
well-defined even if they’re not used.
Connector CN2 is a 25-pin D-sub con-
nector identical to those found on
the rear of a PC. It carries 12 of the
outputs and five of the inputs. The
remaining inputs and outputs are con-
nected to CN3. These will not be used
for existing hardware projects, but it
would be a shame not to make them
available for future projects.

The heart of the state

machine is U6, a 74HCT4017
10-state counter with fully
decoded outputs. R10, C4, and
a NAND Schmitt trigger cre-
ate an oscillator for this
counter. It starts only when
there is data in the receive
buffer of the FT8U245AM
(*RXF = 0) and runs until the
state machine is finished pro-
cessing the data. The NOR
gates of U8 and a NAND
gate in U7 combine the out-
puts to generate the signals
shown in Figure 3.

Theoretically, there can be

a timing problem on the *RD
signal. A glitch can be gener-

D7

D6

D5

D4

D3

D2

D1

D0

13

11

9

8

7

6

5

4

3

2

18

17

16

15

14

1

*B

USY

AC

K

P

APER

SELECT

ERR

OR

*SELECT

INT

*A

UT

OFEED

*STR

OBE

25-pin female D-sub connector

= Output

= Input

19

20

21

22

23

24

25

12

10

Figure 1—

The standard PC printer port connector is mapped to the control

registers of the PC hardware.

EECS

RCCLK

AV

C

C

A

GND

XT

OUT

XTIN

VCC

GND

*EEGNT

*EEREQ

*RXF

VCC

*TXE

WR

EESK

EEDATA

VCC

*RESET

TEST

3V3OUT

USBDP

D1

D2

D3
D4

D5

D6
D7

GND

*RD

USBDM

D0

17

24

FTDI

FT245AM

XXYY

32

25

9

16

1

8

Figure 2—

From the top of the 32-pin Quad Flat Pack package,

you can see the pinout of the FT8U245AM.

background image

14

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

gate produces an inverted signal to reset
the state machine. All outputs are
reset to a low level. The FT8U245AM
also receives a reset so that the USB
Parallel Port is in a well-defined state
and ready to receive data.

VOLTAGE AND CURRENT

Multiple voltages are required for

the USB Parallel Port. The inputs and
outputs must operate with 5-V logic
levels in order to be compatible with
standard printer ports. However, the
data lines of the USB interface must
operate at 3.3-V logic levels. This volt-
age is generated by a low-dropout
regulator on the FT8U245AM. Pin 6
provides a 3.3-V power supply that’s
derived from the voltage on the
chip’s V

CC

pins. All other data and

control signals of the FT8U245AM
use the V

CC

level, which can be

between 4.4 and 5.25 V.

This voltage range is exactly what’s

available on a standard USB interface,
which allows USB hardware to use the

PC’s power supply instead of an exter-
nal power supply. The USB host inter-
face supports an initial current of
100 mA. After the USB device is con-
figured, it can request an increase in
current to a maximum level of 500 mA.
The host controls this. If there is no
power available, the request is denied
and the device is shut down.

As you know, a standard printer

port does not provide a power supply
connection; so, all of your hardware
projects already have external power
supplies that also can be used to
power the USB Parallel Port. U9 pro-
duces a stable 5 VDC from any input
between 8 and 12 VDC, and diode D1
protects the hardware from accidental
reverse polarization.

A solid copper heatsink is designed

into the PCB that has an area of
4.5 cm

2

. This produces a thermal

resistance of about 42°C/W, which
allows U9 to dissipate up to 2.6 W.
The maximum output current depends
on the input voltage. At 9 VDC, U9
must drop 4 V, which limits the cur-
rent to 2.6 W divided by 4 V, giving a
total of 650 mA. If more current is
required, U9 must be mounted stand-
ing up and attached to an aluminum
heatsink. It’s also advisable to build
up the ground and power lines to con-
nector CN2 with solder in order to
reduce their resistance.

Figure 4—

The FTDI FT8U245AM and standard CMOS series for logic are the basis of the electronics required to build your own USB parallel port.

*RXF

*RD

CP1

CP2

*OE

WR

Figure 3—

The various control signals must be gener-

ated in a particular order. The blue arrows indicate that
the signal is flank-triggered.

background image
background image

16

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

In the USB design rules, it states

that an externally powered device is
not allowed to put voltage on the sig-
nal lines if the PC is switched off.
This requires the USB Parallel Port to
cut off the 3.3 VDC generated by the
FT8U245AM because current can flow
into the interface via pull-up resistor
R3. To prevent this, transistor Q2 in
combination with resistors R15 and
R16 block the 3.3-VDC power supply
to R3. As soon as the PC is switched
on, the DATA+ line is pulled to
3.3 VDC, indicating to the PC that this
is a high-speed USB device (i.e., sup-
porting data transfers at 12 Mbps). If
R3 were connected to the DATA– line,
the PC would limit the data transfer
speed to 1.5 Mbps. The FT8U245AM
adjusts itself accordingly.

THE FIRST TIME

After the PCB is finished, I imagine

you’ll want to turn on the power.
Don’t do it just yet; first, mount the
PCB onto a flat surface or in a hous-
ing. It wouldn’t be the first time a
small piece of wire caused a short on

your PCB when you just placed it on a
table. Secondly, you need to do some
work on the PC before you can con-
nect the USB Parallel Port.

I have developed a special test pro-

gram for the USB Parallel Port that
you may download from my web site
(home.planet.nl/~jkamer) or the Circuit
Cellar

ftp site. The installation program

Setup.exe takes care of multiple tasks.
The test software is installed as well as
the EEPROM programmer software
from FTDI. The device drivers for the
FT8U245AM are placed in a FTDI sub-
folder, which are needed only when the
USB Parallel Port is connected for the

first time. A documentation sub-folder
that contains several specs and user
manuals is also created. Finally, the
source files of the test program are
placed in a source folder. The test pro-
gram is developed using Delphi. The
best part is that the software is free
and can be distributed freely.

After installing the test software,

you are all set and ready to go. Now,
connect a 9-VDC power supply to
CN4. LED D2 will light up to indicate
that power is available. This is the
moment you’ve been waiting for: it’s
time to plug a USB cable type AB into
your PC and into the USB Parallel
Port. Windows will start thinking (the
famous hourglass) and prompt you
with a “New Hardware Found” dialog.

The rest is simple as you follow the

instructions presented by Windows.
As soon as Windows requests the
location of the device information file,
point it toward the folder that con-
tains the FTD2XX.INF file. After com-
pletion of the installation, the status
of the FT8U245AM can be requested
using the Windows device manager

Photo 1—

I made the prototype of the USB Parallel

Port by hand.

background image

EFFORT…BIG

PRIZES!

Innovate with the HC08 from Motorola

Innovate with the HC08 from Motorola

These products incorporate SuperFlash

®

technology licensed from SST. Motorola and the stylized M Logo are registered in the U.S.

Patent and Trademark Office. All other product or service names are the property of their respective owners. © Motorola, Inc. 2002

68HC908QT4 Demonstration Kit

Flash Innovation 2003 Design Contest

Enter our Flash Innovation
2003 Design Contest
involving our new HC08
Q-Family. You may be
eligible to win a 60” thin
plasma screen HDTV
or one of several other
exciting prizes. We are
offering prizes valued
together at more
than $30,000.

Innovate with the HC08!
Motorola’s HC08 Q-Family
of 8-bit microcontrollers
is available in small
8- and 16-pin packaging.
With Flash, you gain the
flexibility to reprogram
in-application and
in-circuit, which helps

make field upgrades
easy and inexpensive.

Take advantage of
our 68HC908QT4
Demonstration Kit,
which has everything
you should need to
get started.

Entries can be from the
very simple to the most
intricate. Innovation,
architectural elegance
and quality of design are
the keys to success in
Flash Innovation 2003.

DEADLINE FOR ENTRIES: JUNE 30, 2003

For information on entering and for contest rules,
visit us at

www.circuitcellar.com/fi2003

SMALL

P

ARTS,

LOW

-COST

TOOL,

LITTLE

EFFORT

…BIG

PRIZES!

background image

18

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

type of device. In order to tell
them apart, each device must
have its own serial number
and device description. By
default the FT8U245AM uses
a VID of $0403, a PID of
$6001, no serial number, and
no device description. Because
no serial number or device
description is given, by default
only one FT8U245AM device
can be connected to the PC.

With the help of an EEPROM

these values can be changed to
make the devices unique. You
can request a new VID number
from the USB organization, and
then change the FTDI’s default
value. This isn’t affordable for
most hobbyists, so instead you
might want to limit yourself to
changing the serial number and
device description.

The FT8U245AM spec docu-

ments how to organize the EEPROM
contents. However, it is not necessary
to develop an EEPROM programmer;
the FT8U245AM can take care of this
itself using the USB interface. To make
life easy, FTDI provides a program that
allows you to enter the settings you
want (see Photo 3). You can download
the program from the FTDI web site.

There are many suppliers of serial

EEPROMs. The basic function is the
same but the use of non-serial pins 6
and 7 and the memory layout seem to
vary from supplier to supplier. The
chip used here must have a 64 × 16 bit
memory layout, and FTDI recom-
mends the 93LC46B (among others)

(under the Control Panel). A
new USB device will appear in
the list with the description
“FTDI FT8U2xx Device.”

What might look strange is

that the properties of this
device indicate a USB-to-serial
device. This is because FTDI
also supplies a serial version of
its chip, the FT8U232AM. The
device driver for both chips is
the same; the parallel version
uses only a subset of the func-
tions. For example, commands
that set the data rate are not
needed for the parallel version.

If Windows doesn’t find the

new hardware or does not rec-
ognize the hardware as a USB
device, you face an interesting
challenge. But, don’t throw the
PCB out the window just yet;
first, remove the USB cable and
power supply. If you didn’t do it
yet, use a multimeter to check that
there are no shorts between the pins
of the FT8U245AM. Then, measure all
of the tracks among the components
to make sure the PCB is OK. You can
also reconnect the power and measure
the voltage on the logic pins; these
should be at a nice high or low logic
level. If everything checks out and
after reconnecting it to the PC it still
is not recognized, your only remaining
option is to try a different PC. My PC
is one of the first that contained USB
ports and Windows 98SE as an operat-
ing system. It seems that the first USB
host chips were not as compliant with
the standard as they claimed.
Replacing the USB card with a later
model solved the problem.

After Windows has installed the

FTDI device drivers, the test program
can be launched. After detecting the
USB Parallel Port, all of the outputs
can be modified directly using the
checkbox closest to the output you
want to change. Photo 2 shows a
screen dump of the software. The
checkboxes that are placed close to
the inputs cannot be modified but
instead display the current status of
the corresponding input. A mark in
the checkbox indicates a high level,
and no mark means a low level. Note
that if you change the level at one of

the inputs on the hardware, then you
will not see this in the software until
you change an output.

DEVICE CONFIGURATION

I succeeded in designing the USB

Parallel Port without the use of micro-
controllers or any other programmable
hardware. However, a small EEPROM
memory is connected to the
FT8U245AM at U2. Proper operation
of the USB Parallel Port does not
require this chip, so why put it there?

Every USB device must identify

itself to the PC; this is done by two
codes, the Vendor ID (VID) and the
Product ID (PID). These two 16-bit
numbers are the first the
PC calls for after a device
is connected. Depending
on the value of these
numbers, Windows will
decide which device driv-
ers must be loaded to sup-
port the device. If the
device is a known device,
Windows takes care of
this without your help. If
the device is new,
Windows will prompt you
with the “New
Hardware” dialog.

It is possible to connect

more than one of the same

Photo 3—

The EEPROM programming utility for programming the EEP-

ROM code in-system was developed by FTDI.

Photo 2—

The test software for the USB Parallel Port provides easy access

to each input and output.

background image

second. At the same time, the inputs
are also read 190,000 times. This is
achieved using a transmit buffer size of
2 × 8000 = 16,000 bytes. If the buffer
size is increased, the interface collaps-
es and the throughput is reduced. It
seems it is no longer possible to
divide the data over the available time
slots, and incoming data is lost.

I measured the speed with only one

USB Parallel Port connected on the
USB interface so that all 1000 slots
were available for the device. If more
USB devices are connected, the band-
width is divided and the throughput
will decrease accordingly.

I

www.circuitcellar.com

Issue 151 February 2003

19

CIRCUIT CELLAR

®

from Microchip. Available in many
packages, I selected a 93LC46B-P, the
P indicating an 8-pin DIL package.

Place an empty EEPROM in the sock-

et for U2 after removing the USB cable
and switching off the power supply.
After inserting the EEPROM, the USB
Parallel Port can be connected to the
PC again and the EEPROM configura-
tion program FTD2XXST.EXE can be
launched. Fill in the requested data using
the VID and PID numbers from FTDI. If
you changed these numbers, Windows
will recognize the parallel port as a dif-
ferent device because it won’t know
the new numbers. The FTD2XX.INF
configuration file must be changed to
reflect the new values. The device driv-
ers themselves do not have to change.

After entering the required data in

FTD2XXST.EXE, it can be written into
the EEPROM by selecting the Program
command from the Device menu.
Remove the USB cable, switch off the
power supply, and then switch on and
insert the USB cable again. Windows
will find new hardware but the PID
and VID will be known this time, so
Windows will assume the device uses
the registered device drivers.

From this point onward, you’ll have

the ability to connect multiple USB
Parallel Ports. The test software does
not support this, but because the
source code is available (including a
special Delphi USB Parallel Port
object), it’s easy to modify the software
as needed. Note that you still have to
do some of the programming yourself.

PERFORMANCE MEASUREMENT

After every write cycle of 2 bytes,

the hardware places 1 byte in the

PROJECT FILES

To download the PCB layouts,
go to ftp.circuitcellar.com/pub/
Circuit_Cellar/2003/151/.

SOURCES

FT8U245AM Interface chip
Future Technology Devices
International Ltd.
44 141 353 2565
www.ftdichip.com

93LC46B Chip
Microchip Technology Inc.
(480) 786-7200
www.microchip.com

RESOURCE

USB Information
USB Implementers Forum
(503) 296-9892
www.usb.org

Jan van de Kamer earned a B.S. in
Technical Computer Science from
Hogeschool Arnhem, the Netherlands,
in 1993. After graduation, he success-
fully started his own business design-
ing microcontroller embedded sys-
tems for industrial applications. On
the side, he designs robots using
these types of systems. He enjoys
interfacing with mechanical parts
and bringing them to life. You may
reach Jan at jkamer@planet.nl or
through his web site at home.planet.
nl/~jkamer.

transmit buffer. The size of the trans-
mit buffer is 384 bytes, so after send-
ing 2 × 384 = 768 bytes, the PC must
execute a read cycle to prevent the
loss of data.

When I tested this on the prototype,

I found a strange effect. Even when I
transmitted a block of 1000 bytes, I
was able to execute a read cycle of
500 bytes. How was this possible?
The USB protocol divides every sec-
ond into 1000 time slots. In each slot,
data can be exchanged between a PC
and the addressed device. If you send
1000 bytes to the FT8U245AM, the
Windows device driver from FTDI
will transmit this data to the chip
using a handshake protocol over sev-
eral time slots. After sending each
packet, the status of the FT8U245AM
is reported back with 1 bit indicating
whether the transmit buffer contains
data. If so, this buffer is read by the
PC before sending more data to pre-
vent data loss. This uses up some
bandwidth, but the benefit is obvious.

In order to determine the maxi-

mum speed of the USB Parallel Port, I
connected some of the outputs to
inputs. By varying the buffer size and
counting how many of these buffers
could be processed in 1 s, I produced
the graph shown in Figure 5. The x-
axis displays the buffer size as passed
to the device driver. For example, a
value of 1025 indicates a transmit
buffer of 2050 bytes and a receive
buffer of 1025 bytes. The number of
cycles is listed on the y-axis, where
one cycle represents setting 16 out-
puts and reading eight inputs.

The graph shows a maximum of

190,000 changes to the outputs per

200,000

180,000

160,000

140,000

120,000

100,000

80,000

60,000

40,000

20,000

0

Buff

er siz

e

Number of cycles (per second)

25

525

1025

1525

2025

2525

3025

3525

4025

4525

5025

5525

6025

6525

7025

7525

8025

Figure 5—

You can compare the number of access cycles that can be made per second to the USB Parallel Port

versus the buffer size used in the access cycle.

background image

20

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

hen we joined a

small group respon-

sible for the develop-

ment of instrumentation

for various systems, we didn’t have
many resources in our laboratory.
Moreover, we were developing micro-
processor-based instrumentation solu-
tions with an 8085 microprocessor-
based CPU card that was purchased
from a local vendor. Although the card
was powerful with its densely packed
peripheral chips, the after-sales sup-
port was unsatisfactory.

At the same time, the instrumenta-

tion community was adopting the 8-bit
MCS-51 microcontroller (i.e., the Intel
8051), which had a lot of peripheral cir-
cuitry built right on the chip, as well
as an instruction set that was opti-
mized for instrumentation and control
applications. This chip made it possible
to develop single-chip applications
without having to add a single external
peripheral device for I/O or memory.

The chip impressed us so much that

we initiated smaller projects based on
the Intel 8751 (i.e., an 8051 microcon-
troller with 4 KB of on-chip EPROM).
Soon thereafter, we decided to develop
a general-purpose CPU card to address
the need for different types of data
acquisition and control systems.

We had experience designing vari-

ous microcontroller-based embedded
systems, so the advantages of modular
design were obvious to us. We devel-
oped an 8051 microcontroller-based
CPU card in 3U single EURO form
factor (160 mm × 100 mm) with a pro-
prietary expansion bus on a 64-pin
EURO connector. The card has 64 KB
of ROM, 32 KB of RAM, and other
glue logic with a selectable RS-
232/RS-422 or RS-485 serial interface,
a matrix keypad, and an LCD inter-
face. Since then, we’ve executed many
instrumentation projects that were
based on our 8051 CPU card.

One day, a professor from a local

engineering college visited our labora-
tory. After inspecting the various proto-
type systems, he understood the impor-
tance of a general-purpose CPU and few
I/O cards. He pointed out that such a
general-purpose microcontroller-based
development system would be highly
useful to engineering students for
their coursework and designers in
embedded systems laboratories.

Many commercial manufacturers

use programmable logic devices (PLD)
or application-specific integrated cir-
cuits (ASIC) for their development
systems. These devices are advanta-
geous because of their low cost and
high packing density, which results in
a small board size. However, most of
the circuit gets encapsulated inside
one or two devices, making it espe-
cially difficult for students to trou-
bleshoot and examine the technology.

The situation becomes worse when

one of these devices is damaged by a
mistake on the part of the students,
which is bound to happen at this
introductory stage in their careers.
The bad device, being proprietary (the
device fuse map is not disclosed for
commercial reasons), has to be pur-
chased from the hardware manufac-
turer. Thus, in spite of the availability
of commercial systems, they aren’t
used in college labs because of the
scarcity of funds, poor after-sales sup-
port, insufficient documentation and
source code, and lack of trouble-shoot-
ing expertise in college departments.

The professor suggested that if a

system were specially designed for
college students, many colleges would

MCS-51 SBC for the
Classroom

Part 1: Hardware

w

College students tend
to experience a lot of
problems when work-
ing with development
systems that use
PLDs and ASICs. So,
at the behest of a local
college professor,
Praveen and his col-
leagues developed an
inexpensive 8051-
based SBC that’s per-
fect for the classroom.

Praveen Deshpande
Prajakta Deshpande
Viraj Bhanage

FEATURE
ARTICLE

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

21

Another aim of ours was to provide a

powerful monitor program resident in
either an on-board ROM socket or 8051
on-chip ROM. The size of the monitor
program decides its final deployment in
on-chip or external ROM.

The monitor program is designed to

provide all of the basic features: pro-
gram entry using an in-line assembler,
program execution, single stepping,
break point, viewing and modifying
various memory areas, registers, SFRs,
program uploading and downloading,
and so on.

A serial interface is a valuable

resource for communicating with a
host computer during the debugging
session. A jumper-selectable RS-
232/RS-485 serial interface is included
for communication with the host
computer (see Figure 1).

An 18-key matrix keyboard, a six-

digit LED, and a 2 × 16 or 4 × 20 alpha-
numeric LCD interface are included for
basic input/output. The on-board key-
board and display comes to your rescue
if a host computer isn’t available for
software development during the
learning stage. The serial EEPROM is
included because it can be used to store
various configuration parameters
should you decide to use this SBC for
developing a serious embedded system.

The 8-pin socket accepts a variety of

serial NVRAM devices from 128 bytes
to 1 KB or more, and it requires just
two processor I/O lines for interfacing!
Finally, if you discover at a later stage
that the hardware on the SBC is insuf-

be interested in using it. So, we agreed
to design a single-board computer
(SBC) for the students. In this article,
we’ll describe the 8051 microcon-
troller-based SBC that we developed.

We chose the 8051 microcontroller

because of its industry-standard archi-
tecture, availability, and low cost. In
addition, the professor’s students were
using the 8051 in a few courses.

DESIGN OBJECTIVES

Our main design objective for the

8051 SBC hardware was to use inex-
pensive and available components (see
Table 1). We chose a 40-pin device
because it was readily available and
inexpensive, but you can choose from
the Intel 8031 (no ROM) or one with
4 or 8 KB of on-chip program memory
(e.g., Atmel or Philips 89C51/52).

If you need two hardware serial

ports, then the DS80C320/520 from
Dallas Semiconductor is a good
choice. Cygnal, Philips, Maxim, and
Siemens also offer compatible
(enhanced in many cases) 8051 cores
and many more on-chip peripherals
(e.g., ADC, PWM channels, watchdog
timer, analog comparator, etc.); never-
theless, they’re more suitable for sin-
gle-chip applications rather than fully
expanded systems. Without external
peripheral devices, you can easily

operate the 8051 at its maximum
clock speed (i.e., 50 MHz for the
Dallas 80C420).

External program memory and

external data memory are combined
by applying the RD and PSEN signals
to the input of an AND gate, and by
using the output of the gate as the
read strobe to the external program
and data memory. The obvious disad-
vantage is that the overall memory
space is cut in half. You can still
develop a sufficiently complex embed-
ded application with a combined 64-KB
code and data memory space.

Table 1—

We laid down ambitious specifications at the time of design. Fortunately, we were able to meet our objec-

tives with readily available, inexpensive devices.

Figure 1—

The SBC is designed to be rich in resources such as serial interface, keyboard display, LCD, EEPROM,

and 64 KB of shared memory space. Moreover, you can expand it further by adding your custom hardware on a
prototyping board.

64-pin DIN EURO expansion connector

IC23

EEPROM

24C01

IC3

74HCT373

IC4

74HCT373

IC2

74LS245

SDA (P1.6)
SCL (P1.7)

RS-232 Interface

IC18

MAX232

IC22

75176

Reset

IC6E

P2[0..7]

P0[0..7]

P1[0..7]

P3[2..5]

TXD

RXD

*RD, *WR, ALE

IC6

74LS04

IC7

74LS393

IC5

74LS367

11.0592 MHz BCLK 8279CLK

Control bus

Address bus

RST

IC (11,13,14)

I/O Decoder logic

IC (8,19,20,21)

Keyboard and

seven-segment LED

IC (6,14,15,16)

LCD Interface

IC10

32 KB of RAM

IC17

32 KB ROM or RAM

Data bus

(IC1)8051 µC

BCLK0

Device

Description

CPU

MCS-51-compatible 40-pin (DIP) device

Speed

11.0592 MHz

Memory

32 KB of ROM, 32 KB of RAM, 60-KB downloadable overlapped program and

external data memory

I/O space

256 bytes of fully decoded I/O space

On-board input devices

18-key push-button matrix keypad using Intel 82C79 controller

Display interface

2 × 16 or 4 × 20 LCD, Six-digit, seven-segment LED

Serial interface

RS-232 or RS-485 (jumper selectable)

Nonvolatile memory

Support for 8-pin serial EEPROM devices with I

2

C interface

Digital I/O

12 (includes on-board timer and interrupt input pins)

Expansion

8-bit proprietary expansion bus on a 64-pin DIN EURO connector with buffered

data, address, and control signals

Firmware

Boot loader for Intel hex file downloading and execution; powerful retargetable

debugging monitor program

Power requirement

5 V at 0.5 A (without LCD backlit drive)

Miscellaneous

On-board reset switch, LEDs for power indication

background image

8279 (IC8). You can imple-
ment up to 64 keys and
16 digits using this device.
IC19 through IC21 pro-
vide decoding and driving
functions. The IRQ line is
taken to logic high when a
key is available in the on-
chip FIFO memory of IC8.
This line is inverted and
can be connected to the
INT1 line of the micro
through jumper JP9.

The memory map’s

structure is illustrated in
Figure 2. The system has
four memory areas: on-
chip internal program
memory, external data
memory, internal scratch
pad memory, and external
program memory. The
32-KB external code mem-
ory area starts at 0000H.

The circuit diagram on

the Circuit Cellar ftp
site shows a 32-KB

EPROM device 27C256 for IC17. If
you choose to use a boot loader pro-
grammed inside the MCS-51 on-chip
code memory, you can insert a 32-KB
RAM in the IC17 socket. Only pins 1,
27, and 22 need to be reconfigured,
and JP4 through JP6 are provided to
accomplish this (see Table 2).

Diode D1, R3, C2, and a NOT gate
(IC6E) generate a power-on RESET sig-
nal. You can reset the micro with the
switch SW1. CN1 extends the Reset
button to the system’s front panel.

The SBC provides an on-board key-

pad with 18 push-button keys and six
seven-segment LEDs using an Intel

22

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ficient for your applica-
tion, an expansion bus is
available on a 64-pin DIN
EURO connector for
adding external hardware.

THE SBC CIRCUIT

You may download a

complete circuit diagram
for the SBC from the
Circuit Cellar

ftp site.

Even though it has a 40-
pin generic 8051-micro-
controller device (IC1),
any other compatible 40-
pin device can be used. A
ROM-less device usually
is the cheapest option.
Refer to the Circuit
Cellar

ftp site for a list of

compatible devices.

The circuit has an

11.0592-MHz crystal
oscillator built around a
few gates in IC6, R1, R2,
Y1, and C1. The buffered
clock signal (BCLK0)
drives either the X1 or X2 pin of the
microcontroller. The 8051 microcon-
troller has an on-chip oscillator circuit
that needs an external crystal and two
capacitors, but it doesn’t provide a
CLOCKOUT signal, which may be
required for many external peripheral
devices used in this design (e.g., the
8279 keyboard and LED controller). For
this reason, an external crystal oscilla-
tor is used and IC7 (74LS393) divides
the 11.0592-MHz clock signal to pro-
duce BCLK (5.5296 MHz) and 8279CLK
(1.3824 MHz). Note that 11.0592 MHz
gives you many standard data rates for
serial communication on an RS-232
interface; however, you may use a dif-
ferent clock if necessary.

We found that the input pin (X1 or

X2) used for an external clock is differ-
ent for Intel, Atmel, and other micro-
controller devices. A jumper (JP3)
enables you to drive either the X1 or
X2 pin from the external clock signal.
You can leave the remaining pin
unconnected or grounded as per the
device’s datasheet.

Resistor R4 takes the *EA/VP pin

high. You can disable the on-chip pro-
gram memory (if available) on an 8051
device by inserting shorting jumper JP1.

Figure 2—

The MCS-51 has three types of memory space. It was cleverly designed with single-

chip control applications in mind. However, you can easily expand it by adding external devices.
This SBC memory map shows the physical addresses for various areas and I/O devices.

FFE0H

FFC0H

FFA0H

FF80H

FF60H

FF40H

FF20H

FF00H

*BPCS5

*BPCS4

*BPCS3

*BPCS2

*BPCS1

*BPCS0

*LCD1

*8279CS

External data

memory

mapped I/O

space (256 bytes)

32-KB External

data memory

+

code memory

space

overlapped

(user code

download area)

24-KB External

data memory

+

code memory

space

overlapped

(IC17 is RAM)

8-KB On-chip

program

memory on

AT89C52

(boot loader)

SFR Direct
addressing

only

Indirect

addressing

only

Direct and

indirect

addressing

FFH

80H

FFH

80H

7FH

00H

Internal data memory

RAM and SFR space

External data and code memory space

32-KB External
program (code)

memory

IC17 is

EPROM/ROM

(boot loader

or application

code)

FFFFH

FF00H

FEFFH

8000H

7FFFH

2000H

1FFFH

0000H

Table 2—

The SBC hardware is highly configurable. You can change the memory map, enable or disable certain

memory areas, and select the serial interface of your choice. In addition, you can play with the configuration using
the various shorting jumpers listed here.

Jumper

Purpose

Position/status

Description

JP1 (two-pin)

Enables/disables 8051 on-chip

Open

Disabled

program memory

Closed

Enabled

JP2 (three-pin)

RS-232/485 serial interface selection

1–2

RS-485

2–3

RS-232

JP3 (five-pin)

8051 device external system clock

2–3

Drives X1 pin

11.0592-MHz driving pin selection

3–4

Drives X2 pin

1–2

X1 pin is grounded

4–5

X2 pin is grounded

JP4 (three-pin)

Configuration of IC17 as either 32-KB

1–2

32-KB ROM device

JP5 (three-pin)

ROM or RAM. JP4, JP5, and JP6

2–3

32-KB RAM device

JP6 (three-pin)

have identical positions 1–2 or 2–3.

JP7 (two-pin)

*IRQ signal from 8279 (IC8)

Closed

INT1 gets *IRQ on key-
strokes

JP1 (6 × 2 pin)

Card-select signal on the prototype

1–2

*BPCS0

expansion board for choosing a

3–4

*BPCS1

base address for that board. A

5–6

*BPCS2

unique position must be selected

7–8

*BPCS3

for each additional board. Only one

9–10

*BPCS4

position should be selected for

11–12

*BPCS5

each board.

background image

Flash

Facts

$49

.95

($199 Value)

Now for a limited time

ZiLOG redefines 8-bit with the new Z8 Encore!

family

of flash microcontrollers that simplifies your development
process, increases design productivity and gives you
more functionality than any other 8-bit MCU in history.

But don’t take our word for it.
Visit us at www.zilog.com/Z8encore2 or
call us at 866-498-3626 and receive our complete
development kit for only $49.95.
Act now because when this special introductory
offer ends, the kit will sell for $199.95!

Z8 Encore!

will be available in all standard flash memory

configurations from 4K to 64K. Incorporated into new
designs or upgrading from existing 8-bit (including Z8

®

)

architectures, this next-generation MCU has features
and performance that leaves the competition in the dust.

The Z8 Encore!

Test Drive Kit Includes

Hardware
• Evaluation Board
• Target Interface Module Board
• Serial Cable
• Universal Power Supply

Software
• ZDS II IDE with full
version C-compiler
• Sample Code
• Device Drivers
• Documentation CD

The New Z8 Encore!

MCU Block Diagram

10-bit A/D

Converter

Port A Port B Port C Port D Port E Port F Port G Port H

16-bit Timer

w/PWM

16-bit Timer

w/PWM

16-bit Timer

w/PWM

16-bit Timer

w/PWM

I

2

C

SPI

UART 0

UART 1

Watch-Dog

Timer

Crystal

Oscillator

Register File

4K X 8

DMA

Controller

Interrupt

Controller

eZ8

20MHz

CPU

Reset

Control

On-Chip

Debugger

Flash

Program

Memory

64K X 8

THE

THE

ORDER NOW!

Visit us at

www.zilog.com/Z8encore2

or call us at

866-498-3626

(866-4Z8-Encore)

Z8

ENCORE!

ZiLOG, Z8 Encore! and Z8 are trademarks or registered trademarks of Zilog Inc. in the United States and in other countries. Other logos, product names and service names mentioned herein may be trademarks of the companies with which they are associated.

This comparison is valid as of 9/27/2002.

FEATURE

ZILOG

MOTOROLA

ZILOG

MOTOROLA

Z8F6403

MC68HC908AS60A

Z8F3202

MC68HC908GP32

Actual CPU Speed

20MHz

8MHz

20MHz

8MHz

On board DMA

Yes

No

Yes

No

High Speed Flash

64K

60K

32K

32K

SRAM

4K Bytes

2K

Bytes

2K Bytes

512

Bytes

A/D Converter

10-bit

8-bit

10-bit

8-bit

SPI & I

2

C

Both

No

I

2

C

Both

No

I

2

C

UARTs

2 (9-bit)

1

(8-bit)

2 (9-bit)

1

(8-bit)

16-bit Timers

4

Multi-mode 2

Multi-channel

4

Multi-mode 2

Multi-channel

Independent

Synchronous

Independent

Synchronous

Timers

Timers

Timers

Timers

background image

A 32-KB RAM HM62256

(IC10) maps to the upper memo-
ry space starting at 8000H. An
eight-input NAND gate (IC13)
and decoder (IC9) provide eight
chip-select outputs for the top-
most 256 bytes of external mem-
ory space (FF00H through FFFFH)
for connecting external peripher-
als. Two outputs, *8279CS and
*LCD1, are used to address the
on-board keyboard/display con-
troller and the LCD interface.

The remaining six chip-select

signals (*BPCS0 through
*BPCS5) are made available on a
64-pin DIN EURO connector for
further expansion. The expansion
connector J1 has all the necessary sig-
nals (e.g., buffered data bus, address
bus, *BRD, *BWR, BRST, and BALE),
in addition to P1 port lines, for fur-
ther expansion. The microcontroller’s
timer input pins (T0 and T1) and
interrupt inputs (INT0 and INT1) are
made available, and the expansion
board can also draw power (5, 12, and
–12 V) from this connector.

The SBC provides an LCD interface

on CN3. You can use a 2 × 16 or 4 × 20
LCD with LED backlight, and either a
4- (two transfers) or 8-bit (single trans-
fer) data bus for the LCD controller.
The LCD controller needs an active-
high ENABLE signal (LCDEN); it also
requires a single R/*W signal to indi-
cate an active-high READ and active-
low WRITE. Because the MCS-51 has
two independent signals for data read

and write, a flip-flop is imple-
mented using two NAND gates
(IC14B and IC14C). The output
of this flip-flop becomes the
R/*W signal.

The LCD controller also

requires an active-high ENABLE
signal that must be delayed at
least by 100 ns with respect to
the R/*W signal. The actual delay
value depends on the LCD con-
troller used (refer to the datasheet
for your controller). R4, C3, and
two inverter gates in IC16 gener-

ate the delay. The display can be
separate from the SBC (e.g., on
the front panel of an enclosure).

The SBC implements a three-wire

RS-232 serial interface using a
MAX232 (IC18). You have to make a
cable for connecting the SBC to the
host computer in a null modem con-
figuration. The handshake signals
(e.g., RTS and CTS) should be looped
back to the host computer.

A two-wire RS-485 serial interface

is implemented using a 75176 trans-
ceiver (IC22) from Texas Instruments.

24

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

Photo 1—

Take a look at the boot loader in action. You can use Windows

HyperTerminal for communication with the SBC. After the sign-on message,
send your hex file using the pop-down menu pointed to by the cursor.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

25

the object code (i.e., Intel hex file for-
mat) into the on-board memory. It may
optionally perform a RAM test and
notify you of any errors. Then, you can
execute the downloaded code.

The Intel standard hex file is one of

the most popular formats in the MCS-
51 world. The standard is used to burn
the MCS-51 program into an EPROM,
PROM, and so on. For instance, an
8051 assembler will usually generate

Because the 8051 has only one on-
chip UART, you select either the RS-
232 or RS-485 serial interface using
jumper JP2. The TxD signal is always
connected to both the MAX232 and
75176, which helps you to develop
RS-485-related software because you
can see the data on the RS-485 net-
work via a PC’s serial port.

P1.5 pin of the microcontroller is

connected to the data enable pin of
the 75176. If you’re using the RS-485
interface, make sure the data enable
pin P1.5 is taken low by your power-
up initialization routine. You must do
this because it’s made high by the
hardware reset of the 8051 microcon-
troller, enabling the RS-485 transmit-
ter. This blocks the RS-485 network.

The SBC supports an 8-pin (e.g.,

AT24C01) serial EEPROM using a bit-
banged I

2

C interface. Few 8051

devices offer an on-chip hardware I

2

C

interface; however, to make the SBC
accept the most general 8051 micro-
controller device, we decided to
implement the I

2

C in the software.

Atmel has documentation that pro-

vides the details for the soft-
ware implementation. [1]

You will find three LEDs for

power supply indication: D2,
D3, and D4. Each application
may have different power
requirements, hence we kept
the power supply separate.

FIRMWARE

The minimal software com-

ponent required to start work-
ing with the SBC is a boot
loader program resident at the
RESET vector location (i.e.,
either micrcontroller on-chip
code memory or external
EPROM). This program enables you to
download your object code from the
host PC using an RS-232 serial inter-
face. At the PC, you can use any ter-
minal emulator program (e.g.,
Windows HyperTerminal) to send the
hex file to the SBC’s serial port.

The boot loader program is responsi-

ble for initializing the on-board hard-
ware (e.g., UART, 8279, and LCD),
posting a sign-on message, and loading

Photo 2—

Unfortunately, the single-board computer’s keys were

not mounted at the time of the photograph. You must mount a
64-pin reverse EURO (right-angled female) connector to accom-
modate the expansion boards.

background image
background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

27

an Intel standard hex file that can be
loaded into an EPROM programmer
and burned into the chip.

The boot loader C code in Listing 1

uses a function,

LoadIntelHexFile(),

to convert the Intel hex file on the fly
to binary. It also computes the check-
sum and verifies that the file has been
downloaded correctly in the SBC’s
code memory space.

First, a few lines display a sign-on

message. After you see a ready string,
you should send the hex file to the
SBC’s serial port (see Photo 1). The boot
loader starts reading individual fields
after it receives a colon. Two helper
functions,

GetData() and GetAddr(),

return 8- and 16-bit values after reading
appropriate ASCII characters from the
serial port and converting them to cor-
responding binary quantities.

The

Asc2Bin() routine converts

each character (a nibble) into an 8-bit
value using a look-up table to speed
up the process. Because we used only
a three-wire serial interface, the PC
sends the serial data continuously
without bothering with how it’s con-
sumed. As the RTS/CTS flow control
lines are looped back, the PC notes
that the serial data is consumed by the
receiving end, and is ready to accept
new data. The boot loader has to con-
vert the received ASCII datastream to
binary, separate each field, identify the
record type, and load the data bytes to
the physical address location.
Furthermore, it has to compute the
checksum and validate it before the
next line reception begins.

As you can tell, the CPU has little

time to echo each received character.
Instead, the progress of the download-
ing is shown by displaying a

# for each

line received. The

LoadIntelHex

File() function (see Listing 1) initial-
izes an external data memory pointer
variable (

p) with the load address, and

writes all of the data bytes received
from one input line received from the
Intel hex file to the physical memory. It
initializes another code memory pointer
variable (

cp) with the same load address

and simultaneously reads back the writ-
ten data for checksum computation.

The use of a separate code memory

pointer is essential because the CPU
will fetch the code from the code mem-
ory, and it must get the correct code
bytes during program execution. The
computation of the checksum by
adding the read-back code bytes ensures
not only the correct data reception from
the host PC, but it also confirms that
it’s correctly accessible via the code
memory space. If the computed check-
sum is found to be correct, the code
proceeds to receive the next record.

Listing 1—

With boot loader code, you can quickly start software development with the SBC. It downloads

the Intel standard hex files from the host PC. Remember to configure your serial port to RS-232. The use of
C language simplifies the coding effort.

void LoadIntelHexFile(void)

//Convert hex file to binary and load it

unsigned char count,ch, i, rec; {

unsigned char far *p;

unsigned char code *cp;

unsigned int addr, min_addr=0xFFFF, byte_counter=0;

char buf[30];

BaseAddr = 0xFFFF;

//Go address computed

SendS ("\r\nMCS-51 Single Board Computer"); //Sign-on message

SendS ("\r\n(C) 2002, P P Deshpande, V P Bhanage");

SendS ("\r\nBoot Loader IntelHex File v1.0");

SendS ("\r\nREADY\r\n");

while(1) {

if ((ch = RecvChrw()) != ':') continue;

SendChrw('#');

checksum =tchk=0;

tchk += count = GetData();

//Get number of bytes

addr = GetAddr();

//Load address

tchk += uIntBytes.b.hb;

//Add the address byte

tchk += uIntBytes.b.lb;

if ( addr < BaseAddr) BaseAddr = addr;

tchk += rec = GetData();

if ( rec == 1) {

i=0;

break;

}

p = (unsigned char far *)addr;

//External data memory pointer

cp = (unsigned char code *)addr; //Code memory pointer

if (rec == 0) {

for (i=0; i < count; i++) {

*p++ = GetData();

tchk += *cp++;

}

checksum = GetData();

//Read checksum byte

}

tchk += checksum;

//Should result in 0

if (tchk) {

//Not 0, report checksum error

i = 2;

break;

}

byte_counter += count;

//Count bytes loaded

}

if (i==0) {

//Inform that file download is successful

sprintf (buf, "\r\n%d bytes loaded!", byte_counter);

SendS(buf);

//Display number of bytes successfully loaded

SendS("\r\nPress 'g' to Execute.\r\n");

} else {

HandleChecksumError();

//Report checksum error

}

while (toupper(RecvChrw()) != 'G');

//Wait for “g” command

SendS ("\r\nExecuting...");

asm ("clr a ");

asm ("mov

dph,_BaseAddr+0");

//Load base address

asm ("mov

dpl,_BaseAddr+1");

asm ("jmp

@a+dptr

");

//Jump to user program

while(1);

}

background image

six seven-segment displays. If you’ve
hooked up the SBC to the host PC,
you will see a sign-on message on the
PC screen (see Photo 1), followed by a
“Ready” prompt. At that stage, the
SBC will be waiting to receive the
object code from the PC.

We haven’t included the design of

the power supply in this article. The
SBC requires only a 5-V power supply;
however, a 12- and –12-V power sup-
ply is made available for an expansion
circuit board that may contain signal
conditioning and other detector front-
end analog electronics. Thus, the
power supply current requirement is
dependent on the expansion circuit.

If you decide to use low-power com-

ponents (e.g., the HCT series), the
power requirement reduces even fur-
ther. The board requires 5 V at 0.5 A if
TTL ICs are used for all of the logic
devices except IC3 and IC4, and the
CMOS devices for 89C52, 82C79, and
62256. A 0.5-A current is usually suffi-
cient for 12-V supplies unless your
application drives numerous 12-V
relays, motors, and the like. Always use
a proper heatsink for voltage regulators.

CODE DEBUGGING?

If you require code-debugging fea-

tures, you’ll need a monitor program
that enables you to set break points,

28

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

Otherwise, the loader reports a check-
sum error with a dump of the loaded
code bytes, load address, record type,
received and computed checksum val-
ues, and so on. You may use this
information for troubleshooting.

When an end-of-file record field is

encountered, the
LoadIntelHexFile() function dis-
plays the actual number of bytes
loaded with a prompt to press the “g”
key to execute the program. After you
hit the “g” key, it displays the mes-
sage “Executing” and makes an indi-
rect jump to the lowest load address
received during the download. If you
wish, you can modify the code to set
an explicit start address for execution.

Listing 2 shows you how to set up

an interrupt vector table to redirect
each vector to the corresponding loca-
tion in the user code memory starting
at 8000H. This is essential if you wish
to use of any of the available interrupt
sources in your application. Many 8051
derivatives, such as the DS80C320,
have more interrupt sources than
what’s shown in Listing 2.

If you decide to use any such

device, you must add a device-specific
interrupt vector redirector to your
boot loader code. As you write your
application code, it should begin at
8000H. You may use an assembler
directive (e.g., ORG 8000H) to locate
your code. In addition, you should
declare the interrupt service routines
at corresponding vector locations rela-
tive to 8000H (e.g., 8003H must have
external INT0 vector).

You may download the source code

and Intel hex file for the boot loader
from the Circuit Cellar ftp site. We
used the Hi-Tech C compiler with sin-
gle-chip memory model for compiling
the code, but any other C compiler
should do the job.

The code size of the boot loader is

greater than 4 KB because we used
standard C library functions (e.g.,
sprintf()). The code doesn’t require
any external data memory for its oper-
ation. The hex file can be readily pro-
grammed into the on-chip code mem-
ory of the 8051 microcontroller or
external EPROM. We used 19,200-bps,
8-bit, no-parity, 1-stop bit settings to
communicate with the host PC.

CONSTRUCTION

As you can see in Photo 2, the PCB

is double-sided with plated-through
holes. We used IC sockets for easier
component replacement.

After you solder all of the IC sockets

and the power supply connector, make
sure that a continuity tester doesn’t
show continuity between 5 V and
GND. Then, apply 5 V and make sure
that each TTL IC is getting a 5-V sup-
ply. Solder all of the discrete compo-
nents (i.e., resistors, diodes, capacitors,
crystal, etc.) and insert the 74LS04 (IC6)
into its socket. Don’t forget the 0.1-µF
ceramic decoupling capacitors near the
power pins of all of the logic devices.

You should also see a RESET signal if

you press the reset switch (SW1). Insert
the IC MAX232 (IC18) and check the
voltages at pins 2 and 6 with a multi-
meter; they should read approximately
9 V and –9 V, respectively. Insert IC7
and check the clock signal at pin 2,
BCLK, and other 8279CLK signals.

After the clock signals are verified,

it’s time to insert the other ICs. The
boot loader code must be programmed
either in the external EPROM or in
the internal code memory space of the
microcontroller. Set jumpers JP1, JP3,
JP4, JP5, and JP6 to match your mem-
ory configuration. If all is well, you
should see a sign-on message on the

Listing 2—

You must initialize the interrupt vector table in this way if you wish to use it in your application.

By doing so, all of the interrupts are redirected to the corresponding vector locations of the user program
area starting at 8000H.

//Set up an interrupt vector table (8052 device specific). All

interrupts are redirected to START_ADDR (8000H). You may need to

add more vector locations if you choose an MCS-51 derivate with

more interrupt sources.

#define START_ADDR 0x8000

#asm

psect vectors,ovrld ; assemble directive to tell this is IVT

ORG 03h

; EXT INT0 vector

LJMP START_ADDR + 03h

ORG 13h

; EXT INT1 vector

LJMP START_ADDR + 13h

ORG 0Bh

; TIMER0 vector

LJMP START_ADDR + 0Bh

ORG 1Bh

; TIMER1 vector

LJMP START_ADDR + 1Bh

ORG 23h

; serial port(RI+TI)vector

LJMP

START_ADDR + 23h

ORG 2Bh

; TIMER2 vector (8052 only)

LJMP START_ADDR + 2Bh

#endasm

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

29

PROJECT FILES

To download the code and
schematics, go to ftp.circuitcel-
lar.com/ pub/Circuit_Cellar/
2003/151/.

REFERENCE

[1] Atmel Corp., “Interfacing

AT24Cxx Serial EEPROMs
with AT89Cx051 Microcon-
trollers,” October 1998.

RESOURCES

P. Deshpande, “Implementing a
Two-Wire RS-485 Network,”
Circuit Cellar

133, August 2001.

Intel Corp., MCS 51 Family
User’s Manual

, Intel Corp., Santa

Clara, CA, 1994.

———, Microprocessor and
Peripheral Handbook

, vol. 2

Peripheral, Intel Corp., Santa
Clara, CA, 1988.

SOURCES

AD7713 sigma-delta ADC
Analog Devices, Inc.
(781) 329-4700
www.analog.com

AT24C01, AT89C51/52
Atmel Corp.
(408) 441-0311
www.atmel.com

87C520/80C320
Dallas Semiconductor, Inc.
(972) 371-4000
www.dalsemi.com

C compiler
Hi-Tech Software, LLC
(800) 735-5715
www.htsoft.com

MCS-51 Microcontroller
Intel Corp.
(408) 765-8080
www.intel.com

75176 transceiver
Texas Instruments, Inc.
(800) 336-5230
www.ti.com

Praveen Deshpande earned his
B.S.E.E. from The Regional
Engineering College (REC) in Nagpur,
India. He’s a senior scientific officer in
the field of distributed data acquisi-
tion and control. You may reach him
at ppd@cat.ernet.in.

Prajakta Deshpande has a B.S. from
Sagar University and a Master of
Computer Applications (M.C.A.) from
Barkatullah Vishwa Vidyalaya, both
in India. Currently, she lectures
about computer science. You may
reach her at ppd@nettaxi.com.

Viraj Bhanage received a B.S. in elec-
tronics and telecommunications from
Shivaji University in Kolhapur, India.

Currently, he designs laser-based
systems. You may reach Viraj at
viraj@cat.ernet.in.

perform a single-step execution, and
examine various memory areas and
CPU registers. This is a topic in and of
itself, so we’ll discuss the implemen-
tation of a re-targetable monitor pro-
gram in another issue. Until then, you
can test the SBC hardware and think
about powerful embedded applications
based on this SBC.

I

background image

30

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ith today’s

stand-alone global

position system (GPS)

receivers, you are able to

pinpoint your own position. But, what’s
more useful about stand-alone GPS
receivers is that they can transmit your
position information to other receivers.
We decided to use both of these fea-
tures to create a wireless vehicle track-
ing and control system for the Design
Logic 2001 Contest, sponsored by
Atmel and Circuit Cellar.

To design the Port Navigation

System, we combined the GPS’s ability
to pinpoint location along with
the ability of the Global System
for Mobile Communications
(GSM) to communicate with a
control center in a wireless
fashion. The system includes
many GPS-GSM Mobile
Navigators and a base station
called the control center.

Let us briefly explain how it

works. In order to monitor
ships around a port, each ship
is equipped with a GPS-GSM
Mobile Navigator. The naviga-
tor on each ship receives GPS
signals from satellites, com-
putes the location informa-
tion, and then sends it to the

control center. With the ship location
information, the control center dis-
plays all of the ships’ positions on an
electronic map in order to easily moni-
tor and control their routes. Besides
tracking control, the control center
can also maintain wireless communi-
cation with the GPS units to provide
other services such as alarms, status
control, and system updates.

HARDWARE

GPS became available in 1978 with

the successful launch of NAVSSTAR 1.
Later, in May of 2000, the U.S. gov-
ernment ended selective availability
(SA); as a result, the GPS accuracy is
now within 10 to 30 m in the horizon-
tal plane and slightly more in the ver-
tical plane. For more information on
GPS and its accuracy, read Jeff Stefan’s
article, “Navigating with GPS”
(Circuit Cellar 123).

The GPS-GSM Mobile Navigator is

the main part of the Port Navigation
System. The design takes into consid-
eration important factors regarding
both position and data communica-
tion. Thus, the project integrates
location determination (GPS) and
cellular (GSM)—two distinct and
powerful technologies—in a single
handset (see Photo 1).

The navigator is based on a micro-

controller-based system equipped with
a GPS receiver and a GSM module
operating in the 900-MHz band. We
housed the parts in one small plastic
unit, which was then mounted on the
ships and connected to GPS and GSM

GPS-GSM Mobile
Navigator

w

What’s the more laud-
able engineering feat,
designing a naviga-
tion system capable
of tracking ships in
Shanghai Port or
placing at the top of a
competitive design
contest? With the
award-winning GPS-
GSM Mobile
Navigator, Ma and Lin
accomplished both.

Ma Chao & Lin Ming

FEATURE
ARTICLE

LCD

Button

control

AT45D021

Flash

memory

AT90S8515

Microcontroller

Alarm

Power

supply

3:1

Mux

GPS

module

RS-232

Interface

GSM

module

SPI

UART

Figure 1—

The AT90S8515 microcontroller is the basis for the

GPS-GSM Mobile Navigator.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

31

buzzer or presented on the LCD. The
first way is to receive the command
from the control center; the second
way is to manually send the alarm
information to the control center with
the push of a button.

The GPS-GSM Mobile Navigator is

powered by either a rechargeable bat-
tery or DC input.

GETTING GPS DATA

After the GPS module computes the

positioning and other useful informa-
tion, it then transmits the data in some
standard format—normally in NMEA-
0183 format. When you’re building this
project, it’s nice to be able to buy
stand-alone GPS OEM modules. Just
check the pages of Circuit Cellar for
manufacturers. We used a Sandpiper
GPS receiver from Axiom for this proj-
ect. The Sandpiper is intended as a
component for an OEM product that
continuously tracks all satellites in
view and provides accurate satellite
positioning data. With differential GPS
signal input, the accuracy ranges from
1 to 5 m; however, without differential
input, the accuracy can be 25 m.

The Sandpiper has two full-duplex

TTL-level asynchronous serial data
interfaces (ports A and B). Both binary

antennas. The position, identity, head-
ing, and speed are transmitted either
automatically at user-defined time
intervals or when a certain event
occurs with an assigned message (e.g.,
accident, alert, or leaving/entering an
admissible geographical area).

This information is received by the

system in the dispatching or opera-
tions center, where it is presented as a
Short Message Service (SMS) message
on a PC monitor. SMS is a bidirection-
al service for sending short alphanu-
meric (up to 160 bytes) messages in a
store-and-forward fashion. If the only
data received is time and position,
then the data can be displayed on a
digitized map and also recorded in a
database file; the recorded information
can be replayed later for debriefing or
evaluation of a mission.

The hardware block diagram is

shown in Figure 1. The AT90S8515
microcontroller assures that all of the
components work well together; it con-
trols all incoming and outgoing mes-
sages as well as the I/O channels, serial
interfaces (RS-232), peripheral devices
(e.g., LCD and buttons), and all other
parts. The GPS module receives the
GPS signals and outputs the data to the
AT90S8515 microcontroller via a TTL-
level asynchronous serial (UART) inter-
face. The microcontroller works with
the GSM module by communicating
with the GSM network. The interface
between the GSM module and
AT90S8515 is also TTL async serial.
An RS-232 interface is used to exchange
data with the PC.

Because the AT90S8151 has only one

UART, a three-channel multiplexer is
used to switch among three working
modes. The location information and
other data is stored in the 2-Mb serial
data flash memory of the AT45D021.
The flash memory stores up to 2160
pieces of location information in 12 h,
because the GPS-GSM Mobile Navigator
saves GPS signals every 20 s. Four but-
tons, an LCD, and a buzzer enable you
to display the system status and infor-
mation and control the navigator.

SYSTEM FEATURES

As we explained, the GPS module

outputs the ship location information
such as longitude, latitude, and
Greenwich Time every 2 s. The loca-
tion information is then stored every
20 s in flash memory, which has
enough power to memorize the track
of a ship even when the power is off.

Note that the GSM wireless commu-

nications function is based on a GSM
network established in a valid region
and with a valid service provider. Via
the SMS provided by the GSM network,
the location information and the status
of the GPS-GSM Mobile Navigator are
sent to the control center. Meanwhile,
the mobile navigator receives the con-
trol information from the control cen-
ter via the same SMS. Next, the GPS-
GSM Mobile Navigator sends the
information stored in flash memory to
the PC via an RS-232 interface. (Note
that you can set up the navigator
using an RS-232 interface.)

There are two ways to use the

mobile navigator’s alarm function,
which can be signified by either a

Table 1—

The NMEA RMC data values are based on the following example:

$GPRMC,161229.487,A,3723.2475,N,12158.3146,W,0.13,309.62,120598,,*10.

Photo 1—

On the front side of the main board, you can

see an LCD, four programmable keys, a GSM module,
an RS-232 connector, and some other components.

Name

Example

Units

Description

Message ID

$GPRMC

RMC protocol header

UTC Position

161229.487

hhmmss.sss

Status

A

A = data valid; V = data not valid

Latitude

3723.2475

ddmm.mmmm

N/S Indicator

N

N = north; S = south

Longitude

12158.3416

dddmm.mmmm

E/W Indicator

W

E = east; W = west

Speed over ground

0.13

Knots

Course over ground

309.62

Degrees

True

Date

120598

ddmmyy

Magnetic variation

Degrees

E = east; W = west

Checksum

*10

<CR><LF>

End of message termination

background image
background image
background image

34

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

and NMEA initialization and configura-
tion data messages are transmitted and
received through port A. Port B is con-
figured to receive RTCM DGPS correc-
tion data messages, which enable the
GPS unit to provide more accurate posi-
tioning information. But, we didn’t
require the use of port B for this project.

About 45 s after the GPS module is

cold booted it begins to output a set
of data (according to the NMEA for-
mat) through port A once every sec-

ond at 9600 bps, 8 data bits, 1 stop bit,
and no parity. NMEA GPS messages
include six groups of data sets: GGA,
GLL, GSA, GSV, RMC, and VTG. We
use only the most useful RMC mes-
sage—Recommended Minimum
Specific GNSS Data—which contains
all of the basic information required
to build a navigation system. Table 1
lists the RMC data format.

We only need position and time

data, so the UTC position, longitude

with east/west indicator, and latitude
with north/south indicator are picked
out from the RMC message. All of
this data will be formatted into a stan-
dard fixed-length packet with some
other helpful information. Next, this
data packet will be transmitted to the
control center and stored in the
AT45D021’s flash memory.

The data packet is a 42-byte long

ASCII string, which includes the pack-
age ID, system password, terminal ID,

Figure 2—

Jack port JP1 is the 20-pin GPS socket header. Jack port JP2 is the 40-pin GSM socket header. U2 is the dual four-channel multiplexer controlled by PA2 through

PA3. All of the data traffic runs at 9600 bps.

Table 2—

Take a look at the 42-byte data package format and the following example ready to be saved: :10019999E121263457N311864290742160030000#.

Name

Byte

Definition

Description

Start byte

1

:

Start symbol of data package

Data package ID

1

0~9

Package ID is repeated from 0 to 9

System password

3

000~999

System password

Terminal ID

4

0000~9999

Terminal ID

Position data

19

E000000000~E180000000

E means east longitude, which is from 000° and 00.0000 min. to 180° and 00.0000 min.

N00000000~N90000000

N means north latitude, which is from 00° and 00.0000 min. to 90° and 00.0000 min.

UTC

6

hhmmss

Greenwich Time (hour, minute, second)

Upload time rate

3

001~255(003)

Upload time interval = basic upload time × upload time rate

Alarm information

4

xxxx

0 means OK; 1 means alarm
Byte 1: aberrance alarm
Byte 2: over-speed alarm
Byte 3: dangerous area alarm
Byte 4: manual alarm

Stop byte

1

#

Stop symbol of data package

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

35

position data, UTC, and other
operational information.
Table 2 shows the definition
of a reforming data packet
and an example ready to be
saved or transmitted.

GSM TRANSMITS DATA

A committee of telecom

vendors and manufacturers in
Europe—the European
Telecommunications Standards
Institute (ETSI)—designed GSM as a
digital wireless communications system.
Commercial service began in mid-1991,
and by 1993 there were 36 GSM net-
works in 22 countries, with 25 addi-
tional countries looking to participate.
Furthermore, the standard spread
quickly beyond Europe to South Africa,
Australia, and many Middle and Far
Eastern countries. By the beginning of
1994, there were 1.3 million subscribers
worldwide. Today, GSM is also the
most widely used communications stan-
dard in China, and covers almost all of
the country. So, we didn’t need to set
up a communications base station for
our system; this, of course, significantly

reduced the total cost of the project.

The most basic teleservice supported

by GSM is telephony. Group 3 fax, an
analog method described in ITU-T rec-
ommendation T.30, is also supported by
the use of an appropriate fax adapter.
SMS is one of the unique features of
GSM compared to older analog sys-
tems. For point-to-point SMS, a mes-
sage can be sent to another subscriber
to the service, and an acknowledgment
of receipt is sent to the sender. SMS
also can be used in Cell Broadcast mode
to send messages such as traffic or news
updates. Messages can be stored on
the SIM card for later retrieval.

SMS is effective because it can trans-

mit short messages within 3 to 5 s via

the GSM network and doesn’t occupy a
telephony channel. Moreover, the cost
savings makes it a worthwhile choice
(i.e., in China, each message sent costs
$ 0.01 and receiving messages is free).
With SMS transmitting, gathering posi-
tion data is easy and convenient.

As with GPS modules, stand-alone

GSM OEM modules are available. We
used the FALCOM A2D from Wave-
com for this project. The FALCOM
A2D is a dual-band embedded GSM
module (GSM900/DCS1800). It fea-
tures the following services: telepho-
ny, SMS, data, and fax.

The GSM module has one TTL-

level serial data interface. We use AT
commands to control and program the
FALCOM A2D. The data and control
commands are exchanged between the
microcontroller and GSM module
through the serial interface.

There are many groups of AT com-

mands, including: Call Control, Data
Card Control, Phone Control, Computer
Data Card Control, Reporting Operation,
Network Communication Parameter,
Miscellaneous, and Short Message
Service. We use some of the SMS com-
mands to communicate with the con-
trol center. The main AT commands
for using SMS are listed in Table 3. You
can download the GSM 07.07 and
GSM 07.05 protocols for more details
about the AT commands that are used
in GSM communications. [1, 2]

Let’s review an example of how to

make a GSM module send and read a
sample SMS in Text mode. First, initial-
ize the GSM module with AT com-
mands AT+CSCA and AT+CMGF. Using
the former sets the SMS center number
to be used with outgoing SMS messages.
Remember, the number will be saved on
the SIM card just like in normal mobile
phones. There are two different modes—
Text mode and Protocol Data Unit

Table 3—

To send SMS messages, you can use these (mainly) AT commands. For more details, you may want to read the

GSM 07.07 protocol on the ETSI web site.

Command

Definition

AT+CSCA

Set the SMS center address. Mobile-originated messages are transmitted through this service center.

AT+CMGS

Send short message to the SMS center

AT+CMGR

Read one message from the SIM card storage

AT+CMGD

Delete a message from the SIM card storage

AT+CMGF

Select format for incoming and outgoing messages: zero for PDU mode, one for Text mode

AT+CSMP

Set additional parameters for Text mode messages

Initialization

EEPROM check

Flash memory check

GPS/GSM reset

Mode select
(= 0, 1, 2, 3)

N

Power Off

button

pressed

>1s

Y

Power off

Prepare UART

communication

Reset

system parameters

Received

"$"

from the PC

Send all of the data in

flash memory to PC

Standard

working mode

Update system

parameters with data

Data

received is in

correct format

Display current

system parameters

while receiving

data from PC

Return to

mode select

Return to

the current mode

Y

N

M = 3

M = 2

M = 1

M = 0

Y

N

N

Y

Power on

Figure 3—

After initialization, you can select the function mode by pressing the Menu button and Enter button. The

LCD will show the status and system parameters.

background image

ple tasks between the GPS and
GSM modules, although it has
only one UART serial port. With
the programmable flash memo-
ry, you have high reliability and
can update your system. The
EEPROM makes it possible to
store system parameters such as
the SMS center number, con-
trol center number, and prede-
termined time intervals.

Other components on the

board are the four-channel
multiplexer, a large capacity
data memory, and the user
interface. The latter consists of
a 2 × 16 LCD, a buzzer, and
three push buttons.

ACCESSORIES

An AT45D021’s serial-inter-

face flash memory is used as a
black box to store data packages.
The 2,162,688 bits of memory
are organized as 1024 pages of
264 bytes each. In addition to
the main memory, the micro
also contains two data SRAM
buffers of 264 bytes each. The
simple SPI serial interface facil-
itates the hardware layout,

increases system reliability, and
reduces the package size and
active pin count. The
AT90S8515 saves GPS data to

flash memory via an SPI port at a user-
defined specific interval. Or it reads
data from the flash memory to backup
to PC. Up to 2160 pieces of information
can be stored in flash memory.

Because the AT90S8515 has only one

UART port, another chip is used to
expand the serial port for three kinds of
different functions. The digitally con-
trolled MC14052B analog switch is a
dual four-channel multiplexer. With
two I/O pins, the AVR controls it to
switch among three channels, all of
which are UART serial interfaces.

One MAX202 chip accomplishes the

conversion between TTL/CMOS level
and RS-232 level, which is necessary
for the RS-232 interface between the
navigator and PC. Using the RS-232
port, the system can backup the data in
flash memory to the PC. Also, you
can change some system parameters
through the PC via the RS-232 port.

36

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

(PDU) mode—for handling short
messages. The system default
is PDU mode; however, Text
mode is easier to understand.
So, use the AT+CMGF=1
command to set the module to
the GSM 07.05 standard SMS
Text mode.

The AT+CMGS command is

used to send a short message.
The format of this command is:

AT+CMGS=<da><CR>Message

Texts<CTRL-Z>

Here,

<da> is a subscriber’s

mobile phone number that you
want to send the short mes-
sage to. The GSM module can
receive incoming short mes-
sages and save them on the
SIM card automatically. You
can use the AT+CMGR com-
mand to read an incoming
short message from the SIM
card storage, and then use the
AT+CMGD command to
delete it when you’re finished.

If you want to read an SMS

message, then send a
AT+CMGR=x command to tell
the GSM module which short
message you want to read.
Next, check the serial port to
receive the message from the
GSM module.

Rs232_r is a subrou-

tine used to receive data from the
UART. Listing 1 demonstrates sending
and reading a short message in a BAS-
COM-AVR program. In this code seg-
ment,

chr(34) converts the ASCII

value 34 to the right quote character
(

”). It also converts chr(13) to <CR>

and

chr(26) to <CTRL-Z>. As you

can see, “My SMS Message” is the
message you want to send.

CIRCUIT DESCRIPTION

The difficult part of designing this

project was learning both the NMEA
GPS message and GSM AT command
protocols. The easy part was designing
the hardware circuit (see Figure 2).
You may download a table of the pin
assignments from the Circuit Cellar
ftp site. As you can see from the
schematic, there are three jack ports.
JP1 (20 pins) is used for the GPS mod-

ule, JP2 (40 pins) is for the GSM mod-
ule, and JP3 is used for communica-
tion with the PC.

The AT90S8515 (U1) is the core of

the circuit. This low-power CMOS 8-bit
microcontroller is based on the AVR-
enhanced RISC architecture. By execut-
ing powerful instructions in a single
clock cycle, the AT90S8515 achieves
throughputs approaching 1 MIPS per
megahertz, allowing you to optimize
power consumption versus processing
speed. The AT90S8515 features 8 KB of
in-system programmable flash memory,
512 bytes of EEPROM, 512 bytes of
SRAM, and 32 general-purpose I/O lines.
Flexible timer/counters with compare
modes, internal and external interrupts,
a programmable serial UART, an SPI
serial port, and two software-selectable
power-saving modes are also available.

The high speed of the AT90S8515

makes it possible to complete multi-

To set

GSM module

work mode

The time

is even second

or odd second

To set

a 1-s timer

Even

Odd

Check

GSM status

The time

is what?

Else

12, 16, 18 s

Read

GPS information

from GPS

module

Save GPS

data to

flash memory

Let GSM module

send GPS data out

according to given

interval

Display messages or

alarm according to

the process done above

Count to

20 s

N

Clear

counter to 0

Y

Check if

there is a short

message

Y

Display short

message for

4 s, and then clear

N

Mode = 1

Figure 4—

The main function is mode 1. The AT90S8515 microcontroller

receives the ship location data every 2 s from the GPS module, and then
saves the data in flash memory every 20 s. At a user-defined time interval,
the AT90S8515 sends the location data to the control center, and then
receives the control information from the control center via the GSM module.

background image

The flow charts in Figures 3 and 4
describe the AT90S8515 program that
controls the devices. The software han-
dles a number of key functions, such as
initializing the system and starting the
GPS and GSM modules. The software
also selects the working mode.
Additionally, it checks and sets the
system parameters in mode 0, backs
up the trace data stored in flash mem-
ory to the PC in mode 2, and resets
the system parameters in mode 3.

Mode 1 is the standard working

mode during which many tasks are
completed. During mode 1, the GPS
signals are read every 2 s from a satel-
lite; the location information is saved
in flash memory every 20 s; and the
GSM module sends location data to
the control center according to the
given interval time. Meanwhile, the
navigator receives the control infor-
mation from the control center from
the GSM module.

APPLIED TECHNOLOGY

Our system is now being used in

Shanghai Port, China for navigation
and monitoring of ships. Aside from
tracking ships, the GPS-GSM Mobile
Navigator can also find use in other
applications, such as navigating taxis.
The system works quite well, and we
plan to adapt it for future projects.

I

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

37

With two control pins and four data

pins, the AVR gives the LCD specific
information to display. Port pins PC2
through PC4 individually sense the
three push-button switches. There is a
Menu button to select the work mode,
and an Enter button to confirm the
selection. The third is an SOS button
used to send an alarm message to the
control center.

SOFTWARE DESCRIPTION

We used the powerful BASCOM-AVR

to develop the software. An IDE is
provided with an internal assembler.
You can also generate Atmel OBJ code.
Additionally, the BASCOM-AVR has a
built-in STK200/300 programmer and
terminal emulator. Other notable fea-
tures include: structured BASIC with
labels; fast machine code instead of
interpreted code; special commands
for LCDs; I

2

C; one wire; PC keyboard

and matrix keyboard; RC5 reception;
and RS-232 communications. The
BASCOM-AVR has an integrated ter-
minal emulator with download option,
an integrated simulator for testing, and
an integrated ISP programmer.

You can easily write the firmware for

this project using the BASCOM-AVR.
And with the ISP benefit of AVR, on-
line emulation is almost unnecessary,
so you can program and test with ease.

Ma Chao is a professor of Electronic
Engineering at East China Normal
University in Shanghai, China. He is
a specialist in digital image compres-
sion and processing, embedded con-
trol systems, and computer network
systems. You may reach Ma at ma-
chao@online.sh.cn.

Lin Ming is a graduate student com-
pleting a Master’s degree in Electronic
Engineering at East China Normal
University. He works primarily with
embedded systems and microcon-
troller-based applications. You may
reach him at lmcrr@online.sh.cn.

PROJECT FILES

To download the pin assignments
and source code, go to ftp.circuit
cellar.com/pub/Circuit_Cellar/
2003/151/.

SOURCES

AT90S8515 and AT45D021
Atmel Corp.
(714) 282-8080
www.atmel.com

Sandpiper GPS receiver
Axiom Navigation, Inc.
(714) 444-0200
www.axiomnav.com

FALCOM A2D GSM module
Falcom Wireless Communications
GmbH
(800) 268-8628
www.falcom.de

BASCOM-AVR
MCS Electronics
+31 75 6148799
www.mcselec.com

RESOURCE

NMEA Specification
National Marine Electronics
Association
(919) 638-2626
www.nmea.org

REFERENCES

[1] European Telecommunications

Standards Institute, “ETSI GTS
GSM 07.05,” V.5.5.0, 1998.

[2] ———, “ETSI GTS GSM 07.07,”

V.5.0.0, 1996.

Listing 1—

We created a program to send an SMS message to a mobile phone (13916315573). The pro-

gram directs the GPS-GSM Mobile Navigator to read and delete an incoming short message. The Print
command is a BASCOM-AVR instruction that sends output to the serial port. The

Rs232_r subroutine is

used to read input from the serial port.

constant definition

Const Gsm_center = “+8613800210500”

//SMS center number

Const Send_number = “13916315573”

//Phone number the SMS

sends to

Const Sms_texts = “My SMS Message”

//Message texts to be sent

//Initialize the GSM module

Print “AT+CMGF=1”

//Set GSM module in Text mode

Print “AT+CSCA=” ; Chr(34) ; Gsm_center ; Chr(34)

//Set SMS center number

//Send a message

Print “AT+CMGS=”; Chr(34); Send_number; Chr(34); Chr(13);

Sms_texts; Chr(26)

//Read and delete an incoming short message

Print “AT+CMGR=1”

//Read first short message

from SIM card storage

Gosub Rs232_r

//Receive message

Print “AT+CMGD=1”

//Delete message from SIM

card storage

background image

38

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ere in the south-

ern Arizona desert

we almost worship

humidity. That’s

because we have so little of it, except
in July and August when it tends to be
muggy. And recently, with the west-
ern United States suffering from pro-
longed drought and disastrous wild-
fires, the subject of atmospheric mois-
ture is of more than passing interest.

Over the years I have acquired vari-

ous inexpensive weather instruments,
including an anemometer, an
indoor/outdoor wireless thermometer,
a rain gauge, and two humidity instru-
ments

an inaccurate human-hair-type

hygrometer and an ungainly sling psy-
chrometer. A while back, I tried search-
ing the Internet for “humidity” and was
rewarded with the datasheet for the rela-
tively new HIH-3610 series of humidity
sensors from Honeywell/Microswitch.
These are solid-state elements described
as delivering instrumentation-grade
humidity sensing performance with
an accuracy of 2%. At an input voltage
of 5 VDC, the output voltage of the sen-
sors varies linearly with relative humidi-
ty over a range of 0 to 100%. Because
the sensors looked interesting, I resolved
to have a crack at designing a humidi-
ty meter around them.

PROJECT GOALS

I decided to build the meter in two

pieces, an indoor unit incorporating
the display and a battery-operated out-
door unit. Data from the outdoor unit
would be transmitted by radio to
avoid the complication of a connect-
ing cable. Reasonable immunity to
interference from Part 15 devices
was essential. I wanted the display to
be switchable from outdoor to indoor
humidity and readable from across
the room in darkness (while lying in
bed wondering if the humidifier had
run out of water). And, the outdoor
unit would be built with surface-
mounted parts so it would be small
and inconspicuous.

I pondered how to deal with a sur-

face-mounted microcontroller. The
one I chose is one-time programma-
ble, but, what if I needed to change
the program? There was no way I
could have gotten it right the first
time. Moreover, how would I pro-
gram the thing to start with? Clearly,
it would not plug into the ZIF socket
on my programmer.

The answers to these questions,

which I’ll explain in this article,
turned out to be simple. But, right
away I discovered that my under-
standing of such subjects as wireless,
SMT, and microcontrollers was woe-
fully behind the times. I’ve learned a
lot from this project, and it has been
fun inventing (or, more accurately,
reinventing) ways of getting the
desired results. One of the things
that helped me significantly was
reading Circuit Cellar articles on
related subjects. Another has been
Digi-Key’s excellent web site, with
its wealth of easily accessible prod-
uct information and datasheets.

Partway through the design stage, I

discovered another goal to set. I have a
friend in western Pennsylvania, Dr.
Daniel Nadler. Dan is an ophthalmol-
ogist who has good woodworking tools
and knows how to use them. Earlier,
he had sent me a 0.5-mm automatic
pencil that he had constructed from a
rare wood. During a chat on the
Internet, I mentioned the humidity
meter I had in mind and the fact that
it needed a nonconducting enclosure
to allow for an internal receiving

A Wireless Indoor/
Outdoor Humidity Meter

h

Fascinated by weather
instrumentation, Ken
recently built an
indoor/outdoor humidi-
ty meter with several
basic components and
a few PIC micros. In
this article, he
describes how to build
the separate indoor
and outdoor units and
how to make them
aesthetically pleasing.

Ken Macleish

FEATURE
ARTICLE

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

39

through a red filter that is cement-
ed into the front panel bezel. A
dot at the lower right corner of
the LED (normally a decimal
point) is lit when the outdoor
humidity is being displayed.
Changing from outdoor to indoor
humidity, or vice versa, is done
by momentarily pressing the but-
ton on the back of the unit. The
sensor for indoor humidity,

which is identical to the one in
the outdoor unit, plugs into the

bottom of a circular plastic well on
the epoxy-glass back panel. The well
protects the sensor and helps to pre-
vent the air around the sensor from
receiving heat from the interior of
the enclosure. It’s made from three
thick nylon washers, two inside the
panel and one outside.

The base of the internal structure

is a 5.375

× 2.375

aluminum plate

that serves as a ground plane for the
receiving antenna. Near the middle
of the ground plane is a BNC panel
receptacle that accepts a Smiley rub-
ber-duck antenna made for 70-cm
hand-held transceivers. The wireless
receiver is a 1.98

× 0.72

daughter-

board plugged into strip sockets on
the back of the circuit board. The
receiver is connected to the antenna
receptacle by a short length of RG-
174 coaxial cable. With this antenna
configuration and with a similar
antenna installed on the outdoor
unit, the unobstructed operating
range is a little over 1000

.

I ordered the 3.8

× 2.5

two-sided

circuit board online from
ExpressPCB in California.
ExpressPCB delivered the circuit
board in three days, along with two
identical sisters, for $62. I down-
loaded the company’s free board
design firmware and found it
extremely easy to learn and use.

Now it’s time to take a look at the

circuit diagram, which is shown in
Figure 2. A Microchip PIC12C672
microcontroller services the indoor
humidity sensor. In addition, a
PIC16F84A microcontroller identi-
fies signals from the receiver,
processes the data, tends the
indoor/outdoor sensor switch, and
controls the two digits of the LED.

antenna. Dan came back with,
“How about wood?” We decided it
would be fun to make the meter
not only a weather instrument, but
also an attractive article of furni-
ture built with some exotic wood.
We ended up working together
despite being 2000 miles apart, and
the meter came out in a nice-look-
ing enclosure that Dan crafted out
of rosewood and curly maple.

TEMPERATURE, HUMIDITY,
AND DEW POINT

Relative humidity is important

because it can be measured with simple
instruments. Dew point is more impor-
tant in meteorology because it’s closely
related to the proportion of water vapor
in a given air sample. Relative humidi-
ty changes when an air sample is heat-
ed or cooled; dew point does not. If you
know the temperature and relative
humidity, a simple chart can give you
the dew point. Such a chart is depicted
in Figure 1. As an example, on the chart
is a dot at a temperature of 76°F and a
relative humidity of 52%. Interpolating
between the two adjacent curves gives a
dew point temperature of 57°F.

I thought about including tempera-

ture sensors in the meter and perhaps
programming the controller to show
dew point and temperature as well as
relative humidity. But, the wireless
thermometer offered by Radio Shack
(part no. 63-1026) is an excellent
instrument, and I saw no need to
duplicate its function. So, for simplic-
ity, I decided to omit temperature
sensing from the meter.

THE INDOOR UNIT

Photos 1 and 2 show the front and

back of the indoor unit and Photo 3
shows its internal construction. The
0.56

seven-segment LED is visible

105

100

95

90

85

80

75

70

65

60

55

50

45

40

35

30

35

40

45

50

55

60

65

70

75

80

85

90

95

100

105

110

100

95

90

85

80

75

70

65

60

55

50

45

40

35

30

25

20

15

5

10

0

Temperature (

˚

F)

Relativ

e humidity (%)

Dew point (

˚

F)

Figure 1

With this chart, you can determine the dew point temperature when you know the air temperature and

relative humidity.

Photo 1

The indoor unit displays relative humidity from 0 to 99%.

The dot means that the unit is showing outdoor humidity.

background image

40

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

PIC16F84A FIRMWARE

I’ll describe some critical parts of

the PIC16F84A firmware here; the
assembly listing is available to down-
load from the Circuit Cellar ftp site
(local.asm). The listing is heavily com-
mented and may be consulted for pro-
gramming details. I’ll cover the
PIC12C672 firmware later in connec-
tion with the outdoor unit.

Now, I would like to concentrate on

measuring outdoor humidity. An
amplitude-modulated wireless trans-
mitter in the outdoor unit sends a
brief digital packet on 433 MHz every
10 s. A 1 bit is represented by the RF
output lasting 1 ms

±

1.5%, and a 0 bit

is represented by the absence of out-
put for an equal time period. Each
packet consists of a preamble of
24 alternating 1 and 0 bits (12 one,
zero pairs: 10), a 4-bit sync nibble
(1100), a 0.5-ms start pulse, and 1 data
byte. The data byte is an 8-bit binary
number equal to the percent of rela-
tive humidity at the outdoor unit.

In the receiver, a packet that’s been

down-converted, amplified, and enve-
lope-detected is fed to an internal
data slicer that performs a 1-bit ana-
log-to-digital conversion. The slicer
outputs 4 V to the receiver’s data ter-
minal while the detector output is

greater than a threshold value, and
outputs 0 V when the detector out-
put is less than the threshold. With a
time constant of many milliseconds,
the threshold voltage adjusts itself to
the average value of the detector out-
put. The analog-to digital conversion
is faithful if the threshold voltage set-
tles at a value that is halfway between
the minimum and maximum detector
output; this will be true if the digital
packet contains equal numbers of
intermixed 1 and 0 bits.

Between packets, the wireless trans-

mitter is silent, the receiver AGC may
go to full gain, and the data slicer
threshold voltage moves slowly to the
average value of receiver noise plus

any extraneous signals present on the
same frequency. The data slicer now
outputs a random series of 4-V noise
pulses possibly mixed with extraneous
signals. The first duty of the
firmware is to find the next humidi-
ty packet amid this mess.

When it comes along, the preamble

lasts long enough to put the threshold
voltage of the data slicer where it
belongs. Conventional wisdom states
that for satisfactory operation, equal
densities of zeros and ones should
prevail throughout the digital packet.
During the preamble and sync nib-
ble, my packet meets this criterion,
but the data byte could contain all
zeros, all ones, or anything in-
between. Usually, a balance of ones
and zeros is maintained until the end
of the attached data. This is com-
monly done by encoding the data as
Manchester code, wherein each bit is
changed to a high plus a low (if the
bit is a one) or a low plus a high (if a
zero) before transmission.

I didn’t encode the data byte.

Because of the threshold-voltage gen-
erator’s long time constant, the
threshold voltage doesn’t have time
to change much while the start pulse
and the single data byte are coming
through. Therefore, for the humidity

Figure 2

In the indoor unit, the PIC16F84A microcontroller gets data from either the wireless receiver or the PIC12C672, as selected by the push button. The two digits of

the seven-segment LED, lit alternately by the RA0 and RA1 outputs of the PIC16F84A, appear to be on simultaneously.

Photo 2

The back panel of the indoor unit has a

push button that toggles between outdoor and indoor
humidity. The indoor humidity sensor plugs into a circu-
lar well in the middle of the panel.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

41

meter, Manchester or other encoding
is unnecessary and would only add to
the complexity of the firmware at
both ends of the RF link. This still
might be true even if the data is a
couple of bytes long, but it would
depend on the dynamics of the
threshold voltage.

In the foregoing description, I’ve

assumed that the signals from the out-
door unit are strong enough to sup-
press any extraneous signals. Packets
that are corrupted by interference will
be skipped. Generally this is not a
problem, because humidity changes
occur slowly. The meter simply dis-
plays the last humidity value
obtained until the interference stops
and new readings come in.

All of this still prompts an impor-

tant question: How does the system
lock in on the desired signals?

EXTRACTING DATA

The firmware samples the data

slicer output every 40 µs. Each time a
positive transition (i.e., a change from
0 to 4 V) occurs, the program meas-
ures the time to the next positive
transition. If this time is near 2 ms, it
means the 2 bits of a 10 pair in a pre-
amble might have been detected. If
the next positive transition occurs
2 ms later, it’s likely that these were
two of the 10 pairs in a preamble. If
several more 2-ms intervals follow,
the probability is high that this is
either part of a preamble or a similar
pulse train from an extraneous source.

After detecting the end of the pulse

train, the program tests whether or
not the next positive transition arrives
in 4 ms, as it would after the 4 bits of

a sync nibble. (The 1100 sync nibble
always ends with a positive transi-
tion, thanks to the adjacent start
pulse.) If a 4-ms interval follows the
pulse train, then the program assumes
that it was a sync nibble and proceeds
to clock in the 8 bits of relative
humidity. Otherwise, the program
continues to look for a preamble.

Indoor humidity values go from the

PIC12C672 to the PIC16F84A over a

circuit board trace. The absence of
receiver noise and extraneous signals

in this case could simplify the process,
but it’s easier to have the PIC16F84A
execute the same procedure for both
indoor and outdoor humidity.

AVERAGING

Successive humidity readings some-

times vary by 1% and occasionally by
2%. I think the variations are caused
by slight inhomogeneities in the air
wafting past the sensor (the sensor
responds rapidly). To smooth out
these variations, five consecutive

Photo 3

The insides of the indoor humidity sensor

unit slide into the enclosure from the rear. Four
screws go up through the rubber feet and floor of the
enclosure, and then into threaded spacers that sup-
port the aluminum ground plane.

background image

advice, I made the cable short (4

) and

isolated the signal lines by using 10-
conductor ribbon cable with every
other conductor grounded.

REPROGRAMMING AN OTP

In the PIC manual for mid-range

devices, Microchip discusses how to
reprogram a one-time programmable
microcontroller. [1] Check out section
28.7 in the manual. The technique uses
the fact that in the EPROM, a 1 bit can
be electrically reset to zero, although
not vice versa. The maximum number
of times you can reprogram depends on
the program size in relation to the total
program memory; in my example, it
can be done about 16 times by using a
new section of the program memory
every time you reprogram.

For additional details about repro-

gramming your own microcon-
troller, look at the assembly code for
the PIC12C672. You’ll find the code
file (remote.asm) along with the
other assembly code file on the
Circuit Cellar

ftp site.

REDUCING INTERFERENCE

Interference between this device

and others that use the same frequen-
cy is a twofold problem. One issue is
interference from other signals, and
the other is interference to other sig-
nals. With an increasing number of
Part 15 devices running at 433 MHz,
preventing interference can be diffi-
cult. Amateur stations are licensed
users of this frequency. If a legal Part
15 device or an amateur station inter-
feres with the humidity meter, my
only recourse would be to improve my

design or move away. On
the other hand, if the
humidity meter interferes
with the functioning of a
Part 15 device, I could be
required to change the
design, cease using the out-
door unit, move away, or
earn an amateur radio
license. The easiest solution
is to restrict the power radi-
ated from the outdoor unit
and earn an amateur license.

Obtaining an amateur tech-
nician license isn’t difficult
and is a good idea anyway.

42

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

readings are summed by the firmware,
and then the firmware computes and
displays their average value. When the
sensors are switched, an initial delay
is avoided by having the program
show the next reading as soon as it
arrives. Thereafter, the program oper-
ates in Averaging mode, updating the
display every 50 s.

THE OUTDOOR UNIT

Photo 4 shows the outdoor unit sus-

pended from the ceiling of my porch.
The 9-V battery is attached to the unit
with Velcro. Figure 3 and Photo 5
illustrate the circuit diagram and inte-
rior details, respectively. The backside
of the circuit board is a nearly solid
ground plane. I ordered the board from
ExpressPCB, and again liked the
results. The board is so small that the
minimum order, when cut up, yielded
12 boards—all of them perfect.

Several circuit features help to

hold down power consumption: the
transmitter consumes no power
except while sending a one;
the PIC12C672 microcon-
troller sleeps between read-
ings; and 5-V power is sup-
plied to the humidity sen-
sor only while a reading is
under way. That leaves the
voltage regulator as the
principal power consumer,
because it has to run contin-
uously to energize the
watchdog timer in the
PIC12C672. I have yet to
replace the original battery
after seven months of con-
tinuous operation.

The Pomona 2390 die-cast alu-

minum box came with a BNC panel
receptacle at each end. I replaced one
of the receptacles with the power
connector, which happened to fit the
same hole. That left four empty
screw holes around the connector,
which now provide air circulation to
the humidity sensor and drain con-
densation from the box. Additional
access to ambient air is provided by a
hole in the cover plate located over
the humidity sensor.

PIC12C672 FIRMWARE

The PIC12C672 micros in the

indoor and outdoor units run identical
firmware. Every 10 s, each micro per-
forms an A/D conversion on the DC
output of a humidity sensor. The pro-
grams then calculate the relative
humidity from the linear equation
that relates humidity to the sensor
output. Finally, they formulate a digi-
tal packet and feed it serially to the
wireless transmitter’s data terminal
(in the outdoor unit) or to the RA2 ter-
minal of the PIC16F84A (in the indoor
unit). The PIC12C672 then goes to
sleep until the watchdog timer wakes
it for the next reading.

I programmed the PIC12C672 of the

indoor unit by plugging it into my
Microchip PICSTART Plus program-
mer, but that wasn’t possible with the
outdoor unit’s surface-mounted
PIC12C672. For the outdoor unit, I
made up a little cable with appropriate
connectors at the ends and used it for
in-circuit serial programming via the
programming header and the program-
mer’s ZIF socket. Heeding Microchip’s

Photo 5

Here

s the outdoor unit without its cover plate. The principal components

are (left to right) the BNC antenna receptacle, the wireless transmitter, the white
programming header, the 8-pin PIC12C672 microcontroller, the humidity sensor, the
voltage regulator, and the power connector. The humidity sensor is the small black
object plugged in at the lower right of the PIC12C672.

Photo 4—

The outdoor unit hangs by its antenna from

a vinyl-covered cup hook on my porch.

background image

short wire antenna on the outdoor
unit were easy tasks. The abbreviated
transmitting antenna is an inefficient
radiator, and impedance mismatch
lowers the power delivered to it by
the transmitter. As you can see in
Table 1, I measured the relationship
between the transmitting antenna and
the maximum unobstructed range.

Because the range I needed was

less than 50

through one or two

intervening walls, I settled for a 5/8

wire antenna, which incidentally
permitted the nice mounting
method shown in Photo 4.

Before someone tries patiently to

explain to me the extensive FCC
Part 15 regulations, I’ll conclude by
saying that so far I haven’t received
any complaints from either ham
operators or Part 15 devices!

I

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

43

Initially, I used the simplest algo-

rithms I could think of for receiving
data from the outdoor unit, but soon I
ran into trouble. Some infernal device
in the neighborhood was messing up
the readings. After much sleuthing, I
found that the culprit was my own
Radio Shack Part 15 wireless ther-
mometer! It puts out a whale of a sig-
nal on the 433-MHz band and my 1-
mW-plus transmitter, even with a rub-
ber-duck antenna, couldn’t compete.
The problem vanished after I installed
the firmware described earlier. Now
the two instruments coexist amicably.

I lowered the probability of interfer-

ence to other services by substantially
reducing the power radiated by the
outdoor unit. My philosophy was to
use the best receiving antenna that
would fit inside the indoor unit’s
enclosure, and then reduce the radiat-
ed power to the minimum required for
reliable reception. Installing a rubber-
duck antenna in the indoor unit and a

PROJECT FILES

To download the code and a parts
list, go to ftp.circuitcellar.com/
pub/Circuit_Cellar/2003/151/.

SOURCES

Two-sided board
ExpressPCB
www.expresspcb.com

MAN6940 LED
Fairchild Semiconductor
(207) 775-8100
www.fairchildsemi.com

HIH-3610 Sensors
Honeywell International, Inc.
www.honeywell.com/sensing

LT1121CST-5 Voltage regulator
Linear Technology Corp.
(408) 432-1900
www.linear.com

PIC12C672/16F84A Micros
Microchip Technology, Inc.
(480) 786-7200
www.microchip.com

2390 Box
Pomona Electronics
(909) 469-2900
www.pomonaelectronics.com

RCR-433-HP receiver, RCT-433-AS
transmitter
Radiotronix, Inc.
(405) 794-7730
www.radiotronix.com

RDMD-440 Rubber-duck antenna
The Smiley Antenna Co.
(619) 579-8916
www.htantennas.com

RESOURCES

Digi-Key Corp.
(800) 344-4539
(218) 681-6674
www.digikey.com

FCC Part 15 regulations
www.fcc.gov/oet/info/rules/part15

Ken Macleish is a retired engineer liv-
ing in Tucson, Arizona. He graduated
from Caltech in 1939 and has a doc-
torate in nuclear physics from the
University of California. During
World War II, he worked in Oak
Ridge, Tennessee at Tennessee
Eastman Company. Before retiring in
1970, he was with Eastman Kodak
and Perkin-Elmer Corporation in vari-
ous engineering and management
positions. Ken may be reached at
kmacleish@comcast.net.

REFERENCE

[1] Microchip Technology Inc.,

“PICmicro Mid-Range MCU
Family Reference Manual,”
DS33023A, December 1997.

Table 1—

Note the maximum operating range for vari-

ous transmitting antennas.

Antenna

Range

None

3

5/8

wire

100

1.25

wire

127

2

wire

160

Rubber duck

1030

Figure 3

In the outdoor unit, as in the indoor unit, the DC output of the humidity sensor feeds the PIC12C672

s

A/D converter via the chip

s AN2 port while the GP4 port supplies 5-V power to the sensor. Digital data packets go

from the GP5 port to the modulating input of the wireless transmitter.

background image

44

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

’ve been inter-

ested in robotics

since I was a little

boy. Back when I was in

junior high school, I built a mobile
robot platform out of the drive portion
of a child’s motorized car and a
Commodore VIC-20. Over the years,
advances in technology have made
experimenting with robotics more
enjoyable. The Game Boy Camera is
an ingenious addition to the Game
Boy Color game unit that came out a
couple of years ago. It’s a black-and-
white digital camera with a resolution
of 123 × 128 pixels, operating at a rate
of one to 30 frames per second.

The camera’s original price was

between $40 and $50, making it some-
what cost-prohibitive for hobbyists.
However, because the product was
recently discontinued, I found some
on eBay selling for between $10 and
$20. The reduced price makes the
camera an attractive solution if you’re
interested in robot navigation. It’s
even less costly than a single
Polaroid sonar module ($30 to $50)
and in the same ballpark as reflective
infrared sensors ($5 to $15).

The sensor inside the camera is a

highly integrated CMOS array with
built-in edge enhancement and extrac-

tion. Built-in image processing enables
a microcontroller to perform object
detection and tracking, provided cer-
tain assumptions about the back-
ground of the image are valid.

Atmel’s AT90S8515 microcontroller

has an external memory interface bus
that allows you to easily connect an
SRAM IC. The on-chip hardware
UART makes it possible to output
processed data without consuming
precious processing resources, and the
timers enable it to control hobby
servo motors without much work. In
addition, the AVR series of microcon-
trollers has a high-speed RISC archi-
tecture (e.g., most instructions take
one or two clock cycles) that makes
timing calculations simple. In short,
the flexibility of the AVR 8-bit
microcontrollers makes attaching
special-purpose peripherals like the
Game Boy Camera a breeze.

Figure 1 is a block diagram of a

camera interface and object-tracking
system. As you can see, the camera is
controlled via some of the microcon-
troller’s general-purpose I/O pins.
The analog output of the camera is
attached to the external A/D con-
verter. The servos are connected to
two more pins of the microcon-
troller, and the RS-232 converter
conditions the UART’s signals for
connection to the outside world.

Figure 2 details the interface circuit.

A few notes might be helpful here.
The A/D converter needs to be fast
enough to read out a pixel value
every 2 µs if the maximum frame
rate is desired. This means the sam-
ple frequency of the ADC must be at
least 500 kHz. A speed requirement
like this rules out the use of the
built-in ADC on most microcon-
trollers (e.g., the AT90S8535).

For my circuit, I settled on the

Analog Devices AD7822, which does-
n’t have the added complication of
pipelining that many of the newer
ADCs seem to have. Also, you don’t
need the RS-232 converter IC if the
circuit will be interfaced directly to
another microcontroller’s UART. I
used a 7.3728-MHz crystal to achieve
compatibility with standard data rates.
A speed of 115,200 bps is the maxi-
mum speed that a standard PC serial

Easy Image Processing

i

Since childhood,
Daniel has incorporat-
ed high-tech toys in his
robotics projects.
Thus, it’s no surprise
that he used a Game
Boy Camera in one of
his recent designs.
Now, he’ll show you
how to use the camera
to enhance the naviga-
tion system on your
own mobile robot.

Daniel Herrington

ROBOTICS
CORNER

Camera Interfacing for Robotics

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

45

In the first part of the pro-

gramming process, you can
set the camera’s registers for
a normal (positive) or invert-
ed (negative) image, an edge-
enhanced image, or an edge-
extracted image. Register set-
tings also control the cam-
era’s exposure time, the out-
put voltage offset level, and
the gain of the video signal
(i.e., how much it varies from
the output voltage offset).

The maximum frequency

for the camera’s XCK input is
500 kHz (T = 2 µs). With a
microcontroller crystal fre-
quency of 7.3728 MHz (T =
135.6336 ns), the time for

each half-period of XCK is:

or approximately eight microcon-
troller clock cycles. I tuned the timing
of the assembly code by adding NOP
instructions where appropriate.

It’s interesting to see how different

register settings affect the image out-
put from the camera. Table 1 shows
two settings: Normal mode and Edge
mode. These settings were derived by
experimentation and may need to be
adjusted for any given environment.

I set up a test area with various

medium- and high-contrast colored
objects on a light-colored floor (see
Photo 4). The top-center image frames
within Photo 5 show what the Game
Boy Camera images look like with
specific register settings: Photo 5a is a
normal image; Photo 5b is a negative
image; and Photo 5c is an edge-
extracted image. I used this type of
image for object tracking. Note that
the light-colored objects (red and

port supports, so I pro-
grammed the microcontroller
to work at that speed.

The completed prototype

circuit board is shown in
Photo 1. It’s a simple wire-
wrapped board with all
through-hole components
except the ADC. The poten-
tiometer is used to adjust the
reference voltage for the micro-
controller’s on-chip analog
comparator. The comparator is
used in place of the ADC for
the hobby robot depicted in
Photo 2. I found that the opti-
mum setting for the reference
voltage for my test environ-
ment was about 4.66 V.

PHOTOGRAPHY 101

The Game Boy Camera uses

Mitsubishi’s M64282FP CMOS image
sensor. This sensor is special because
Mitsubishi designed some image pro-
cessing capabilities right into the
CMOS array itself.

Software isn’t required to perform

edge detection, enhancement, or
extraction from the image. To get an
edge-extracted image, simply put the
sensor in the appropriate mode and
then read out the resulting analog
pixel voltages for the entire image.
After this image is read out, it can be
further manipulated by the microcon-
troller. Photo 3 shows the M64282FP
chip inside the camera.

I didn’t use the camera’s cartridge

base in these experiments. After the
cartridge is opened, the ball can be
disconnected from the cartridge. I
disconnected the purple cable from
the cartridge and soldered a standard
0.1

double-wide header on the end.

This allowed a 0.050

ribbon cable to

be used for a long-distance connec-
tion, although I don’t recommend
exceeding 1

or so.

By the way, I cut a hole in the back of

the ball so that the cable could exit in a
place where it doesn’t interfere with
mounting the camera on a pan-tilt base.
You may download the pinout of the
original connector that’s coming out of
the ball from the Circuit Cellar ftp site.
The numbers refer to the corresponding
pin numbers on the M64282FP chip.

To simplify the interfacing of the

assembly code and speed things up, I
turned the camera sensor board in the
camera ball upside-down. This
ensures that the first pixels to be read
from the camera are those correspon-
ding to the bottom-right corner of the
image instead of top-left. Furthermore,
this makes the calculation of the near-
est object faster, because the image is
read out serially from the sensor.

The procedure for programming

and using the M64282FP is straight-
forward. First, load the registers in
the M64282FP using a synchronous
serial protocol that is similar to
other two-wire synchronous serial
interfaces. The microcontroller gen-
erates the XCK, SIN (data), and
LOAD signals for loading all of the
registers in the camera IC.

Next, give the Start command.

After the exposure is finished, the
camera IC will return a READ signal.
When the READ signal becomes
active, read 15,744 pixels (123 × 128)
worth of analog data on the VOUT
pin synchronously
with the XCK sig-
nal that the micro-
controller gener-
ates. After all of the
image data has been
output, the READ
signal becomes
inactive, and the
camera automati-
cally starts another
exposure.

RS-232

converter

Game Boy

Camera

U
A
R

T

Memory

interface

Timers

General-purpose

I/O

A/D

converter

Latch

32K x 8

SRAM

Pan/left

Tilt/right

Servo

Servo

AT90S8515

Figure 1—

You can use the two servos for either panning/tilting a camera

head or driving the left and right wheels of an autonomous robot. For the lat-
ter, the servos must be modified to allow for continuous rotation. This servo
hack is common for hobby robots.

Register

Address

Normal mode

Edge mode

0

000

0x80

0x3F

1

001

0xD6

0xD6

2

010

0x06

0x18

3

011

0x00

0x00

4

100

0x01

0x01

5

101

0x00

0x00

6

110

0x01

0x01

7

111

0x07

0xF3

Table 1—

When you’re switching from Normal to Edge mode, it’s important to

remember the M64282FP registers 0, 2, and 7.

background image

46

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

orange in this case) don’t show up as
well in the edge-extracted image. You
can increase or decrease the exposure
setting to allow these low-contrast
objects to be seen in Edge mode.

OBSTRUCTED VIEWS

Ian Horswill’s 1993 dissertation,

“Specialization of Perceptual
Processes,” details some of his research
concerning image processing for robot-
ics. Horswill outlines various assump-
tions that may be made by a robotic
image-processing system for detecting
obstacles in a given environment.

After the edges have been extracted

from an image, the height of the first
edge from the bottom of the image can
be determined. Let’s assume the cam-
era is mounted somewhere on the

front of the robot, several inches or
feet above the floor. If the camera is
aimed forward and down, and if the
floor doesn’t have visible edges (i.e.,
the carpet color is constant, and
there are no high-contrast seams or
changes of color), then the only
edges should be the obstacles on the
floor or a floor-to-wall transition in
front of the robot.

If the robot moves near a wall, and if

there is enough of a contrast between
the wall and floor, an edge will be
detected at that location in the image.
Using this technique, the robot can tell
how far away the edge of the obstacle is
by its height in the image.

If the image is divided into thirds

(i.e., left third, center third, and right
third), then the lowest edge in each

third of the image gives the robot the
distance it can move in that direc-
tion. Then, the robot can turn and
move toward the farthest direction to
avoid the closer obstacles. This
“greatest third” approach is well
suited for corridor following, because
the greatest third of the image is most
likely the direction of the corridor. [1]

The camera takes care of extracting

the edges from the image, but the
microcontroller must perform any
additional processing. For instance, if
you want to know an object’s distance
(or depth) from the robot, then you’ll
need an algorithm to post-process the
image and reduce the information
down to a depth table. The index to
this table could represent a given
x location, or column. The entry at

Figure 2—

With this processor and interface circuitry and connector design, you can enhance your own robotics applications with the Game Boy Camera.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

47

each index within the table
could be written with the
row of the lowest edge pixel
in a given column. This algo-
rithm is implemented in the
microcontroller as shown
in Listing 1.

Now, I’ll explain the oper-

ation of the depth-finding
code. Starting at the bot-
tom-right corner of the
image, count the number of
pixels vertically until one is
reached that surpasses a pre-
defined threshold value. Put
the row number (i.e., depth)
of that pixel in a table, step
to the next column to the
left, and repeat the process.

When the depths of all of the

columns of the image have been
recorded, send that information out
of the UART. A graphical representa-
tion of the depth map for the test
objects in Photo 4 is shown in the
Depth/Nearest/Track frame in
Photo 5c. The groups of shaded
columns are areas that include objects.

POINT AND SHOOT

The opposite of obstacle avoidance

is object tracking. The camera can be
panned and tilted in response to an
object found in the image. Assuming
the lowest edge in the image above
some brightness threshold is an object
to be tracked, the microcontroller can
command servo motors to pan and tilt
the camera to move the object to the
center of the image. This requires

some intelligent control of the
motors to prevent a slow response,
overshooting, and ringing.

To perform object tracking, the

microcontroller searches the image
in RAM from the bottom up. When
it finds the first edge brighter than a
given threshold value, it marks the
x and y locations and measures the
horizontal and vertical distance of
this edge from the center of the
image. Then, the microcontroller
issues a corrective movement com-
mand to the servos, which respond
by redirecting the camera until the
object is centered in the view.
Listing 2 shows how it’s done.

Photos 6a and b show the pan-tilt

servo mechanism. The pan servo is
directly mounted to the tilt servo’s
control surface. Note that the sub-

micro-sized servos in my
photos allow for a com-
pact installation.

The performance of the

pan-tilt camera head is
adequate for tracking
small objects, provided
that the object isn’t mov-
ing faster than about 1

per

second at a distance of 4

from the camera. This
means you can roll a ping-
pong ball at a moderate
speed across the floor
roughly 4

in front of the

camera, and the camera
will lock on and track the
ball until the servos reach
their limit.

The system won’t notice a bounc-

ing ball. Using a large ball (e.g., a
basketball) causes different edges
(left and right) of the ball to be
detected, and the camera oscillates
between the two nearest edges if they
alternate in intensity or y position.

One helpful piece of equipment for

tuning the system is a laser pointer.
With a laser pointer, a bright point can
be moved from one location to another
almost instantaneously. Using one, you
can observe the reaction of the servos.

The gain of the system is set too

high if the servos overshoot and
“ring” (i.e., oscillate until they come
to a rest) at the new location. The
gain should be set by increasing or
decreasing the divisor of the error
amount so that the correction amount
causes the servos to overshoot slightly

Photo 1—

The prototype circuit board is small enough to fit inside a mobile hobby robot.

Photo 2—

I’ve provided you with four views of the mobile robot. The servo that controls the tilt angle of the camera is for future expansion.

a)

b)

c)

d)

background image

48

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

without ringing. Look for the con-
stant,

TRACKDIV, in the assembly

code for more information.

Incidentally, the entire image-cap-

ture/process/output sequence takes
roughly 11 ms, yielding a frame rate
of about nine frames per second. The
pan-tilt camera head is only able to
track objects while they are within the
servo’s travel limits. If a subject is lost
because it moved too far to the left or

right, the camera will wait for up to 30
frames for the object to reappear before
it returns to the center position to look
for another object. You can overcome
this limitation by giving the camera the
ability to pan all the way around. To do
this, mount it on a mobile robot.

FOLLOW THAT SUBJECT!

You can apply the theory used for

panning and tilting a camera to con-
trolling a mobile robot. The camera
itself is stationary with respect to
the robot base. Instead of controlling
the camera directly, the microcon-
troller commands the robot base to
move in a certain direction at a spec-
ified speed. This arrangement allows
the mobile robot to find high-con-
trast objects and approach them.

The robot is able to search for objects

by spiraling out in an ever-widening arc
until an object is within view. When an
object is detected, the robot faces the
object and speeds toward it. The robot
slows down gradually until it stops
with the object located in the center of
the camera image. As long as the object

doesn’t move too fast, the robot will
continue to rotate, move forward, or
move backward to keep the object in
the center of the image. Photo 2 shows
the prototype of the mobile robot.

Instead of using the external ADC,

the microcontroller uses the on-chip
analog comparator to detect bright
pixels. In addition, the RAM isn’t
used, because the only information
the robot requires is the nearest

Photo 3—

There’s only one chip and two capacitors on

the circuit board in the camera ball. Take a look at the
clear-packaged M64282FP IC.

Photo 4—

The perfect testing area may be closer than

you think. I placed the test objects on my kitchen floor,
which has a practically constant texture and surface.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

49

Photo 5a—

The normal image doesn’t have valid depth or nearest-object information. b—You can familiarize your-

self with a negative image. Notice that I had to increase the exposure (register 2) in order to get a decent image.
c—

The top frame holds the edge-extracted image. The black columns in the bottom frame make up the depth

map, and the nearest object is marked with a red dot.

a)

b)

c)

TERMS:

NO MINIMUM ORDER

. Shipping and handling for the

48 continental U.S.A. $6.00 per order. All others including AK,
HI, PR or Canada must pay full shipping. All orders delivered
in CALIFORNIA must include local state sales tax. Quantities

Limited. NO COD. Prices subject

to change without notice.

MAIL ORDERS TO:

ALL ELECTRONICS

CORPORATION

P.O. Box 567

Van Nuys, CA 91408

FAX (818)781-2653

e-mail allcorp@allcorp.com

CALL, WRITE

FAX or E-MAIL

for our

FREE

96

Page

CATALOG

Outside the U.S.A.

send $3.00 postage.

CHARGE ORDERS to Visa, Mastercard,

American Express or Discover

1-800-826-5432

ORDER TOLL FREE

New Lower Pricing!

JMC# 1225-12HBA
120 mm (4.72") square x
25 mm (1") wide cooling fan.
Dual ball bearing fan pro-
vides reliable output of
88 CFM @ 2600 RPM.
12 Vdc @ 0.6 Amps.
45 Dba max @ 1M. Designed
for 50,000 hours @ 25 deg. C. Thermoplastic
housing and 7 blade impeller. Three 7" pigtail
leads with 3-pin connector (0.1" cntrs). Third
lead is for sensing rotation. Prepped with
metal finger guard. UL, CSA,CUL, CE. Large
quantity available.

CAT# CF-153

$

4

00

each

90 for $3.00 each

450 for $2.25 each
990 for $1.50 each

1980 for $1.30 each

Incredible Price! 12 Vdc

120mm Cooling Fan w/ Screen

SUPER BRIGHT RED 6,000 mcd T-1 3/4

CAT# LED-94 75¢ each
100 for $50.00 - 1,000 for $350.00

BLUE - water-clear 1,500 mcd T-1 3/4

CAT# LED-74

$1.75 each

100 for $115.00 • 1,000 for $950.00

WHITE - water-clear 3,000 mcd T-1 3/4

CAT# LED-75 $2.00 each
100 for $165.00 • 1,000 for $1300.00

Transparent hinged plastic
box with 10 compartments.
Great for parts storage or
display of small items.
Outside dimensions 7" x
3.4" x 1.25". Friction-lock lid with dual clasps.
Each box individually wrapped in a cardboard

sleeve.

CAT # SB-10

10 Compartment Plastic

Storage box

SHOP OUR ONLINE STORE

www.allelectronics.com

$

1

00

each

Case of 36 for $30.60

(85¢ each)

background image

50

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

object location. To determine the
location of the nearest object, the
pixels from the camera are read and
processed on the fly.

Because the information isn’t sent

from the UART, it’s pointless to have
the RS-232 converter on the board.
Therefore, you can construct a

reduced circuit for the mobile robot.
The only components that you need
for the mobile robot’s microcon-
troller board are the microcontroller
itself, the crystal, a potentiometer
(which is used for adjusting the ana-
log comparator reference voltage),
and a few capacitors.

Regarding the performance of the

mobile robot, the camera does an
excellent job sensing high-contrast
objects within its view; however, it
is inadequate for detecting the major-
ity of medium- and low-contrast
obstacles. In the real world, you
should always use multiple layers of

Photo 6a—

Four AA NiCd or NiMH batteries power the circuit board used for the pan-tilt head. b—These servos have a quick transit time. It takes only 0.09 s to rotate the con-

trol surface through 60°! This fast response time keeps the servos from being the limiting factor in the system’s reaction time.

a)

b)

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

51

sensors. It is a good idea to try sup-
plementing the camera with a
bumper panel or whiskers.

DEVELOPING

The software for this project con-

sists of two parts. The first section
consists of the assembly code in the
AVR microcontroller that talks to
the camera, RAM, and serial inter-
face. The second part includes the C
program for a Linux-based PC that
reads and writes camera registers. In
addition, this portion captures
images and obtains depth informa-
tion, nearest object information, or
object-tracking locations.

I assembled the microcontroller

code with the tavrasm AVR assem-
bler and programmed the microcon-
troller with sp12. I wrote the C pro-
gram for the host PC using the
Simple DirectMedia Layer (SDL)
library, which is a public cross-plat-
form graphics and multimedia-pro-
gramming library.

SDL includes routines for drawing

pixels on the X-windows display. A
user-contributed extension, Bfont,
supplies the routines for writing text
to the window. Refer to Photo 5 for
screen shots of the user interface.
Although I completed all of the devel-
opment for this project in Linux, it
should be fairly easy to port to a
Windows environment.

There are two versions of the AVR

assembly code. The pan-tilt program
controls the pan-tilt camera head, and
the chase program controls the
mobile robot. The pan-tilt code has
the added overhead of communicating
with the PC through the UART. In
addition, it requires the use of the
pan-tilt C program on the PC. This
adds significant delays to the opera-
tion of the pan-tilt camera.

If you want to get the maximum

performance out of the pan-tilt cam-
era, you can hard-code the register
settings and remove the calls to the
UART communication routines. The
chase code is already optimized for
the fastest possible frame rate.
Either of the AVR programs can be
modified to allow for higher-level
behavior by adding calls to new rou-
tines in the main loops.

ENLARGEMENTS

One way to enhance the output of

the tracking system would be to
mount a low-power laser pointer on
the pan-tilt head. Then, as long as the
field of view is kept away from
humans and highly reflective surfaces
(in addition to other appropriate safe-
ty precautions), the robot could alter-
nate between strobing the laser point-
er and tracking an object. This would
let you see a pulsating red dot, signal-
ing where the robot is actually focus-
ing its attention.

You could also use the laser and a

cylindrical lens to generate a flat,
fanned-out beam (visible as a hori-
zontal line on any objects in its
path). This line would be visible
only at points in the field of view
where an object is obstructing the
beam (T. Ward, “Scope Out the Laser
Range Finder,” Circuit Cellar 46).
Therefore, the camera would have a
much greater ability to detect low-
contrast objects against the floor
background. Additionally, this
approach would also help in finding
low-contrast walls.

If a high-speed parallel connection

to a PC were used instead of the serial
one, then the PC could attempt to per-
form pattern recognition in real time,
comparing the edge-extracted image to
an edge database of known objects.

A similar improvement would be

to use two cameras in tandem with-
out pan servos. A microcontroller
could send both edge-extracted
images via a high-speed parallel con-
nection to a PC, allowing the PC to
compare the two images and attempt
to find matching patterns of edges.
Assuming that the pan angles of the
two cameras were fixed, the match-
ing pattern locations would then
allow the PC to determine the dis-
tance to certain objects based on the
distance between the two cameras
and the difference in pan angles. [2]

I

Daniel Herrington received his
B.S.E.E. and M.S.E.E. from the
University of Texas at Arlington. He
has been a VLSI design engineer for
the past eight years. Currently, he’s
working in the ASIC Products divi-

background image

52

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

Listing 1—

The depth-finding code simply checks each column for the first bright pixel, starting from the

bottom of the image. This code relies on the camera sensor being mounted upside-down in the ball (an
easy modification).

ldi

col_cnt, 0

//Start at right-hand column

depth_outer_loop:

ldi

row_cnt, 0

//Start at bottom row

depth_inner_loop:

ldi

temp1, 0

//The next few lines are a shortcut for ptr = row_cnt × 128

mov

ptrlo, row_cnt

lsl

ptrlo

lsl

ptrlo

lsl

ptrlo

lsl

ptrlo

lsl

ptrlo

lsl

ptrlo

lsl

ptrlo

mov

ptrhi, row_cnt

lsr

ptrhi

add

ptrlo, col_cnt

//ptr = ptr + col_cnt

adc

ptrhi, temp1

ldi

ZL, low(RAMBASE)

ldi

ZH, high(RAMBASE)

//Z = pointer to image in RAM

add

ZL, ptrlo

//Z = Z + ptr

adc

ZH, ptrhi

ldi

YL, low(DEPTHBASE)

ldi

YH, high(DEPTHBASE)

//Pointer to depth table

add

YL, col_cnt

adc

YH, temp1

ld

pixel, Z

cp

pixel, thresh

//If the pixel is above the

threshold,store the row in the

depth table

brsh

edge_in_this_pixel

depth_no_edge_here:

inc

row_cnt

cpi

row_cnt, DEPTHROWS

//If not to the top of the

rows, go to the next row

brne

depth_inner_loop

edge_in_this_pixel:

st

Y, row_cnt

//Store the new y-location of

bright spot

inc

col_cnt

cpi

col_cnt, DEPTHCOLS

//If not to left-hand side of

image,go to the next column

brne

depth_outer_loop

rjmp

output_depth

output_depth:

ldi

YH, high(DEPTHBASE)

ldi

YL, low(DEPTHBASE)

ldi

col_cnt, 0

outc

DEPTHSTART

//Output flag to signal start of depth table

output_depth_next:

ld

rxbyte, Y+

outcreg

rxbyte

//Transfer depth table through

UART

addi

col_cnt, 1

cpi

col_cnt, DEPTHCOLS

brne

output_depth_next

end_write_depth:

outc

DEPTHSTOP

//Output flag to signal end of

depth table

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

53

RESOURCES

Mitsubishi Electric Research
Laboratories, “M64282FP Artificial
Retina Technical Information,”
www.lh.co.nz/hardware/ar/
techinfo.htm.

Mitsubishi CMOS imaging sensors,
www.mitsubishichips.com/
products/assps/a_retina/index.htm.

SOURCES

AD7822 A/D Converter
Analog Devices, Inc.
(800) 262-5643
www.analog.com

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

BFont (Billi Font Library)
Diego Billi
www.cs.unibo.it/~dbilli/bfont/bfont.
html

M64282FP CMOS image sensor
Mitsubishi Electric and Electronics
USA, Inc.
(408) 730-5900
www.mitsubishichips.com

Game Boy Camera
Nintendo of America, Inc.
(425) 882-2040
www.nintendo.com

SDL Cross-platform library
Sam Lantinga
www.libsdl.org

gEDA Design suite
www.geda.seul.org

tavrasm AVR assembler
www.tavrasm.org

sp12 AVR programmer
www.xs4all.nl/~sbolt/e-
spider_prog.html

Listing 2—

Based on the direction and amount of position error (i.e., the distance of the object from the

center of the image), this code pans the camera left or right.

track_init_vars:

ldi ZH, high(RAMBASE) //Load pointer with start of image

(bottom-right corner)

ldi ZL, low(RAMBASE)

ldi row_cnt, 0

track_outer_loop:

ldi col_cnt, 0

track_inner_loop:

ld

pixel, Z+

//Increment RAM pointer

cp

pixel, thresh

//If pixel is greater than threshold

value, track object in the x-direction (pan)

brsh track_obj_x

track_no_obj_here:

addi col_cnt, 1

//Increment column counter

cpi col_cnt, DEPTHCOLS

brlo track_inner_loop

//If cols are less than 128, do next col

addi row_cnt, 1

//Increment row counter

cpi row_cnt, DEPTHROWS

brlo track_outer_loop

//If rows are less than 121, do first

column

track_obj_x:

cpi col_cnt, 4

brlo track_out_of_view

cpi col_cnt, 120

brsh track_out_of_view

cpi col_cnt, 62

//If object is to right of center, then

pan right

brlo

track_obj_to_right

cpi col_cnt, 67

//If object is to left of center, then

pan left

brsh track_obj_to_left

rjmp track_obj_y

//If object is in center in x direc-

tion, then track in y direction (tilt)

track_obj_to_left:

subi col_cnt, 64

divi col_cnt, TRACKDIV //Divide error by TRACKDIV (this allows

tuning of control loop gain)

in

temp1, OCR1AL

sub temp1, col_cnt

cpi temp1, 43

brlo track_out_of_view

track_left_output:

out OCR1AL, temp1

//Set servo to new value

rjmp track_obj_y

track_obj_to_right:

ldi temp2, 64

sub temp2, col_cnt

divi temp2, TRACKDIV

in

temp1, OCR1AL

add temp1, temp2

cpi temp1, 131

//Make sure value is still within limits

If not, don't set servo to new value

brsh track_out_of_view

track_right_output:

out OCR1AL, temp1

REFERENCES

[1] I. Horswill, “Specialization of

Perceptual Processes,” (Ph.D.
diss., MIT, 1993).

[2] I. Horswill and M. Yamamoto,

“A $1000 Active Stereo Vision
System,” presented at IEEE/IAP
Workshop on Visual Behaviors,
Seattle, WA, 1994.

PROJECT FILES

To download the code and pinout,
go to ftp.circuitcellar.com/
pub/Circuit_Cellar/2003/151/.

sion at Agilent Technologies. Daniel’s
technical interests include robotics,
radio-controlled airplanes, nonlinear
video editing, and Linux. You may
reach him at dherr@frii.com.

background image

54

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ecently, I learned

that the Circuit

Cellar

readership pool

is comprised of numerous

8051 fans. So, in keeping with Circuit
Cellar

’s reader-oriented heritage, I’m

going to mix it up this month with a
home-brewed 80C51-compatible Philips
P89C668 microcontroller development
board, a set of data radios from the land
down under, and the latest Keil C51
compiler for the 8051.

FROM 8748 TO P89C668

My first encounter with the 8751

(i.e., a UV-erasable 8051) occurred
when I stepped off the 8748 boat back
in the early 1980s. Although I didn’t
have a tool like the Keil C51 compiler
in those days, the 8751’s firmware was
friendly and its hardware was easy to
incorporate in my designs. I loved my
8748 micro and fell even deeper in
love with the 8751 after I gained a bet-
ter understanding of its architecture.

For one of my 8751 projects, I built a

musical instrument tuner. Obviously, I
was in good company in those days.
And, judging from the number of you
who are mating the Packet Whacker
with various 8051 variants, I’m still in
good company today.

This whole P89C668 development

board thing started when a reader
requested that I meld the Packet
Whacker’s Ethernet engine onto a
development board featuring a flash-
based 8051 device. The hardware design
was hammered out over multiple
e-mail sessions. In the end, I determined
that the development board would have
to be simple to build with room for
experimentation and expansion.

The reader suggested that I base the

8051 development board project on the
Philips P89C668. I thought he meant
P89C664 not P89C668, so I went mer-
rily along my way, collecting P89C664
microcontrollers and the peripherals to
support them. Things changed, howev-
er, when my box of P89C664s was
delivered to the Florida room.

The P89C664 is also an excellent

choice for an 8051-compatible micro.
Like the P89C668, the P89C664 is
based on the 80C51 CPU and can be
programmed in-circuit (in-system pro-
gramming, or ISP) or programmed in-
circuit by the application (in-applica-
tion programming, or IAP).

An important feature is the user-

accessible, serial-based, low-level flash
memory programming routines con-
tained in the P89C66x boot ROM.
And, with the right software tool set,
you don’t need a dedicated 87C51 pro-
grammer for development.

For this project, it’s better to use the

P89C668 instead of the P89C664,
because the P89C668 comes with 8 Kb
of on-chip ERAM as opposed to the
2 Kb of ERAM found on the P89C664.
I did need some extra ERAM for the
Ethernet and serial I/O buffer area. One
last note before getting started: all of
the P89C66x family’s low-level 80C51
details (e.g., instruction set and timing)
are identical to the original 80C51.

P89C668 HARDWARE

Take a look at the schematic in

Figure 1. Only three additional integrat-
ed circuit logic elements and a general-
purpose transistor are needed to create a
potent, easy-to-build, easy-to-under-
stand P89C668 development platform.

Supported by a 74HCT573 low-

order address line latch, the P89C668
is configured in the traditional way. A
74HCT138 one-of-eight decoder uses

A P89C668 Development
Board for 8051 Fans

r

Despite their geo-
graphical and occupa-
tional differences,
most of Fred’s read-
ers have one thing in
common: their love of
the 8051. This month,
Fred assuages their
appetite for 8051-
related projects with a
simple 80C51-com-
patible P89C668
development board.

Fred Eady

APPLIED
PCs

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

55

and the programming interface sim-
ple, Flash Magic—which is a free ISP
program from the Embedded Systems
Academy—is used to program the on-
board P89C668. The active compo-
nents shown in Figure 3 process the
RS-232 signals from the Flash Magic
PC application, allowing you to read
and program the P89C668’s code flash
memory and configuration bits.

To be honest, another reason why I

chose Flash Magic was to have an
excuse to build the Sipex 233ACP/
PN2222A/74LS125-based hardware ISP
interface that’s described in the Flash
Magic manual. You can use Flash
Magic without the fancy RS-232 con-
trol interface; however, with a little
more effort and a few more dollars,
the convenience offered by installing
the ISP interface makes it worthwhile.

Flash Magic uses the RTS and DTR

signals to control the PSEN and RST
signals. When PSEN is low, EA is at
5 VDC, ALE is floating at the falling
edge of the reset pulse, and the P89C688
boot ROM boot loader routines are
invoked. After they’re activated, the
boot loader routines accept commands
and data in Intel hex format from Flash
Magic via the P89C668’s UART.

As soon as the device is programmed,

Flash Magic sets the status byte to
0x00. Then, it uses the RTS and DTR
signals to reset the P89C668 and exe-
cute the program contained within the
P89C668’s code area flash memory.

The Sipex SP233ACP and Q2 pull

the RS-232 inputs low when there is
no COM port attached or the Flash
Magic is inactive. The inactive state
of the RS-232 inputs forces the con-
verted RS-232 outputs to a TTL high.
The tri-state inputs of the 74LS125
see this TTL high and block the
74LS125 inputs. Thus, PSEN and RST
are left to the mercy of the external
circuitry they’re attached to.

In an active state, the 74LS125 would

pass its inputs and force PSEN low and
RST high. To enter Boot ROM mode,
PSEN is driven low by the RTS signal.
Then, it’s held there until RST (driven
by DTR) is forced high and allowed to
return low by the reset circuit, which
consists of a 10-µF capacitor and a
10-k

resistor. A processor reset is per-

formed at the end of the ISP operation

the three most significant address bits
to provide chip select signals for the
external I/O devices you may want to
add to the board.

One of the resident I/O devices is an

old friend of mine. The UPD71055L is
an 82C55 variant made by NEC
Electronics that’s connected to the
P89C668 in the traditional fashion. Q1,
which is a PN2222A NPN general-pur-
pose transistor, acts as an inverter for
the interrupt signal that’s produced by
the second resident external I/O device,
an RTL8019AS Ethernet engine IC.

The RTL8019AS is a modified Packet

Whacker configuration with the AEN
line acting as a chip select. The
RTL8019AS portion of the P89C668
development board is shown in Figure 2.

The data bus (AD0–AD7), address

bus (A0–A15), open P89C668 port pins
(portions of ports P1 and P3), and all
of the UPD71055L I/O port pins are
terminated on standard 0.1

male

headers that are adjacent to an over-
sized breadboard area. The initial
P89C668 development board proto-
type is shown in Photo 1.

Don’t let the hardware’s simplicity

fool you. At only six clocks per cycle,

the P89C688’s top speed (20 MHz), as
well as its large internal code and data
memory structure, make it a viable
micro in the 8-bit world.

A FLASHY PROGRAM

There are numerous programs capa-

ble of enabling the P89C668 ISP inter-
face. To keep the project affordable

Photo 1—

The idea behind this design is to make it

simple and cheap enough to build multiple boards so
that each development board can be an Ethernet node,
serial node, or RF node on a network. If you’re won-
dering about the location of the supporting capacitors
and resistors, they’re all SMT devices that are mounted
on the backside of the board.

Photo 2—

I used the blank check and display flash memory functions to verify that I had obtained access to the

P89C688 flash memory using the Sipex SP233ACP ISP circuitry.

background image

screens that I used for this project are
shown in Photo 2.

A NETWORK NODE

Because the P89C668 development

board contains Ethernet and RS-232
hardware, you probably think I’m
going to describe the process of coding
the P89C668 development board hard-
ware for use as an Ethernet node on a
LAN or WAN. Well, the LAN or WAN
part is correct, and the Ethernet func-
tionality will be exploited; however,
for this particular project, the primary
method of communication between
P89C668 nodes will be via RF.

As you probably know, writing code

to deploy an embedded RF solution,
can be a pain. Basic data radios require
the coder to produce at a minimum
firmware that generates a preamble, an
addressing scheme, and a CRC. After
that code is finished, if the data radios
are to be of any use, they must be able
to communicate reliably (i.e., each
radio must be able to check the validi-
ty of the received data and acknowl-
edge that validity or notify the sender
that the incoming message is bogus).

Now, assume there are more than

two data radios that need to communi-
cate. Also add the possibility that some
of the data radios may be out of the
range of the nodes they need to commu-
nicate with. After you get all of those
requirements under control, you’ll have
to deal with FCC certification.

To eliminate as many of the RF has-

sles as possible, I used Embedded
Communications Systems (ECS) radio

modems. I managed to get my hands
on a pair of RM-232-433 radio
modems that are designed for the
OEM market. In simpler terms, that

boils down to possessing
radio modems without the
ECS commercial cases.

The RM-232-433 operates as

a short-range, license-exempt
device on a center frequency
of 433.920 MHz. You can get
RM-232 radio modems that
operate on many of the other
popular frequencies including
914.500 MHz.

All of the potential problems

relating to embedded RF imple-
mentation that I described ear-

lier are addressed in the RM-232-433
hardware and firmware. The RM-232-
433 operates in both acknowledged
Point-to-Point and Multipoint modes.
There’s even an acknowledged
Multimaster mode. The preamble,
data encryption, error checking, and
acknowledge logic all are built into
the RM-232-433’s operating firmware.
The RM-232-433 radio modems are
easy to use. Simply apply power, con-
nect an antenna, and feed the radio
modem data via its serial port.

Even though it’s that easy to get on

the air with a pair of RM-232-433s, I
managed to foul things up. I’ve worked
on many projects with a number of dif-
ferent data radio modules. In the
process, I’ve managed to accumulate
antennas for each set of data radios
found on the Florida room’s shelves.

As you can see in Photo 3a, my set of

RM-232-433s came with a threaded
antenna connector that’s a standard for
this type of RF equipment. The idea
behind the connector is to allow legal
antennas to be easily attached and
deter the attachment of unapproved
antennas. I didn’t receive any antennas
with my ECS radio modems. So, I rum-
maged through my bag of stubbies and
pulled out a pair of antennas that fit
the threaded RF connector perfectly.

After the antenna problem was

solved, I moved on to determine how I
should apply power to the set of radio
modems. A standard 9-V transistor
radio battery or an external power
source between 9 and 12 VDC can
power the RM-232-433.

After studying the radio modem’s

board layout, I added the 2.5-mm power
connector that you see in Photo 3a. I
added the SMT diode with the orange

56

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

by holding PSEN high while
a reset is performed using the
DTR signal. Using the
Sipex/PN222A’s RS-232 ISP
interface, Flash Magic takes
care of the programming and
reset details as they pertain
to the PSEN and RST signals.

To allow for the use of

debuggers or other peripher-
als that require the COM
port during development,
Flash Magic commands only
the COM port signals when
it’s active. Using Flash Magic and the
RS-232 ISP control hardware allows the
P89C688 to be programmed and erased
in-socket with little hardware overhead.

I can also add Flash Magic com-

mand strings to a menu in my Keil
C51 compiler toolbar. This permits an
automated code, erase, program, and
debug development cycle that can be
initiated from the Keil µVision2 IDE.

In addition to being the heart of the

ISP operation, Flash Magic also pro-
vides a means of displaying a flash
memory dump and incorporates utili-
ties to read and write the security bits.
A series of the Flash Magic operation

Photo 3a—

All of the RF plumbing is on this side of the board, because the BiM2

module is a complete 433-MHz transceiver. b—This is the digital side of the ECS
radio modem. The antenna connector can be mounted in either set of antenna
pads. Cut the link to the unused antenna pads in this fashion. The bank of status
LEDs is located just above the PIC16F84A.

a)

b)

Photo 4a—

The banner is primarily used to tell you that

you’ve established a serial communications session with
the ECS radio modem. As you can see in b, there’s an
option to turn this banner off (

signon). I suggest

requesting the RM-232-433 user manual from ECS if you
want the details for each of these command options.

a)

b)

background image

HC08 Q FAMILY OF 8-BIT MICROCONTROLLERS

MOTOROLA

and

the

Stylized

M

Logo

are

registered

in

the

U.S.

Patent

and

Trademark

Office.

All

other

product

or

service

names

are

the

property

of

their

respective

owners.

©

Motorola,

Inc.

2002.

1.5K–4K of second-generation .5 micron Flash

• 128 bytes of RAM

Up to 4-ch 8-bit A to D converter

2-ch 16-bit timer with input capture, output compare, or PWM

Trimmable internal OSC (+/-5% accuracy)

Available in 8-pin DIP/SOIC or 16-pin DIP/SOIC/TSSOP

68HC908QT4 demonstration board and tutorial

– CodeWarrior

®

Integrated Development Environment

– C compiler, assembler, linker and debugger

– Auto code generator for on-chip peripherals

– Full chip simulation and Flash programming

HC08 Q FAMILY KEY FEATURES

Efficient. Programmable. Affordable.

Our powerful HC08 Q family of 8-bit micro-

controllers includes six new derivatives,

available now, in volume, and competitively

priced against 8-bit MCUs without Flash.

Available in small 8- and 16-pin packaging

with a full set of peripheral options – and

more are in development. Leading edge

Motorola Flash is easier to program and

is re-programmable in

the field, so products

are “Future Enabled”

to stay in the market longer. Get started for just $25 with the comprehensive

68HC908QT4 Demonstration Kit. Order yours now at www.motorola.com/mcu

JUST WHAT 8-PIN MCUs NEED:

A LITTLE FLASH

.

System Integration Module

External Interrupt

Power-On-Reset

Low-Voltage Inhibit

MON08

COP

Internal RC

128 Bytes RAM

HC08

CORE

2 Channel

16-Bit Timer

• Input Capture

• Output Compare

• Pulse Width Mod.

4K Bytes

FLASH

1.5K Bytes Option

4 Channel

8-Bit ADC

I/

O

Demonstration Kit

background image

58

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

bands to route the power from the
newly installed 2.5-mm power con-
nector to the radio modem’s active cir-
cuitry (see Photo 3b). The black diode
that’s perpendicular to the diode
routes power from pin 1 of the 9-pin
RS-232. Pin 1 of the 10-pin header
area is also connected to pin 1 of the
9-pin RS-232 female socket. In fact,
you can use a 10-pin header instead of
the 9-pin socket in situations where
the radio modem is entirely enclosed.
Of course, the steering diode I added is
optional, because both diodes are only
there to protect against attaching a
power source with the wrong polarity.

At that point, I had a set of antennas

and the ability to apply power using a
standard wall wart. Next, I took a look
at the commercial units on the front
of the RM-232-433 user’s guide and
noticed that they were sporting some
status LEDs. That meant that there
had to be provisions for the LEDs on
the OEM radio modem board.

Well, the LED access area was not

obvious to me, so I decided to follow
the traces from the line of 10 holes

along the edge of the board. In doing
so, I discovered a set of SMT LEDs.
This was too good to be true. I wasn’t

looking forward to building an exter-
nal jig just to see a few LEDs blink.
So, to test my new discovery, I applied

Photo 5—

I used a bit of editorial privilege for this shot. Actually, you can only open one memory window. Note the

tabs at the bottom of the memory dump select the differing memory areas.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

59

Houston, we have liftoff. The receive
and transmit status LEDs on the radio
modems became active, so I turned off
the radar and performed some success-
ful pings. My first successful data trans-
mission consisted of the word “Duh.”

CODING THE NODE

Here’s where the fun begins. You

can write the P89C668 development
board’s firmware using the latest ver-
sion of Keil’s C51 compiler for the
8051. Although the P89C668 is a true
8051 derivative, there are minor differ-
ences in its architecture that must be
recognized by the compiler to allow
you to manipulate the part fully. For
instance, the P89C668 has ERAM that’s
logically treated like external memory.
The P89C668 also houses an additional
DPTR register. Provisions to use the
internal ERAM and second DPTR are
already in place, because the C51 com-
piler supports the P89C688 directly.

The firmware plan includes writing

diagnostic code for the P89C668 devel-
opment board so that you won’t have to
suffer the pains I did while developing
and debugging it. After the diagnostic
code has been written and debugged,

power to one of the radio modems. I
got the blinking pattern that matched
a radio in Listen mode.

At that point, things were going well.

As an initial test, I planned to attach
one radio modem to my laptop, one to a
desktop machine, and then drive them
with HyperTerminal. I put some dis-
tance between the radios and fired up
both of them. The banner that you can
see in Photo 4a appeared on both PCs.

Because I had the banner and the

radio modem’s attention, I decided to
check out the configuration options
with the Configuration mode. I typed
“+++,” hit the Enter key, entered
“help,” and pressed the Enter key one
more time. You can see the result in
Photo 4b. Some of the other features of
the RM-232-433 radio modem include
the ability to act as a repeater (

rptmode

[on | off | all]) and to be remote-
ly configured (

remote [[(on|off] |

sno cmd [params]]).

In Configuration mode, I could set

the radio modem node as a master or
slave (

ptpmode [on | off | slave

| master]) and control just about
every aspect of the radio modem’s oper-
ation including setting delays, timeout

periods, character pacing, on-the-air
data rates (

airspd [600–14400]),

and the radio modem’s serial port data
rate (

baud [600–115200]). Each ECS

radio modem is addressable. This
facilitates the implementation of mul-
tiple radio modem LANs using a com-
mon frequency.

The defaults should have been fine

for the initial test. All I had to do was
type in some characters on one of the
PCs and the characters would appear
in the receiving PC’s terminal win-
dow. Well, that’s what I did, but noth-
ing happened. After an hour or so of
troubleshooting, I was nowhere near
solving the problem. I tried the ping
and radar functions on both radio
modems with no luck. Finally, I put
one radio modem in Radar mode and
returned to my stash of data radio
parts to see if I could figure out what I
might have done wrong.

As I was looking through the batch

of radios, I discovered that the only
other threaded antenna connections
belonged to a set of 900-MHz units.
Duh! I removed the cute, stubby, 900-
Hz antennas and replaced them with a
simple piece of hook-up wire. Bang!

Figure 1—

Note the absence of external SRAM. The P89C668 contains a little over 7 Kb of usable internal ERAM that’s accessed just like external SRAM by clearing a bit

(EXTRAM) in the AUXR register. It’s easy to add external storage to the development board if your project requires more than the P89C668 provides.

background image

60

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ing the ERAM area in another win-
dow and monitoring the serial output
in yet another window (see Photo 5).

As I stepped through the source code,

I could see the serial data being placed
in the ERAM area defined as the receive
buffer (the X:000000 memory window
in Photo 5) as well as the transmitted
data flowing through the transmit buffer
area (the X:000100 memory window).
The serial output window emulates an

you’ll have the basis for the
final operating firmware
because you won’t have to
write radio modem code at all.

The ECS radio modems are

fed through their serial ports,
and I figured that would be
the easiest 8051 code to
write. It wasn’t, so I decided
to use interrupt-driven serial
I/O. Even though there’s good
skeleton code included with
the C51 compiler, I ran into a
rough spot getting the
P89C668’s UART to work.

The interrupt-driven serial I/O rou-

tines use external memory as a buffer
area, which in this project is internal
ERAM on the P89C688. My version of
the Keil 8051 C51 compiler (PK51) has
the ability to debug the code I write
by simulating the hardware. So, I
turned all of the debugger and simula-
tion knobs to get a view of my code in
assembly language format while view-

ASCII terminal, and I was able
to enter a character and see the
results just as if my P89C668
hardware were attached to
HyperTerminal.

The simulation allowed me

to determine that the code was
working as designed and my
problems were most likely in
the hardware. I coded a simple
serial output program that didn’t
use interrupts or the ERAM,

successfully simulated it, and
loaded it onto the development

board. Nothing was displayed in the
HyperTerminal window. Because things
were getting weird, I wired the develop-
ment board to my computer running
Frontline’s Serialtest Async and hit the
Reset button on the P89C688 develop-
ment board. Oh, yeah. There was my
data loud and clear.

Confident that HyperTerminal had

thrown me a curve ball, I reloaded the
development board with the interrupt

Figure 2—

This is basically the Packet Whacker module with the AEN line pulled out for use. Using the NE2000 code skeleton, the RTL8019AS is dead easy to implement for

almost any microcontroller.

Photo 6—

Serialtest Async has saved me many times. I can always count on

Serialtest to give me accurate serial port captures. The ASCII interpretation in
this shot is the banner generated by my interrupt-driven serial I/O code.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

61

modem network without having to
swap cables after every compile, I
added a switch to disconnect DTR and
RTS from the Sipex233ACP when a
HyperTerminal session is active.

After I finished debugging, I had to

connect the ECS radio modems to the
P89C668 development board using a
null modem arrangement. I did this
because both the development board
serial port and the ECS radio modems
are configured as DCE devices.

USING THE NODE

In terms of usage, the ECS radio

modems are self-sufficient. If you can
get your message out of the P89C668’s
UART, you can make use of the RF
link the ECS radio modems provide.

You may download the P89C668

development board source code (in C51
project format) from the Circuit Cellar
ftp site. I also provided a silkscreened
circuit board and a parts kit for people
who want to get a jump start on the
Ethernet functionality of the develop-
ment board and the P89C66x series. If
you don’t own a copy of the C51 com-
piler, or you don’t want to port my
source, you can get an evaluation copy
of the C51 compiler on Keil web site.

I had forgotten how fun coding for

the 8051 could be. The Keil C51 com-
piler is as fun to work with as it is
powerful, and the plug-and-play ECS
radio modems will allow me to put
little wireless nodes all over the

code and nothing appeared on the
Serialtest Async display. Something
was definitely wrong with either the
interrupt routines or external memory
access. I ruled out interrupt problems
and turned to Keil’s knowledgebase for
a possible answer. In the knowledge-
base I found a document titled “C51:
Using XRAM on the Philips 80C66X
and 80C51RX Devices.” The part
numbers were close enough, and I was
desperate enough, so I read it.

As it turned out, the P89C668’s

ERAM was never activated and the
knowledgebase document contained a
fix that I could add to the P89C668
start-up code. All I had to do was to
identify the AUXR register and turn
off a bit inside it (EXTRAM) to enable
the on-chip ERAM. Two lines of code
and a compile later, I was spitting
characters out of the serial port with
the interrupt code (see Photo 6).

During the battle with the P89C668

UART, I found that HyperTerminal
doesn’t allow Flash Magic to borrow
the COM port. HyperTerminal is pri-
marily designed to work with a
modem; thus it holds DTR active when
a HyperTerminal session is active. This
effectively holds the P89C668 in reset.

PSEN is also confused because dur-

ing a HyperTerminal session, RTS is
turned on and off at the wrong times
in relation to the ISP hardware inter-
face on the development board. To
facilitate the live testing of the radio

PROJECT FILES

To download the code, go to
ftp.circuitcellar.com/pub/Circuit_
Cellar/2003/151/.

SOURCES

RM232-433 Radio modem
Embedded Communications
Systems, Ltd.
www.embeddedcomms.com.au

Flash Magic
Embedded Systems Academy
www.esacademy.com/philips

Serialtest Async
Frontline Test Equipment, Inc.
www.fte.com

C51 C compiler, µVision2 IDE
Keil Software, Inc.
www.keil.com

Modems
Lemos International, Inc.
www.lemosint.com

µPD71055L
NEC Electronics Corp.
www.nec.com

P89C668 Microcontroller
Philips Semiconductor
www.philips.com

RTL8019AS Ethernet engine IC
Realtek Semiconductor Corp.
www.realtek.com

SP233ACP
Sipex Corp.
www.sipex.com

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

Figure 3—

The ISP interface can be conceived with just about any RS-232 converter IC. I had Sipex SP233ACPs

in the Florida room; they were clean and easy to implement. I ran out of receive buffers, and instead of adding
another SP233ACP, I used a PN2222A to translate the RTS signal. With the exception of the 74LS125, the whole
ISP interface could be built using only PN2222A transistors and a handful of resistors.

Florida room. I have visions of col-
lecting information and controlling
devices via an RF link into a master
P89C668 node that’s attached to the
Florida room’s LAN. This time, a
Circuit Cellar

subscriber has again

proven that it doesn’t have to be com-
plicated to be embedded.

I

background image

62

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ow often do you

pick up the wrong

station when you’re

trying to tune in to a

specific radio program? You expect
that dialing up a number on the
receiver will select a specific station
with a transmitter on that frequency,
which is what usually happens.

Amateur radio operators, particularly

those living in cities, often encounter
radios that emit loud squawks, tones,
garbled speech, or stations transmitting
on a different frequency. Sometimes
the radio changes from one bizarre
sound to another before returning to
normal. Generally, the unexpected
stations lie outside the ham bands,
although anything seems possible.

The culprit, intermodulation inter-

ference, may not be attributable to the
radio or an electronic device; it can
arise in a rusty bolt on an antenna
tower! Strangely, radio designers make
use of the same effect (although they
call it nonlinear mixing) to select the
desired station from the myriad of
transmitters on the air.

In the past, I’ve described linear

audio mixers that combine signals by
addition. Now, let’s look at how sig-
nals combine in nonlinear mixers and
some of their unexpected properties.

NONLINEARITY 101

Analog designers feel comfortable

around linear circuits because the
mathematics works out nicely: the
output is always a linear function of
the input. In fact, considerable design
effort goes into forcing a circuit to be
linear by choosing a specific operat-
ing point, wrapping negative feed-
back around it, or compensating for
nonlinear behavior.

By definition, the output of a linear

circuit is proportional to its input,
which also implies the principle of
superposition. This means that the
output caused by two separate signals
is equal to the sum of the outputs
caused by each signal applied separate-
ly. In effect, nothing comes out that
you don’t put in.

For example, the voltage across a

resistor induces a linearly related cur-
rent. If you double the voltage, the cur-
rent increases by a factor of two. An
op-amp circuit may have a gain of two,
but when you double the input, the
output also doubles. Therefore, the
gain is fixed and the output increases
by the same factor as the input.

You know that an arbitrary input sig-

nal can be represented as the sum of a
collection of sine waves (i.e., the sig-
nal’s Fourier transform). Those sine
waves will pass through a linear circuit
and emerge with predictable amplitude
and phase relationships, which means
that you can probe the circuit with one
sine wave at a time and determine its
response to the entire set.

By definition, nonlinear circuits

include anything that doesn’t behave
linearly. When a diode’s current
increases exponentially with applied
voltage, a preamp’s gain decreases as
the input increases or a driver’s output
clips at a preset power level. That’s
nonlinear behavior.

Superposition doesn’t apply to non-

linear circuits, because the output sig-
nal is not simply the sum of the input
signals. Circuits with slight nonlinear-
ities have outputs that are nearly the
sum of the inputs, but additional sig-
nals are always present. As you’ll see,
you can’t probe a nonlinear circuit
with one sine wave and decide what
will happen with even as few as one
additional sine wave.

Nonlinear Mixing

h

In a number of previ-
ous articles, Ed has
covered the topic of
linear audio mixers.
This month, he will
address the flip side
of the coin, nonlinear
mixing. If you’re not
accustomed to work-
ing with nonlinear
mixers, this article is
the perfect place to
begin.

Ed Nisley

ABOVE THE
GROUND
PLANE

background image

Replacing the lower resistor (R2)

with a standard 1N4148 diode pro-
duces Photo 1b. The amplitude has
increased slightly, with the 500-Hz
signal at 0 dB, because the forward-
biased diode exhibits more than 100

of resistance at this operating point.

The second harmonic rises to 20 dB
below the main signal with the third
harmonic remaining 10 dB below that.
Additional harmonics also appear out
of the grass at higher frequencies.

A standard oscilloscope view of the

signal across the diode shows basically
what you’d expect, although I didn’t
include a photo. The upper peaks of
the sine wave no longer reach 400 mV,
because the increasing current through
the diode rounds them off. That dis-
tortion represents the new frequency
components in Photo 1.

Adjusting the signal generator’s

amplitude and DC offset changes the
diode’s operating point and the amount
of nonlinearity. When you try this on
your bench, compare the visible distor-
tion on your oscilloscope (or PC) with
the magnitude of the harmonics.

Although distortion is thought of as

bad, it’s a good way to generate new
signals with a precise relation to an
existing one. Suppose you have a stable
100-MHz oscillator and need a stable
300-MHz signal. If you feed 100 MHz
into a diode, band-pass filter the output
around 300 MHz, and amplify the
result, you can get the job done with-
out complex circuitry or even a DSP.

…TWO SIGNALS…

The layout in Figure 2 adds a second

sine wave through a resistor. I used a
direct digital synthesizer for the 500-Hz
signal and the same function generator
as before for the 700-Hz signal. The

two tall bars in Photo 2b show the
input signals at –5 dB, and the smaller
trace shows the generator’s 1400 Hz
second harmonic at –40 dB. The har-
monics from the DDS are barely above
the grass starting at 2000 Hz.

Replacing R5 with D2 produces the

forest of signals shown in Photo 2b.
Not only are higher harmonics pres-
ent, but you’ll also see frequencies
below the input signals. Yes, in this
case, 500 plus 700 equals 100!

You should check the resources I

list at the end of the article, in partic-
ular the ARRL Handbook for Radio
Communications

, for the derivation of

the math concerning nonlinear mix-
ing. Photo 2 shows most of the formu-
las in action.

Combining two sine waves in a

nonlinear mixer will produce output
signals with frequencies equal to the
sum and difference of all of the integer
multiples of the input frequencies. For
inputs at frequencies F

1

and F

2

, the

outputs will be at

±

nF

1

±

mF

2

.

The order of a given output signal is

the sum of its frequency coefficients.
The two first-order mixing products in
Photo 2a are the input signals at F

1

=

500 Hz and F

2

= 700 Hz. The four sec-

ond-order products are at 200, 1000,
1200, and 1400 Hz. There are actually
eight of these products, four with posi-
tive and four with negative frequencies,
but I’ll discuss negative frequencies
later. Suffice it to say that they’re real!

You can see some of the third-order

products in Photo 2, most notably
300 and 900 Hz. The hump around
2000 Hz conceals the 1500-, 1700-,
1900-, and 2100-Hz products. Higher-
order products abound even in this
simple example. The 400-Hz bar is
fourth-order (–2 × 500 + 2 × 700), and

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

63

ONE SIGNAL…

Working at radio frequencies requires

test equipment that’s both tricky to
use and expensive to own. However, if
you restrict yourself to audio frequen-
cies, you can probe circuits using
nothing more than a PC with a sound
card and some readily available soft-
ware. The principles remain the same
even with frequencies scaled by six
orders of magnitude.

I used a True Audio real-time analyz-

er, TrueRTA, for this column. If you
don’t need TrueRTA’s stimulus out-
put, then take a look at Visualization
Software’s Spectrogram. Both run on
Windows; I was unable to find any-
thing comparable for Linux.

Figure 1 shows a pair of 100-

resis-

tors driven by a 400-mV

PP

sine wave

from my function generator. I offset
the sine wave by 200 mV to slightly
forward-bias the diode that you’ll
meet shortly. The two resistors form a
simple and completely linear circuit.

Using TrueRTA’s stimulus output,

you can add the DC bias with a bat-
tery and trimpot. Typical Line-In ports
have resistors to both 5 V and com-
mon to set the DC level in front of
their AC-coupling capacitor. Do not
overpower those input resistors.

A perfect signal generator would

produce a single frequency, but mine
wasn’t that good. The tallest bar in
Photo 1a represents the main 500-Hz
signal at –3 dB. The two shorter bars
show that the 1000-Hz second har-
monic is 37 dB below the main signal,
and the 1500-Hz third harmonic is
10 dB below that.

Note that the grass growing below

those bars includes noise from the gen-
erator and PC sound card. As you
spend money on test equipment, you’ll
lower that noise floor and increase the
dynamic range of the measurements.

To PC

R1

R2

100

100

500-Hz sine

GND

1N4148

D1

Figure 1—

A resistor and a diode produce completely

different outputs from this simple circuit, even with only
a single sine wave as input.

Photo 1a—

The sine wave output of a signal generator has moderately low harmonic content. b—Replacing R2

with diode D1 increases the amplitude of the harmonics.

a)

b)

background image

64

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

the 100-Hz bar is actually a fifth-order
mixing product (3 × 500 – 2 × 700).

There isn’t a simple relationship

between the order of a mixing product
and its real-world amplitude, although
higher-order products tend to be
weaker. The relative strengths change
as you vary the input levels and DC
bias point, so you can indeed tune for
the best picture.

…THREE, AND MORE!

Remember that the forest of spikes

in Photo 2 grew from just two input

sine waves. A third input signal, with
a mixing formula of

±

nF

1

±

mF

2

±

pF

3

,

would create even more products. If F

3

were, say, 600 Hz, you’d see six unique
second-order mixing products!

You’ve certainly seen the forest of

antenna towers atop hills or buildings.
Each tower may have several antennas,
each transmitting or receiving on any
frequency from a few tens of megahertz
to a few gigahertz. Part of the transmit-
ter licensing process involves verifying
that it won’t interfere with other trans-
mitters or receivers in the same area.

Radio transmitters emit low-level

spurious outputs, just as my signal
generator produces the small third-
harmonic signal in Photo 1. All of the
transmitters on a site must be coordi-
nated so that none of their spurs fall
within the band-pass of any of the
nearby receivers. The analysis actually
extends high up the harmonic scale,
requires a spreadsheet (at least) to keep
track of the various mixing orders and
products, and provides employment
security for RF engineers.

Although silicon diodes are the most

familiar, they’re not the only semicon-
ductors in the world. The corrosion
that forms between two metal objects
can act as a rectifier and resemble a
pair of low-breakdown, leaky, back-to-
back diodes. If that corrosion happens
to form between a mounting bolt and
an antenna tower, ambient RF energy
will produce the same mixing prod-
ucts you’ve just seen.

By definition, receivers must be sen-

sitive to low-level RF signals and con-
nected to excellent antennas. Two,
three, or four RF carriers that are

Photo 2a—

Two sine waves add linearly in a resistor to show only one generator harmonic. b—Replacing R5 with

diode D2 produces many additional frequencies that are now present in the inputs.

a)

b)

JK

microsystems, Inc.

Visit us on the web www.jkmicro.com

Call 530-297-6073 Fax 530-297-6074

Tools

to

Move

Data

µFlashTCP-EP

*

10Base -T Ethernet

2 Serial Ports

7-34 VDC

Optional I /O Interface

Rugged Enclosure w/

Industry Standard

Connectors

Starts at

$229

LogicFlex

*

10Base -T Ethernet

2 Serial Ports

46 Digital I /O’s

Programmable Xilinx CPLD

Hardware Clock/Calendar

Expansion Bus for

Peripheral Boards

Starts at

$189

Dual-E

*

2 Ethernet Ports

2 Serial Ports

3 Counter / Timers

5 Digital I /O’s

Onboard Connectors

USNET TCP/IP

Software in Kits

Starts at

$199

TCP/
IP

Solutions

All products based on the Intel 386Ex with DOS and NE2000 compliant, 10Base-T Ethernet. Standard
memory includes 512K RAM

&

512K Flash plus DIP socket to accept an M-Systems DiskOnChip.

Development systems contain necessary hardware and software tools for fast development.

1403 Fifth St., Suite D

Davis, CA 95616 USA

JK microsystems connects you with embedded control solutions. Our cost-effective DOS based
controllers are ideal for data acquisition, networking or industrial technology applications.

*

LogicFlex-EPX

*

10Base -T Ethernet

2 Serial Ports

16 Opto-Isolated inputs

16 Relay Outputs

@

500mA ea.

Quick-Disconnect Connectors

Rack Mount Enclosure

LCD

&

6 Pushbuttons

Starts at

$499

NEW

Products

background image
background image
background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

67

located near an impromptu diode can
produce an in-band mixing product
that is strong enough to swamp a
receiver tuned to a nearby frequency.

The mixing product frequency

depends on the input frequencies and
will be reasonably constant. However,
the modulation that you’ll find on
that signal won’t resemble any of the
carriers that produced it. Passing that
type of mush through a radio that is
designed to demodulate narrowband
FM only adds to the confusion. A
squawk may be the best thing that
you can expect.

resistors and diodes can do when you
mix them with a PC sound card and a
bit of software!

I

CONTACT RELEASE

The chapter titled “Mixing, Modu-

lators, Demodulators” in the ARRL
Handbook

presents the basic math

required to understand nonlinear mixers.
Assuming you have a handful of resis-
tors and diodes, you can read the hand-
book while fiddling with the display on
your PC. There’s nothing like an exam-
ple to illustrate those obscure formulas!

Although most components behave

in a linear manner over a reasonable
operating range, if you continue to
double the voltage applied to, say, a
speaker, it will eventually release its
magic smoke and exhibit a different
type of linearity (i.e., zero current
regardless of the applied voltage). You
can think of that as infinite resistance
if you like, but it is definitely not the
normal situation. Take care when
cranking the gain on that signal gener-
ator, particularly if you’re monitoring
the output on your PC’s speakers.

Next time around, we will take

closer a look at a double-balanced
mixer and explore frequency shifting.
Until then, see what a handful of

RESOURCES

The American Radio Relay
League, Inc., ARRL Handbook
for Radio Communications

,

Newington, CT, 2002.

XMMS for Linux,
www.xmms.org.

Ed Nisley, PE, is an electrical engi-
neer and a ham radio geek (call sign
KE4ZNU). You may contact him at
ed.nisley@ieee.org.

SOURCES

TrueRTA spectrum analyzer and
signal generator
True Audio
(865) 494-3388
www.trueaudio.com

Spectrogram
Visualization Software, LLC
www.visualizationsoftware.com

To PC

R4

R5

100

100

100

R3

700-Hz sine

500-Hz sine

GND

1N4148

D2

Figure 2—

Combining two sine waves in a resistor

produces their linear sum. Substituting a diode gener-
ates a nonlinear forest of frequencies from the two
input signals.

background image

68

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

t’s no secret that

engineers are

embedding micros in

almost everything these

days. I’ve been ranting about small
micros since Microchip introduced an
8-pin micro (circa 1997). Atmel
hopped on the low pin count band-
wagon with the 8-pin AVR series. You
know this isn’t a pet rock fad when
the company that controls roughly
24% of the market for 8-bit micros
sets its sights on dominating every
segment of the microcontroller mar-
ket. Motorola’s ammunition comes in
the form of a new flash memory prod-
uct line that’s based on the HC08. The
company expects its Nitron family of
microcontrollers to have the muscle
and price that designers
need to win design-ins.

The kickoff begins with

8- and 16-pin packages
using 0.5-µm, second-gen-
eration flash memory
technology. Currently, the
Nitron family consists of
three new parts, each of
which is available in an 8-
(six I/O) or 16-pin (14 I/O)
package. Note that the
base parts have 1.5 KB of
code space. The first option

adds a four-input, 8-bit ADC, and the
second option includes the ADC and
increases the code space to 4 KB.

It’s no secret. It’s no coincidence.

Motorola’s vision of dominance plays
right into Motorola’s Flash Innovation
2003 design contest. If you’re unfamil-
iar with Motorola micros or the
68HC08 architecture, this month’s
column will bring you up to speed.
Soon, you’ll be able to jump right in
with the rest of us and hopefully come
up with a winning design.

If you’re already familiar with the

HC08, then skim the features section
for new information. As you do, pay
close attention to the description of
the free tools that Motorola has made
available for these parts.

THE 68HC908

The Nitron family of 8-bit MCUs is

a complex instruction set computer
(CISC) that uses von Neumann archi-
tecture (i.e., data and code in one con-
tiguous space). The core CPU is the
high-performance HC08, so the object
code is fully compatible with the other
processors in the family (see Figure 1).

In addition to the flash memory,

RAM, 16-bit timer, and internal clock
oscillator, there are several other
important features to consider: a
watchdog, low-voltage detect/reset, an
embedded monitor, high-current I/O
with interrupt capability, and an
optional ADC. Now, I’ll describe the
highlights of each feature.

THE CORE

As you can see in Figure 2, the

CPU consists of a control unit and
execution unit. The former is a finite
state machine that’s responsible for

Newcomer Nitron

i

Motorola’s
2003
design
contest is
upon us,

so now’s the time to
get familiar with the
Nitron family. This
month, Jeff intro-
duces us to the flashy
technology that will
soon permeate the
low-end markets.

Jeff Bachiochi

FROM THE
BENCH

Motorola’s Leading 8/16-Pin MCUs

External interrupt

Power-on reset

Low-voltage inhibit

MON08

COP

System integration module

Internal RC

128 bytes of RAM

HC08

core

Two-channel
16-bit timer
• Input capture
• Output compare
• Pulse width modulation

Four-channel

8-bit ADC

4-KB flash memory

1.5-KB option

I/O

Figure 1—

The Motorola Nitron microcontroller family is built around

flash memory and the proven HC08 core CPU. The on-board monitor
(MON08) offers access to the internals via half-duplex serial communi-
cations on a single pin.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

69

Protection against the unintention-

al erasure or programming of the
flash memory is carried in the flash
block protect register (FLBPR). This
register indicates the starting block
to be protected up to the end of
memory $FFFF. The FLBPR prevents
the HVEN bit from being set when
attempting to erase or program a pro-
tected block, including the block
containing the FLBPR.

So, after it’s programmed, you can-

not change FLBPR without applying a
high voltage to the IRQ pin forcing
the micro into Monitor mode after a
reset. Then, you can perform a mass
erase via the monitor.

VOLATILE MEMORY

The volatile memory consists of

generating all of the execution unit’s
control signals; it uses four clock
cycles to prepare the needed output
(one execution cycle).

The execution unit contains five

registers: an accumulator (A), control
code register (CCR), stack pointer
(SP), program counter (PC), and index
register (H:X). In addition, it includes
the arithmetic logic unit (ALU) and
special-function logic for the DAA,
MUL, and DIV instructions.

The 8-bit A register holds operands

and the results of arithmetic/logic
operations. The 8-bit CCR register
contains six flags: overflow, half-
carry, interrupt, negative, zero, and
carry/borrow. Although the 16-bit SP
register can reach the full address
space, make sure it remains in the
RAM space located between the $0080
and $00FF addresses on these devices.

The SP is initialized to the end of

RAM and works downward. In addi-
tion, the 16-bit PC register can also
reach the full address space. At reset,
the program counter is loaded with
the address in the reset vector at the
$FFFE:$FFFF addresses. The 16-bit
H:X register is used to index or point
to a memory location.

FLASH MEMORY

The on-board flash memory is in-

circuit reprogrammable thanks to an
internal charge pump. The linear
memory array (1.5 or 4 KB) is located
at the top of the 16-bit memory
space and extends downward from
$FDFF. There is an additional 48 bytes
($FFD0 to $FFFF) for interrupt vectors.

One block of 64 bytes is the mini-

mum number of bytes that can be
erased at one time (i.e., beginning at
any address $xx00, $xx40, $xx80, or
$xxC0). The maximum number of
bytes that can be programmed at one
time is one row of 32 bytes (i.e.,
beginning at any address $xx00,
$xx20, $xx40, $xx60, $xx80, $xxA0,
$xxC0, or $xxE0).

The flash memory control register

(FLCR) controls the erase and program
operations. Four bits are responsible
for all of the operations: high-voltage
enable (HVEN) enables the internal
charge pump; the mass erase control
bit facilitates total erasure; the erase
control bit permits block erasure; and
the program control bit (PGM)
enables row programming.

Table 1—

In the lower part of the MC68HC908Qxx address space, there are 128 bytes of RAM between $0080 and

$00FF. As you now know, the majority of the status, control, and data registers are between $0000 and $003F.

CPU control

ALU

68HC08 CPU

CPU registers

Accumulator

Index register

Stack pointer

Program counter

Condition code register

V I I

Z C

H I N

Figure 2—

The HC08 CPU is based on a control and

execution units. The CPU uses five registers. The 16-bit
program counter can reach the total address space.

Address space

Registers

$0000

Port A data register (PTA)

$0001

Port B data register (PTB)

$0002–$0003

Unimplemented (two bytes)

$0004

Data Direction register A (DDRA)

$0005

Data Direction register B (DDRB)

$0006–$000A

Unimplemented (5 bytes)

$000B

Port A Pull-up Enable register (PTAPUE)

$000C

Port B Pull-up Enable register (PTBPUE)

$000D–$0019

Unimplemented (13 bytes)

$001A

Keyboard Status and Control register (KBSCR)

$001B

Keyboard Interrupt Enable register (KBIER)

$001C

Unimplemented

$001D

INT Status and Control register (INTSCR)

$001E

Configuration register 2 (CONFIG2)

$001F

Configuration register 1 (CONFIG1)

$0020

TIM Status and Control register (TSC)

$0021

TIM Counter register high (TCNTH)

$0022

TIM Counter register low (TCNTL)

$0023

TIM Counter modulo register high (TMODH)

$0024

TIM Counter modulo register low (TMODL)

$0025

TIM Status and Control register channel 0 (TSC0)

$0026

TIM Channel 0 register high (TCH0H)

$0027

TIM Channel 0 register low (TCH0L)

$0028

TIM Status and Control register channel 1 (TSC1)

$0029

TIM Channel 1 register high (TCH1H)

$002A

TIM Channel 1 register low (TCH1L)

$002B–$0035

Unimplemented (11 bytes)

$0036

Oscillator Status register (OSCSTAT)

$0037

Unimplemented

$0038

Oscillator Trim register (OSCTRIM)

$0039–$003B

Unimplemented (3 bytes)

$003C

Adc Status and Control register (ADSCR)

$003D

Unimplemented

$003E

Adc Data register (ADR)

$003F

Adc Input Clock register (ADICLK)

$0040–$007F

Reserved (64 bytes)

$0080–$00FF

RAM (128 bytes)

$0100–$27FF

Unimplemented (9984 bytes)

$2800–$2DFF

Auxiliary ROM (1536 bytes)

$2E00–$EDFF

Unimplemented (49,152 bytes)

background image

changes. In this case only one output
is available as the channels are used in
an alternating fashion.

OSC

All of the standard oscillator configu-

rations are available on the ’908Q. Take
note of the external RC, crystal (or
oscillator), and an internally generated
fixed clock frequency (12.8 MHz).

Two internal clocks are derived

from the oscillator. One is a divide-
by-2 that’s used by the system inte-
gration module (SIM) and COP. The
other is a divide-by-4 that’s used by
the CPU as an instruction cycle
clock (bus clock).

70

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

user RAM, reserved registers, and I/O.
As I mentioned in association with
the SP, there are 128 bytes of RAM
between $0080 and $00FF (see Table 1).
Most of the control, status, and data
registers are within the $0000-to-
$003F address space.

Additional RAM status and control

registers are located in the $FE00-to-
$FE0C upper address space in addi-
tion to $FFBE, $FFC0, and $FFFF (see
Table 2). The $FFFF location per-
forms two functions. When this
address is read, it contains the LSB of
the reset vector. On the other hand,
when this address is written to, it
resets the computer operation prop-
erly (COP) watchdog counter.

TIM

The timer interface module (TIM)

is a two-channel timer that provides
timing reference, input capture, out-
put compare, and PWM functions.
Figure 3 illustrates the TIM. The
prescaler has seven prescaler select
bits for a divide by 1/2/4/8/16/32/64
from the internal bus clock. The 16-
bit counter (TCNTH:TCNTL) can
be configured to count up until
matching the TMODH:TMODL reg-
isters and then reset to zero or free
run. TCNTH:TCNTL can be read at
any time without disturbing the
count. The timer overflow can cause
an interrupt.

Two pins, TCH0 and TCH1, can

serve as inputs to capture separate
events. On input, the 16-bit counter
value is latched into separate cap-
ture/compare registers (i.e.,
TCH0H:TCH0L and TCH1H:TCH1L).
The input capture edge polarity can be
rising, falling, or both. In addition, the
capture can cause an interrupt.

It’s possible to use the

same pins as outputs con-
trolled by the capture/
compare registers. In this
mode the output pin can
be set, cleared, or toggled
on a match.

When used in conjunc-

tion with the 16-bit timer
overflow, PWM outputs

can be created. If the cap-
ture/compare register val-
ues are changed asynchro-

nously, transition glitches can occur
in the counts. This isn’t a problem in
most applications. Linking the two
channels together makes synchronous

Address space

Register

$EE00–$FDFF

Flash memory (4096 bytes) MC68HC908QT4/Y4
• Unimplemented (2560 bytes)
• Flash memory (1536 bytes) MC68HC908QT1/T2/Y1/Y2

$FE00

Break Status register (BSR)

$FE01

Sim Reset Status register (SRSR)

$FE02

Break Auxiliary register (BRKAR)

$FE03

Break Flag Control register (BFCR)

$FE04

Interrupt Status register 1 (INT1)

$FE05

Interrupt Status register 2 (INT2)

$FE06

Interrupt Status register 3 (INT3)

$FE07

(Reserved for) Flash Test Control register (FLTCR)

$FE08

Flash Control register (FLCR)

$FE09

Break Address High register (BRKH)

$FE0A

Break Address Low register (BRKL)

$FE0B

Break Status and Control register (BRKSCR)

$FE0C

Low-Voltage Interrupt Service register (LVISR)

$FE0D–$FE0F

Reserved for flash memory test (3 bytes)

$FE10–$FFAF

Monitor ROM (416 bytes)

$FFB0–$FFBD

Flash memory (14 bytes)

$FFBE

Flash Block Protect register (FLBPR)

$FFBF

Reserved flash memory

$FFC0

Internal oscillator trim value

$FFC1

Reserved flash memory

$FFC2–$FFCF

Flash (14 bytes)

$FED0–$FFDD

User vectors (14 bytes)

$FEDE

ADC conversion complete vector high

$FEDF

ADC conversion complete vector low

$FEE0

Keyboard vector high

$FEE1

Keyboard vector low

$FEE2–$FFF1

User vectors (16 bytes)

$FFF2

TIM overflow vector high

$FFF3

TIM overflow vector low

$FFF4

TIM channel 1 vector high

$FFF5

TIM channel 1 vector low

$FFF6

TIM channel 0 vector high

$FFF7

TIM channel 0 vector low

$FFF8–$FFF9

User vectors (2 bytes)

$FFFA

IRQ vector high

$FFFB

IRQ vector low

$FFFC

SWI vector high

$FFFD

SWI vector low

$FFFE

Reset vector high

$FFFF

(Read) Reset vector low (Write) COP Control register (COPCTL)

Table 2—

Additional RAM status and control registers are located in the upper part of the MC68HC908Qxx address

space. Take a look at $FE00 through $FE0C in addition to $FFBE, $FFC0, and $FFFF.

Capture/Compare

unit

16-bit counter

Prescaler

Port pin

Port pin

TCH0

TCH1

External MCU bus

Internal MCU bus

TCH0 Interrpt

TCH1 Interrpt

Internal address bus

TOV Interrupt

Internal data bus

Internal bus clock

Figure 3—

The timer interface module (TIM) has three main parts: a

prescaler, 16-bit counter, and capture/compare unit. Two independ-
ent channels use an I/O either as input for counting or output for sig-
nal generation.

background image

Pure Wireless

Over 4,500 Design Engineers

Over 300 Leading EOEM Suppliers

50 Technical Educational Sessions

The Largest and Longest Wireless
EOEM Event in the Silicon Valley

Cut the Cord and Go Pure Wireless...
Log onto www.wsdexpo.com

Wireless Systems Design

C

O N F E R E N C E

&

E

X P O

February 24-27, 2003
San Jose Convention Center
San Jose, CA

For General Information:

Penton Technology Media

|

611 RT 46 W Hasbrouck Heights, NJ 07604

|

t: 01.201.393.6032

|

f: 01.201.393.6297

|

e:

electronicevents@penton.com

A Penton Event

background image

72

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

The internal oscillator is adjustable

±

25% to within less than 5% by set-

ting a trimming register with a value
other than the default value of $80.
(Note that values less than $80 slow
down the oscillator, and values greater
than $80 speed it up.)

An oscillator divide by 4 (bus

clock) is an option available for cali-
bration purposes on pin OSC2. The
maximum external frequency is 8
MHz for 5-V operation and 4 MHz for
3-V operation.

COP

The free-running COP counter will

interrupt the device if it overflows.
This is an attempt to recover from
runaway code. In order to prevent the
COP from interrupting during the
normal execution of code, your code
must clear the COP counter at regu-
lar intervals.

The COP counter is a 6-bit counter

clocked by the divide-by-12 SIM count-
er (clocked from the oscillator). The
overflow can come from stage one or

six of the COP counter depending on
the COP rate select (COPRS) bit in
the CONFIG1 register. That’s either a
1- or 32-ms overflow at the maximum
oscillator frequency (8 MHz). The
COP is cleared by writing any value to
the $FFFF address.

LVD

The ’908Q has low-voltage detect

(LVD) circuitry that’s used to create a
reset if V

CC

falls below a V

TRIPF

volt-

age or doesn’t rise past a V

TRIPR

volt-

age. An LVD output of logic 1 indi-
cates an improper V

CC

; it’s polled or

used to reset the device.

Four LVD configuration bits are

located in the CONFIG1 register.
Because the ’908Q devices run on 3 or
5 V, a LVI5OR3 bit changes the V

TRIP

levels for the different V

CC

levels. The

LVIPWRD bit enables/disables the LVD
function, the LVITSTD bit enables/dis-
ables the device reset function, and the
LVISTOP bit enables/disables the LVD
function during Stop mode.

MON

Pin function is of the utmost impor-

tance, especially on devices with low
pin counts. Adding a monitor function
to a micro usually means dedicating
I/O to that function. The ’908Q device
checks the I/O state during reset
release and uses I/O PTA0 as a half-
duplex serial communications channel
for user access to the preprogrammed
monitor program.

When the device is empty (i.e.,

erased), Monitor mode is entered
using an internal or external oscilla-
tor without special voltages. After it’s
programmed, Monitor mode is forced
only via an external oscillator and a
high voltage on the IRQ input (V

CC

+

2.5 up to V

CC

+ 4).

Serial communication is 9600 bps

using an 8N1 format with the internal
oscillator (or 9.83 MHz with the exter-
nal oscillator). Six commands are avail-
able via the monitor ROM: READ
memory, WRITE memory, IREAD
indexed read, IWRITE indexed write,
READSP read stack pointer, and RUN
execute user program.

Each byte received from the host is

echoed back for error checking. Table 3
lists the command opcode and

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

73

operands. A security feature prevents
the unauthorized reading of flash mem-
ory if the first 6 bytes after reset don’t
match the bytes programmed in the
$FFF6-to-$FFFD addresses (i.e., inter-
rupt vectors). The host sends a break
(10 zero bits) if a match is attained. A
security failure will allow monitor com-
mands, including the execution of a
mass erase function. Thus, you can
recover control of the device without
revealing the programmed code.

I/O

Devices with low pin counts

require a port pin to function in mul-
tiple modes in order to achieve the
highest level of versatility. Port pins
are configured as digital input or out-
put (with the exception of PTA2,
which is only input) through the data
direction register (DDRx).

Any input bit can have an internal

pull-up that’s enabled via the Port X
pull-up enable register (PTxPUE). All
of Port A’s inputs can be used as an
external interrupt through the key-
board interrupt module (KIM). These
are configured for edge or level detect
via the MODEK bit in the keyboard
status and control register (KBSCR).

The KEYF bit indicates input detec-

tion and allows you to poll for this
action. The IMASKK bit enables/dis-
ables the external interrupts. The port
bits are read from or written to using
the PTx (data register). Bit 6 of PTA
has a special function, the AWUL bit
can enable/disable an automatic wake-
up from Stop mode in the KIM.

ADC

The ADC uses linear successive

approximation to convert an analog
input into an 8-bit digital representa-
tion in 16 ADC clock cycles. Analog
input is routed to the ADC from one
of four bits via a multiplexer. The

maximum ADC frequency is 1 MHz.
When the system execution cycle is
faster than 1 MHz, an ADC prescaler

(divide by 1/2/4/8/16) is used to
reduce the ADC clock. This ADC
supports both single and continuous

Command

Op-byte

Operand

Return

Action

READ

$4A

ADRSH:ADRSL

Contents of specified address

Retrieve value located at 16-bit address

WRITE

$49

ADRSH:ADRSL:DATA

None

Put value into 16-bit address location

IREAD

$1A

None

Contents of next two addresses

Retrieve the next two values located at the last 16-bit

(auto incrementing)

address + 1 and address + 2

IWRITE

$19

Data

None

Put value into the last 16-bit address + 1

READSP

$0C

None

SP + 1 as 2 bytes SPH:SPL

This allows you to locate the stack. You can alter the PC
loaded on the stack at SP+5:SP+6.

RUN

$28

None

PULH and RTI

Unload the stack and execute at PC

Table 3—

Six monitor commands are available. The half-duplex communications are handled on a single pin. Note that the monitor will echo each input byte received.

CadSoft Computer, Inc., 801 S. Federal Highway, Delray Beach, FL 33483

Hotline (561) 274-8355, Fax (561) 274-8218, E-Mail : info@cadsoftusa.com

EAGLE 4.0

Schematic Capture • Board Layout

Autorouter

800-858-8355

Light

Standard

Professional

Layout

Schematic

Schematic +

Autorouter

Autorouter

Layout +

Layout +

Layout +

398$

798$

399$

398$

798$

49$

597$

1197$

199$

Prices

Pay the difference for Upgrades

EAGLE 4.0 Light is Freeware!

EAGLE 4.0 Light is Freeware!

http://www.CadSoftUSA.com

http://www.CadSoftUSA.com

Windows is a registered trademark of Microsoft Corporation
Linux is a registered trademark of Linus Torvalds

Windows

®

for

and

You can use EAGLE Light for testing and

for

non-commercial applications without charge. The Freeware
Version is restricted to boards up to half Eurocard format,
with a maximum of two signal layers and one schematic
sheet. All other features correspond to those of the
Professional Version. Download it from our Internet Site
or order our free CD.

The Standard Version is suitable for boards in Eurocard
format with up to 4 signal layers The Professional Version
has no such limitations.

Frustration? No, thanks.

Fun? Yes, please.

Version 4.0 Highlights

!
!
!
!
!
!

!

!

!

New Library Management with
Component Browser
Technology and Package variants for
components
Design your own commands via User
Language
Unlimited length for component
names/values
Design Rules define pad/via
dimensions and shapes
Net Classes for Autorouter and DRC
Minimum Autorouter grid: 0.02 mm

SMD pads can be rounded or round
Different pad shapes for Top, Bottom,
or Inner layers

Satisfied customers - the key to our success

>
>

>

>
>

that´s why every new EAGLE version is based
on the feedback from our customers
that´s why all our customers have access to our
highly acclaimed, comprehensive support, free
of charge
that´s why EAGLE has no hidden costs for
libraries or modules which prove to be
indispensable after purchasing
that´s why we really want customers to enjoy
working with EAGLE
that´s why EAGLE is one of the top-rated
programs for schematic capture and board
layout

FREE

background image

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

75

conversion with a conversion-com-
plete flag and interrupt available. As a
rule of thumb, wait one conversion
time between channel changes and
enabling the ADC.

BREAK

If you want to create debugging

tools, this module allows you to take
control of program execution. The
break module is an address match
check with a jump to the SWI vector
at $FFFC:$FFFD (or $FEFC:$FEFD in
Monitor mode).

It would take several columns to

explain how to use this module, so
I’ll move on. Just remember that this
module is perfect if you enjoy getting
your fingers dirty.

DEMO KIT

Motorola put together an impres-

sive package to support the new
Nitron family. The 68HC908 demon-
stration kit consists of a small PC
board with a ’908QT4. It’s powered
by a 9-V battery and has serial-level
shifters that allow you to connect
directly to a PC’s COM port. Also,
the device is preloaded with an
application, so you can place the bat-
tery on it and immediately know
that all is well.

In addition, Motorola is working

with Metrowerks to give you a free
version of the CodeWarrier IDE that
supports the Nitron microcontroller
family. This special-edition toolset
features the IDE with a project man-
ager for up to 32 files. Whether you
work in assembly or ANSI C, the
source debugger will make it easy to
obtain clean code. Also, built-in sta-
tionary (templates) will help you get
started immediately.

P&E Microcomputer Systems tech-

nology brings full-chip simulation and
flash memory programming support to

the hardware kit. Processor Expert
from UNIS lets you focus your efforts
to the application code instead of the
system peripherals by providing
“beans.” The beans produce the code
that’s necessary for handling the
micro’s peripheral by selecting a few
items from the properties (i.e., physi-
cal configuration) and methods (i.e.,
routines required) menus.

DOCUMENTATION

The demonstration kit comes with

two CDs. The first CD, developed by
Metrowerks, installs the CodeWarrier
IDE software and contains all of the
documentation you’ll need. The guided
tour (HC908QT4_Tutorial) will help
you get your first project off the ground.
Processor Expert has an animated tuto-
rial that will help you understand its
process. You’ll also find a cool bean
trailer on the CD. (Enough said.)

The newest and most useful (IMHO)

part of the IDE is the real-time simula-
tor, which allows you to simulate hard-
ware connected to the device being
simulated. You’re free to choose from a
number of pre-made components like a
keyboard, potentiometer, LED, LCD, or
oscilloscope. You can also make your
own. Note that all of these operate in
real time to provide input to or get
output from the simulator.

The second CD contains documenta-

tion for the demo kit hardware and
other hardware tools that support
Motorola processors. Included are
datasheets and manuals that cover all
aspects of the devices. There are appli-
cation notes specific to the Nitron
family in addition to notes on the
other HC08 applications.

The Motorola CD also contains

product overviews and selector
guides that will help you choose the
right part for your application (see
Table 4). If you want to learn more

about the Nitron family of parts, this
CD has valuable information about
the monitor ROM.

After installing the CodeWarrier IDE

and following the tutorial, I unsoldered
the ’908QT4 from my kit’s PCB and
soldered a DIP socket in its place. It’s
not that I want to get rid of the part,
but just the opposite: I want another
device to be delivered. I want to use
this device in a new project, now!

BRACE YOURSELF

Watch out, everyone, here comes

the 8-bit micro leader expanding its
reach into the low-end market. The
Nitron family will be tough to com-
pete against. With flash memory and
an HC08 architecture, this beast is a
powerhouse shoehorned into 8- and
16-pin shoes. With free tools and sub-
$1 quantity prices, Motorola has
rearmed itself for an attack.

I

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

CodeWarrior Development Studio
Metrowerks, Inc.
(512) 997-4700
www.metrowerks.com

M68DEMO908QT4 Demonstration
board, Nitron 8-Bit HC08
Microcontroller family
Motorola, Inc.
(847) 576-5000
www.motorola.com

Processor Expert
UNIS, Ltd.
+420 5 41515777
www.unis.cz

Versions

68HC908QT1

68HC908QT2

68HC908QT4

68HC908QY1

68HC908QY2

68HC908QY4

Flash memory

1.5 KB

1.5 KB

4 KB

1.5 KB

1.5 KB

4 KB

ADC

Four-channel, 8-bit

Four-channel, 8-bit

Four-channel, 8-bit

Four-channel, 8-bit

Package

8-lead 8-lead

8-lead

16-lead

16-lead

16-lead

SOIC/PDIP

SOIC/PDIP

SOIC/PDIP

SOIC/PDIP/TSSOP

SOIC/PDIP/TSSOP

SOIC/PDIP/TSSOP

Temperature range

–40° to 85°C

–40° to 85°C

–40° to 85°C

–40° to 125°C

–40° to 125°C

–40° to 125°C

Table 4—

Presently, there are six devices available in the Motorola Nitron microcontroller family: three 8-pin devices and three 16-pin devices. All of the devices are packaged

in PDIP, SOIC, and TSSOP (16-pin only).

background image

76

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

lectrolumines-

cent (EL) lamps are

devices that convert

electrical energy into

light or luminescence; the term lumi-
nescence is generally associated with
solids that generate light. In the case
of electroluminescence, an electric
field (voltage) is applied to a thin phos-
phor layer to produce light. The typi-
cal lamp consists of light-emitting
phosphor sandwiched between two
conductive electrodes. One of the elec-
trodes is optically clear to allow light
to escape. As an AC voltage is applied
to the electrodes, the electric field
causes the phosphor to rapidly charge
and discharge, resulting in the emis-
sion of light during each cycle.
Because the size and number of light
pulses depends on the magnitude of
applied voltage and frequency, the
brightness of EL lamps generally can
be controlled by varying the operating
voltage and frequency.

The nominal voltage and frequency

for EL lamps are 115 V and 400 Hz,
respectively. Varying the lamp voltage
or frequency will change the lamp
brightness and, to some extent, the
color. For example, increasing the
voltage increases lamp brightness,
whereas increasing the frequency will

increase lamp brightness and shift the
color slightly toward blue. However,
increasing voltage and frequency will
reduce lamp life.

EL lamps do not catastrophically or

abruptly fail; instead, the lamp bright-
ness will gradually decrease over long
periods of use. EL lamp life is affected
by voltage, frequency, temperature,
and humidity. Because EL lamps gener-
ally require drive voltages and frequen-
cies not available from batteries or AC
line voltage, a conversion is needed to
obtain optimum color and brightness.
For battery operation, a DC-to-AC
voltage frequency inverter is needed.

I designed a simple EL lamp driver

circuit that uses the Supertex HV826
integrated circuit, which is able to
handle large loads. Furthermore, the
HV826 is designed to work with EL
lamps. [1] For all of the details, you
should read the datasheet.

The HV826 has a 1.8- to 3.5-V input

supply voltage range. A ±80-V nominal
regulated output voltage is applied to
the EL lamp. This driver has only one
inductor and a minimum number of
passive components. The HV826’s
lamp drive oscillator is separate from
the power conversion oscillator, which
allows you to set the lamp drive fre-
quency independently from the power
conversion frequency.

For many applications (e.g., mobile

phones, two-way pagers, GPS, and
other wireless communication
devices), optimizing the overall per-
formance in this manner is necessary.
Figure 1 illustrates a fully optimized
system. You can use different inductor
(L1) values or parts from different
manufacturers in place of what is
shown; however, it’s important to
note that the device’s switching fre-
quency is fixed at 53.4 KHz, and the
inductor saturation current won’t even
be approached at this frequency.

The design shown in Figure 1 has

excellent drive capability and provides
a symmetrical bipolar drive, resulting
in a zero-bias signal. Many lamp man-
ufacturers recommend a zero-bias
drive signal to avoid potential migra-
tion problems and improve lamp life.

If the inductor saturation current is

lower than what the circuit or your
application requires, then the inductor

e

In this complicated
world, quick solutions
can be lifesavers. D.
Prabakaran recently
designed a straightfor-
ward EL-lamp driver
that includes an
HV826 integrated cir-
cuit. With it, he can
enhance backlighting
applications ranging
from laptop displays to
keypad lighting.

D. Prabakaran

SHORT
SOLUTIONS

Simple EL-Lamp Driver

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

77

or IC will be damaged. As with the
inductor values, you can use differ-
ent capacitor types (C2). Using a dif-
ferent capacitor type will generate
audible noise as a result of the piezo-
electric effect caused by the materi-
als used for their structure (e.g., X7R
and 5YU capacitors).

You also have the option of using a

capacitor of a different value. The
manufacturer recommends using a
larger value C2 capacitor (10 nF) for

REFERENCE

[1] Supertex, Inc., “High Voltage EL

Lamp Driver,” November 2001.

D. Prabakaran earned a B.E. in Mech-
anical Engineering, and now heads the
Department of Mechanical Engineering
at N. L. Polytechnic College, Mettu-
palayam in India. He likes to work
with amateur radio and electronics.
He has published many articles about
his circuit designs. You may reach him
at pabakar10@yahoo.com.

SOURCE

HV826 Integrated circuit
Supertex, Inc.
(408) 744-0100
www.supertex.com

large EL lamps or
extremely high-input
voltage ranges. Smaller
value CS capacitors
can be used as long as
the overall efficiency
of the circuit is not
decreased. Using larger
value capacitors won’t
significantly affect

the performance of
the circuit.

The circuit I

designed consumes
around 15 to 20 mA
at 3 V, which may be

derived from a battery. Excessive
input current may be a good indica-
tion of connection errors or incorrect
component values. A sharp rise in
current usually indicates a saturated
inductor. To avoid inductor satura-
tion, use a high current rated inductor
or increase the conversion frequency
by lowering the RSW resistor value.

This system can work for various

backlighting applications, including
calculator displays, laptop displays,

Figure 1—

To keep today’s plethora of wireless communication devices up and

running, you need to optimize your system. By using an integrated circuit like
the Supertex HV826, which has a lamp drive oscillator that’s separate from
the power conversion oscillator, you can control the lamp drive frequency inde-
pendently from the power conversion frequency.

photographic transparencies, and com-
puter peripheral displays. Other
options include portable or stationary
advertising displays, clock and watch
dials, portable table lights, safety/res-
cue apparel and accessories, and key-
pad lighting.

I

background image

78

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

ord comes down

from on high:

“We’ve got to network-

enable our widget!”

As a design engineer bombarded by

management mandates, you may
sometimes feel your job is not to rea-
son why, only to do or die. But, when
it comes to getting embedded applica-
tions on the I-way, believe me when
I say that you (and everybody else
involved) had better understand why,
or you won’t know what to do.
Worse yet, you’ll do something you’ll
be sorry you did.

The fact is, your first response

needs to be, “Er, what exactly do you
mean by network-enable?” That
should give everybody something to
chew on. Let’s try to come up with a
few answers as we take a look at a
gaggle of gadgets that, each in their
own way, bring the ’Net to embedded
apps (see Photo 1).

ETHER OR NOT

Over the last decade, most corpora-

tions have had to migrate from whatev-
er proprietary, ad-hoc networking lash-
up they had before, some of which were
schemes going as far back as the Bronze
Age of the mainframe and minicom-

Working the ’Net

w

Tom Cantrell

Shouldn’t
every
engineer
know a lit-
tle more

about the process of
network-enabling his
or her widget? Tom
definitely thinks so.
With Tom on your
side, you’ll be working
the ’Net to your
advantage in no time.

SILICON
UPDATE

puters. Big-iron legacy applications and
hardware die hard, so the transition typ-
ically doesn’t happen overnight.

It’s easier to change the wire than

the proprietary software and 24/7
devices behind it. In the course of
enterprise IT reconfiguration, it’s not
hard to imagine situations in which
there is a need to maintain some pro-
prietary RS-232-based hardware and
software across the transition to
TCP/IP and Ethernet.

Consider an existing application

with a factory-floor, RS-232 device—
perhaps an electronic scale, ticket
printer, or bar code reader—hard-wired
to a PC. Having run Ethernet cable
hither and yon, now what? Neither
the existing application software run-
ning on the PC nor the RS-232 device
knows anything about Ethernet, not
to mention the Internet.

The solution is conceptually simple:

turn the Internet into a virtual RS-232
cable with products like the Lantronix
CoBox or i2Chip IGM7100. In essence,
they’re RS-232-to-Ethernet converters.
Connect one of them to the COM port
on your PC and one to the RS-232
port on your embedded device. Now,
you’ve got Ethernet jacks at each end,
and you can plug in an Ethernet cable,
or for that matter, the entire Internet
in-between them.

The beauty of the scheme is that it’s

transparent to the application hard-
ware and software at each end. Both
the PC and embedded device continue
to talk to their UARTs, blissfully
unaware that traffic is actually mov-
ing over the network.

You can cut back to just one adapter

if the PC has a built-in Ethernet port,
which will be the most likely case
given the entire scenario revolves
around upgrading to a network.
Normally that would call for rewriting
the software on the PC to talk to the
Ethernet instead of the COM port. An
easier approach is to use COM port
redirector software that installs a driv-
er to trap COM port-related OS calls
and routes them via the Ethernet port.

That’s the approach I took, using the

redirector software that came with the
Lantronix box. Sure enough, I was able
to connect an existing RS-232-based
application to both the Lantronix and

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

79

would allow the user to enter a
desired temperature as well as display
the actual current temperature.

SitePlayer makes an otherwise stat-

ic page dynamic by embedding special
tags in the HTML. The tags, denoted
by a caret (

^), refer to variables that

pass one-way or the other (or both
ways) between the SitePlayer web
server and your embedded device serv-
er. For instance, in the thermostat
example, your web page could simply
display the following string:

The current temperature is

^temp

As SitePlayer dishes up the web page,
it will notice the

^temp variable and

substitute the current value of the
temperature variable.

SitePlayer knows about the

^temp variable by virtue of a
SitePlayer definition file
(extension .spd) that you cre-
ate. Along with various config-
uration parameters (i.e., the IP
address, whether or not to use
DHCP or a password, etc.), the
.spd file defines the location
and data type for each variable.

On the device server side

(i.e., RS-232), the embedded
system (e.g., thermostat)
updates the

^temp variable

using a simple protocol (com-
mand and data) that accesses
SitePlayer’s internal memory.
In the thermostat example,
you would send the current

temperature via the RS-232 to
the location in SitePlayer cor-

i2Chip boards. Everything worked just
as advertised (i.e., exactly as before
without software changes).

There is one thing to watch out for,

though. The serial port on both of
these converters is designed to plug
directly into a PC to provide an alter-
nate path (instead of Ethernet) for
downloading and configuration. But,
that means when you unplug your
embedded device from the PC’s COM
port and plug it into the converter’s
serial port, you have to perform the old
DTE-DCE switcheroo (i.e., swap the TX
and RX pins). Don’t toss your RS-232
breakout box just yet. The more things
change the more they stay the same.

WEB SITE LITE

I suspect that when the marketing

department bangs on the table for net-
working, they usually mean to say,
“web browser enabling.” In other
words, the ability to interrogate, con-
trol, upgrade, and otherwise interact
with an embedded product using a
standard web browser.

These days, practically all embed-

ded products have a user interface,
whether it’s a full-featured, touch-
screen display or a DIP switch and
blinking LED. The user interface even
can be a PC with some kind of soft-
ware making the connection, ranging
from a simple terminal program to a
custom-programmed GUI.

The advantage of the web-based

approach is compelling. In
short, it puts the user-inter-
face ball squarely in the user’s
court, which turns out to be a
win-win for everyone. Users
get to choose their favorite
browsing platform, which is
typically a PC but is inexorably
expanding to include PDAs,
smart phones, web TVs, hand-
held games, and ultimately just
about anything with a display
and input device.

Meanwhile, the equipment

supplier is relieved of the bur-
den of having to make provi-
sions for (and support) propri-
etary software and hardware
at the user end. The engineer-
ing spec is simple: add an
Ethernet jack and cough up a

web page. All that’s left is to
figure out the simplest, quick-
est, and cheapest way to do it.

NetMedia targets this sce-

nario with their SitePlayer,
which is notable for its laser-
like focus. All nonessential
baggage is tossed overboard in
pursuit of the singular goal of
talking to a web browser.
There’s no socket-level pro-
gramming, e-mail, execution
of user code (although the
web site alludes to a pro-
gramming language in the
works), or anything else.
Thanks to it’s single-minded purpose,
SitePlayer gets by with a remarkably
tiny bill of materials. It’s literally
made up of two chips: a standard
Philips flash memory ’51 and a com-
modity RealTek Ethernet MAC chip.

That’s not to say such a streamlined

approach doesn’t come with some
compromises. For example, because
your SitePlayer-based web site is lim-
ited to the ’51’s 48-KB on-chip flash
memory, leave your bloated eye candy
at home. Nevertheless, with care you
can come up with up with an attrac-
tive user interface that doesn’t bust
the bit budget (see Photo 2).

Of course, serving up a mere static

web page isn’t that hard nor is it very
useful. You’ll generally want to dis-
play or input dynamic data. For
instance, a web-enabled thermostat

Photo 1—

Moving clockwise from the top left, you can see the i2Chip

IGM7100, Lantronix CoBox Micro, NetBurner SB72, and SitePlayer.
These are evaluation setups with the base modules plugged into car-
rier boards that include the RS-232 level shifter and connector, and, in
the case of i2Chip and SitePlayer, the Ethernet PHY and connector.

Photo 2—

If you keep your design tight, you can get SitePlayer to serve up an

appealing interface, even with only 48 KB of flash memory to play with.

background image

80

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

of built-in objects that you can access.
These include various ’51 resources
such as the on-chip special function
registers and I/O lines along with
higher-level objects like COM and
SPI. The former provides easy access
to the ’51’s UART. For instance, refer-
ring back to Photo 3, clicking on
Hello invokes a link that looks like:

<A HREF="comtest.spi?com=

Hello%20World%0d%0a"
>Hello</A>

which sends the

Hello World string

followed by a carriage return and line
feed out the UART.

Meanwhile, the SPI object provides,

as you might have guessed, access to
SPI peripheral ICs. When using the SPI
object, three of the eight available
SitePlayer ’51 I/O lines take on the
clocked serial role (i.e., SCK, MOSI,
and MISO) with any or all of the
remaining five lines used as SPI chip
selects. The manual contains exam-
ples of the admittedly cryptic HTML
needed to perform a SPI access, but
also explains that you may have to get
your hands dirty (e.g., Java) to make
much use of the cascade of bits associ-
ated with a particular peripheral chip.

There’s even a universal datagram

protocol (UDP) object that allows your
device to send, receive, and broadcast
packets to other UDP-capable devices,

including, of course, other
SitePlayers. Just remember
that unlike TCP/IP, with UDP
there are few guarantees in
terms of delivery and correct-
ness, so you’ll have to harden
your application against the
possibility of network errors.

FRESHEN UP

The SitePlayer package is

reasonably friendly and easy to
use, all the more so by virtue
of some handy utilities that
streamline development. The
standard flow is to define your
variables and such in the
aforementioned SitePlayer def-
inition file (.spd) and then cre-
ate your web page using a

combination of web-authoring
tools and tweaking the result-

responding to the

^temp variable as

defined in the .spd file. Now, the next
time the page is refreshed the current
temperature will be displayed.

Of course, as soon as you’ve crafted

a simple character-oriented interface,
the call will come down from on high
to spiff it up with graphics for a more
glamorous first impression. The
SitePlayer allows you to, for example,
replace a simple numeric variable with
its virtual seven-segment LED equiva-
lent. Photo 3 shows a web page in
which

var is defined as a byte dis-

played as a decimal number of
up to three digits (i.e., 0–255).

SitePlayer allows you to

pick off individual digits using
a colon notation (

:). Examples

include

^var:3, ^var:2, and

^var:1. In turn, the digits are
grafted onto the file name
calling out a particular LED
image file. For instance, if the
value of the variable is 234,
^var:1_LED.jpg will bring
in the file 4_LED.jpg, which is
the bitmap image of an LED
showing the number four. A
variety of useful image files
(e.g., seven-segment LEDs,
sliders, and knobs) come with
the SitePlayer software.

As usual, the complexity (if

not the devil) is in the details.
Using Word as my web page

authoring tool, I couldn’t find a way to
generate the colon syntax. Thus, I had
to edit the HTML directly, something I
imagine is required for some of the
other fancy constructs as well. Also, I
was unable to come up with a scheme
to blank leading LED zeros. There may
be a way for users to kludge around it,
but I would say this is a feature that
should be added to the tools.

COM SPI WITH ME

Besides user-defined objects like

variables, SitePlayer offers a number

Photo 3—

A key SitePlayer technique is to parse the numeric value of a variable to create a file name that references

a graphic file, in this case a seven-segment LED. Meanwhile, the Serial Tester utility facilitates PC-based debug-
ging by allowing easy access to variables and monitoring the associated RS-232 command and response packets.

Photo 4—

With a TCP/IP stack and GNU development tools, NetBurner can do

it all. For example, turning your embedded gadget into an FTP server provides
an easy way to move application data to or from a file. Just copy and paste.

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

81

ing HTML. Put the HTML and all
other files associated with your
SitePlayer web site (e.g., the seven-
segment LED .jpg files and any other
graphics) in a folder and call up the
SiteLinker program.

SiteLinker chews on your web site

folder and spits out a SitePlayer binary
(.spb) file that’s downloaded into the
’51’s flash memory via the network.
Refresh your web browser to see the
results and repeat the cycle as necessary.

As I mentioned earlier, SitePlayer

web sites are limited to 48 KB by the
confines of the ’51’s on-chip flash
memory. That means you have to be
careful about going overboard with
fancy graphics, long file names, and so
on. The good news is that the 48-KB
limit translates into a reasonably
quick link-download-reflash cycle that
takes only 20 to 30 s.

Nevertheless, even a relatively

minor delay inhibits the quick itera-
tion that’s called for by the artistic
exercise of creating a web page, not to
mention the tweak-and-try personali-
ty of the SitePlayer tools. To that end,
the SitePlayerPC utility provided
essentially turns the PC into a big
SitePlayer, allowing you to run your
web site .spd binary file in situ.

Similarly, the serial tester utility

allows development to proceed using
the PC COM port as a stand-in for the
embedded device that ultimately will
be connected to the SitePlayer’s serial
port. The utility allows easy access
(GET and PUT) to SitePlayer objects.
It also displays the commands and
responses traveling across the serial
link, which is valuable assistance when
you’re writing the serial interface code
that runs on your own device.

BURNING DOWN THE ’NET

The previously described products

are all designed to ease the process of
migrating an existing application
toward a network-based solution.
Eventually, or if you’re starting from
scratch, the time will come to consid-
er consolidating your embedded appli-
cation processing and networking to
run on a single processor.

Enter NetBurner. Despite it’s small

size (and price), don’t be fooled. Based
on a 66-MHz Motorola MC5272 Cold-

Fire chip (see Figure 1), NetBurner is a
stand-alone 32-bit SBC with up to
512 KB of flash memory and a whop-
ping 8 MB of SDRAM. Under the hood
is a full-blown RTOS (µC/OS) and com-
plete TCP/IP stack. Here, you’ll find
every letter in the alphabet soup of pro-
tocols that handle web serving, e-mail,
file transfer (i.e., FTP), and all the rest.

What separates NetBurner from

many other 32-bit SBCs are specific
utilities, libraries, and application
examples that tailor the device for

quick and easy (or at least quicker and
easier) Internet apps. Tools start with
the familiar GNU toolchain, including
a C compiler, assembler, debugger,
linker, and so on. However, those of
you who have dabbled with GNU
before know that merely manhandling
the tools, not to mention getting any
work done, is a nontrivial task.

To make life easier, NetBurner

comes with a predefined

make script

that handles the messy details.
Notably, this includes consolidating

Join the conversation.

Give your programmable instruments the command language of
choice, supported by major manufacturers and familiar to customers.

Talk the language. Talk SCPI with JPA-SCPI Parser.

The SCPI command language presents your
instruments with a familiar and professional
programming interface, reducing support
needs and reinforcing your position as a truly
proficient manufacturer.

In the past, the power and flexibility of the
SCPI language meant employing a consultant
or spending days and weeks writing an inter-
preter in-house. Not any more.

Using JPA-SCPI Parser, your own developers
are empowered to build a full SCPI interpreter
for your instruments quickly, easily and at
very low cost.

More than just a source code library, JPA-SCPI
Parser is a complete software toolkit to give
you SCPI capability in the shortest time.

Take a look at some of the highlights

x

Suitable for any peripheral interface
e.g. GPIB, RS232, USB etc.

x

Works on almost any processor/platform

x

Minimal ROM & RAM requirements

x

Written in C, fully ANSI/ISO compliant

x

NO ROYALTIES / RUNTIME FEES

x

Fully compliant to current SCPI standard

What’s Included

x

C source code comprising the parser itself
and access functions

x

Template command sets for 10 common
types of instrument

x

Base template suitable for all instruments

x

Example source code

x

Comprehensive user manual to take you
through each stage to your SCPI parser

x

Design notes manual

x

Unlimited royalty-free runtime licenses

x

Free technical support and product
upgrades for 1 year





Pricing

Single-brand site license, allowing use of
JPA-SCPI Parser for an unlimited number
of your company’s instruments: $495

A multi-brand site license is available for
consultancy houses:

$2475

JPA Consulting

accelerating product development

Try JPA-SCPI Parser today.

Download our demo application to see

for yourself just what it can do.

Available from our website.

For full details or to purchase, visit

www.jpacsoft.com

background image
background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

83

If you just want to put a web-

friendly face in front of your existing
hardware with minimal software
changes, web browser enabling is
really what you’re talking about.
The NetMedia SitePlayer is designed
to do just that. And although I didn’t
get into it this time, note that easy
e-mail enabling is also an option
with products from the likes of
ConnectOne and Cermetek.

Maybe you’re starting from scratch

and need a full-blown, Internet-
enabled solution that can handle any
and all protocols (e.g., web, e-mail,
and FTP) as well as your application
processing. That calls for a full-
blown computing platform (à la
NetBurner) with sufficient memory
and MIPs to carry the load.

Yes, there are a lot of questions to

work through, but take heart. The
good news is that for every question
you come up with there are folks

working hard to make sure you can
find just the right answer.

I

SOURCES

IGM7100 Serial-to-Ethernet gate-
way module
i2Chip, Inc.
(408) 432-5081
www.i2chip.com

CoBox Micro device server
Lantronix, Inc.
(949) 453-3990
www.lantronix.com

MC5272 ColdFire Microprocessor
Motorola, Inc.
(847) 576-5000
www.motorola.com

SB72 Serial-to-Ethernet device
NetBurner, Inc.
(858) 558-0293
www.netburner.com

SitePlayer Ethernet web server
NetMedia, Inc.
(520) 544-4567
www.siteplayer.com

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@cir-
cuitcellar.com.

and compressing all related applica-
tion and web files for packing into
the flash memory. Then, after reset,
NetBurner decompresses and trans-
fers the code to SDRAM, which, in
conjunction with the ’5272’s high-
speed on-chip cache and RAM,
delivers speedy processing.

For dynamic web pages, feel free

to use all of the highfalutin tech-
niques—such as Java applets, com-
mon gateway interface (CGI), and
socket-level programming—that
this 32-bit processor and its megs
of memory can support. Just
remember that even though the
platform is downsized, such big-
iron programming isn’t for begin-
ners or the faint of heart.

NetBurner offers an easier way

out with a “tagged HTML” approach
similar to the one I described earlier
for SitePlayer. The difference is that
the NetBurner tags, rather than just
displaying variables and objects, per-
form a C function call for unlimited
processing capability (see Listing 1). A
particular item that appears on the
web browser’s screen might have 10
or 10,000 lines of code behind it.

I was impressed with the collec-

tion of nearly two-dozen example
applications. They encompass every-
thing from the simplest Hello World
demo to e-mail, Telnet, PPP, UDP,
FTP, and much more (see Photo 4).
There’s just no better way to learn
how to do something than to see how
it’s done, and the examples will prove
to be a helpful starting point for your
own application.

HAVE IT YOUR WAY

Having seen the variety of choices,

I think you can understand that
there’s more to getting your applica-
tion on the I-way than meets the
eye. The question of whether or not
to do it is the easiest to answer—a
resounding “yes” in my opinion—
but only the first.

Perhaps you’ve got a legacy serial

port app and simply want to change
the wire with no intention of upgrad-
ing the hardware or software beyond
that. If so, Ethernet enabling is the
way to go with a simple converter
such as the Lantronix CoBox or
i2Chip IGM7100.

Listing 1—

NetBurner’s approach to dynamic web pages embeds tagged C function calls in the HTML.

<html>

<B>Click on the boxes <br>

to toggle the LEDs on the NetBurner board

<table border=1>

<tr>

<!--FUNCTIONCALL DoLeds -->

</tr>

</table>

<br>

Dip Switches:

<!--FUNCTIONCALL DoSwitches -->

</body>

</html>

1K

I-Cache

4K

SRAM

10/100

Ethernet

controller

DMA

USB1.1

Module

Three

PWMs

Two

UARTs

MAC
H/W

divde

JTAG

Debug

module

DMA

Four

timers

Software HDLC

module

System

bus

controller

Interrupt

controller

SRAM

controller and

chip select

General-

purpose I/O

QSPI

Four

TDMs

I Addr Gen

I Fetch

Instr Buf

Dec and

Sel Op

A General

and EX

V2

Figure 1—

Where’s the kitchen sink? The Motorola MC5272

at the heart of NetBurner is a networking workhorse with
built-in Ethernet, USB, SPI, and UARTs.

background image

84

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

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

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.

Suppliers Directory now available online. Check out our web site

www.circuitcellar.com to see who has what and how to get it!

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

85

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

BOB-3 is a team player.
BOB-3 will only say what you want.
BOB-3 plays well with NTSC and PAL.
BOB-3 is your new best friend.

Decade Engineering's new BOB-3 module
easily overlays text on video. BOB-3 displays
up to 17 lines of 40 characters, including 63
custom characters. Other features include
vertical scrolling, a stand-alone display option,
faster serial communication, automatic video
generation, and much more.

Get to know BOB-3 at

www.decadenet.com

Meet BOB-3.

Decade Engineering
503-743-3194
Turner, OR, USA

background image

86

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

87

background image

88

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

89

background image

90

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

JK



microsystems

Call

530-297- 6073

Email

sales

@

jkmicro.com

On the web at

www.jkmicro.com

l



Flashlite 186 controller

l



Borland C/C++ ver 4.52

l



FREE Email Tech Support

l



Serial Driver library

l



AC Adapter and cable

l



186 processor

@

33 MHz

l



DOS w/ Flash File system

l



44 Digital I/O lines w/ CPLD

l



Console / Debug Serial Port

l



7-34V DC or 5V DC power

l



Accepts 8MB DiskOnChip

l



512K DRAM & 512K Flash

l



Expansion options with Peripheral Boards

Flashlite

l



2

Serial Ports

l



2 16-bit Timers

l



Watchdog Timer

186

Development

System

$

99

$

69

QTY 1

Development kit includes:

r

e

s

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

91

Front Panels?

www.frontpanelexpress.com

Download the free ›Front Panel Designer‹
to design your front panels in minutes

Order your front panels online
and receive them just in time

Unrivaled in price and

quality for small orders

Email: sales@picofab.net

background image

92

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

background image

www.circuitcellar.com

CIRCUIT CELLAR

®

Issue 151 February 2003

93

RS232

to Windows

WinWedge inputs real-time
serial data from any device
direct into Excel, Access, VB
or any Windows program.

www.taltech.com

New CE
version!

background image

MCS-51 SBC for the Classroom—Part 2: Software Development

Updating the Home Control System—Part 1: FPGA Upgrade Board

Intelligent Light–Effects Controller for Entertainment Systems

2-D Optical Position Sensor

A Look at Computer Viruses

Using Rotary Encoders as Input Devices

Build Your Own MP3

I Applied PCs: Get Hooked On Video With the STV5730A

I From the Bench: The Switching Approach—Infiltrating the Linear Supply Market

I Silicon Update: Not Fading Away

Preview of March Issue 152

Theme: Signal Processing

94

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

INDEX

91

Abacom Technologies

41

Acon, Inc.

85

ActiveWire, Inc.

49

All Electronics Corp.

86

Amazon Electronics

92

AP Circuits

90

Appspec Computer Tech. Corp.

50

Arcturus Networks

24

Arcom

7

Atmel

90

Bagotronix, Inc.

85,95

Basic Micro

90

Bellin Dynamic Systems, Inc.

73

CadSoft Computer, Inc.

93

CCS-Custom Computer Services

92

Conitec

29

Connecticut mircoComputer, Inc.

91

Cyberpak Co.

9

Cypress MicroSystems

89

CWAV

90

DataRescue

85

Decade Engineering

87

Delcom Engineering

86

Digital Products

1

Earth Computer Technologies

86

EE Tools

(Electronic Engineering Tools)

77

EMAC, Inc.

25

ExpressPCB

The Advertiser’s Index with links to their web sites is located at www.circuitcellar.com under the current issue.

Page

85

FDI-Future Designs, Inc.

17

Flash Innovation 2003

91

Front Panel Express

85

Hagstrom Electronics

65

HI-TECH Software, LLC

91

HVW Technologies Inc.

16

ICOP Technology Inc.

87

IMAGEcraft

91,92

Intec Automation, Inc.

90

Intronics, Inc.

51

Intuitive Circuits, LLC

66

Jameco

64,90

JK microsystems, Inc.

81

JPA Consulting Ltd.

51

JR Kerr Automation & Engineering

52

LabJack Corp.

52

Lakeview Research

88

Lemos International

2

Link Instruments

93

Lynxmotion, Inc.

72

MaxStream

89

MCC (Micro Computer Control)

29

Microchip

90

Microcross

89

Micro Digital, Inc.

92

microEngineering Labs, Inc.

74

Micromint

85

MicroSystems Development, Inc.

84

MindTel LLC

87

MJS Consulting

57

Motorola

17

Motorola Contest

82

MVS

93

Mylydia Inc.

C2

NetBurner

87

OKW Electronics, Inc.

67

On Time

86

Ontrak Control Systems

25

PCBexpress

58

PCBpro

C4

Parallax, Inc.

84

Phytec America LLC

84

Phyton, Inc.

91

Picofab Inc.

88

Pioneer Hill Software

48

Polydroids

90

Prairie Digital, Inc.

89

Pulsar, Inc.

84

QKITS.COM

89

R2 Controls

26

R4 Systems Inc.

15

Rabbit Semiconductor

93

Radovan Robotics

58

Remote Processing

67

RF Digital

89

RLC Enterprises, Inc.

Page

Page

Page

ADVERTISER’S

92

Rutex

5

Saelig Company

3

Scott Edwards Electronics Inc.

88

Sealevel Systems

86

Senix Corp.

85

Sensory, Inc.

84

Signum Systems

86

Softools

92

Spectrum Engineering

84

Square 1 Electronics

88

SUMBOX Pty Ltd.

93

TAL Technologies

C3

Tech Tools

32,33

Technologic Systems

86

Technological Arts

88

Tern Inc.

90

Triangle Research Int’l, Inc.

77

Trilogy Design

52

Trinity Robotics Contest

93

Weeder Technologies

71

Wireless Systems Design Conference

91

Xeltek

87

Z-World

51

Zagros Robotics

86

Zanthic Technologies Inc.

23

Zilog, Inc

April Issue 153

Deadlines

Space Close: Feb. 10

Material Due Date: Feb. 17

Theme:

Robotics

A

TTENTION

A

DVERTISERS

Call Sean Donnelly to

reserve your space!

860.872.3064

e-mail: sean@circuitcellar.com

background image
background image

ave you ever thought about how much the evolution in communication technology affects the way you live today?

Perhaps the remotest we can be from today’s Information Age is going back to the days of the Greeks. Let’s face

it. Communication technology back then wasn’t much more than determining who could yell the loudest. Their idea of

“advanced technology” meant adding the mechanical acoustics of an amphitheater. Crude but effective.

Remote communication was an even more difficult task. Doing something as ordinary as trying to gather government representatives

together for a meeting involved sending messengers to the far corners of the land and waiting days or even weeks for replies. When the mes-
senger reached his destination, he personally exchanged the message in the presence of the recipient. From there, the messenger returned
the response. Of course, this presumed that the messenger didn’t meet with the ancient equivalent of a spam filter, where he was killed based
on the recipient’s opinion of the message.

The first real revolutionary advance in communication technology was the telegraph. Instead of purely mechanical enhancements, it com-

bined ideas of electricity and mechanical signaling as a method of sending distant communications. And, although it was a first step towards
modern-day communication technology, an operator still had to translate the Morse Code into written language and then hand deliver the mes-
sage to the recipient.

Pre-Information Age people had a completely different view of the role of communications than we do today. When individuals communicat-

ed over long distances, they expected long delays and simply waited. No one really seemed to be in a hurry to do things. Communication was
an extension of the natural use of language and not an independent tool that grants universal access and demands instant response.

Information Age society has a decidedly unique view of the world, and it has radically affected the way we interact with each other. Today,

we communicate without leaving the comforts of the home and with little special effort. We can communicate with 100 people without ever
seeing a face or hearing a voice. One hundred years ago, the rising sun determined the workday. And, although we might view it as a difficult
existence, it was decidedly slower paced and far more interactive. Today, it’s a 24/7 world where too many of us need it to be 30/7.

The Internet and other forms of enhanced communication have altered the nature of our interactions and concept of time. Today, we define

time by its accomplishment-value, not just the passing of seconds. The fact that the mechanical efficiency of communicating has improved
doesn’t necessarily make us feel like we’re accomplishing more. Despite the fact that we are indeed saving time, we continually pack our lives
with more and more things to do in order to preserve this value.

We’ve been communicating since the first of our species could talk. How we do it affects our personal relationships and all the others

around us. Advanced technology has altered our lives and our mind-set.

In the future, communication technology will offer even more choices. People once had to rely on face-to-face communication, because they

had no other alternative. Today, the Internet allows us to be physically remote yet totally connected to the world. At the rate we’re going, it is
not inconceivable that tomorrow’s workplace will be completely virtual.

Although inefficient by today’s standards, talking facilitates understanding between individuals and contributes to the social order. In a

cyberspace-only world, we run the risk of having less socialization and many more of the misunderstandings that can result from it. Society
must be wary of the isolating aspect of high-tech communication exercised to the extreme.

Before we dismiss the past as irrelevant in today’s high-speed world, we have to look at what we lose along with the gains. The solution for

me has been to simply walk away from the computer and talk to real people.

Real People

INTERRUPT

h

steve.ciarcia@circuitcellar.com

96

Issue 151 February 2003

CIRCUIT CELLAR

®

www.circuitcellar.com

PRIORITY

background image
background image

Wyszukiwarka

Podobne podstrony:
circuit cellar2000 02
circuit cellar1995 02
circuit cellar1991 02,03
circuit cellar1994 02
circuit cellar2004 02
circuit cellar2002 02
circuit cellar1993 02
circuit cellar1997 02
circuit cellar1990 02,03
circuit cellar2001 02
circuit cellar1996 02
circuit cellar1992 02,03
circuit cellar2000 02
circuit cellar1992 02,03
circuit cellar1993 02
circuit cellar1991 02,03
circuit cellar1994 02

więcej podobnych podstron