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





 

Issue 151 February 2003
Working the ’Net


by Tom Cantrell

Shouldn’t every engineer know a little more about the process of network-enabling his or her widget? Tom definitely thinks so. With Tom on your side, you’ll be working the ’Net to your advantage in no time.


Start Web Site LiteCOM Spi with Me Freshen Up Burning Down the 'NetHave It Your WaySources and PDF

WEB SITE LITE

I suspect that when the marketing department bangs on the table for networking, they usually mean to say, "web browser enabling." In other words, the ability to interrogate, control, upgrade, and otherwise interact with an embedded product using a standard web browser.

These days, practically all embedded products have a user interface, whether it’s a full-featured, touch-screen display or a DIP switch and blinking LED. The user interface even can be a PC with some kind of software making the connection, ranging from a simple terminal program to a custom-programmed GUI.

The advantage of the web-based approach is compelling. In short, it puts the user-interface ball squarely in the user’s court, which turns out to be a win-win for everyone. Users get to choose their favorite browsing platform, which is typically a PC but is inexorably expanding to include PDAs, smart phones, web TVs, hand-held games, and ultimately just about anything with a display and input device.

Meanwhile, the equipment supplier is relieved of the burden of having to make provisions for (and support) proprietary software and hardware at the user end. The engineering spec is simple: add an Ethernet jack and cough up a web page. All that’s left is to figure out the simplest, quickest, and cheapest way to do it.

NetMedia targets this scenario with their SitePlayer, which is notable for its laser-like focus. All nonessential baggage is tossed overboard in pursuit of the singular goal of talking to a web browser. There’s no socket-level programming, e-mail, execution of user code (although the web site alludes to a programming language in the works), or anything else. Thanks to it’s single-minded purpose, SitePlayer gets by with a remarkably tiny bill of materials. It’s literally made up of two chips: a standard Philips flash memory ’51 and a commodity RealTek Ethernet MAC chip.

That’s not to say such a streamlined approach doesn’t come with some compromises. For example, because your SitePlayer-based web site is limited to the ’51’s 48-KB on-chip flash memory, leave your bloated eye candy at home. Nevertheless, with care you can come up with up with an attractive user interface that doesn’t bust the bit budget (see Photo 2).

Photo 2—If you keep your design tight, you can get SitePlayer to serve up an appealing interface, even with only 48 KB of flash memory to play with.

 

Of course, serving up a mere static web page isn’t that hard nor is it very useful. You’ll generally want to display or input dynamic data. For instance, a web-enabled thermostat would allow the user to enter a desired temperature as well as display the actual current temperature.

SitePlayer makes an otherwise static page dynamic by embedding special tags in the HTML. The tags, denoted by a caret (^), refer to variables that pass one-way or the other (or both ways) between the SitePlayer web server and your embedded device server. For instance, in the thermostat example, your web page could simply display the following string:

The current temperature is ^temp

As SitePlayer dishes up the web page, it will notice the ^temp variable and substitute the current value of the temperature variable.

SitePlayer knows about the ^temp variable by virtue of a SitePlayer definition file (extension .spd) that you create. Along with various configuration parameters (i.e., the IP address, whether or not to use DHCP or a password, etc.), the .spd file defines the location and data type for each variable.

On the device server side (i.e., RS-232), the embedded system (e.g., thermostat) updates the ^temp variable using a simple protocol (command and data) that accesses SitePlayer’s internal memory. In the thermostat example, you would send the current temperature via the RS-232 to the location in SitePlayer corresponding to the ^temp variable as defined in the .spd file. Now, the next time the page is refreshed the current temperature will be displayed.

Of course, as soon as you’ve crafted a simple character-oriented interface, the call will come down from on high to spiff it up with graphics for a more glamorous first impression. The SitePlayer allows you to, for example, replace a simple numeric variable with its virtual seven-segment LED equivalent. Photo 3 shows a web page in which var is defined as a byte displayed as a decimal number of up to three digits (i.e., 0–255).

Photo 3—A key SitePlayer technique is to parse the numeric value of a variable to create a file name that references a graphic file, in this case a seven-segment LED. Meanwhile, the Serial Tester utility facilitates PC-based debugging by allowing easy access to variables and monitoring the associated RS-232 command and response packets.

SitePlayer allows you to pick off individual digits using a colon notation (:). Examples include ^var:3, ^var:2, and ^var:1. In turn, the digits are grafted onto the file name calling out a particular LED image file. For instance, if the value of the variable is 234, ^var:1_LED.jpg will bring in the file 4_LED.jpg, which is the bitmap image of an LED showing the number four. A variety of useful image files (e.g., seven-segment LEDs, sliders, and knobs) come with the SitePlayer software.

As usual, the complexity (if not the devil) is in the details. Using Word as my web page authoring tool, I couldn’t find a way to generate the colon syntax. Thus, I had to edit the HTML directly, something I imagine is required for some of the other fancy constructs as well. Also, I was unable to come up with a scheme to blank leading LED zeros. There may be a way for users to kludge around it, but I would say this is a feature that should be added to the tools.