circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 99, October 1998
Networking with DeviceNet—Part 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, you’re 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 trouble—err…fun—with connection states and fragmented messaging.

Let’s 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 don’t need a special library and linker to generate ROMable code.

brady-p1.jpg (18689 bytes)

Photo 1—The 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. It’s 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 lot’s been said about the poor suitability of C++ for real-time embedded development. But, it’s 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 I’ve done using standard C with small CPUs. I’ll show you some performance measurements later on.