This is only a preview of the July 2005 issue of Silicon Chip. You can view 37 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Remote-Controlled Automatic Table Lamp Dimmer":
Items relevant to "Lead-Acid Battery Zapper":
Items relevant to "PICAXE In Schools, Pt.3":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
Pt.2: By ED SCHOELL*
Managing Director, JED Microprocessors
Pty Ltd.
Assembling and programming the
AVR200 Single
Board Computer
Last month, we published the circuit details
for JED Micro’s new low-cost ATmega32
development board and described the
various I/O options. This month, we show
you how to assemble it and go on to describe
several popular software development and
programming options.
A
SSEMBLY OF THE AVR200 is
quite straightforward as the PC
board is a plated-through, doublesided design with solder resist on both
sides. To reduce component count and
simplify construction, most resistors
are contained in single-in-line (SIL)
arrays.
84 Silicon Chip
In its standard configuration, the
board provides eight analog inputs
or digital inputs/outputs, 11 digital
inputs and nine Mosfet outputs. Also
included are a real-time clock, buffered I2C port and RS232 serial port.
If the standard port I/O arrangements
are not suitable for your application,
then most port lines can be swapped
from inputs to outputs or vice versa
with only minor component changes.
It is therefore important to examine the
various options carefully before starting assembly, to ensure that the correct
parts are installed from the outset.
We covered the various options in
detail last month. In summary, the kit
contains all of the components needed
to configure all available port lines (28)
as inputs, if desired. Eight of these can
be either analog or digital inputs, with
the remainder being digital only.
Note that the remaining four port
bits of the ATmega32 are dedicated to
the I2C and RS232 serial interfaces.
Conversely, if more than the standard nine port lines are required as outputs, then up to 12 additional Mosfets
can be installed for a full complement
siliconchip.com.au
Fig.5: use this diagram
as an aid when
assembling your board.
Socket strips are needed
for resistor packs RP2RP7, with all others
being soldered directly
into the board. Of the
six packs, only RP5 &
RP6 are installed in the
standard configuration
shown here. To install
optional items, follow
the silkscreen overlay
printed on the board
and the instructions in
the text.
of 21 outputs (still giving seven digital inputs). The extra Mosfets are not
included in the basic kit but can be
ordered separately from JED.
Preliminaries
To help make construction easier,
we’ve organised our description into
logical steps, first assembling the
components common to all configurations. We then separately describe the
assembly of the components needed
for each port (A-D) in turn, with the
standard configuration shown first and
the optional configuration (if any) immediately after.
We recommend that you map out
your desired I/O port configurations,
including requirements for any additional features (eg, RS485 port and
high-resolution voltage reference) and
read the entire assembly instructions
before commencing construction.
Power supply
The power supply section should
be assembled and tested first. Begin
by installing the LM2940T voltage
regulator (U3). It mounts horizontally
on the board, so first bend its leads at
siliconchip.com.au
90° about 6mm from the body and trial
fit it into position to ensure that the
hole in the tab lines up with the large
hole in the PC board. Adjust the lead
bend as necessary, then position the
TO-220 heatsink between the regulator and the PC board (see photos).
Finally, fasten the assembly in place
using an M3 screw, nut & flat washer
before soldering and trimming the
regulator’s leads.
All other components related to
the 5V power supply should now be
installed. These are the 2-way terminal
block (J1), DSS706 filters (LC1, LC4LC8), all 100nF monolithic capacitors
and the four 33mF tantalum capacitors. Note that the positive leads of
the tantalum capacitors must go in as
indicated on the overlay diagram, otherwise they’ll be destroyed in a flash at
power on! The power indicator circuit,
consisting of the LED and 1kW resistor
(R7), can also go in now.
Now connect a 6-18V DC power
source to the input terminals on J1
(note polarity) and power up. Check
for correct operation of the power supply by measuring the voltage between
the ground and output terminals of
the regulator (U3). You should get a
reading of between 4.75V and 5.25V.
Note also that the LED power indicator
should light.
Common assembly
Rather than a conventional 40-pin
socket, the ATmega32 (U2) is mounted
in two 20-pin socket strips. As with all
other headers and socket strips used in
this project, these must be cut down
from the longer sections supplied in the
kit. This is done using a sharp utility
knife or a pair of side-cutters.
When installing the socket strips,
make sure that they’re seated all the
way down on the PC board and at right
angles to it before soldering. Once that’s
done, install all of the components that
go underneath the microcontroller.
This includes the TL7726 hex clamp
ICs (U5 & U6), the real-time clock
IC (U7), 32kHz crystal (X2) and
100mH inductors (L1 & L2).
As usual, take care with the orientation of the ICs and zener diodes. Note
that U5, U6 & U7 must be soldered
directly into the board. Don’t use IC
sockets, because it will not be possible
to fully insert U2 later on.
July 2005 85
Fig.6: both “common”
and “series” single-in-line
resistor packs are used in
this project. Here’s how
they’re wired internally.
As you can see, orientation
is important with the pullup/pull-down type, with
pin 1 being the common
connection point for the
resistor array.
Next, install reset switch SW1, the
DS1233 reset IC (U1), the 3.6864MHz
crystal (X1) and the 27pF capacitors.
The crystal is supplied with an insulating washer that fits over its leads to
isolate the underside of the package
from the PC board. Make sure that this
is in place during installation.
Note also that the “arrow” on the
top of the reset switch should point
towards the “RESET” marking on the
overlay.
To complete the common part of the
assembly, install all of the connectors
and headers, including the screwterminal blocks (J2-J5 & J9-J12), the D9
connector (J8), I2C headers (J6 & J14),
SPI header (J13), and links L13-L18,
with attention to the following:
Before installing J13, cut pins 7-10
off flush with the plastic carrier using side-cutters or pull them out with
a pair of pliers (see Fig.5). Note that
J13, J14, L13 and L14 are cut down
from longer dual-row header strips,
whereas links L15-L18 are cut down
from single-row strips.
Port A – analog/digital inputs (standard): install eight 7-pin socket strips
in locations L4-L11. Again, these are
cut down from the longer strips supplied in the kit.
Various components are plugged
into the strips to perform basic signal
conditioning functions ahead of the
port inputs, as described in Pt.1.
86 Silicon Chip
At a minimum, each input should
have a series resistor (see Fig.4a) to
protect the microcontroller (in conjunction with the TL7726 voltage
clamps). Eight 10kW resistors are
provided in the kit for this purpose.
Port A – digital outputs (optional):
the socket strips (L4-L11) are also
installed if you wish to use port A as
low-current digital outputs. In this
case, a small resistor (about 100W)
should be inserted in series with each
output (see Fig.4a).
The socket strips must not be installed if you want to use port A as
high-current Mosfet outputs. Instead,
the Mosfets and their 10kW gate pulldown resistors (Rpd) are soldered
directly into the PC board in place of
the socket strips (see Fig.4f).
Note that the Mosfets are not supplied in the kit but can be ordered
separately from JED, part number
MTD3055VL.
Important: while it is possible to mix
digital inputs and outputs on port A,
it is not recommended to mix analog
inputs and digital outputs, as noise
from the outputs may cause inaccuracies in analog readings.
Analog reference (standard): if
the +5V (Vcc) supply is to be used as
a voltage reference, link L3 must be
shorted by “blobbing” it with solder.
Conversely, if the internal +2.56V
band-gap reference is to be used, the
link is simply left open and the selection is made under program control.
Precision analog reference (optional): parts for the 4.096V precision reference are optional and can
be purchased separately from JED as
part number AVR200-REFK. Included
in the option pack are a MAX874CPA
voltage reference IC (U4), 2.2MW and
3.3MW resistors (R1 & R2), 1MW trimpot (VR1), 47nF capacitor (C14) and
4.7mF tantalum capacitor (C15). After
installing all of these parts, the output
from U4 (pin 6) must be trimmed to
precisely 4.096V by adjusting VR1.
Port B – digital inputs (standard):
to configure port B for all digital inputs, first install 6-pin socket strips in
positions RP5 & RP6. A 4.7kW, 5-pin
common resistor pack can then be
plugged into each of the sockets. As
described last month, one end of the
socket strip is connected to +5V (pin
6) and the other to ground (pin 1). This
means that the resistor packs can be
used to perform a pull-up or pull-down
function simply by orienting them
correctly in the socket strips.
Next, install 4.7kW 8-pin series resistor packs in locations RP7 & RP15,
and six 4.7V zener diodes in locations
Z6-Z9. Make sure that you have the
banded (cathode) end of the zeners
around the right way. Leave location
RP1 empty, as it’s only required when
using port B for high-current outputs,
as described below.
Port B – digital outputs (optional):
the upper (PB4-PB7) and/or lower
(PB0-PB3) bits of port B can be used as
low-current digital outputs, if desired.
For example, to use the upper lines as
outputs, leave out RP6 and install four
low-value series resistors (about 100W)
in place of RP7. A similar scheme can
be applied to the lower lines.
Provision has also been made to
use the lower four lines (PB0-PB3) as
high-current outputs, if desired. To do
this, leave out RP5 & RP15 and install
MTD3055VL Mosfets in locations
F1-F4. These devices are available
separately from JED. A 4.7kW, 5-pin
common resistor pack must also be
installed in the RP1 position.
Naturally, if you decide to expand
“upstairs” via J13, then many of these
port bits will not be available for general-purpose use on the screw-terminal
blocks (J11 & J12). This means that you
may be able to leave out some or all of
the resistor packs mentioned above.
Port C – TWI (I2C) port: the lower
siliconchip.com.au
two bits (PC0 & PC1) of port C are used
for the I2C port. By default, the I2C port
is “buffered”, so links L24 & L25 (beneath U11) must remain open. Install
the 82B715 buffer (U11), the 1.5kW and
330W pull-up resistors (R3, R4, R9 &
R10), and the two 10W series resistors
(R11 & R12). The two 4.7V zener diodes
(Z1 & Z2) that protect the micro’s inputs
should also be installed.
If you want to connect non-buffered
I2C devices, do not install U11, R9 &
R10 but do install the two series resistors (R11 & R12). Note, however, that
these must be 100W rather than the 10W
values shown on the diagrams. In addition, links L24 & L25 must be shorted
by bridging them with solder.
Port C – digital outputs (standard):
in the standard build, the upper six
bits (PC2-PC7) of port C drive power
Mosfets to provide high-current opendrain outputs. All that needs to be
installed here are the Mosfets (F5-F10)
and the two 4.7kW, 6-pin series resistor
packs in locations RP8 & RP9. Locations RP2, RP3, RP13 & RP14 remain
empty.
If desired, all of these bits may also
function as low-current digital outputs.
In this case, omit all the Mosfets and
resistor packs mentioned above and
install low-value series resistors (about
100W) in place of RP13 & RP14.
Port C – digital inputs (optional):
to use PC2-PC7 as digital inputs, do
not install the Mosfets or RP8 & RP9.
Instead, install two 5-pin socket strips
in locations RP2 & RP3. That done,
4.7kW 4-pin common resistor packs
can be plugged into these sockets to
perform pull-up or pull-down functions, as described earlier.
Next, install six zener diodes (Z10Z15) in locations RP8 & RP9. These
do not appear on the circuit or overlay
diagrams, but are simply soldered
vertically into the holes left vacant by
the two resistor packs. Check that you
have the zeners around the right way;
the anode ends connect to the ground
plane on the topside of the PC board.
Par t s Lis t for AVR200 (Standard Build)
1 AVR200 PC board
6 DSS706 EMI suppression
filters (LC1, LC4 – LC8)
1 3.6864MHz crystal (HC49U
package) (X1)
1 32.768kHz miniature watch
crystal (X2)
1 BR1225/1VC 3V lithium cell
(BATT1)
2 100mH miniature axial inductor
(L1, L2)
1 sub-miniature slide switch (SW1)
1 10-way 2.54mm pitch DIL
boxed header (J6)
1 9-way right-angle female ‘D’
connector (J8)
1 6-way 3.81mm pitch screwterminal block (J3)
3 5-way 3.81mm pitch screwterminal block (J2, J11, J12)
4 4-way 3.81mm pitch screwterminal block (J4, J5, J9, J10)
1 2-way 3.81mm pitch screwterminal block (J1)
2.54mm pitch SIL header strips
(see text)
2.54mm pitch DIL header strips
(see text)
2.54mm pitch SIL socket strips
(see text)
1 M3 x 6mm screw, nut &
washer
1 TO-220 heatsink
1 LM2940T-5.0 low-dropout +5V
regulator (U3)
2 TL7726 hex voltage clamping
IC (U5, U6)
1 DS1307 real-time clock IC (U7)
1 MAX202E RS232 transceiver
IC (U8)
1 P82B715 bi-directional I2C bus
buffer IC (U11)
9 MTD3055VL logic-level
Mosfets (F5 –F13)
18 4.7V 0.5W zener diodes
(Z1-Z18)
1 3mm red LED (LED1)
Capacitors
4 22mF 10V tantalum (C9-C11,
C16)
8 100nF 50V monolithic ceramic
(C1-C8)
2 27pF ceramic disc (C12,C13)
Resistors (0.4W, 1%)
8 10kW (see text)
2 1.5kW (R3, R4)
1 1kW (R7)
2 330W (R9, R10)
2 10W (R11, R12)
Resistor packs
3 4.7kW 4-pin common resistors
(RP2-RP4)
3 4.7kW 5-pin common resistors
(RP1, RP5 & RP6)
6 4.7kW 6-pin series resistors
(RP8-RP14, RP16)
2 4.7kW 8-pin series resistors
(RP7, RP15)
Semiconductors
1 DS1233 5V reset IC (U1)
1 ATmega32-16P microcontroller
(U2)
Finally, install 4.7kW 6-pin series
resistor packs in locations RP13 &
RP14.
Port D - RS232 (standard): the lower
two bits of port D (PD0 & PD1) are reserved for use as the transmit/receive
data lines for the serial port. To build
the standard RS232 serial interface,
install the MAX202 (U8) first, followed
by the five 100nF capacitors (C4-C8) if
not already in place. Links L20 & L21
should also be shorted by bridging
them with solder.
In its most basic configuration, the
RS232 port does not provide hardware
handshaking; the RTS/CTS lines are
Table 1: Resistor Colour Codes
o
o
o
o
o
o
siliconchip.com.au
No.
8
2
1
2
2
Value
10kW
1.5kW
1kW
330W
10W
4-Band Code (1%)
brown black orange brown
brown green red brown
brown black red brown
orange orange brown brown
brown black black brown
5-Band Code (1%)
brown black black red brown
brown green black brown brown
brown black black brown brown
orange orange black black brown
brown black black gold brown
July 2005 87
Setting The RS232
Port Mode
Fig.7: links L13 & L14 are used
to set the RS232 port mode. The
default configuration is “DCE”
with no handshaking, as it allows
connection to a PC and use of the
MegaLoad software programmer.
simply looped back on the D-9 connector by installing a jumper on L14
(the “no handshake” setting in Fig.7).
However, provision has been made for
hardware handshaking using port bits
PD7 & PD6. This feature is enabled by
shorting L22 and installing a jumper
on L17 pins 2-3.
As described last month, the
RS232 port can be set for either DTE
or DCE modes. The required mode
is selected via links L13 & L14, as
shown in Fig.7.
Port D – three inputs & outputs
(standard): of the remaining six bits of
port D, three are normally configured
as outputs (PD4, PD5 & PD7) and three
as digital inputs (PD2, PD3 & PD6).
To use PD4, PD5 & PD7 as high-current outputs, install Mosfets F11-F13
and a 4.7kW 6-pin series resistor pack
in location RP10. In this case, locations
RP4 & RP16 remain empty.
If desired, all of these bits may
also function as low-current digital
outputs. To do this, simply omit the
Mosfets and resistor pack (RP10) and
install low-value series resistors (about
100W) in the RP16 location.
To configure bits PD2, PD3 & PD6
as inputs, install 4.7kW 6-pin series
resistor packs in locations RP11 &
RP12 and three 4.7V zener diodes in
at locations Z3-Z5. Links L15 & L16
allow PD2 & PD3 to be connected to
either the screw-terminal block (J9) or
the I2C headers (J6 & J14). In addition,
link L18 allows the PD6 input to be
pulled up or pulled down.
88 Silicon Chip
Note that PD6 & PD7 can be redirected to the RS232 port (via links
L17 & L22) in support of hardware
handshaking, which would make them
unavailable for general-purpose use.
Port D – swapping inputs & outputs
(optional): as with all the generalpurpose I/O ports described thus far,
the standard roles of the six port D bits
are easily reversed if more inputs or
outputs are needed in a particular application. This is achieved in a similar
manner to that already described for
ports B & C. However, we’ve covered
it again here to avoid confusion.
To configure bits PD4, PD5 & PD7 as
digital inputs, omit the three Mosfets
(F11-F13) and install a 4.7kW 6-pin
series resistor pack in location RP16.
Also, leave out RP10 and install three
4.7V zener diodes (Z16-Z18) to protect
the micro’s inputs. Again, these do
not appear on the circuit or overlay
diagrams but are simply soldered
vertically into the holes left vacant
by RP10.
Check that you have the zener
diodes around the right way; the anode
ends connect to the ground plane on
the top side of the PC board.
Next, fit a 5-pin socket strip in location RP4 and plug in a 4.7kW 4-pin
common resistor pack. The “common” pin of the resistor pack (pin 1)
goes to the grounded end (pin 1) of the
socket to pull down the three inputs
or to the Vcc end (pin 5) to pull them
up to +5V.
Finally, to configure bits PD2, PD3
& PD6 as low-current outputs, leave
out RP12 and install three low-value
series resistors (about 100W) in place
or RP11.
Port D – RS485 (optional): as men-
Where To Buy A Kit
Kits and options for this project are
available from JED Microprocessors Pty Ltd. A complete price list
and order form can be downloaded
from www.jedmicro.com.au/
avr200.htm, phone (03) 9762 3588
or email jed<at>jedmicro.com.au
AVR200 kit .............................. $99
AVR200 assembled & tested
(standard options) ................ $185
Atmel AVR-ISP ....................... $66
Note: all prices include 10% GST.
tioned last month, the AVR200 includes support for an RS485/TTL
serial port. Parts for this option are
available separately from JED (part no.
AVR200-RS485K). We do not describe
the RS485/TTL serial port here but
complete details on installing it will
be included on the CDs with the kits
and on the JED website.
Note also that “revision 0” of the
AVR200 board does not support this
option, so be sure to mention your
requirements when ordering.
Finally, those with specific cabling
requirements will be pleased to know
that there are additional rows of pads
at the I/O connector mounting positions to allow for machine or crimpedon plug-in connectors. Again, contact
JED with your specific requirements.
By now, you should have a fully
assembled board, so let’s move on
and look briefly at what’s available for
application development. We’ll also
check out a couple of popular choices
for getting your completed code into
memory.
Software development options
We’ve already mentioned that Atmel’s AVR architecture was designed
from efficient execution of compiled
code. Development packages that
allow you to make the most of this
advantage are readily available. Atmel
recommend a long list of third-party
programming packages in their “AVR
8-Bit RISC Third Party Support”
document, available from www.atmel.
com. Supported languages include C,
BASIC, Pascal, Forth and Java.
Apart from the Atmel website,
another useful resource for AVR programmers is the very active AVR user’s
group at www.avrfreaks.net. You’ll
find an even longer list of compilers,
assemblers and other goodies in the
“Tools” section of their site.
JED Micro use and support several lower-cost development options.
Check out their AVR200 page at www.
jedmicro.com.au/avr200.htm for all
the details.
Free assembler & C compiler
For those that need to program
AVR micros at the grass roots level,
a complete assembler, simulator and
debugger is included in the “AVR Studio” software package. The package
boasts an integrated development environment (IDE) that allows third-part
compliers to be plugged-in as needed.
siliconchip.com.au
AVR Studio is free and it’s included
on the Atmel CD that ships with the
AVR200 kit and can be downloaded
from www.atmel.com.
For the beginner and hobbyist interested in embedded C programming,
the free WinAVR GCC compiler offers
an excellent, all-round development
suite. It has I/O port support, extensive
help and embedded support functions
for things like delays, EEPROM access,
WDT and CRC. It can also produce a
debug file for AVR Studio, thus allowing use of the simulation and debugging facilities.
Although WinAVR doesn’t include
a full IDE like many commercial packages, the “Programmers Notepad” editor can run a “Make” file to automate
the whole code generation process. A
sample “Make” file is included on the
CD with the kit to help first-time users
get up and running. WinAVR can be
downloaded from winavr.sourceforge.
net or check out the links on JED’s
website.
CodeVisionAVR C Compiler
Although at the lower-priced end of
the commercial range, CodeVisionAVR
from HP Infotech offers ample features
and includes a full IDE, including
debugger, programmer and terminal.
It has library function support for
EEPROM access, Dallas 1-Wire, I2C,
BCD/Gray code conversion, LCD support, SPI, the Dallas real-time clock
and more.
Perhaps one of CodeVisionAVR’s
best features is the automatic code
wizard generator that removes the
tedious aspect of setting up your initial
register conditions. You can examine all of the other features at www.
hpinfotech.ro and browse the on-line
user group site at groups.yahoo.com/
group/codevisionav
BASIC Compiler
If you need results in a hurry and
your C skills are a little rusty, then
BASIC compilers are worth a look.
MCS Electronics offers a powerful
commercial compiler for the AVR
series. The package, called “BASCOMAVR”, includes a full IDE, including
debugger, programmer, simulator and
terminal, as well as comprehensive
documentation.
BASCOM-AVR produces fast machine code, not interpreted code like
some other products. It includes library support for EEPROM access, Dalsiliconchip.com.au
Fig.8: MegaLoad is
an easy way to get
your code into the
ATmega32 and it’s
free! If you request
this option when
ordering the AVR200,
JED will install the
necessary bootloader
code into the top
of the micro’s code
memory.
las 1-Wire, I2C, LCD, SPI and real-time
clock. As a bonus, statements are 99%
compatible with Microsoft’s QBASIC.
View the product details or download
a free demo version at www.mcselec.
com. You’ll find an on-line user group
at www.grote.net/bascom
Readers interested in purchasing
the above products will find links
to the appropriate sites from JED’s
AVR200 page at www.jedmicro.com.
au/avr200.htm
Programming the micro
JED is offering two options for getting your programs into the ATmega32
micro. The first of these requires an
additional piece of hardware called
the AVR-ISP programmer. This device plugs into your PC’s serial port
as well as the 6-pin section of J13 on
the AVR200 board. It accepts the hex
or binary file output from your assembler or compiler and programs it into
the micro’s Flash (program) and/or
EPROM (data) memory and sets option
fuses all in one operation.
The AVR-ISP is supported by AVR
Studio and most third-party development tools. However, for those
that don’t need to fiddle with the
ATmega32’s fuses, the “MegaLoad”
bootloader and companion Windows
application are a much cheaper option.
MegaLoad can be supplied free with
your AVR200 kit; all you need to do is
tick the right box on your order form.
JED will then pre-install it in the top
part of the micro’s memory (3C00H)
before despatch.
To program the micro using MegaLoad, launch the MegaLoad Windows
application (supplied on CD) on your
PC, connect the AVR200 to the PC serial port and toggle the Reset switch on
the AVR200 board. The program code
is then transferred over the serial link
at 115k bits/second, with no external
hardware needed.
Wrap up
JED Micro are supplying two CDs
with all AVR200 boards. One includes
all AVR200 circuits, layouts, assembly
instructions, a test program with instructions and sample code snippets
written in BASCOM Basic and CodeVision C. Also included are MegaLoad
and a sample setup and Makefile for
WinAVR.
The second disk is supplied by
Atmel. It contains their complete
“Software and Technical Library”,
including the AVR Studio software
suite, product datasheets, application
notes, user guides and source code
examples, etc.
Now all of that should keep you
SC
busy for quite some time!
July 2005 89
|