|
Issue
99, October 1998
Networking
with DeviceNetPart
2: A Weather Station Application
by
Jim Brady
Think
programming a DeviceNet interface in C++ is tough? Jim
disagrees. With its excellent response times and adequate
program size, Jim gets the same excitement writing code
for a fast 32-bit CPU as he got from his 67 Camaro.
Start
Can
Chips
Chip
Setup
Real Time
Message
Flow
Connections
Timers
Analog
Input Point
Identity
Object
Fragmented
Messages
Getting
Physical
Applying
DeviceNET
Software,Sources
If
you like programming as much as I do, youre in for
a real treat with DeviceNet. The DeviceNet specification
is fully object-oriented, with each object described in
terms of attributes and services.
These
items correspond to C++ class data and member functions,
so if you use C++, all you have to do is understand the
specification and translate it to code. Just make sure
you have some strong coffee on hand when tackling the
tricky parts. I had the most troubleerr
funwith
connection states and fragmented messaging.
Lets
cover the PC/104 hardware first. After surveying the many
processor boards available for PC/104, I went with the
Micro/sys SBC1386, a 25-MHz 386EX board, shown in
Photo 1. It comes with BIOS and a DOS run-time environment
that runs the application out of RAM. That way, you dont
need a special library and linker to generate ROMable
code.
|

Photo 1The
PC/104 weather station is entirely powered from
the DeviceNet bus. The weather station board
is sandwiched between the 386EX CPU board
on bottom and the DeviceNet interface on top.
The humidity transducer and thermistor are on
the small board in front.
|
The
board also includes the Borland remote debugger in flash
memory. Its nice to be able to send the program
to the board at 115 kbps, set some breakpoints, and let
er rip. My program is written entirely in C++ using
the Borland compiler (large memory model).
A
lots been said about the poor suitability of C++
for real-time embedded development. But, its more
than adequate for a fast-response DeviceNet interface.
The
program weighs in at 45 KB of code space, including the
weather-station application code. This size is comparable
to DeviceNet interfaces Ive done using standard
C with small CPUs. Ill show you some performance
measurements later on.
|