Oscilloscope, Logic Analyzer, Spectrum Analyzer, FFT. (PDFDrive)
Oscilloscope, Logic Analyzer, Spectrum Analyzer, FFT. (PDFDrive)
CELLAR
O
®
.R
i2
.H
LE
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
E
Smartswitch Smarts
iU
.G
An LCD Controller
W
W
Dealing with
Dead Time
0 7>
7 25274 75349 9
O
.R
• 2 Channel Digital Oscilloscope DSO-2102S $525
i2
• 100 MSa/s max single shot rate DSO-2102M $650
• 32K samples per channel Each includes Oscilloscope,
.H
• Advanced Triggering Probes, Interface Cable, Power
• Only 9 oz and 6.3” x 3.75” x 1.25” Adapter, and software for
• Small, Lightweight, and Portable Win95/98, WinNT, Win2000
LE
• Parallel Port interface to PC and DOS.
• Advanced Math options
• FFT Spectrum Analyzer options
E
Logic Analyzers
M
U
R
iU
.G
W
www.LinkIns4.com
Link Instruments • 369 Passaic Ave • Suite 100 • Fairfield, NJ 07004 • (973) 808-8990 • Fax (973) 808-8786
W
W
W
.G
iU
R
U
M
E
LE
.H
i2
.R
O
check out what’s new at www.saelig.com!
DrDAQ
Educational
PC-based Instruments NEW!!
Datalogger ADC-10 8-bit $85 through ADC-216 16-bit $799—display 12-bit
with built-in scope, spectrum and meter simultaneously. Connect to PC
sensors! parallel port and start 100Ms/S
www.drdaq.com gathering/displaying data dual-ch
immediately!
DrDAQ plugs into a PC for useful scope
• EnviroMon temperature adapter
datalogging at school, college,
logging/alarm system
industry. Built-in sensors for light, standalone or with PC.
sound, temp. or add pH sensor and ADC-212/100
run one of the many suggested
• TH-03 thermistor-
to-PC converter
science experiments! - only $99!
• TC-08 8x thermocouples
$1015!!
Remote control & data acquisition
RS232 to RS422/485 Make PCs
self-pwrd converters BITlink ®
• Plug directly into PC
2 talk I C power & data
on two-wire
— self powered!
• Drive any RS422 easily! control network
or RS485 devices.
• Send control and data Industry-standard card for PC’s NEW! Euroquartz filters/crystals!
100s of feet! ISA/P-port/PCI versions
K422/K485, 25pin > 9pin . . . $69 2-6V I2C bus versions 2-year self-contained
DATALOGGERS for volts, switch-
K2 9pin > 9pin . . . . . . . . . . $69 • Master, Slave or Bus monitor
closures, events, flow, pressure, etc.
Isolate RS232/422/485 signals • Control or program I2C devices See www.abidata.be for details
K4xx-ISOL 25pin ICA90/93LV - PICA90/93LV PCI90/93LV
self-powered . . . . . . . . $139 I2 C”
! PCI/ISA/PCMCIA/PC104/ by J
WILKE TIGER MODULES
a
W
Sn g VME/cPCI format boards. fo nz
PCMCIA
O com r all
multitasking powerful BASIC building blocks
N Pi Software drivers for most OS’s. pute
Go g g rs
Datalogger TDS2020
L CAN/Ethernet bridges, etc.
BASIC Tigers are
tiny multitasking
computer systems lowpower PCcard logging SMD PCB adapters
for quick project
• Store analog/digital for prototyping
development.
Powerful features and low /GPS or CANbus data
prices make Tigers a number
one choice for developers: super-fast
on FlashATA cards -
read on your own PC! USB ic’s
development cycle, high reliability products, • > 100 customizable USB <> RS232 easily!!
>100,000 instructions/s, up to 38 I/O lines, software modules— US232: USB <> RS232 cable $35
A/D, D/A, I2C, SPI, , text/graphic LCD inter- finish REALLY quickly.
face, up to 50,000 lines of BASIC, RTC/watch-
• 8ch 10bit A/D, 33 I/Os, I2C, 2 x Saelig Company brings you unique,
dog timer. Easy connection and software for
RS232, interrupts, sleepmode, easy-to-use control and instrumentation
Expansion Modules for CANbus, TCP/IP for
net-access, opto-I/O, 64 analog inputs, 64 dig-
pre-emptive multitasking, easy to products to USA, mostly from Europe,
ital outputs, high-current outputs, etc. attach LCD or keypad. but now from worldwide. (Need USA
sales help - overseas companies?)
• CANbus adapter—recompile or log
TIGER Starter Kits start from $159! data over huge network! Our customers comment
on our unrivalled FREE
Customer list inc: Intel, after-sales support.
20 Short Solutions
Build a Graphics LCD Bias Supply
AVR MCU-Based AC Phase Controller
144
Brian Millier
52
RoCK Specifications
Part 4: Tying Up Loose Ends
Joseph Jones & Ben Wirz
6 Task Manager
30 I ROBOTICS CORNER Jennifer Huber
Reliable Information
Extreme OSMC
Part 2: The Modular OSMC Brain
Sonny LIoyd
8 New Product News
edited by John Gorsky
46 I APPLIED PCs
Building a Modular Programming Platform
Part 1: The Program Module 11 Test Your EQ
Fred Eady
94 Advertiser’s Index
70 I FROM THE BENCH
SmartMedia File Storage
August Preview
programmed task. 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
[email protected] of Circuit Cellar Inc. Reproduction of this publication in whole or in part without written consent from Circuit Cellar Inc. is prohibited.
Vishay Silconix
(408) 988-8000
www.vishay.com
on #8926
Option #1530 8-bit PWM Inverting
g Amplifier
p
Option #625 Low Pass Filter 24-bit Timer
Option #4237 16-bit CRC Notch Filter
Analog 12-bit AC
A
Use the Cypress PSoC™ instead of an MCU for Comparator Incremental A/D 8-bit DAC
on
o
more flexibility, fewer parts and lower cost. Band Pass Filter
12-bit
Incremental A/D
IrDA
The versatile PSoC Programmable System-on-Chip ™ ™
Transmitter Band Pass Filter 8-bit Counter tor
il
microcontroller, winner of EDN magazine’s Innovation
of the Year Award in the 8- and 16-bit microcontroller CPU Programmable
Instrumentation
Amplifier
nnter
category, is the world’s first MCU that lets you custom
Instrumentation
Amplifier CPU Gain Amplifier lle
ffier
Analog
g
configure the exact part you need. 8-bit DAC Comparator
11-bit Analog
Delta Sigma A/D Comparator 16-bit PWM
Graphically select, place, and interconnect
the peripherals you want and adapt the
architecture with PSoC Designer™ software. There are many more blocks to work with—
and thousands of MCU configurations. To learn more
Dynamically reconfigure a single PSoC
chip multiple times—changing functionality about our innovative PSoC solutions and to enter a
on the fly in any application. drawing to win a free PSoC Development Kit
(a $1495 value), visit: www.cypress.com/ad/mcu.
Reduce BOM cost by reducing the number
of external components.
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.
Test Your EQ
Problem 1—The circuit shown below is Problem 5—A full adder is a circuit with three
an adjustable output voltage regulator. inputs and two outputs, and the output is a 2-bit
CIRCUIT CELLAR
Assume that the basic op-amp is ideal. binary number that gives the number of ones on
Find the regulated output voltage VO. the inputs. Can you come up with a circuit using
only full adders that can count the number of ones
+V on 15 inputs?
R2 Contributed by Dave Tweed
–
R1 + VO Problem 6—Now suppose you want to know if
VZ there are more than N ones on the inputs, where
N is presented as a 4-bit binary number. Can you
add this functionality using just full adders (with
Contributed by Naveen PN perhaps some inverters)?
Contributed by Dave Tweed
Problem 2—A dynamic RAM cell that
holds 5 V has to be refreshed every 20 ms
so that the stored voltage does not fall by Problem 7—For the circuit shown below,
more than 0.5 V. If the cell has a constant VCC = 15 V, hFE(min) = 30, and ib = 100 µA.
discharge current of 0.1 pA, what is the Find the minimum value of RL that will ensure
storage capacitance of the cell? saturation operation.
Contributed by Naveen PN
VCC = 15 V
RL
Problem 3—Prove that the basic resis- RB
tor-transistor logic (RTL) gate shown
below is a NOR gate. ib
VCC
Contributed by Dave Tweed
RC
VO
V1 Problem 8—What is “comfort noise”?
Q1 Q2
V2
Contributed by Dave Tweed
Contributed by Naveen PN
CONTEST ENTRY
ARTICLE Obviously, a microcomputer is
needed to drive the display. I wrote
the software so that the user interface
is through a series of RAM locations.
Aubrey Kagan This allows display access to an exter-
nal hardware interface such as a serial
or parallel driver (based on the micro-
t
In addition, the PSoC is available in
DIP packages, which is great for low-
he NKK volume applications and debugging.
Smartswitch is a And that’s a plus for aging baby
single-pole, normally boomers who have difficulty seeing the
Sure, the NKK open switch with an pins on SMD devices, let alone con-
LCD screen that serves as its activa- necting an oscilloscope probe to one.
Smartswitch looks like tor. I have often looked at the adver-
tisement for the Smartswitch and THE LCD
a cool device, but thought about how cool it would be to The LCD is controlled row by row
use it. But where and how can the with a 40-bit shift register. The first
how can you actually Smartswitch be used? In this series of four bits shifted out are invisible, but
use it? Aubrey found articles, I’ll explain my answer to
those questions.
they must be included in the shifting
process. Each pixel has been allocated
the answer with a little The switch head of the Smartswitch a number so that the software imple-
consists of a 24 × 36 pixel LCD and mentation can address a specific loca-
help from a Cypress some rudimentary driver electronics tion. You can see this allocation in
that drive one row at a time. Control Table 1. The firmware display driver
Microsystems PSoC signals are required to shift out the creates a memory map where each
pixel state for each row, latch the pixel maps to a unique bit in RAM. As
microcomputer. In this pixel states, and synchronize the first you’ll see, the map is continuously
article, Aubrey line. In addition, the display has a
backlight that can be configured as
output to the display by the drivers.
In order to economize on RAM, the
describes the inter- red, green, or yellow. I have tried to memory map is implemented as a 24 ×
make the display interface pixel 5 unsigned character array (cMatrix
face to drive the
Smartswitch. Visible pixels Invisible pixels
Row 0 39 38 37 … 7 6 5 4 3 2 1 0
Row 1 79 78 77 … 47 46 45 44 43 52 41 40
Row 2 119 118 117 … 87 86 85 84 83 82 81 80
… … … … … … … … … … … … …
Row 22 919 918 917 … 887 886 885 884 883 882 881 880
Row 23 959 958 957 … 927 926 925 924 923 922 921 920
Table 1—The numbering of the pixels is arbitrary. Pixels 0, 40, 80, etc. are the first bits shifted out for each row.
Figure 2a—This is a row update. Although difficult to count here, there are 40 SCP pulses in five bursts between
each LP signal. Note the 1-ms update time. b—The FLM extends from before the first data bit to the trailing edge
of the LP signal. FLM becomes active before the first SCP transition for the row. You’ll see later that the LP will
trigger an interrupt that flags the background program. The FLM is set in the background program. The indicated
time is the time for the processor to get to the point in the program where the bit is set. Care must be taken to see
that the last of the 40 bits is shifted in before the next LP signal.
Listing 3—The terminal count on the timer module will generate an interrupt and output pulse every mil-
lisecond. A flag is sent in the interrupt routine to indicate to the background routine that the pulse has been
generated so that the next line can be shifted out. Note the software loop that delays the reset of the FLM
line. This happens every interrupt whether or not the FLM is set.
Timer8_1INT:
//place user code here
//set cStatus bit to indicate interrupt has happened
push a
mov a,01h
or [_cStatus],a
//if requested, drop FLM
tst [_cStatus],02h
jz skip1
//delay so FLM goes to negative after LP
mov a,48
skip2:
dec a
jnz skip2
and [_cStatus],0fdh
//clear the bit
and reg[PRT0DR],0feh
//clear the FLM
skip1:
pop a
reti
Syntax
A complete set of easy to use commands ! Serin, Serout,
Learn to Program PIC Microcontrollers in easy to use BASIC
If..Then..Elseif..Else..Endif, Do..While, While..Wend, OWin, OWout,
ADin, Pulsin, Pulsout, PWM, Xin, Xout and more! Plus easy acces to
all PICmicro built-in hardware peripherals.
3,&0,&52722/6
®
Optional ISP-PRO
Items Available
- Plastic Enclosure
- 40 Pin Zif Adapter
- Universal Adapter
7RRUGHUYLVLWwww.basicmicro.com
RUFDOO
0)$0WR30(67
M i c r o c o n t r o l l e r s M a d e E a s y™
MBASIC is a registered trademark of Basic Micro Inc.
PICmicro is a registered trademark of Microchip Inc.
are two internal prescalers available signal from an 8-bit timer that would
PSoC NKK for clocking functions, 24V1 and interrupt every millisecond. I took
P0_6 27 9 SCP 24V2. The former is the internal 24- the terminal count (TC) output
26 10 DIN
P0_4 MHz oscillator divided by a number directly to an output pin to be used as
P0_2 25 8 LP
P0_0 24 7 FLM from one to 16. The latter will further the LP signal. The width of the TC
divide 24V1 by a number from one to signal is the same as the high period
16. I set 24V1 to 16 and 24V2 to 15 in of the input clock.
Figure 3—The wire interface is simple. Note that the order to generate a clock signal of To drive the data and SCP lines, I
pin numbers for the PSoC are for the 28-pin DIP. 100 KHz with a counter resolution of used an SPI master (SPIM) without the
10 µs. All of these settings are set up receiver function. As expected, it’s pos-
Currently, PSoC Designer does in a graphical user environment, part sible to configure the edge and polarity
nothing to enhance this. It allows for of which is visible in Photo 1. PSoC of the clock signal relative to the data
one configuration and then it’s up to Designer then translates the settings being shifted out. So, I thought I would
you to create alternatives to overlay into code in a process that is transpar- relieve the processor overhead by
these functions. Cypress has decided ent to the user. allowing the hardware to shift eight
that this feature is a competitive I didn’t need many modules for the bits at a time. This called for proces-
advantage, so they have a new version implementation of the hardware sor intervention after every byte
of their PSoC Designer in the wings interface, so I decided to drive the LP under interrupt control. The only
that will simplify this process.
Cypress produces three kinds of
documentation. The first is the stan- Listing 4—The first byte transmitted from the SPIM module is initiated from the background program.
dard datasheet, which at first glance When the transmission is complete, an interrupt will be generated and program execution will be vectored
to this routine. This routine will fetch a further byte and transmit it until four more bytes have been sent.
is somewhat bewildering because of After these five bytes have been transmitted, the routine does not send another byte, so the interrupt will
the variety of configuration options. not occur again until the first byte of a new line is sent from the background routine.
When you select a module in the
user interface, a datasheet for the SPIM_1INT:
//place additional SPIM interrupt level processing here
module appears on the screen. In
push a
addition to samples of the code, the push x
datasheet reading includes all the call bSPIM_1_ReadStatus
relevant registers and I/O points. As ;wait for SPIM done, rather than buffer empty
your product is configured, the PSoC ;because of taking FLM low, after all the data has gone
Designer creates a third datasheet and a,(SPIM_SPI_COMPLETE)
jz SPIM_EXIT
specifically for that particular
//Have we transmitted five bytes (one from C call and four
arrangement so you have complete continuing from there)?
documentation of your product. mov a,[_cByteCount]
All of this is available in an 8- to jnz SPIM1
64-pin package for about $5. A full
development environment that //At this point, all 30 bits have been shifted out, so clear
FLM. reg[PRT0DR],0feh FLM must be high during LP, so set
includes C costs less than $300. And
the request.
you’d think they were paying me to or [_cStatus],02h
say this, but unfortunately they’re not. jmp SPIM_EXIT
g raphic LCD
panels require a
stable negative volt-
help of the ATtiny12’s internal analog
comparator. I’ve configured the analog
comparator to use an internal 1.2-V
band-gap reference as the positive
comparator input. The comparator’s
When Brian proposed age source for bias pur- negative input is connected to port B1.
poses, termed VEE. Depending on the This pin acts as a summing junction
these two straightfor- size of the display, the voltage required made up of the negative bias output
could be between –7 and –15 V, but voltage and the VCC supply, the pro-
ward, simple fixes, we the current draw is miniscule. portions of which are adjustable by
Because this bias sets the contrast of R4, the voltage adjust potentiometer.
thought it was a great the display, it must be stable but vari- For now you should ignore R3.
idea to combine them able over a small range to maintain
good display contrast at various tem-
The ATtiny12 is constantly in loop
checking the analog comparator and
as a section of quick peratures. It’s also useful if the VEE sending a 10-µs pulse (followed by a
source can be varied smoothly under 50-µs rest) whenever it senses that the
solutions. Read on for computer control. Although I’ve used bias voltage is dropping below the
chips designed specifically for this user-specified set point. This action
inexpensive ways to purpose, I thought I could build a less maintains the charge on C2 and keeps
expensive version using the smallest the output well regulated. Because of
control a high-current
resistive load and
how to build a graph-
ics LCD bias supply
with Atmel products.
Figure 1—Here’s the Graphic LCD VEE generator with an Atmel ATtiny12 microcontroller.
AC phase control is a well-estab- is essential to filter out any false trig- and results in a gate pulse being sent to
lished way of controlling high-current gering that might otherwise occur the triac, which turns it on. The triac
resistive loads such as lights and from noise/spikes on the AC line. gate drive is provided by the MOC3009
heaters. You can achieve this under The ’2313 receives a rising-edge optocoupler, which is specifically
computer control by using a simple INT0 interrupt just prior to the zero designed for triac triggering.
AT90S2313 AVR microcontroller to crossing. First, the ISR turns off the A three-pole DIP switch sets the
convert user-specified power levels triac drive by setting the port D4 pin device address for the controller to a
into properly timed trigger pulses to high. It clears Timer1 and loads value between zero and seven, allow-
fire a high-power triac device. Timer1’s Output Capture register with ing up to eight controllers to be inde-
Inexpensive 15-A triacs can easily the necessary delay time to produce pendently controlled using a single
handle power levels of 1800 W. the desired output power. Later in the RS-232 signal.
To accomplish this, the ’2313 AC cycle when Timer1’s value match- Timer1 is clocked by the 4-MHz
microcontroller must sense the power es the Output Capture register, a system clock that is prescaled by 64,
line zero crossing, which occurs at a Timer1 output capture interrupt is which results in it being incremented
120-Hz rate. Power control is achieved executed. The interrupt drops port D4 every 16 µs. Because the INTO inter-
by triggering the triac after some spe-
cific delay from this zero crossing. No
delay would result in full power, and a
delay approaching 8.33 ms (one half-
cycle of the AC line waveform) would
result in little power being delivered
to the load. The exact relationship is
described later.
Accurate triac trigger pulses can be
generated by a ’2313 AVR microcon-
troller using an Interrupt Service
Routine (ISR) prompted by the INT0
interrupt. INT0 is connected to a
MOC5009 optocoupler that’s fed by
the otherwise unused negative half of
the power supply’s bridge rectifier. In
this configuration, the MOC5009’s
output will be low for the entire AC
line cycle time apart from a short
interval surrounding the zero crossing.
The MOC5009 incorporates a Schmitt
trigger in its detection circuit, which Figure 2—This a complete circuit diagram of the AT90S2313.
% Power
60 new power level upon receipt of
— Actual
40
— Fitted subsequent power level commands.
Because the ramp time parameter is
20 defined as the time it takes to ramp
0
from 0% to 100%, proportionately
0 30 60 90 120 150 180 less time is needed for smaller
Phase angle power level changes to occur.
Figure 1—You can see the relationship between the percent- All controllers, regardless of
age of power delivered and the triac firing angle. their device number (as set by the
DIP switch), will respond to com-
rupt occurs just prior to the zero cross- mands sent to device eight. This
ing, I measured that a delay of 29 (of allows you to control numerous lamps
the 16 µs clocks) was needed to pro- simultaneously. The controller’s
duce the gate pulse at the zero crossing. firmware is written using the BAS-
Similarly, the maximum delay needed COM-AVR compiler. The data rate is
for zero power was 578 clocks. Figure 1 set to 9600 bps. If you replaced the
shows the complete circuit diagram. RS-232 level shifter with the standard
The mathematical relationship MIDI optocoupler input circuit and
between a traic’s firing angle and the changed the data rate to 32,500 bps,
percentage of power delivered (0% to you could use this controller for MIDI
100%) is shown in Figure 2. This rela- applications instead of RS-232.
tionship seemed too complex for the You may download the source and
small microcontroller to calculate on object code for this circuit from the
the fly. Therefore, the power range Circuit Cellar web site. As with near-
was broken down into three straight- ly all members of the Atmel AVR fam-
line segments and a simple linear ily, this is a flash memory device and
interpolation routine was performed. is readily programmable. For more
The routine required one multiplica- information, I provided details of a
tion and one subtraction. As you can simple programmer in my previous
see, this does not result in too great article, “My fAVRorite Family of
an error from the ideal firing angle. Micros” (Circuit Cellar 133). I
I patterned the controller’s com-
mands as a subset of the MIDI com- Brian Millier is an instrumentation
mand protocol used by electronic engineer in the Chemistry Department
musical instruments. The two con- of Dalhousie University in Halifax,
troller functions are implemented Canada. He also runs Computer
using commands corresponding to Interface Consultants. You may reach
MIDI Control Change messages. him at [email protected].
BXH 07 pp is the power level, which
corresponds to the volume level in SOFTWARE
MIDI. Here, X is the controller device
To download the code, go to
number (0–8) and pp is a 1-byte value
ftp.circuitcellar.com/pub/Circuit_
representing the percentage of power
Cellar/2002/144/.
delivered (0 to 100 V).
BXH 01 dd is the ramp time, which SOURCES
corresponds to the modulation wheel
AT90S2313 AVR, ATtiny12
in MIDI. Here, X is the controller
Atmel Corp.
device number (0–8). dd is a 1-byte
(408) 441-0311
value representing the ramp time (in
Fax: (408) 436-4200
seconds) for a 0% to 100% power
www.atmel.com
level change (0–127).
Setting the ramp time equal to zero BASCOM-AVR compiler
makes the controller switch power MCS Electronics
levels immediately upon receipt of a 31 75 6148799
power level command. Alternately, set- www.mcselec.com
Visit our website @ www.micromint.com to see our complete line of OEM Solutions.
Power Supply
face to other devices like ADCs and
DACs. The pins serve as read and
write signals for proper bus operation
like the read cycle and write cycle. So,
after interfacing the ROM, ADCs, and
DACs, you’re left with 14 I/O pins.
Port 1 is used to interface and read
e
the keypad. Some of the pins in port 3
are used for the Set Voltage and Set
very engineer, Current buttons, while others are used
technician, and to control the relay and analog switch-
hobbyist needs a sta- es to read the voltage and current to
ble power supply to be fed to the ADC.
power up the circuits they’re working U2 74HC373 is a transparent latch
on. However, it would be nice if you (see Figure 2). It’s used to obtain the
Even if you’re a could vary the potential to accommo- address because the address bus and
date many circuits. It also would be data bus are multiplexed on port 0 to
novice, it’s pretty easy pleasant if you could vary the current conserve pins coming out of the IC.
supplied to the circuit, which would The address is obtained after the
to control the power limit the power delivered in case address latch enable, or ALE, is assert-
something is wrong. The circuit fea- ed. U3 is an 8 KB × 8 UV EPROM
supplied to the cir- tured here is an 80C31-controlled (27C64) that stores the program that
cuits you’re working power supply that has voltage and
current limits that you can change to
sets the voltage and current and reads
the ADC. I chose the 27C64 EPROM
on. In this article, suit your needs (see Photo 1). Its volt- because it’s inexpensive, available, and
age ranges from 0 to 22 V, and its cur- the firmware will fit in it. You can
Noel introduces us to rent ranges from 0 to 2.5 A. actually use larger EPROMs like the
In most power supplies, you turn a 27C512, but they’re a waste of space,
a 80C31-controlled knob to adjust the voltage and current. money, and time because you’ll have
The 80C31 CPS, however, has a keypad to wire the added address pins. The
power supply, which for entering the voltage and current, 4K × 8 EPROM can also be used but
is a circuit that as well as Set Voltage and Set Current
buttons so you can change the voltage
it’s hard to obtain.
CIRCUIT DESCRIPTION
The brain of the circuit is the popu-
lar 80C31 microcontroller, which is Photo 1—Take a look at the front panel of the 80C31-
the version of the 80C51 without controlled power supply.
Instruction
16
analog converters. They convert a dig-
register
ALE*PROG Timing
DPTRs
*EAVPP and
ital value to an equivalent analog cur- RST Control
multiple
Figure 2—In the digital portion of the power supply, U2 74HC373 is a transparent latch used to obtain the address.
Figure 3—When looking at the analog portion of the power supply, you notice that the rectifier diodes convert alternating current to pulsating DC.
BUILD IT YOURSELF
What else can I say? Everyone on the
OSMC design team is pleased with the
outcome of the project. The approxi-
mate cost of the entire electronic
speed controller was kept within rea-
son. The OSMC board’s components
cost about $100, and the MOB can be
assembled for approximately $35.
That’s a great deal given the OSMC
project’s capabilities and reliability.
I hope you enjoy building this elec-
tronic speed controller as much as I
did, and that you’ll join us in dis-
cussing related topics (or not) on the
official web site’s message board. I
SOFTWARE
To download the code, go to
ftp.circuitcellar.com/pub/Circuit_
Cellar/2002/144/.
REFERENCES
[1] Atmel Corp., “8-bit AVR
Microcontroller with 16K Bytes
In-System Programmable Flash—
Atmega163, Atmega163L,” rev.
1142c, September 2001.
RESOURCES
µMOB Circuit board, starter kits
Larry Barello
e-mail: [email protected]
b
industries have to worry about the
possibility of lighting strikes. But
ack in May, I even the humblest consumer appli-
described the chal- ances can be exposed to unexpected
lenges high intensity transients. Therefore, many consumer
Transients, such as radiated fields (HIRF) products can benefit from some level
present to your designs (“Working With of transient protection.
electrostatic dis- EMC,” Circuit Cellar 142). You learned All modern designs that use thin
that radiated fields were composed of film components and microelectronics
charge and lightning, electric (E) and magnetic (H) compo- must address ESD, which is an espe-
nents, and that their ratio, or wave cially sneaky threat because it can
can create major impedance, for predominantly electric weaken a microelectronic device or
problems for many of fields becomes a constant 377 Ω. You cause latent damage. In cases in which
should remember this number because ESD damage occurs, failures often arise
your electronic many RF engineering concepts rely on at the worst possible moment. Some
it. For example, the commonly used ICs are advertised as containing inter-
designs. However, 200-Vpm e-field immunity requirement nal ESD or transient protection, which
originated from the assumption that RF is better than nothing. But you should-
there are several power at 100 W per square meter is n’t rely on them exclusively except for
dangerous to humans: the most rudimentary designs.
ways to limit the com-
V = P × R = 100 × 377= 194.16 DAMAGE TOLERANCE
ponent damage and Two major problems can arise when
functional upset that Hence, the magical 200-Vpm e-field a system is exposed to transients.
immunity requirement for electronic First, the equipment can be badly
results from transient equipment in vehicles. damaged or destroyed completely. You
Transients such as a lightning strike can prevent this by clamping or oth-
exposure. and electrostatic discharge (ESD) pres- erwise limiting the transients. The
ent a different set of problems. You second problem the system can expe-
must remember that transient protec- rience is a functional upset, which
tion will not work without good EMI can occur even when the transient is
immunity. Therefore, transient limiters well clipped and no damage to the
are usually physically located before equipment is apparent. Because dam-
EMI filters. There are two reasons for age prevention is prerequisite, we’ll
this, and if you consider the circuit first consider ways to ensure damage
topology and cabinet construction in tolerance before tackling the problem
Figure 1, you’ll see why this is the case. of functional upset.
t
V (t ) =1.033 V0 × sin 2π × f × t × e – π × f × 24
100
Surge protectors have finite
PRACTICAL DESIGN Single braid Optimized
single
internal impedance. A 5-V
APPROACH 10
braid logic circuit needs a clamp that
Referring back to Figure 1, Double presents negligible leakage at
braid
you can see that the threat level 1 5 V, so it would have the
Triax
and maximum value of resistors braid
breakdown voltage at around
R1 and R2 will determine 5.2 V. But during the transient,
0.1
whether or not the spark gap is the voltage across the clamp
needed in the first stage. The could easily rise above 6 V.
0.01
test waveforms are defined in That wouldn’t be healthy for
Solid
terms of the generator’s open copper
the IC. The situation becomes
voltage and short circuit cur- 0.001
screen more serious when the tran-
rent. As long as R1 and R2, 102 103 104 105 106 107 108 sient arrives and the unit is
F (H )
which limit the maximum pulse Figure 4—This plot of transfer impedance shows several common cables. not powered. In the absence of
RS232/RS422/RS485 Converters
RS232 TO RS485
2 wire
• Makes your RS232 port an
RS485 port
• Supports up to 40 RS485
CMC’s low cost converters adapt any devices
RS232 port for RS422 or RS485 • Automatically determines
operation. These converters provide yourdata direction.
• Signal powered version
RS232 device with all the advantages of available
RS422 or RS485 including reliable high
speed operation (up to 200 kbaud) andADA485 (requires 9VDC) $79.00
ADA485-1 for 110VAC
data transmission distances up to 5000 89.00
ADA485L signal powered 84.00
feet. Two AD422s can be used to extend
any RS232 link up to 5000 feet.
Completely transparent to the system; RS232 TO RS485
no software changes of any type are 4 wire
necessary. • Converts an RS232 port for
use with RS422 or RS485
RS232 TO RS422 devices
• Converts bi-directionally • Supports up to 40 RS485 or
between RS232 and RS422 RS422 multidrop devices
• Use as a short haul modem • Adds multidrop capability to
• Plug in and go. No software RS232 devices
changes required • Automatically determines
data direction.
AD422 (Requires 9VDC) $79.00
AD422-1 for 110VAC 89.00 ADA425 (requires 9VDC) $89.00
AD422L signal powered 84.00 ADA425-1 for 110VAC 99.00
WWW.2CMC.COM Fax:(203)775-4595
www.circuitcellar.com CIRCUIT CELLAR® Issue 144 July 2002 37
bance could be filtered out so that the problem. The simplest solution arises If you are not allowed to reset, then
system couldn’t even hiccup. when the system is allowed to shut the common approach is to hold the
Unfortunately, this is not always down and reset as soon as it detects last valid input for a predetermined
the case. When the surge protectors an invalid input. period of time. Two seconds is general-
begin to clamp, the signal that’s super- How can you detect an invalid ly considered the right amount of time
imposed on the transient also starts to input? It’s the voltage resulting from for the effects of a lightning strike to
clamp. On the differential lines, the the clamping action of the surge pro- settle down. If by then the input has
transient may look like a bona fide tector, which the normal signal is not not gone back to the valid range,
signal (i.e., a trigger pulse), but on allowed to reach. For example, a dis- there’s probably a failure. In this case,
common mode lines both lines may crete input could be 0 to 3 V as another action, such as switching to a
swing to the point where signals are logic 0 (you always want a nice noise backup channel, must be taken.
obliterated. A DC offset could also margin to avoid ground noise prob- If reset or hold isn’t permitted, then
appear on differential and/or common lems), or 3 to 5 V as logic 1. A clamp- you’ll need to use symmetrical inter-
mode lines because of the rectifying ing action would result in a voltage at faces to ensure only common mode
action of the surge protector followed least one diode drop above 5 V or swings of the signal lines. After that,
by low-pass filters. Either way it’s a below zero. increase the common mode range of
The current limiting resistance (R1 in Figure 1) is 20 Ω and K = 1.4 for the approximation of the falling part of the wave-
the transzorb clamps is at 5.2 V, assuming the voltage is form in Figure 2:
constant and the internal resistance is negligible.
t
Therefore, the peak current the transzorb will be exposed I pk × e 1.44× τ
to is:
Here, τ is the duration for Ipk to drop to 50%. K = 0.86 for
I P = 750 – 5.2 = 29.79 A the approximation of the damped sinusoid in Figure 3:
5 + 20
t
Now we need to find a device rated for 30 A and at least I pk × sin π × t × e – τ
7 A per 70-µs pulse.
Sometimes surge protectors are specified by the energy where τ is the duration for Ipk to drop to 50%.
they dissipate in joules (J). Looking at the waveform in As an example, let’s take the pulse waveform in Figure 2
Figure 2, the energy is equivalent to the area surrounded and split it into two parts (see Figure S1). The first section is
by the curve and can be calculated as from zero until Ipk reaches its maximum of 29.79 A, which
t
is the peak current calculated above. The time τ = 6.4 µs
E = VC (t) × I (t ) dt = K × VC × I × τ and K = 0.5. For the decaying section, τ = 70 – 6.4 µs. The
0
clamping voltage is 5.2 V.
Here, Vc is the clamp voltage, I is the peak current, τ is This amount of energy (14.25 mJ) is not high and there
the pulse duration, and K is a constant. Solving the inte- are many devices in catalogs that will satisfy this require-
gral based on the accurate waveform is laborious, so in ment. Consult the manufacturers listed at the end of this
order to make your life easier, the constant K has been article in the Resources section. Their data sheets and
published for differ- application notes
ent shapes. It may Section 1: E = 0.5 × Vc × I × τ = 0.5 × 5.2 × 29.7 × 6.4 × 10–6 = 494 × 10–6 J available at their
vary slightly with Section 2: E = 1.4 × Vc × I × τ = 1.4 × 5.2 × 29.7 × (70 – 6.4) × 10–6 = 13.75 × 10–3 web sites contain
respect to time con- Total = 14.25 × 10–3 J a wealth of infor-
stants, but it’s mation.
Figure S1—If you split the pulse waveforms shown in Figure 2, you get these two equations.
Shown Here: BS2 Carrier Board, Motor Mind C, 2 Easy Roller Wheel Kits
Figure 2—Using this schematic, you can interface the Epson S1D13708 to the Microchip PIC17C452. Here is the Epson L2D25001 ND-TFD panel. It’s a pure 3.3-V device.
A MODULAR APPROACH
My original idea was to construct a
a
requirements are identical to the
PIC18Fxxx devices and the physical
t this moment, I programming pins are also the same.
feel like Mick The differences are with the program-
Jagger. I can’t get no ming algorithm and the size and
Fred is dreaming of satisfaction. I’m looking pinout of the programming socket.
forward to using the new PIC18Fxxx The easy thing to do would be to
producing an inexpen- parts because they can run faster and build up this modular PIC18Fxxx pro-
have quite a bit more RAM and grammer and throw in some code and
sive PIC18Fxxx pro- ROM than the currently available sockets to use a PIC16F628 instead.
PIC16Fxxx devices. The problem is For those of you who like to experi-
grammer that will ulti- that I can’t get my hands on any of ment, the modular programmer plat-
mately allow him to the new parts. I can’t even get sam-
ples from the Microchip FAE.
form can be broken down into small-
er subassemblies that you can
use the new PIC parts However, I’m not going to let the remove and replace with a better or
absence of a part keep me from press- experimental circuit by simply pin-
in future PIC Internet/ ing on with this project. Even though ning out the separate submodules to
the main piece of programmable larger subassemblies.
Ethernet projects. hardware is missing, I still have the I won’t get too modular in this
PIC18Fxxx datasheet and program- series, considering that being too
With the datasheet ming specifications to work from. modular adds complexity and cost.
and programming My goal is to produce an inexpen-
sive PIC18Fxxx programmer that
Instead, I’ll stick to a two-module pro-
grammer platform. One module, the
specs in hand, he will ultimately allow me to use the power module, will house all of the
PIC18Fxxx parts in future PIC power components. The other mod-
takes us through the Internet/Ethernet projects. And, ule, the program module, will contain
because the new PIC18F4xx series is the microcontroller, program memory
first part of his project. pin-compatible with the PIC16F87x storage, communications interface,
devices, I can also expand the and any other programming algo-
PIC18Fxxx programmer’s capabili- rithm/target microcontroller-related
ties by simply sticking in a hardware. A standard board-to-board
PIC18Fxxx part with more code and or module-to-module pinout will be
RAM space to replace the PIC16F8xx enforced so that power and program
instruction that will be stored in the to reduce parts count. I’ll also show
PIC’s ROM at address 0x00000 will you how to use the PWM module of
SOFTWARE
reside in the SRAM at address the PIC16F877 to generate the high- For the pin assignments and con-
0x00000 (low byte) and 0x10000 voltage programming power supply. trol logic, go to ftp.circuitcellar.
(high byte), which, when ignoring I’m a little nervous about the com/pub/Circuit_Cellar/2002/144/.
A16, logically equates to SRAM PIC18Fxxx datasheet, because I haven’t
address 0x00000. had the opportunity to handle the SOURCES
Normally, I would store 0x83 at device and work out the potential
PIC C compiler
SRAM location 0x00000 and then gotchas. So, assuming the PIC18Fxxx
CCS, Inc.
store 0x3C at SRAM location parts will be available before I talk to
(262) 797-0455
0x00001. Then, I would have to keep you again, I hope to have some real
E-mail: [email protected]
my mindset focused on converting experience with the PIC18Fxxx parts
the SRAM addressing model to the to pass on to you. Whether or not the PIC18Fxxx, PIC16Fxxx
PIC addressing model. Partitioning parts appear, I’ll still perform experi- Microchip Technology Inc.
the SRAM eliminates the brainteaser ments based on the data in the PIC- (480) 786-7200
and saves cycles as well. 18Fxxx datasheet and knock out some Fax: (480) 899-9210
C code to bring the MPP to life. I www.microchip.com
MPP PREVIEW uPD71055L-10 PIU
That pretty much completes the
NEC Corp.
description of the program module Fred Eady has more than 20 years of
(800) 338-9549
hardware. I’ve included a schematic experience as a systems engineer. He
011-813-3454-1111
for those of you that want to build has worked with computers and com-
www.nec.com
your program module and get ready munication systems large and small,
for Part 2 of this series (see Figure 4). simple and complex. His forte is SP233ACP
Next time, I’ll describe the power embedded-systems design and com- Sipex Corp.
module. The plan is to use switching munications. Fred may be reached at (978) 677-8700
power supply technology in an effort [email protected]. www.sipex.com
t
as the back electromotive force (EMF).
Back EMF voltage is directly propor-
his is the final tional to the motor’s speed and is
installment in our given by the formula:
series on the Robot
In Parts 1, 2, and 3, Conversion Kit (RoCK).
In the past three issues, you’ve learned
Joseph and Ben dis- how we arrived at the RoCK’s specifi- As the motor turns faster, V increases.
cations, how and why we designed the The motor reaches equilibrium and its
cussed the RoCK’s circuitry, and the scheme we used to speed becomes constant when the
program it. This month, we’ll tie up applied voltage is equal to the back
specifications, circuit- the loose ends by describing the EMF voltage minus resistive losses.
ry, and programming. RoCK’s discrete motor driver, explain-
ing the low-level RoCK/host interface,
The motor current (I) is proportion-
al to the total torque produced by
In this final part, and walking you through the creation the motor:
of a new user-programmed task.
they’ll describe its dis-
WHAT IS A MOTOR?
crete motor driver, Before designing a motor driver, When the motor reaches equilibrium
you have to develop an electrical the current is constant, so the follow-
explain the RoCK/ model of the motor you wish to con- ing term goes to zero:
host interface, and trol. So, what’s a motor? A motor is a
device that converts electrical energy
show you how to cre- into mechanical energy. There are
dozens of different types of motors, If you consider only the equilibrium
ate a new user-pro- but the broadest classification divides condition, you can set this term to
them into direct current (DC) and zero. Then, by substituting for V and
grammed task. alternating current (AC). Most robots I, you arrive at the following equation:
Table 1—In our analysis of a PMDC motor we refer to these ten symbols.
ing problems for discrete H-Bridges. Satisfied customers - the key to our success
Shoot through is a transient condition > that´s why every new EAGLE version is based
that occurs when the high and low on the feedback from our customers
sides of the H-Bridge are unintention- > that´s why all our customers have access to our
ally turned on simultaneously. For highly acclaimed, comprehensive support, free
example, suppose the motor in of charge
Figure 2 is going forward (SW1 and > that´s why EAGLE has no hidden costs for
libraries or modules which prove to be
EAGLE 4.0
SW4 are on) and the direction is sud- indispensable after purchasing Schematic Capture • Board Layout
Autorouter
denly reversed (SW1 and SW4 turn off > that´s why we really want customers to enjoy
for Windows
®
while SW2 and SW3 switch on). If, at working with EAGLE
the time of reversal, SW3 turns on > that´s why EAGLE is one of the top-rated and
faster than SW4 turns off, then there programs for schematic capture and board
layout Windows is a registered trademark of Microsoft Corporation
is a momentary short from the power Linux is a registered trademark of Linus Torvalds
when the power is off. format with up to 4 signal layers The Professional Version Layout +
has no such limitations. Schematic + 49$ 597$ 1197$
Autorouter
HOST INTERFACE http://www.CadSoftUSA.com
Pay the difference for Upgrades
We turn now to the RoCK/host 800-858-8355
computer interface. Ultimately, you’ll CadSoft Computer, Inc., 801 S. Federal Highway, Delray Beach, FL 33483
benefit from a host computer-based Hotline (561) 274-8355, Fax (561) 274-8218, E-Mail : [email protected]
software module that will monitor the
ICON H-Bridge
DC Motor Interface Module
Up to 40VDC Motors
12A Continuous/25A Peak
Over Current Fuse
Over Temperature Fuse
Serial or Direct Drive Mode
2.5 X 1.9 Footprint
Solutions 3
SOLUTIONS CUBED (530) 891-8045 PHONE WWW.SOLUTIONS-CUBED.COM
www.circuitcellar.com CIRCUIT CELLAR® Issue 144 July 2002 57
All of the other values we want to site, www.wirz.com/rock/, for avail-
RESOURCE
store can be saved in the same fash- ability and additional information.
ion. And when they’re finally writ- Pitman, “Pittman Servo Motor
ten, we’ll have created the new Joseph L. Jones grew up in a small Application Notes,”
BumpEm task. We can have the town in the Missouri Ozarks. He stud- www.pittmannet.com.
RoCK run this task by pressing the ied physics at MIT and received a BS
user button and twisting the user in 1975 and an MS in 1978. He took a SOURCE
potentiometer just as we would do for trip around the world, worked at the
FMMT489TA, FMMT589TA
any of the built-in tasks. MIT Artificial Intelligence Lab, and is
Zetex Semiconductors
now senior roboticist at iRobot Corp.
44 161 622 4444
SERIES SUMMARY You may reach him at [email protected].
www.zetex.com
We hope you’ve found our series to
Ben Wirz also grew up in a small
be instructive and that you’re now
town in the Missouri Ozarks. He
eager to build a robot. There are many
studied physics and electrical engi-
resources for learning more about
neering at Washington University in
robots. Searching the ’Net will return
St. Louis, and graduated in 1997. He
hundreds or even thousands of hits.
is currently employed as a senior
You may find a robot users group or a WINNING PROJECTS
electrical engineer by iRobot in addi- MPSLIC: A single-chip FPSLIC MP3
robot club in your area. Joseph’s book,
tion to running his company, Wirz decoder and player
Mobile Robots: Inspiration to
Electronics. You may reach him at Blueport: A card-sized module intended
Implementation, is designed to help to be used as a smart SPI peripheral to
[email protected].
you get started in robotics. And final- provide seamless communication over
ly, please check for new develop- Bluetooth
ments and more information about
REFERENCE Versatile Communications Card for
the RoCK on our web site. I [1] J. Jones, A. Flynn, and B. Seiger, Linux
Mobile Robots: Inspiration to For project descriptions and abstracts, visit
Authors’ Note: We plan to offer the Implementation, 2nd ed., A.K. www.circuitcellar.com/dl2001/index.htm
RoCK for sale. Please check our web Peters, Ltd., Natick, MA, 1999.
DEAD-TIME DISTORTION
Distortion To drive a three-phase electric
motor, a six-transistor inverter circuit
is commonly used. Most voltage-
sourced inverters require a dead time
t
to be inserted between the turning off
of one transistor in a half-bridge, and
he precise con- the turning on of its complementary
trol of electric device. Otherwise, both transistors in
motors is becoming a half-bridge may be on at the same
Dead-time distortion more popular and afford- time, which would destroy the circuit
able because of specific enhance- by shorting together VDD and ground.
can be problematic ments in general-purpose 8-bit By inserting this dead time, a dis-
microcontrollers. In this article, tortion is introduced in the output
when you’re trying to we’ll discuss the type of hardware voltage and current waveforms when
feature that has been added to a low- the inverter is driving an inductive
design a motor con- cost microcontroller to improve its load (such as a motor). This distor-
troller. But that does- motor control capability.
A major problem facing designers
tion, however, can be satisfactorily
corrected in most situations. By
n’t mean you have to of motor controllers is the source of using a Hall Effect current sensor or
distortion that’s common to power other current sensing device, correc-
settle for noisy, rough- stages using totem-pole transistor tion waveforms can be generated that
configurations driving inductive are synchronous to the motor phase
running motors. Ross loads. On AC induction motors run- currents and applied to the PWM sig-
ning open loop, the problem typical- nals. There is also a sensorless tech-
and David explain ly manifests itself as poor low-speed nique that accomplishes this with-
there are inexpensive performance (e.g., torque ripple and
rough operation).
enhanced microcon- The MC68HC908MR32 microcon-
CPU
32-KB
Flash memory
768-byte
troller solves the problem by sensing EEPROM
RAM
trollers that can cor- the motor phase voltages during the
dead-time intervals and modifying
rect distortion. the modulation waveform to cancel LVI Timer
A
Timer
B
SCI
with it. At low frequencies, this PWM signals. For that par- PWM Frequency = 7.3 KHz
effect combines with the stator resis- ticular example, a 50% duty
Output : w = 1.7 Hz
tor losses to further reduce the cycle was desired. With the
motor torque. Over-modulation in insertion of dead time, the
the form of a voltage boost can be top and bottom PWM sig-
used to mitigate this problem. nals had their on times
However, the torque pulsations from reduced by an equal amount
the distortion are still present. to something less than 50%.
The previous analysis is based on The MC68HC908MR32
the supposition that the distortion always uses a single PWM
waveform is perfectly rectangular. register to derive the top and
There can be variances from this bottom signals for each tran-
premise that have an effect on the cor- sistor in a half-bridge, and it
rection technique and make it even automatically inserts a pro-
more complex to correct for. grammable dead time into Figure 6—Here’s a partially corrected current waveform.
intervals. These assumptions are true top PWM and the dead-time PWM1
TCP/IP Solutions
NEW
Products
*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.
JK microsystems connects you with embedded control solutions. Our cost-effective DOS based
controllers are ideal for data acquisition, networking or industrial technology applications.
Starting Down the Pipeline are, the more chainsaws you have to
juggle and the bigger the mess if
something slips up.
Just for fun, we’ll look at Intel’s
Itanium pipeline and the Opteron
from AMD. Both of these are high-
Part 2: The Long and Short of It end, “super-pipelined” processors that
are about as complex as you can get
while still keeping your sanity.
As you can see in Figure 1,
Itanium’s pipeline is 10 stages long.
Even though the Itanium is an insane-
ly complex chip with 25 million tran-
t
sistors, it still has an in-order pipeline.
Athlon and other processors are out-
here’s no deny- of-order machines that rearrange
ing that micro- instructions on the fly.
processor pipelines Itanium is so fast (800 MHz at first,
are getting longer and with faster chips sure to follow) that
Long pipelines are chips are getting faster. But honestly, fetching instructions requires three
needed to reach high- what good is a long pipeline? Does it
necessarily mean better performance,
pipeline stages (the five-stage proces-
sor did it in one). Itanium’s Stage 1
er clock frequencies. cooler engineering, and bragging rights calculates the memory address of the
at the next nerd party? next instruction it needs to fetch.
However, longer The high-end chips from Intel and Stage 2 accesses Itanium’s on-chip
Advanced Micro Devices (not to instruction cache (one of three), and
pipelines aren’t nec- mention SPARC, PowerPC, and Stage 3 puts the new instruction into
Alpha (R.I.P.)) have pipelines that are a buffer. At this point, there’s a break
essarily better in the 10 stages or longer, and most are in the pipeline while Itanium gathers
complicated world of two-way superscalar and aggressive-
ly out of order. Some of these
instructions into its small 24-instruc-
tion buffer.
microprocessors. For aspects are actually purposeful fea- After a brief stop in the buffer,
tures (i.e., they’re beneficial in some instructions move on to Stage 4 where
insight into the issue, way), but others are hacks aimed at they are decoded and the chip decides
overcoming inherent limitations in what type of execution unit (e.g., inte-
read Jim’s explana- the chip’s design. ger, floating point) it will use. Stage 5
performs register renaming, an
tion of the pros and PUT THAT IN YOUR PIPE AND advanced technique that resolves the
cons of processors SMOKE IT
Somewhere along the line, a bright
difference between Itanium’s real reg-
isters and the registers the instruction
with long pipelines. spark in the marketing department thinks it’s using. Note that Itanium
decided to coin the phrase “super- has so many registers, 256 in all, that
pipelining.” Not to be outdone, one it takes two full pipe stages (6 and 7)
of his colleagues came up with just to find and transfer operands from
“hyper-pipelining.” But these terms them. Then, in Stage 8, Itanium actu-
don’t mean a thing. Pipelines are ally executes the instruction, which
pipelines, and no matter how long or takes only one cycle. Stage 9 warms
General
instruction
registers
registers
registers
Instruction
instruction
Execute
the instruction into a register or to
Write back
Data cache
Remap
Access
Access
PC
cache
Queue
Issue
memory (data cache, really). Whew!
ORDER OF EXECUTION
Itanium is pretty straightforward Figure 1—Intel’s Itanium pipeline is in order and 10 stages long.
compared to some of the more exotic
pipelines, but it still carries out some tion is about to change the register in instructions to get the best perform-
out-of-order execution. Out-of-order some way. Other instructions are not ance out of 20-year-old code.
execution is just what it sounds like: allowed to read from that register The Opteron’s 12-stage pipeline is
executing instructions in a different until its scoreboard bit is cleared. longer than Itanium’s because x86
order from the way they appear in the This simple expedient prevents instructions are more complicated and
program. Out-of-order execution dis- instructions from stepping on each harder to decode than Itanium’s com-
obeys the programmer’s (or the com- other’s results. paratively organized VLIW instruc-
piler’s) sequence of instructions and tions (see Figure 2). If you’re a pro-
reorganizes them to make better use CISC PIPE COMPLICATIONS grammer who has written x86 assem-
of the chip’s hardware resources. Itanium is conservative by modern bler code, you know it’s not too diffi-
Certain high-end processors will standards when it comes to out-of- cult. But if you’ve ever had to disas-
dispatch (begin processing) instruc- order execution. On the other hand, semble x86 code, you know how
tions out of order, while others will AMD’s upcoming Opteron is much hideously complex that instruction
only retire (finish processing) instruc- more aggressive about executing set can be. Imagine the Opteron doing
tions out of order. Some processors instructions out of order. The two that disassembly in 1 ns (1 GHz).
will do both. Itanium falls into the processors should have roughly equiv- The Opteron fetches three instruc-
middle category, launching instruc- alent performance, but they get there tions at the same time, and almost
tions exactly the way they appear in in different ways. immediately converts them into its
the code but not necessarily finishing The Opteron is an out-of-order own internal RISC notation. So, for
them that way. processor because it has to be. It exe- the first few pipeline stages, the
For example, if the program calls for cutes x86 instructions that are com- Opteron is a CISC processor; after
one long, complicated instruction fol- patible with Athlon, Pentium, and that, it’s purely a RISC machine. The
lowed by two short, easy instructions, more than two decades of older x86 Opteron’s internal RISC instruction
then Itanium can dispatch all three processors. Itanium, in contrast, exe- set is proprietary to AMD and isn’t
simultaneously, assuming that the cutes new IA-64 instructions that documented anywhere.
integer and floating point execution explicitly define program parallelism The Opteron, like the Itanium, has
units aren’t busy. But there’s no point in such a way that the processor does- nine internal execution units for float-
holding up the two simple operations n’t have to figure out anything. The ing-point instructions, integer instruc-
just because the FP instruction is tak- Opteron doesn’t have this advantage, tions, branch instructions, etc. It tries
ing forever. Itanium allows them to so it shuffles and reorganizes x86 to keep as many of these nine units as
complete even though the busy as possible by aggressive-
instruction before them isn’t ly reorganizing and rearrang-
finished. This is in-order dis- ing the instructions in its
patch combined with out-of- L2 L1 Fetch queue. This means that x86
Convert
Instruction Instruction
order retirement. cache cache Decode
instructions can, and often
The exception to this rule is are, launched before other
Decode
if the three instructions are instructions that appeared
Decode
somehow dependent on one earlier in the program.
another. If the shift instruc- Integer Integer Integer FP Oftentimes, just a few parts of
buffer
tion is supposed to shift the buffer buffer buffer an x86 instruction can be dis-
results of the floating point patched for execution because
square root, it cannot finish (or a single instruction might
AGU
AGU
AGU
ALU
ADD
ALU
ALU
Miscellaneous
C:
Part 2: Directory Entries The DOS prompt is one of the most
recognizable messages known to com-
puter users. Although Windows has
almost succeeded with its plan to do
away with the DOS prompt, it still
can be found in many Start menus.
The letter in the DOS prompt is
h
usually an indication of the type of
physical apparatus connected as a
ave you ever storage device. Even though any
wondered if you’d device can have any drive letter, A
open the mythical and B have become synonymous with
Last Pandora’s box? Because
of my curious nature, I’m prone to
floppy drives, C and D with hard
drives, and E and F with CD drives.
month, act without full knowledge of what In DOS, when a carriage return
I’m getting myself into. Although I (<cr>) is entered, an active device will
Jeff feel like I can relate to some aspects respond with its drive letter. This
of Confucian thought, I try to supple- indicates that the device is installed
explained ment my curiosity with caution. I and ready for use. For this project,
start many projects without any the processor will respond to a <cr>
how to knowledge of what the outcome will with an S: designation after the
exchange embedded be. I’m not sure if I’m subconscious-
ly trying to set myself up for a fall,
application has recognized that a
SmartMedia device has been inserted
data with your PC or if I just need to constantly push into the SmartMedia socket and the
my own envelope. device has been identified. Prior to
applications. In Part 2, This project, however, has given me that time, the application responds
a new appreciation for the DOS FAT with a “No Media” message or some
he’ll cover the Smart- file format. The tiny scraps of infor- other error message.
mation available on how it works are One of the differences in the
Media module and a good indication of the black magic PIC18xxxx series microprocessors is
teach you how to nav- originally used to create it. However,
it’s worth your while to try to make
the multi-level (high/low-level) inter-
rupt structure. The high-level inter-
igate within its DOS sense out of this because it can be use- rupt has fast in and fast out capabili-
ful for other projects. Therefore, most ties, and can automatically save and
FAT file structure. of what I’ll describe here is applicable retrieve the most valuable registers.
to other devices that are based on the In addition, it can interrupt program
same general DOS FAT file system. flow (including a lower-level inter-
In my previous column, I described rupt) without requiring lengthy code,
the parts of the DOS FAT file system decreasing the interrupt latency. Two
and how they are applied to the interrupts are used for the serial
SmartMedia to obtain compatibility. interface. The command interpreter
You can refer to that overview for the routine and Character Received and
Transmitter Empty interrupts handle is determined by the state of the One of the connections on the
all the serial communications with GFORMF (good format) flag bit. So, SmartMedia interface is an output,
an external host. determining the state of this flag is which reflects the device’s working
The PIC18F452 has 1536 bytes (six where I’ll begin this month’s column. voltage. As you can see in Figure 1,
256-byte blocks) of RAM for tempo- pin 17 (Vsense) of the SmartMedia is
rary storage. Two of these blocks are INSERT MEDIA HERE connected to an input pin on the
used as TX and RX ring buffers. One of the most confusing aspects processor via a pull-up. The
Commands from a host always of building or upgrading a PC is how SmartMedia will pull the input to a
require an ending carriage return. the working voltage of processors has logic low if the module requires 5 V.
Characters received by this applica- been reduced from a system’s 5-V To handle both 3.3 and 5-V mod-
tion are placed into the RX buffer, level down to 3.3-V (and lower) core ules, this project was designed to run
while characters placed in the TX voltages. Getting those motherboard entirely on either voltage. Doing so
buffer by this application are sent out jumpers correct for the processor you allows the processor to be connected
to a host. When the command inter- were installing was a pain. directly to the SmartMedia, without
preter recognizes a <cr> in the RX SmartMedia was developed at a time the need for voltage transition buffers.
buffer, the interpreter searches the when 5-V memory was the norm. The When running on 3.3 V, the serial
buffer for a legal command. If the <cr> first SmartMedia devices were 5-V interface will drop to a ±6-V swing but
is found by itself, the <cr> command modules, now SmartMedia is 3.3 V. will still function well with most seri-
routine is evoked. Here’s where the Fortunately (or unfortunately) this al interfaces. The application requires
command prompt S:, or “no media” means that in order to be completely a regulated 5 V. The 5 V along with an
message, is placed in the TX buffer for compatible, you need to handle both on-board 3.3-V regulator is applied to
transmission to the host. The message 5- and 3.3-V devices. a Linear Technology LTC1470. Logic
t
answers to their 16-bit questions. A
case in point is the Texas Instruments
he latest Circuit MSP430 family of 16-bit MCUs. In one
Cellar reader sur- of my earlier articles (“Sweet Sixteen,”
Noting the vey is complete and,
as usual, has some
Circuit Cellar 126), I traced the roots of
the MSP430 all the way back to chips
fact that interesting nuggets of information. that served as the basis for TI’s venture
Unlike supply-side driven market into personal computers in the ’70s.
67% of research (e.g., quarterly shipments), Again, as with 8-bit parts, the popu-
the Circuit Cellar survey provides larity of yesteryear’s parts is explained
respon- useful insight into what designers in by the realities of the embedded mar-
the trenches are thinking. ketplace. Designers want the lowest
dents in a In some cases the survey results price, lowest power, simplest chip that
Circuit Cellar reader’s reinforce conventional wisdom. For
instance, when was the last time you,
can meet their goals and hold all of
the newfangled trimmings. With it’s
poll had a proclivity or for that matter, anyone you know, multiple addressing modes and memo-
designed in a 4-bit chip? It’s lonely at ry-to-memory architecture, the
for 8-bit chips, Tom’s the bottom of the processor pecking MPP430 may not be a theologically
order with only 6% of survey respon- pure RISC. But, putting the emphasis
asking you to forget dents signing on the 4-bit dotted line on the “R,” it’s a fact that in the old
(see Figure 1). A likely explanation days, all chips were reduced as a mat-
about bits for a for the weak support for 4-bit chips ter of necessity.
moment and examine is found in the overwhelming popu-
larity for 8-bit parts. A full two-
alternatives from TI, thirds (67%) of respondents signed-
100
90
80
up. Why bother messing with some 70
Cyan, and Adelante. obscure mini-me 4-bit chip when
60
50
40
67
42 35
55 58
,
GA
PU
16 PU
PU
Flas ROM
emo
DSP
MC -bit
MC bit
MC bit
/FP
U/M
U/M
U/M
M,D
hm
4-
8-
EEP
PLD
SRA
handle on the concern over flash which costs just $99 (see Photo 1). MSP430x12x2
Channel B
Stream
Down
Up
24-bit
PWM Switching multiplexer Addr/data
EMI
8-bit data
VDD
12-bit sensor 64-KB
ADC MMU Flash
EPROM 16/32-bit
PIF
Temperature Interface
sensor
MUX
29-bit I/O
GPIO
Register or control
4 Code System
VIN block
cache clock
External
Power Interrupt Timers
triggers
on request IRC
reset Clock inputs
eCOG1
Low-power eICE Host computer
Reset_In CPU core
Figure 3—An MMU, instruction cache, and the intriguing 180-Mbps IntAct interface are some of the unique fea-
tures that differentiate the eCOG1 from Cyan Technology.
AH/AL or A AH AL Flags T B I U C S N Z
7 6 5 4 3 2 1 0
24 bits
Debug Interrupt Arithmetic/
Index x UXH UX flags flags logic flags
User
Index y UY mode
Index x IXH IX
Interrupt
Index y IY mode
Program
counter PC 16 bits
16 bits Program space
FFFFFF
Data space
Scratchpad FFFF Large address
RAM FFE0 range: 00FFFF: End of small
User mode: 16,320 x 16 address range
Indexed 64-K x 16
IY Small address 000004: Interrupt routine
0000 range: start address
64K x 16 000000: Reset address
Figure 4—More bits doesn’t mean more complexity, as the 16-bit eCOG1 retro programmer model demonstrates.
Application-Specific
instructions
Program memory
16-bit instructions
96 bits Application-Specific
Execution Units
Input registers
Register files
Product registers Overflow registers
DCU
Address registers
Figure 5—VLIW for the masses might be an apt description for Adelante’s Saturn DSP core.
Suppliers Directory now available online. Check out our web site
www.circuitcellar.com to see who has what and how to get it!
phyCORE Modules:
NEW GENERA TION
GENERATION
SINGLE BOARD COMPUTERS
■ Insert-ready sub-mini SBCs (small as 47x55 mm.) supporting the
Philips 8xC591
8xC591, 89C51Rx2
89C51Rx2, XACx
XACx, XAGx
XAGx, Infineon C167Cx
C167Cx,
Motorola MPC555 & ST Microelectronic ST10F168
■ Low EMI design achieved via GND circuitry, 6 to 8 layer PCB, by-
pass capacitor grid and short signal traces achieved via small
footprint and use of 0402 SMD passive components
■ 32 KB to 8 MB external SRAM & Flash (controller-dependent)
■ FlashTools enable on-board in-system (ISP) programming
■ RS-232, RS-485, I2C & CAN interfaces; ADC; Chip-Select signals
■ Controller signals extend to standard (2.54 mm.) or high-density
Molex (0.625 mm.) header pins on two sides of the board,
allowing the SBC to be plugged like a "big chip" into targets
■ Available in Rapid Development Kits including Development Board,
AC adapter, serial cable and SPECTRUM CD with eval software tools
(Keil, TASKING), FlashTools, electronic documentation and demos
PHYTEC America LLC ■ 255 Ericksen Avenue ■ Bainbridge Island, WA ■ USA 98110
www.phytec.com (800) 278-9913
ting
Staart
Pentium 4
DESIGN YOUR DREAM P4!
WITH INTEL MAIN BOARD, $399
PROCESSOR & SOUND.
System includes:
1.8GHz Intel Pentium 4 Processor
Intel 845WN Main Board
1 Parallel, 1 Serial, 4 USB & PS/2 Port
Integrated Audio
P4 Mid Tower Chassis & ATX PS
1.6GHz $579
ITEM #3426
VISIT
AVAILABLE UP TO 2.2GHz!
LOCAL &
DreamTech
© July 2002
Internet Prototyping Board includes: Built-in libraries that work with all chips for RS232
PIC16F877 Flash Chip Schematics . Serial I/O, I2C, discrete I/O and precision delays
ICD Interface PC Cable
Full V.90 Modem Power Supply Source code drivers and ready to run programs
RS232 Port Phone Cable
Push Buttons Example Programs included for LCD modules, keypads, 24xx and
Analog Inputs 93xx serial E2 PROMS, X10, DS1302 & NJU6355
Real Time Clocks, Dallas Touch Memory Devices,
Our limited time offer also includes: DS2223 & PCF 8570 serial SRAM, LTC1298 &
Debugger Unit (ICD)
CCS PCW Windows IDE Compiler PCF8591 A/D converters and more
TCP/IP Lean book, by Jeremy Bentham Use
discount code Integrates with simulators/emulators, such as
IPB0702-CC
MPLAB®.
ALL FOR ONLY $ 499! to order...
ACT NOW! PRICES STARTING AT:
(OVER 20% IN SAVINGS) COMMAND-LINE COMPILERS FOR$125
WINDOWS IDE COMPILERS FOR $350
http://www.ccsinfo.com/picc
262.797.0455 x35
WWW.RADProto.COM
Denver, Colorado, 720-940-5002
[email protected]
Up to 500 feet
Cat-5 Cable
800-959-6439
www.taltech.com
New CE
version!
e ver hear the one about the mid-level manager who arrives at the office every morning, flips on his com-
puter, and scans everything with anti-virus software? He scans the hard drive, system files, RAM, even the
CD-ROM. He runs three different anti-virus programs just to make sure. He does this every morning. He does
this every day even though his computer has been turned off overnight. Who knows, perhaps something sneaked
in between the time he ran the anti-virus scans yesterday and turned on his computer again today. After all, you can’t be too careful
when it affects your job.
Besides, according to all of the daily news reports, it’s a cyber war out there. There are so many deadly computer viruses just
waiting for the opportunity to find an unprotected computer that your only defense is obsessive alertness. Constant media
reminders about the overwhelming cost and destruction from ILoveYou, Michelangelo, SirCam, and other Internet-born germs
make his palms sweat as he quickly yet conscientiously performs his daily search and destroy mission. Our mid-level manager is
determined that no two-bit cyber-thug or third-world terrorist is going to infiltrate his computer. After all, you can’t be too cautious
when it affects your job.
After the scanning is concluded, the leery manager downloads his e-mail from the company Intranet and proceeds to work. He
clicks on an e-mail that he sent to himself from his computer at home. Suddenly a strange and horrified look comes over his face.
He jumps up, rips the Ethernet connection out of the back of the computer and yanks the power cord out of the wall. Frantically, he
dials the network administrator and yells, “We’ve got a virus! My file is gone! It could only be a virus!”
Almost instantly, the network administrator appears at his desk, still panting from the long run down the hall. Viruses are no
minor event. Heading it off early might save hours of system rebuilds later. A quizzical look from the tech and our manager frantical-
ly exclaims, “It deleted my budget folder! I worked on it last night and I e-mailed it to myself this morning. I do this all the time. I work
on something at home and I e-mail it back to the office. This time, something ate it! It’s a deadly virus for sure!”
The network administrator reconnects the computer and sits down at the keyboard. After feverishly typing for 10 minutes, he
looks up and says, “You didn’t attach the file, sir. I looked at e-mail logs on the server. I can see your e-mail from home but there’s
no file. You forgot to attach it.” With that, he gathers up all the test disks he had expected to need, turns toward the office door, and
adds, “I’ll be down in the server room if you have any real problems.”
The manager frantically paces back and forth. “I never forget to send a file! It must be a virus. It must be a new one that’s really
insidious.” Quickly, he jumps in his chair and logs onto the Internet. “Now, if I can just find one of the anti-virus sites that details a
new one that deletes e-mail files. After all, you can’t be too careful when it affects your job,” he mutters.
As comical as this scenario sounds, I’m sure you’ve all met an individual like this or have heard of a similar situation. The con-
stant over-hyping about virus alerts and virus destruction in the media has created a paranoid culture within the ranks of some com-
puter users. Is it much ado about nothing? Certainly not.
Anti-virus software is an important application for all computer users. I’m not denying the gravity of the issue, but it shouldn’t
be cause for paranoia or fear at every newly announced bug in Outlook or Explorer. In the total population of computer users,
most have never seen or received a virus. In truth, the easiest virus path into a computer is a dumb user. Despite all of the warn-
ings about e-mail attachments as a source of viruses, a survey last year found that more than 40% of people would open an e-
mail appearing to be from someone they know if the following appeared in the subject line: “Great Joke,” “Look at this Message,”
or “Special Offer.”
Beware of the media propaganda and don’t suspect that every computer anomaly is generated by a virus. For intelligent users,
virus management is like avoiding being hit by a bus. Looking both ways before crossing the street is the same as deleting suspect
messages and filtering downloads. The best anti-virus technique is the expression of knowledge, not fortification.
Surely not.
Surely someone somewhere
has developed a portable programmer that
has even more features, even greater
flexibility and is even better value for
money.
Actually, no. But don’t take our word for
DATAMAN-48LV it. Use the feature summary below to see
• Plugs straight into parallel port of PC or how other manufacturers’ products compare.
laptop
S4 GAL MODULE MONEY-BACK
• Programs and verifies at 2, 2.7, 3.3 & 5V
• True no-adaptor programming up to 48 • Programs wide range of 20 and 24 pin
30 DAY TRIAL
logic devices from the major GAL vendors If you do not agree that these truly are the
pin DIL devices
most powerful portable programmers you can
• Free universal 44 pin PLCC adaptor • Supports JEDEC files from all popular buy, simply return your Dataman product
• Built-in world standard PSU - for go- compilers within 30 days for a full refund
anywhere programming
• Package adaptors available for TSOP,
SUPPORT
PSOP, QFP, SOIC and PLCC • 3 year parts and labor warranty
• Optional EPROM emulator • Windows/DOS software included
• Free technical support for life
DATAMAN S4 • Next day delivery - always in stock
Orders received by 4pm will normally be despatched same day.
• Programs 8 and 16 bit EPROMs, Order today, get it tomorrow!
EEPROMs, PEROMs, 5 and 12V FLASH, Still as unbeatable as ever. Beware of
Boot-Block FLASH, PICs, 8751 cheap imitations. Beware of false
microcontrollers and more promises. Beware of hidden extras.
• EPROM emulation as standard If you want the best, there’s still only one
• Rechargeable battery power for total choice - Dataman.
Dataman Programmers Ltd
portability Order via credit card hotline - phone 215 East Michigan Avenue
• All-in-one price includes emulation today, use tomorrow. Orange City, FL 32763
leads, AC charger, PC software, spare Telephone (904) 774-7785
Alternatively, request more detailed Fax (904) 774-7796
library ROM, user-friendly manual information on these and other market- Home page: http://www.dataman.com
• Supplied fully charged and ready to use leading programming solutions. Email: [email protected]