Palm-Integrated Sensors Using Altera FPGA Board ICS 213 Project Report March 2001 Ilya Issenin Radu Cornea Ana-Maria Badulescu Project Web Site: http://www.ics.uci.
Contents Introduction ..................................................................................................................... 3 Chapter 1. Description of the hardware used in the project ............................................ 5 Temperature Sensor..................................................................................................... 5 Infrared Transmitter .................................................................................................... 6 FPGA Board.......
Introduction In the increasingly competitive market of today, efficiency is a very important issue. Many tasks previously requiring human intervention are now performed automatically, with the use of embedded systems. Companies can benefit form this, since they require less personal for completing the same tasks. These tasks can be centralizing data from different sources to a central database, which mean that they require collecting the data, processing it, and sending it to a remote location.
o sends collected data from Palm to a server on the Internet via TCP/IP connection. The server processes the data and plots a graph that is posted on the web page.
Chapter 1. Description of the hardware used in the project Temperature Sensor We used TMP04FT9 temperature sensor made by Analog Devices. This sensor has a wide temperature range (-40°C to +150°C) with the accuracy ±1.5°C (in -25°C to +100°C range) [13]. The temperature detector has modulated serial digital output, with the ratio of high and low period being directly proportional to the temperature of the device.
Infrared Transmitter To send data to the Palm PDA via IrDA link, we used NTE3017 infrared GaAs emitting diode (NTE Electronics, Inc.). Its emission wavelength is 950 nm, angle of half intensity is ±22 degrees and radiant power is 15 mW. The nominal continuous current of NTE3017 is 150 mA, while the output current of FPGA I/O pin is only 25 mA [3]. That is why we had to add a simple, one-stage amplifier (see schematics on the next page).
+5V R2 +5V 27 R3 27 U1 TMP04 V+ D1 NTE3017 C1 0.047uF C2 22uF Connector P1 (FPGA pin 10) GND R1 1.2 k Connector P1 (FPGA pin 11) Dout Q1 NTE2363 GND +5V GND Connector MAX_EXPANSION pins 3, 5 Connector MAX_EXPANSION pins 4, 6 GND The amplifier for the infrared emitting diode D1 consists of resistors R1, R2 and transistor Q1. R1 limits the value of the output current of the FPGA pin to Vcc − 0.7V = 3.6mA and R2 limits the current through LED to R1 Vcc − Vled − 0.2V 5V − 1.7V − 0.2V = = = 115mA .
FPGA Programming FPGA was programmed using MAX+PLUS II software with Verilog hardware description language. The block diagram of the designed hardware is depicted on the figure below.
This library module has two parameters: • IrDA_Speed_bod - IrDA transmitting rate, 9600 bod by default; • Clock_Freq_Hz – on-board clock frequency, 25175000 Hz by default.
According to the IrDA Physical Layer specification [12] for the signaling rates up to 115.2 kb/s, the data are send as a stream of frames. Each frame consists of Start Bit, 8 Data Bits and a Stop Bit. No Parity Bit is used. All bits are encoded using RZI (Returnto-Zero-Inverted) modulation, that means that “0” is represented by a pulse with a duration of 3/16 of a bit period, and “1” is represented by no pulse. Least significant bit is transmitted first. We use 9600 b/s transmission rate in our project.
Chapter 2. IR Communication using Palm Introduction Palm PDAs are the handhelds with the high success on the market today. They are easy to use, small and affordable. All Palm devices have a similar architecture, with small differences in term of size, memory, and other characteristics.
The SIR/FIR layer is purely hardware. The SIR (Serial IR) layer supports speeds up to 115k bps while the FIR (Fast IR) layer supports speeds up to 4M bps. IrLAP is the IR Link Access Protocol that provides a data pipe between IrDA devices. IrLMP, the IR Link Management Protocol, manages multiple sessions using the IrLAP. Tiny TP is a lightweight transfer protocol on which some higher-level IrDA layers are built. IrComm provides serial and parallel port emulation over an IR link.
The new serial manager maintains a database of installed hardware and currently open connections. Applications, libraries, or other serial communication tasks open different pieces of serial hardware by specifying a logical port number or a four-character code identifying the exact piece of serial hardware that a task wishes to open a connection with. The new serial manager then performs the proper actions on the hardware via small hardware drivers that are opened dynamically when the port is needed.
In our case, the communication is unidirectional, the board does not have receive capabilities. It continuously sends the data read from the sensor and formatted according to our protocol. From the previous sections, the protocol we choose for transmitting the temperature values from the board to Palm consisted of a series of 3 bytes, which we refer to as a,b and c in the next paragraphs.
Error Correction The procedure specified above can detect problems due to the infrared communication. This may not be enough for the purpose of our experiment: even if the bytes are considered to be correct by the IR receiver synchronization algorithm, they may be logically incorrect (e.g.: weak IR transmission, interpreted by receiver in wrong data or packets lost or data out of range due to different factors). First, we try to remove all values that are obviously out-of-range (e.g.
Temperature Temp Max Temp Min 0 Past time Temp Max and Temp Min are thresholds used by the temperature monitoring application to trigger some actions when they are crossed (see next chapter). Temperature Monitoring In addition to displaying the history of values on the screen, our application also collects all data in an internal database stored on Palm. Periodically, the content of the database is uploaded to an Internet server using the network capabilities of Palm (see next chapter).
• Close IR communication Functions for drawing the graph: • Draw frame • Draw data All the components described in this chapter have been integrated into a demo application.
Chapter 3. Networking Introduction The Palm SDK contains a net library that provides network services, like TCP/IP, to applications. With this library, an application on the Palm device can connect to any other machine on a network using standard TCP/IP protocols. The API for this library is a socket interface, modeled very closely on the Berkeley Sockets API.
two thresholds. However, in reality the temperature oscillates around values. When for instance MIN_TEMP is reached, the temperature oscillates around MIN_TEMP +/- DELTA_TEMP. This would result in sending e-mails all the time while the temperature gradually increases around TEMP_MIN value. To prevent that, we use a hysteresis, i.e. we do not send e-mails until the temperature is between MIN_TEMP + DELTA_TEMP and MAX_TEMP – DELTA_TEMP.
We developed a simple communication protocol used between the client on Palm and the server for uploading data. The server runs on a Unix host. It uses port number 7002, which should be available. If it is not, the port number can be easily changed. The figure on the previous page shows the data flow from Palm client to the server, and a sample graph as it appears on the web page. Functions We developed a collection of generic functions for basic TCP/IP communications.
functions, two of the parameters are pointers to functions for printing the status and error message. These functions are platform dependent. typedef void typedef void *extraInfo); (*StatusCallbackFunc)(char *status); (*ErrorCallbackFunc)(char *problem, char int sendmail(char *smtpHost, char *from, char *to, char *subject, char *data, StatusCallbackFunc statusFunc, ErrorCallbackFunc errorFunc) /* Sends e-mail to a user by connecting to the STMP server smtpHost. From, to and subject are self-explanatory.
Conclusions We provided the infrastructure for monitoring, processing and publishing sensor data. We connected the temperature sensor and IR transmitter to FPGA board. The temperature data acquisition is displayed on the board, as well as transmitted to the Palm via IR link. For programming the board we developed an IrDA_generator library and a Temperature_Measurement library.
Bibliography 1. University Program Design Laboratory Package User Guide, Altera Corporation 1999 2. MAX+PLUS II Getting Started manual 3. MAX7000 Embedded Programmable Logic Family Data Sheet 4. Palm OS SDK Reference, Palm, Inc. 5. Palm OS Programmer’s Companion, Palm, Inc. 6. Palm OS Programming Development Tools Guide, Palm, Inc. 7. Palm OS Developer Forums: Communication Developer Forum, Palm Developer Forum 8. Using the Palm OS Emulator, Palm, Inc. 9. RFC 2616: Hypertext Transfer Protocol -- HTTP/1.