Full Version : 2001 Web-Based AVR Interface
avr >>COMMUNICATIONS & WEB PROJECTS >>2001 Web-Based AVR Interface


AVR_Admin- 04-26-2006
In the vein of today's trends to embed networking cababilities into simple appliances, our project implements a webpage interface for the Atmel AVR microcontroller. One of the original motivations of this project was to develop a low-level network interface for the Atmel device, specifically by controlling an ISA network card (see the eAVR Project) to transmit UDP packets across the Internet. We greatly modified our original plans once we found out about the SitePlayer device:

This board features a Crystal Semiconductors CS8900 Ethernet controller and on-board Flash memory to host a small webpage. Its extremely small footprint makes this device ideal for a embedded systems applications such as ours. It also uses a simple serial interface, which we've connected to the Atmel ATS8535 mcu. The major challenge of this project was to design code that gathers data from our sample peripheral devices (appliances) and formats and outputs to the SitePlayer's webpage.


--------------------------------------------------------------------------------

High level design
Our materials for this project included:

Atmel ATS8535 microcontroller
STK200 evaluation board (spec sheet pdf)
SitePlayer Ethernet Webserver device (spec sheet pdf)
8-digit LCD display for on-site monitoring at the mcu.
Crossover Ethernet connection or other connection for the SitePlayer
Null Modem cable for mcu-SitePlayer serial link
Any parts needed for the attached peripherals
The general scheme of our program's execution is that of a primitive command interpreter. We have a set of commands that will perform I/O on the Atmel's peripherals: a set of LEDs, a temperature sensor and fan (from Lab 6), a photodiode room-light indicator, and an IR security beam. The IR beam can be used to trigger an open door and is currently configured with a debouncing state machine to increment a room-occupation counter.
The following summarizes which commands the Atmel will support:

- status: Returns the status of the SitePlayer web interface.
- greenled[on/off]: Toggles the Green LED on the SitePlayer
- redled[on/off]: Toggles the Green LED on the SitePlayer
- led[X], 0 < X < 6: Toggles the Xth led on the STK eval. board.
- gettemp: Returns the current room temperature, per temperature module.
- lights: Returns the status of the room lights, per photodiode.
- fan[on/off]: Toggles the fan, which cools the temperature module.
- door: Returns the current room-occupancy counter, per IR security beam.


If a command is mistyped, or an input is erroneous, the Atmel will return "badCmd!" to the LCD monitor and a "Syntax Error" output to the webpage.



--------------------------------------------------------------------------------

Program/hardware design
The first major task we faced was sending and receiving data from the 8535 to the SitePlayer. We used the SitePlayer Software manual to understand the technical details of serial transfer to this device. Basically, each I/O operation takes 2-4 bytes: A command byte (like Read or Write with address length specification), an address byte or two (depending on whether we're addressing data in the higher regions of RAM), and the actual byte of data. For example, the printf commands below tell the SitePlayer to set the IP address to 128.84.235.244:

printf("%c",0x93); // Command byte: Write 4 bytes using two-byte addressing
printf("%c%c",0xE6,0xFF); // Address byte: Begin writing at 0xFFE6
printf("%c%c%c%c",128,84,235,244); // Data: 128,84,235, and 244 (the IP address)


Now, we just needed to specify memory areas on the SitePlayer for the input command (16 bytes) and output result (32 bytes). Our program used the Timer1 overflow interrupt to poll the region of SitePlayer memory corresponding to the webpage input. So once we receive something other than 0's, we do our command matching and carry on with the specific job. In each command we produce two output strings, one for the webpage (32 characters) and one for the chip-side LCD monitor (8 characters). For the actual serial transfers to and from the SitePlayer, we employ the UART receive interrupt. Also, the details about how to configure intial memory mappings for HTML variable names involve using the proprietary SitePlayer software to compile .spi configuration files, the details of which can be found here.

For two of our peripherals, we used the 8535's on-board ADC. Since we were using a gain of 4 on our temperature module, conversion to the actual temperature was just a simple division by 10 (the ADC discriminates on intervals of 4 mV). Also, we found it necessary and convenient to set up our temperature and Infrared data collection on a polling loop basis. This way, when a gettemp or door command is received, we need only to check a register value, not carry out the entire analog conversion. Also, the IR module has a 1-second debouncer, so if it were used on a door, the beam must be interrupted for over 1 second before the occupancy counter is incremented. Also, we only want to increment this counter once per beam interruption--this is another feature we decided to build into the IR module.


Link: http://instruct1.cit.cornell.edu/courses/e...ts/s2001/mrd19/


Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.