Date post: | 19-Mar-2018 |
Category: |
Documents |
Upload: | vuongthien |
View: | 212 times |
Download: | 0 times |
ECE 477 Final Report Spring 2008Team 14 SmartGlove
Team Members:
#1: ____Donghan Ryu______ Signature: ____________________ Date: _________
#2: ____Po-Cheng Wang____ Signature: ____________________ Date: _________
#3: ____Yukeun Sim________ Signature: ____________________ Date: _________
#4: ____Shiv Biddanda______ Signature: ____________________ Date: _________
CRITERION SCORE MPY PTSTechnical content 0 1 2 3 4 5 6 7 8 9 10 3Design documentation 0 1 2 3 4 5 6 7 8 9 10 3Technical writing style 0 1 2 3 4 5 6 7 8 9 10 2Contributions 0 1 2 3 4 5 6 7 8 9 10 1Editing 0 1 2 3 4 5 6 7 8 9 10 1Comments: TOTAL
ECE 477 Final Report Spring 2008
TABLE OF CONTENTS
Abstract 1
1.0 Project Overview and Block Diagram 1
2.0 Team Success Criteria and Fulfillment 2
3.0 Constraint Analysis and Component Selection 2
4.0 Patent Liability Analysis 7
5.0 Reliability and Safety Analysis 10
6.0 Ethical and Environmental Impact Analysis 15
7.0 Packaging Design Considerations 18
8.0 Schematic Design Considerations 22
9.0 PCB Layout Design Considerations 30
10.0 Software Design Considerations 34
11.0 Version 2 Changes 37
12.0 Summary and Conclusions 38
13.0 References 39
Appendix A: Individual Contributions A-1
Appendix B: Packaging B-1
Appendix C: Schematic C-1
Appendix D: PCB Layout Top and Bottom Copper D-1
Appendix E: Parts List Spreadsheet E-1
Appendix F: Software Listing F-1
Appendix G: FMECA Worksheet G-1
-ii-
ECE 477 Final Report Spring 2008
AbstractThe SmartGlove is a Bluetooth device used to control a mouse cursor on a PC
wirelessly. The user wears a sensor-laden glove that captures movement, finger clicks and
gestures. What distinguishes this mouse from most other commercial wireless mice is the
absence of a base station plugged into the host PC and thus the popular PS/2 protocol cannot be
used. Users can install a custom client application (with built-in Windows drivers) on their
computer and thus establish connectivity with the glove and thereby control their mouse cursor
with simple finger movements.
1.0 Project Overview and Block Diagram
This project aims to create a computer peripheral allowing for touch-based control of the
mouse cursor. A glove with sensor-based fingertips will serve this purpose. Pressure levels from
the fingers are going to be captured which will be used to detect the strength of the touch and to
extract gestures from the user. The device uses Bluetooth to communicate with the host
computer.
<Figure 1.1 Block Diagram of System>
-1-
ECE 477 Final Report Spring 2008
.
<Figure 1.2 Glove along with case >
2.0 Team Success Criteria and Fulfillment
Charge battery and manage battery powerSuccessful: System shuts down after battery voltage is below threshold level, charges up to maximum value when USB line connected.
Communicate “mouse commands” wirelessly via a Bluetooth interface.Successful: Sensor data transmitted over Bluetooth using home-brewed protocol for sending and receiving to and from microcontroller to PC Client Application.
Move cursor using motion of a single finger.Successful: Sensor data translated into X-Y coordinates on screen.
Distinguish among cursor movement, mouse clicks, and gestures via finger-tip sensors.Successful: Can perform movement, simultaneous and/or multiple mouse clicks.
Encode and decode gestures Successful: Programmed gestures to perform windows functions such as Page Up, Windows Key, CTRL+ALT+DEL, etc.
3.0 Constraint Analysis and Component SelectionThis project aims to create a human interface device allowing for touch-based control. A glove
with sensor-based fingertips will serve this purpose. Pressure levels from the fingers are going to be
captured which will be used to detect the strength of the touch and to extract gestures from the user
with accelerometers on each finger tips. The device uses Bluetooth technology to communicate with
the host computer. Since the device is wearable wireless device, high power efficiency is required to
-2-
ECE 477 Final Report Spring 2008
operate several weeks without replacing a battery. Also, the product should be small and light enough
so that the user feels comfortable when the glove is in use.
3.1 Design Constraint Analysis
The major requirements of this project are robust Bluetooth communication with host computer
at very low latency, operation at very low voltage to save battery without compensating the precision
of accelerometer readings. Therefore, the desired microcontroller should have high power efficiency
with moderate computation speed to manipulate and transmit sensor readings at real time. The total
components price should be around the price of a high-end gaming mouse since the purpose of this
device is replacing traditional mouse. The accelerometer needs to be very high precision because the
displacement of cursor is very small. The pressure sensor needs to be very tiny and deformable due
to the round shape of the finger tips. The major challenge of this project is making it as small as
possible to fit into a thin glove.
3.1.1 Computation Requirements
The major limiting factor of the computation requirements is latency of the transmitting
sensor reading to the host computer. The entire communication should be done in several
milliseconds. The SmartGlove has three 2-axis accelerometers and three pressure sensors, therefore a
total of nine ATD channels are needed. Bluetooth is also used to transmit data to the computer. As a
result, a microprocessor capable of reading nine ATD channels, manipulating the read data, and
transmitting the processed data sufficiently fast is required. Assuming that processing each ATD
channel, which includes reading an ATD channel, performing calculations, and transmitting, requires
around 1,000 instructions, then a total of around 10,000 instructions will be needed to process all
ATD channels. If each instruction takes around one clock cycle to complete, then 10,000 clock
cycles will be required to perform one round of processing. Assuming that users to not experience
lag when processed data is transmitted every 10 milliseconds, then a total of 1,000,000 clock cycles
should be the target clock frequency for the microprocessor, which is around 1MHz. Most modern
microprocessors have programmable clock speed with the range of several KHz to around 50 MHz.
So, this rules out the computation requirement from the major consideration for this project.
3.1.2 Interface Requirements
-3-
ECE 477 Final Report Spring 2008
The SmartGlove uses many sensors to determine the motion and jesters the users is
performing. Therefore the microcontroller used will need enough I/O pins so that pressure
sensors and accelerometers can all communicate at the same time. Most of these pins will be
ATD channels and the UART interface. With the current design, general-purpose I/O pins are
only used to light up the LEDs.
3.1.3 On-Chip Peripheral Requirements
The current design of this product has three pressure sensors, three accelerometers, and a
Bluetooth module for communicating with the computer. For the pressure sensors, the ability to
determine different levels of pressure is needed. For the accelerometers, one ATD channel will
be required for each dimension. Therefore, six ATD channels will be needed for the
accelerometers. As a result, a total of nine ATD channels will be needed with some extra
general purpose I/O pins to measure resistances of the pressure sensor. The resolution of these
ATD channels should be at least 10 bits to get very accurate reading. Finally, since the device is
using Bluetooth to communicate with a computer, the microcontroller will need a method to
communicate to a Bluetooth chip. The UART interface should be adequate for this purpose.
UART speed should be as fast as possible to reduce latency of communication.
3.1.4 Off-Chip Peripheral Requirements
The SmartGlove will require three accelerometers, three pressure sensors and a Bluetooth
module. There are several constraints should be considered to choose accelerometers. These are
the interfaces, the range of operations and the number of axis. Since the glove will be operated
on a surface, two axis accelerometers will be enough. Also, +/- 1.5g to +/-2.5g accelerometer
will be adequate with typical 5V analog output. The pressure sensor needs to be thin and
sensitive to be used to get a slight finger touch to a computer desk. Typical Bluetooth modules
use 3.3V and some different types of interfacing methods including, USB, GPIO, UART. A
Bluetooth module that has UART will be good for this project since it is fairly easy to
implement.
3.1.5 Power Constraints
-4-
ECE 477 Final Report Spring 2008
To reinforce the portability of the device, the SmartGlove will be battery powered. The
microcontrollers that we meets the criteria mentioned above, has operating voltage range from
2.0V to 5.5V. The SmartGlove will require not only a small battery to be installed in a glove, but
also long battery life. To meet those conditions, polymer lithium ion battery is the only feasible
battery type. It is a very small, extremely light weight battery based on the new Polymer Lithium
Ion chemistry. A typical microprocessor can consume anywhere anyway around 10-100mA of
current depending on clock frequency, manufacturing process, and overall microprocessor
design. A typical Bluetooth device can consume around 50-90mA of current depending on
operational range. Therefore, to use the device longer than a day without charging, a battery
with the rating higher than 200 mAh rating is ideal.
3.1.6 Packaging Constraints
There are several packaging constraints for this device, as the glove worn by the user has
to be both comfortable as well as lightweight. To achieve this we have to pick components that
have minimal surface area while not compromising on the performance of each module. The
final design intends on having three usable fingers (thumb, index and middle) and to fit this
purpose, a pool/billiards glove would be suitable in terms of ventilation and keeping moisture
away from the various components. A larger glove size would be preferred to enable a “one size
fits all” commercial appeal.
3.1.7 Cost Constraints
Infusion Systems currently has a similar product called “TouchGlove” selling for a retail
price of $349.41 [3.4]. Their product is primarily a touch controller which can be interfaced
either wired or wirelessly. They sell their wireless PC interfaces – signal encoder and Bluetooth
transmitter along with a battery pack for a charge of $599. Another firm called Immersion sells a
Wireless data glove called the “CyberGlove” with 22 high accuracy joint-angle movements also
different from our design [3.5]. We are waiting for a price quote we requested from their sales
representatives. Overall, according to our requirements we aim to keep our cost under $350,
which is all-inclusive providing both data capture and communication.
3.2 Component Selection Rationale
-5-
ECE 477 Final Report Spring 2008
The major components for this device are the microcontroller, accelerometer and
Bluetooth module. We will discuss the various candidates that were considered for each
component and our rationale for picking them. For the Microcontroller, we considered the
PIC18F4550 from Microchip and the Atmel ATMega640. Both of microprocessors meet all the
constraints we have, but we decided to select the PIC18F4550 because PIC18F4550 has 13
ATDs [3.2] compared to 16 ATDs [3.1]. Also, PIC has very nice IDE called MPLAB with C18
C compiler and standardized C libraries. The specifications of each microcontroller
have been summarized below:Microchip PIC18F4550 Atmel ATMega640
Operating Frequency 4KHz - 48 MHz 16 MHz
Program Memory Type Flash (32 Kb) Flash (64 Kb)
Ram Size 2K x 8 4K x 8
Number of I/O 35 32
Voltage Supply 2.5V - 5V 2.5V, 2.7V, 3V, 3.3V
ADC 13 16
The accelerometer required for this glove needed to track movements precisely as well
as be small in size and many options were looked at. One sensor we considered was the
LIS3L02AL made by STMicroelectronics, a capacitive accelerometer which worked on
detecting linear movements in the X-Y-Z axis. A range of +/-2g can be detected by the sensor
which is suitable for our glove [3.6]. Another sensor we looked at was the ADXL203CE from
Analog Devices. It was very similar to the LIS3L02AL, with low power consumption and
voltage supply requirements. In terms of size, both sensors were within 0.4 mm of each other,
with the ADXL203CE the bigger of the two measuring 5 x 5 x 2 mm [3.7]. The primary
difference was it being capable of detecting tilt, which is a huge benefit since we do not have to
deal with Z-axis measurements when interpreting the positional data. This was the main reason
that the ADXL203CE was picked over the other accelerometers.
For the Bluetooth module, the WML-C40 manufactured by Mitsumi was selected. Its slim form
factor coupled with UART and USB interfaces made it a good fit for this project [3.8]. The other
module we considered was the 765-RN-24E from Roving Networks which featured a much
higher capable range of operation (nearly 150 ft) as well as consumed less power than the WML-
-6-
ECE 477 Final Report Spring 2008
C40. The major drawback was the RN-24E’s price costing about $100 nearly 40% higher than its
counterpart [3.9].
TENERGY 3.7V 430mAh Polymer Li-Ion battery was chosen over Prismatic 3.7V 110 mAh
Polymer Li-Ion Battery because of its higher rating and smaller size. Its dimension is 4.8cm x
3.0cm x 0.3 cm and the weight is 11g [3.10].
3.3 Summary
Many design constraints had to be taken into consideration in order to achieve the
functionality desired. The selection of the microcontroller was based on the need to interface it
with all of the other components. The PIC18F4550 was chosen to run the entire design. The
other components were selected based on functionality and price. The estimated cost to build
one unit is approximately $350.
4.0 Patent Liability Analysis
There may be several patent liability issues with regards to the method the SmartGlove
utilizes to capture and process hand movement and hand gestures. These will be discussed and
analyzed in detail on the ensuing sections.
4.1 Results of Patent and Product Search
After extensive search through the U.S. Patent and Trademark Office’s website[4.1] and
through freepatentsonline.com[4.2], three patents were found to share similarities to the
functions provided by the SmartGlove.
The first patent found to be relevant to the SmartGlove is U.S. Patent 5581484[4.3] under
the title “Finger mounted computer input device.” This patent was filed on June 27, 1994 and
was granted on December 3, 1996 to Kevin Prince. This patent covers an apparatus that uses a
combination of pressure sensors and position sensors located at the tip of at least one finger to
input data to the computer. An apparatus described by this patent can be used as a keyboard,
mouse, etc. There are three main claims for this patent that are relevant to the SmartGlove.
First, pressure sensors place near the tip of the finger correspond to the pressure of the finger tip
against a surface. Second, acceleration sensors are then also placed near the tip of at least one
finger to detect finger movement. Third, data is transmittable using radio waves.
-7-
ECE 477 Final Report Spring 2008
The second patent found to be relevant to the SmartGlove is U.S. Patent 5819206[4.4]
under the title “Method and apparatus for determining position and orientation of a moveable
object using accelerometers.” This patent was filed on March 20, 1997 and was granted on
October 6, 1998 to Crossbow Technology, Inc. This patent covers an apparatus that uses
accelerometers inside an object to determine dimensional position and orientation. The claims of
this patent says that a plurality of electronic linear accelerometers are mounted on a moveable
object to generated computer simulation signals according to the orientation and position of the
object collected by the accelerometers. The claims then state that computer simulation signals
can comprise video, audio, tactile, and/or sensory information.
The third patent found to be relevant to the SmartGlove is U.S. Patent 4988981[4.5] under
the title “Computer data entry and manipulation apparatus and method.” This patent was filed in
February 28, 1989 and was granted January 29, 1991 to VPL Research, Inc. This patent covers
an apparatus that generates control signals for the manipulation of virtual objects in a computer
system according to the gestures and position of an operator’s hand or other body parts. The
apparatus includes a glove worn on the hand which includes sensors for detecting gestures of the
hand, as well as position sensing means coupled to the glove and to the computer system for
detecting the position of the hand with respect to the system. The patent’s claim states that hand
gestures are determined by the flexure of fingers which are detectable using flexure sensors. The
claims also state that control signals generated by the apparatus are used to manipulate objects on
a display.
4.2 Analysis of Patent Liability
With regards to patent 5581484 under the title “Finger mounted computer input device,”
the SmartGlove is basically a word for word copy of the apparatus described in the patent. The
SmartGlove utilizes sensors mounted near the tip of a finger which are stated in the patent; the
SmartGlove uses Bluetooth to transmit data which is a kind of radio wave which is stated in the
patent’s claim. The only difference is that the patent’s claim state that accelerometers are placed
in orthogonal directions with respect to each other. The SmartGlove uses two axis
accelerometers, which performs the same function. The SmartGlove is literally infringing on
this patent and action will be required if the SmartGlove were to be a commercial product.
-8-
ECE 477 Final Report Spring 2008
With regards to patent 5819206 under the title “Method and apparatus for determining
position and orientation of a moveable object using accelerometers,” there is potential for literal
infringement. One of the patents claims states that the apparatus uses of multiple accelerometers
in a object to generate computer simulation signals. The SmartGlove uses three accelerometers
to detect user gestures. Even though only one accelerometer is used to move the mouse cursor,
all three accelerometer are used to manipulate object on a computer screen. For example, scroll
function can be argued to be a function to manipulation of a window, which is an object. As a
result, the potential infringement exists.
With regards to patent 4988981 under the title “Computer data entry and manipulation
apparatus and method,” the SmartGlove has some distinct differences that could set it apart from
this patent. Both the SmartGlove and the apparatus described in this patent are used to detect
operator hand gestures and movement to manipulate an object on a monitor. However, the
method used to detect gestures is different. The SmartGlove uses accelerometer and force
sensors to detect hand gestures while the apparatus described by the patent uses flexure sensors
to detect flexure of fingers of the user’s hand to identify gestures. Another difference is that the
SmartGlove must be used on a flat surface, while the apparatus is meant to be used in open
space. The method used to detect position is also different. The SmartGlove uses the previous
position of the finger to determine the next position. The device covered under the patent, on the
other hand, calculates the position with respect to the display. Therefore, even though the
apparatus described in the patent produces similar results to the SmartGlove, the method that it
uses to achieve the results is different. As a result, the SmartGlove does not infringe on this
patent, either literally or under the doctrine of equivalents.
4.3 Action Recommended
For patent 5581484, the only method to avoid patent infringement is to redesign the
SmartGlove. This is because the SmartGlove is literally a word for word copy of the patent.
Another option will be to get a license to use the patent.
With regards to patent 5819206 under the title “Method and apparatus for determining
position and orientation of a moveable object using accelerometers,” since the patent’s claim
states that multiple accelerometers is required, a potential redesign will be to use only one
-9-
ECE 477 Final Report Spring 2008
accelerometer in the SmartGlove. This will eliminate the literal infringement because the patent
only covers devices using multiple accelerometers.
The SmartGlove does not infringe on patent 4988981. Therefore, no real action is required.
4.4 Summary
Out of the three patents found, the SmartGlove literally infringes on two of them. The first
patent, patent 5581484 under the title “Finger mounted computer input device,” is a basically a
detailed description of the SmartGlove. Therefore, the SmartGlove heavily infringes on this
patent. The second patent, patent 5819206 under the title “Method and apparatus for
determining position and orientation of a moveable object using accelerometers,” is a partial
literal infringed patent. This is because the SmartGlove uses multiple accelerometers to generate
signals to manipulate objects on a computer screen. The third patent, patent 4988981 under the
title “Computer data entry and manipulation apparatus and method,” the SmartGlove does not
infringe on it despite the similarities. The SmartGlove uses force sensors and accelerometers to
detect user finger position and gestures while the apparatus described by this patent uses flexure
sensor.
5.0 Reliability and Safety Analysis Being portable, the SmartGlove is driven by a battery and allows for charging when
needed. This means that battery failure can possibly injure users in case it catches fire. So,
extreme care is required to make sure safety in order not to cause human casualty. All the parts
used in this project are surface mounted and the components are very small and easily shorted.
Thus, all parts should be properly soldered on the PCB without touching each other and covered
by non-conducting materials. In additional to catastrophic hardware failure, under and over
voltage can cause damage to major components and this should be considered thoroughly.
5.1 Reliability Analysis
The MAX1555 battery charging IC, the PIC18F4550 microprocessor, and the AD8354
amplifier are the three components used by the SmartGlove that are most likely to fail. Out of
the three components, a failure of the MAX1555 would lead to an injury of the user by damaging
the battery. The IC could get burned out if exposed to a high voltage battery or an unregulated
-10-
ECE 477 Final Report Spring 2008
USB line. The PIC18F4550 was chosen because it is one of the most power hungry chips used
in the SmartGlove. The AD8354 was chosen due to the fact that it acts as a medium between the
sensors and the microprocessor. However, damage of the AD8354 op-amp cannot be easily
propagated to the microcontroller or other components since diodes are used to block the inverse
current flows. The following paragraphs utilize the MIL-HDBK-217F model to calculate failure
rates for the three components mentioned above.
5.1.1 PIC18f4550 Microcontroller
The SmartGlove is driven by a PIC18F4550 microprocessor. According to the values and
calculations shown in Table 5.1.1a and Table 5.1.1b, the PIC18F4550 has fairly good MTTF.
However, the MTTF value should be even better. This is because the microprocessor will never
run in an environment where the temperature is 100 degrees Celsius.
Description: CMOS Greater than 60,000 gatesλp = λBD πMFG πT πCD + λBP πE πQ πPT + λEOS Failures/106 hours
(MIL-HDBK-217F, Section 5.3)
Parameter Value Description / Justification or Assumption
λBD 0.16 Die Base Failure Rate: Logic and custom ([5.1], Section 5.3) [5]
πMFG 0.55 Manufacturing Process Correction Factor: QML or QPL ([5.1], Section 5.3) [5]
πT 0.71 Temperature Factor:A digital VLSI chip ([5.1], Section 5.8) [3]
πCD 0.36 Die Complexity Correction Factor:Die area is extremely small ([5.1], Section 5.3) [5]
λBP 0.0036 Package Base Failure Rate:44 pins ([5.1], Section 5.3) [5]
πE 2.0 Environmental Factor:All parts are under same condition, and Gf was picked ([5.1], Sec. 5.10) [5]
πQ 2.0 Quality Factor:Most of the groups are included or better than them ([5.1], Sec 5.10) [5]
πPT 4.7 Package Type Correction Factor:Surface Mount Technology ([5.1], Section 5.3) [5]
λEOS 0.065 Electrical Overstress Failure Rate:0-1000V ESD range is chosen ([5.1], Section 5.3) [5]
λp 1.552 Failures/106 hours
-11-
ECE 477 Final Report Spring 2008
MTTF 6.4433 x 105 hours ~ 73.5 years
<Table 5.1.1a and 5.1.1b. PIC18F4550 reliability analysis>
5.1.2 MAX1555 Battery Charger IC
The MAX1555 is the battery charging IC used in the SmartGlove. According to Table
5.1.2a and Table 5.1.2b, it has a MTTF of around 8 years. This value is not great, but due to the
fact that the MAX1555 is responsible for recharging the lithium polymer battery, this kind of
MTTF is expected. It should be pointed out that the TJ used in the calculation is exaggerated.
During normal use, the temperature should never reach such high levels. Another important
point is that the SmartGlove is not recharging the battery all the time. Therefore, the time that
the MAX1555 IC is in operation is reduced. These two additional factors can help improve on
the MTTF value that was calculated. MAXIM also published their own reliability report for the
MAX1555. According to their report, the chip has a =22.62E-9 [5.4]. Unfortunately, the report
does not go into detail regarding the specifics for the method used to derive the number. The test
data given in the report is also from a small sample group, which is not accurate to point out the
real reliability of the chip.
λp = (C1πT + C2πE)πQπL Failures/106 hours (MIL-HDBK-217F, Section 5.1)
Parameter Value Description / Justification or Assumption
C1 0.045 Digital and Linear Gate/Logic Array Die Complexity Failure Rate: 541 transistors, BiCMOS ([5.1], Section 5.1) [5]
C2 0.002 Package Failure Rate for all Microcircuits:5 Pin, Nonhermetic SMT Packaging ([5.1], Section 5.9) [3]
πT 32 Temperature Factor:Assumptions: TJ=100C. ([5.1], Section 5.8) [3]
πE 2.0 Environmental Factor:All parts are under same condition, and Gf was picked
πQ 10.0 Quality Factor:Commercial Product ([5.1], Section 5.10) [5]
πL 1.0 Package Type Correction Factor:Years in Production >= 2 ([5.1], Section 5.10) [3]
λp 14.44 failures per million hours
-12-
ECE 477 Final Report Spring 2008
MTTF Around 70000 hours, or 8 years
<Table 5.1.2a and 5.1.2b. MAX1555 reliability analysis>
5.1.3 AD8354 Quad Op-Amp IC
The AD8354 op-amps are used within the inverter amplifier circuit between the force
sensors and the ADC channels on the PIC18F4550. According to Table 5.1.3a and Table 5.1.3b,
the AD8354 has a MTTF of 34 years, which is pretty good. The MTTF can be improved by
using a more realistic Tj. The data sheet stated that the maximum Tj is 150C. A more realistic
value such as 50C (which is still very high) will result in a more realistic MTTF value.
λp = (C1πT + C2πE)πQπL Failures/106 hours
Parameter Value Description / Justification or Assumption
C1 0.01 Digital and Linear Gate/Logic Array Die Complexity Failure Rate: Assumption: 100 transistors, BiCMOS ([5.1], Section 5.1) [5]
C2 0.0062 Package Failure Rate for all Microcircuits:14 Pin, Nonhermetic SMT Packaging ([5.1], Section 5.9) [3]
πT 32 Temperature Factor:TJ=150C. ([5.1], Section 5.8) [3]
πE 2.0 Environmental Factor:Ground Fixed Environment ([5.1], Section 5.10) [5]
πQ 10.0 Quality Factor:Commercial Product ([5.1], Section 5.10) [5]
πL 1.0 Package Type Correction Factor:Years in Production >= 2 ([5.1], Section 5.10) [5]
λp 3.324 failures per million hoursMTTF Around 300800 hours, or 34.3 years
<Table 5.1.3a and 5.1.3b. AD8354 reliability analysis>
5.2 Failure Mode, Effects, and Criticality Analysis (FMECA)
For each of the major functional blocks, a schematic is shown in Appendix A. A FEMCA
worksheet outlining the failure modes, effects and criticality analysis for each block is filled out
in Appendix B. The functional blocks are categorized into five as in Table 5.2.1.
No. Functional Block1. Power Supply / Battery Charger Block2. Microcontroller Block
-13-
ECE 477 Final Report Spring 2008
3. Accelerometer Mini-Board Block4. Analog / Touch Sensor Block5. Bluetooth Block
<Table 5.2.1>
The FMECA report for each block above is based on these definitions of criticality
levels. A “High” criticality level corresponds to injury to the user or a loss of functionality due
to irreparable damage. “Medium” levels are deemed to failures which lead to a single block
being inoperable while causing no harm to the user. A “Low” criticality level consists of
damage that can be fixed such as faulty cabling or other minor issues.
Criticality Failure Effect Maximum Probability
High Harm to the user or no functionality p 10-6
Medium No harm to the user and partial functionality 10-6 p 10-9
Low Reparable damage or minor flaws p > 10-6
<Table 5.2.2>
In terms of personal injury, a failure mode of the power supply and charging block is the only
conceivable way the user can hurt themselves. Either through battery leakage or potentially an
explosive battery if overcharging occurs or the charging rates is too fast. Other non-hazardous
high criticality levels were major system failures such as having a dead microcontroller or
improper voltage supply. A standard maximum probability of p 10-9 was picked for this level.
Other criticality levels such as medium were assigned probability rates that are reasonable
considering their failure effects. These rates are outlined in Table 5.2.2.
5.3 Summary
After analyzing all the functional areas and components and their criticality levels, one
can conclude that none of the components used stand out as being completely unreliable. It
would require some kind of malfunction on the part of the other components or human error to
cause a serious problem. In terms of safety hazards, the battery charger circuit block stands out
as the single source of possible bodily harm. If the battery charger IC unit is damaged in some
way, there could be damage to the battery such as leakage of toxic materials or explosive
behavior. Several precautions have been taken to avoid these circumstances both in hardware
-14-
ECE 477 Final Report Spring 2008
and software and the enclosure used to case the main PCB seems strong enough to protect the
user from serious harm.
6 Ethical and Environmental Impact AnalysisThe ethical implications of this device are primarily sending data over Bluetooth in a
secure and reliable way. The information passed by the sensors should not be seen or
manipulated by any third-party individual on a PC. The environmental impact of this device is
not a significant concern since the device and its components are small in size, although traces
amounts of lead can still be hazardous to users. Disposal of the battery within the main casing is
also an environmental concern.
6.1 Ethical Impact Analysis
The SmartGlove may seem like a product that has few ethical concerns. However, as a
product designed for the general mass public, even the slightest mistake could cause serious
problems. These problems could result in class action lawsuit, injury, loss of property, etc. The
following paragraphs will explain the ethical issues in depth.
Responsible use of wireless technology is an area of ethical concern. Security is a major
issue that could cause problems. A poorly implemented wireless communication protocol can
cause the computer to be vulnerable to attack. Hackers can exploit the loopholes in the
protocol's architecture to gain control of the computer. An example of such an application is
RedFang by Ollie Whitehouse, a small application which simply tries to connect to a
unique Bluetooth address one by one, until finally a hidden device answers the request that
was sent to that particular address [6.8]. The SmartGlove uses Bluetooth connectivity to
transfer data to the computer. To improve security, a passkey [6.1] should be made mandatory to
connect to the computer. Another method is to encrypt all data that is transferred.
User convenience is also an area of concern. First, the SmartGlove is designed as a right
handed only product. This excludes all left handed people for having the chance of using the
product. To solve this issue, tweaks to the SmartGlove should be made so that both right handed
and left handed people can use the product. Second, not including the option to use the
SmartGlove through a wired connection could also be an inconvenience. For example, wireless
-15-
ECE 477 Final Report Spring 2008
technology is not allowed to be used aboard an airplane. Therefore, the design of the
SmartGlove should be modified so that users can use the device with an alternate wired
connection.
Safety is also an area of ethical concern. Ensuring that the user will not be harmed during
the use of the SmartGlove is critical. Since the SmartGlove is a non-conventional human
interface device, one concern is that possibility of hand or arm injury during extensive use.
Carpal tunnel syndrome [6.2] is one of the possible injuries that could happen. Carpal tunnel
syndrome could be cause by repetitive grasping and movement of the hand, which is what users
have to do in order to operate the SmartGlove. Another possible safety hazard comes from the
lithium polymer battery [6.3] that is incorporated in the SmartGlove. Lithium polymer batteries
have been known to be unsafe when operating in less than stable environments. For example,
high temperatures could cause the lithium polymer battery to catch on fire and/or explode. To
address these issues, warning labels should be placed on the device to warn the user of the
potential hazards that could happen. In addition, guidelines for safe use of the product should be
included in the user manual.
6.2 Environmental Impact Analysis
Throughout the life cycle of this product, there will be various environmental impacts.
This life cycle starts at the manufacturing stage, and continues to the normal use stage, and
finally the disposal/recycling stage. The SmartGlove will go though the same stages as well.
The following paragraphs will explain the various environmental impacts that could be caused
by the SmartGlove.
During the manufacturing stage, the fabrication of the printed circuit board (PCB)
requires the use of hazardous chemicals generating many harmful byproducts. There are waste
sources which happen during Cleaning/Surface Preparation, Catalyst application/Electroless
plating, Pattern printing/masking, Electroplating and Etching. At the Pattern printing/masking
stage, it spends time in a developing solution, resist removal solution, and acid solution and the
byproducts include rinse water made by Vinyl polymers, chlorinated hydrocarbons, organic
solvents and alkali. At the Electroplating and Etching stages, it spends time in plating bath and
etchant and waste byproducts are rinse water and alkali solutions respectively. Waste stream
compositions by those stages are copper, nickel, tin, tin/lead, gold, fluoride, cyanide, sulfate, iron
-16-
ECE 477 Final Report Spring 2008
and acids. Also, acids, stannic oxide, palladium and chelating agents are spent during the catalyst
application and Vinyl polymers, chlorinated hydrocarbons, and alkali are spent during printing
and masking. Solder used to mount components onto the PCB also contain Lead. Lead is a
harmful element that can cause lead poisoning if exposed to any person. To reduce
environmental impact, using RoHS [6.5] complaint manufacturing methods should help.
Triangle Circuits has been pro-actively developing and implementing a lead-free, RoHS
(Restriction of Certain Hazardous Substances) manufacturing process and working with
suppliers regarding lead-free printed circuit board materials [6.9]. The SmartGlove should
be manufactured by Triangle Circuits Company to reduce hazardous chemicals generating
many harmful byproducts.
During the normal use of the SmartGlove there is an environmental concern which is RF
[6.4] emissions from Bluetooth. Bluetooth RF wireless cannot be used in certain areas or
scenarios, such as on an airplane. The airlines do not allow any electric machines to be used
while taking-off and landing until the technology has been proven safe. Also, users are exposed
to small doses of RF energy. However, with such a small field and low operating frequency, the
risk is significantly less than what you would find in cell phone being used every day. So, the
health risks to users of the SmartGlove are insignificant. In addition, users should be careful not
to use the SmartGlove in extreme conditions. High temperatures can damage the battery and
decrease battery life.
When a product reaches the end of its life cycle, it must be disposed properly. The
SmartGlove should also be disposed appropriately. The PCB may contain harmful substances
such as Lead and the Lithium polymer battery could still harm people even though the
SmartGlove once it is no longer usable. Furthermore, the SmartGlove contains components such
as the battery that can be recycled [6.6]. Rechargeable batteries contain materials of good value
that can be recovered and re-used. For example, the Cobalt (Co) in Lithium Ion batteries which
the SmartGlove will use can be used in magnetic alloys. Nickel (Ni) and Iron, from Nickel Metal
Hydride and Nickel Cadmium batteries, can be used in stainless steel; the Cadmium (Cd) can be
used to make new rechargeable batteries. It therefore makes good economic sense to recycle
rechargeable batteries. Another reason to recycle is that some materials in rechargeable batteries,
such as cadmium, are also hazardous to human health and the environment. It is better to
properly collect and recover these materials rather than risk them seeping into the environment
-17-
ECE 477 Final Report Spring 2008
[6.6]. The best form of action is to bring the SmartGlove to a local recycling center. If a
recycling center cannot be located, websites such as freecycle.org [6.7] could help.
6.3 Summary
From this analysis, it is very clear that many ethical and environmental issues have to be
addressed. The SmartGlove has some ethical issues such as Bluetooth security, being right
handed, and user safety. Also, the device faces a number of environmental issues during
manufacturing, normal use, life time and disposal. Since the SmartGlove is a computer
peripheral and small in size, it does not cause any significant concerns, but any minor issue has
to be completely addressed. Safety of customers and all possible ethical/environmental
considerations have to be guaranteed in order to make the SmartGlove a complete product upon
commercial release.
7 Packaging Design Considerations
Packaging is important for this device because as with all human interface devices, users
have to feel comfortable using it. This means the packaging for this product has to be small and
flexible. First of all, finger movement detection should be done without hindering user comfort.
Second, pressure sensors need to be placed that the optimal location so that users can still do
other things such as typing on the keyboard without the need to take off the device. Third,
separating the PCB from the sensors can help reduce overall size of the device and make using
the device more comfortable due to the fact that placing the bulky PCB on the hand will impede
wrist movements and overall dexterity. Fourth, using wireless technology as the means to
communicate with the computer is also important because a wired connection makes the device
unintuitive and difficult to use. Another bonus would be to package this product with low cost
components so that it could be competitive with traditional human interface devices.
7.1 Commercial Product Packaging
Since this project is based on creating a non-conventional human interface device, only a
handful of similar commercial products exist on the market. However, out of the limited number
of similar products, the TouchGlove and the CyberGlove II are two commercial products that
stood out for their uniqueness and functionality. Note that the TouchGlove and the CyberGlove
-18-
ECE 477 Final Report Spring 2008
II are not made to manipulate mouse movement, but the technology and packaging used is never
the less similar.
7.1.1 TouchGlove
The first commercial product compared was Infusion
Systems’ TouchGlove. The TouchGlove is a 6-channel pressure-
sensing data glove built to capture touch input. According to
Infusionsystems.com, it can be interfaced to a Digitizer which can
encode sensor signals to multimedia industry compatible MIDI
messages. It can then transmit these messages to a computer in real-time and thus one potential
application is using the TouchGlove as a fingertip controller for a virtual drum set [7.1].
There are many positive aspects of this product. First, it has a very simplistic package,
which makes it user friendly. Second, it has a very good response time of 1-2 ms [7.1]. Third,
its light weight (90g) makes it an ideal human interface device. Fourth, excellent sensitivity
makes this product suitable for applications that require precise data readings. There are also
many negative aspects of this device. First, this device costs $359.18, which makes it too
expensive for regular consumer use. Second, the device is not wireless, which makes using the
device feel unnatural as hand movement is limited by the wire that is connected to the computer.
The TouchGlove is unique in many ways. First of all, it uses 6 pressure sensors - one on
each fingertip and one on the palm. This is slightly different from this project because the
SmartGlove has 3 pressure sensors and 3 accelerometers in total but the packaging is very
similar to this project. Another important difference is that the TouchGlove is wired while this
project uses Bluetooth to communicate with the host computer. To enable any wireless
communication with the TouchGlove you would have to buy a $500 wireless kit which includes
their Bluetooth module and battery pack.
7.1.2 CyberGlove II
Another comparable commercial product is the wireless data glove, the CyberGlove® II
System built by Immersion Technologies. The basic CyberGlove II data glove includes one
motion capture glove, two batteries, a battery charger, and a USB/wireless technology adaptor
with drivers. According to Immersion.com, the
-19-
ECE 477 Final Report Spring 2008
CyberGlove transforms hand and finger motion into real-time digital joint-angle data—and
works without cumbersome wires that can impede motion or slow movement. The CyberGlove
motion capture system has been used in a wide variety of real-world applications, including
digital prototype evaluation, virtual reality biomechanics, and animation. It uses proprietary
resistive bend-sensing technology to accurately transform hand and finger motions into real-time
digital joint-angle data [7.2]. The biggest difference between CyberGlove II and the SmartGlove
is its implementation. Instead of using bend-sensing technology and capturing the action of
fingers and hand movement, pressure sensors and accelerometers are used for touch-based
control.
There are many defining characteristics for the packaging of the CyberGlove II. The
glove consists of a stretch fabric with open fingertips while a plastic casing is used to house the
electronic components which straps to the users forearm. A single wire runs from the glove to
the forearm module. The packaging design of the CyberGlove II will be extremely similar to this
project except the fact that the module worn on the arm will be more compact and the glove will
be closed tip.
There are three main positive aspects of this device, all of which would benefit on the
SmartGlove project. First, it has an armband to carry the forearm module of the device. This
design makes the CyberGlove II make natural to use. Second, the fact that it runs on battery
power eliminates the need for potential wires that can hinder the user’s experience. Third, using
wireless technology to communicate with the computer means total freedom as to how the device
is to be used. Some drawbacks include its bulky appearance, as well as its weight (about 27 oz.)
[7.3].
7.2 Project Packaging Specifications
The SmartGlove will be packaged in a small plastic enclosure for the Forearm module (Fig 2
of Appendix A) which is connected to a thin billiard glove (Fig 1 of Appendix A). An
ergonomically designed casing was picked making it wearable and this improves its usability.
The PIC18F4550 microcontroller and the Mitsumi WML-C40 Bluetooth module will be on the
forearm casing. Two types of sensors, force sensors and accelerometers will be attached on the
fore sides and back sides of the fingers, respectively. Twisted wires will be used to attach those
-20-
ECE 477 Final Report Spring 2008
sensors with the PCB. The lithium polymer battery will be placed on top of side or the plastic
box in order to protect user’s hand if it gets too hot.
The estimated weight of the whole device is about 50 g. The heaviest part of the device is the
PCB and the plastic enclosure. The battery’s weight is 11 g and that makes about 22% of the
total weight [7.4]. The estimated dimensions of the PCB are 65 mm x 35 mm while the case is
about 80 mm x 93 mm x 30 mm. Most of the space is filled with battery on the top side and the
bottom side is filled by the PCB.
7.3 PCB Footprint Layout
The major components used on this device are the microcontroller, Bluetooth module,
accelerometers and force sensors. Since size is a major constraint, most components were
selected based on their size and weight. The packaging chosen for the microcontroller was the
TQFP type understandably because of its compact size versus the PDIP package. The
microcontroller covers an area of 144 mm2 [7.5]. The Bluetooth module will be on the PCB and
it comes in a surface mounted package style covering an area of about 225 mm2 [7.6]. Other
significant components are the IC package for the battery charger and a micro-USB connector.
The accelerometer and force sensors are off-chip and do not need a footprint for the design. An
analog area was also placed on the PCB for manipulation of the signals that are coming in from
the sensors. The analog circuitry mainly includes inverter amplifier circuits needed to measure
resistance of the force sensors. Another area of the PCB has been dedicated for debugging
purposes and there are 3 LEDs to detect touch signals, 1 LED for power and 2 more LEDs to
detect transmissions and retrieved data through Bluetooth. Two miniature DPST pushbuttons are
also included for reset and general purpose functions.
7.4 Summary
The SmartGlove aims to be packaged with the most lightweight material while being both
comfortable, usable and aesthetically appealing at the same time. Prior to picking packaging, two
commercial products – the TouchGlove and the CyberGlove were extensively looked at and the
best aspects of each packaging design were chosen for this project. The glove chosen was a
billiards glove with material similar to that of the TouchGlove and an ergonomically designed
plastic casing was chosen for the module which is worn on the forearm just like in the
-21-
ECE 477 Final Report Spring 2008
CyberGlove. The overall design aims to have a slim form factor and the battery was also picked
based on this consideration. Based on Appendix B which lists all electrical components, a rough
calculation of area was made and this led to the decision of using a PCB of 65 mm x 35 mm.
8 Schematic Design Considerations Since the accelerometer is very sensitive and vulnerable to noise, it is very important to
minimize noise from accelerometers and wires. Also, because the force sensor has very high
force-sensing resistance within it, it is critical to amplify input voltages high enough to detect
applying force. All the components should be on the 64mm by 54mm by 3 mm PCB to fit into
the enclosure. The components were chosen to maximize space efficiency.
8.1 Theory of Operation
Accelerometer
The accelerometer (Figure 2.1b), ADXL213AE, measures acceleration with a range of ±1.2g
and has both digital and analog outputs [8.1]. Here, we are going to use analog outputs which
will be measured by the ATD converter in the microcontroller [8.2]. The range of the output
signal is 0 to 5V that is proportional to acceleration. Therefore, -1.2g and +1.2g of acceleration
will generate 0V and 5V respectively with a 2.5V bias.
<Figure 8.2.1a: ADXL213AE block diagram>
The accelerometer bandwidth selected will determine the measurement resolution as well as
the smallest detectable acceleration. We can select the bandwidth of the accelerometer using
capacitors Cx and Cy at XFILT and YFILT. The internal resistor (32Kohm), inside the chip, is used
to construct a single-pole low-pass filter by adding external capacitors, Cx and Cy, which
improves measurement resolution and helps prevent aliasing of the output signal. However, noise
is proportional to the square root of the accelerometer’s bandwidth, thus bandwidth should be
-22-
ECE 477 Final Report Spring 2008
limited to the lowest frequency in order to maximize the resolution and minimize the noise.
According to the datasheet, a 0.47uF ceramic capacitor could be used to get 10Hz bandwidth
resulting in a maximum peak-to-peak noise level of 3.8 mg while a 0.1uF ceramic capacitor
could be used to get 50Hz bandwidth with 8.6 mg’s of peak-to-peak noise [8.3]. The noise in
output voltage can be determined by
Noise = (peak-to-peak noise / 2.4g) * 5V
At 10 Hz, the noise is
Noise = (3.8mg/2.4g) * 5V = 7.91mg
And, at 50 Hz, the noise is
Noise = (8.6mg/2.4g) * 5V =17.91mg
The percentages of the noise in output voltage are 0.15% and 0.35% at 10 Hz and 50 Hz,
respectively. Before the right bandwidth is selected, one more thing to be considered is aliasing.
To avoid aliasing, the analog bandwidth must be no more than half the A/D sampling frequency.
PIC18F4550 has a clock speed of 48MHz and this is fast enough to avoid aliasing because
48MHz is much more than twice of both 10 Hz and 50 Hz. We decided to use 50Hz bandwidth
for our project to archive both high bandwidth and relatively low noise.
A follower circuit (Figure 8.2.1c) for each accelerometer will be used to decrease output
impedance of the accelerometer since PIC18F4550 ATD requires an input impedance lower than
2.5Kohm to work correctly. A follower circuit constructed with the AD8532 (rail-to-rail, single
supply source) operational amplifier, enables the ADXL213AE to transfer a voltage to
microprocessor [8.4]. A low impedance transmission line also picks up less noise.
-23-
ECE 477 Final Report Spring 2008
<Figure 8.2.1b: The accelerometer (ADXL213AE) schematic>
<Figure 8.2.1c: The schematic of follower circuit>
-24-
ECE 477 Final Report Spring 2008
Pressure Sensor
The Flexiforce sensor acts as a force sensing resistor in an electrical circuit. When the
force sensor is unloaded, its resistance (Rs) is around 1Mohm which is very high. When a force
is applied to the sensor, this resistance decreases. For this application, we need a voltage
measurement corresponding to the resistance to gauge the force applied [8.5].
<Fig 8.2.2a: an inverting operational amplifier>
The circuit above uses an inverting operational amplifier to produce an analog output
based on the sensor resistance and a fixed reference resistance (RF). The inverting amplifier’s
gain relationship is
Vout = -Vin (RF/ Rs)
From the equation, a decrease in Rs results by applying force to sensor and thus Vout
increases. For a fixed reference resistance, RF, 300Kohm was picked to have good sensitivity as
we desired. To get a positive value for Vout, it is required to provide -5V supply to the op-amp.
The ADM8829 voltage inverter IC was used to achieve that goal [8.6].
-25-
ECE 477 Final Report Spring 2008
<Fig 8.2.2b: The force-to-voltage circuit schematic>
Bluetooth module
The WML-C40 Bluetooth module has a wide voltage supply range and is capable of
communication via UART, PCM, and USB interfaces [8.7]. The signals received from the
computer Bluetooth transmitter and will pass through the WML-C40 to the PIC18F4550 via RX
and TX serial communication channels which are pins 13 and 14 on the module. Although the
Bluetooth module officially uses 3.3V, internal protection circuits will allow us to use 5V rail
and logics.
<Fig 8.2.3a: The Bluetooth module schematic>
-26-
ECE 477 Final Report Spring 2008
Battery charger
The SmartGlove is battery powered using a polymer lithium-ion battery. The MAX1555
battery charger IC can charge a lithium-ion battery from either USB or AC adapter sources. To
reinforce the portability of the device, USB power will be used to charge the battery. A green
LED will indicate if the power is on or not [8.8].
Furthermore, a Schottky rectifier, FBR130, is connected to power so that the device has very
low forward voltage drop. Also, ceramic bypass capacitors are placed within 1cm in the design
which is highly recommended by the manufacturer.
<Fig 8.2.4a: The battery charger circuit schematic>
8.2 Hardware Design Narrative
The primary subsystem utilized within the microcontroller is the ATD module. Each
accelerometer outputs two signals (corresponding to X and Y directions) while the force sensor
outputs one signal. Putting all these sensors together, it adds up to a total of 9 analog inputs. The
pic18f4550 has a total of 13 ATD channels [8.1] which should suffice for this purpose. The
accelerometer has a voltage range of 0 to 5 V while the force sensor has a voltage range between
0 and 3.4 V. The upper voltage limit for the force sensor can be adjusted depending on the size
of the resistor used on our inverting amplifier circuit. A digital filter will be implemented in
-27-
ECE 477 Final Report Spring 2008
software in addition to the analog filters, to reduce the effects of noise on the sampled
conversions.
Besides the ATD module, the SCI interface is also used in the form of UART serial I/O
module. This module is used to interface with the Bluetooth radio (WML-C40). The WML-C40
is programmable to work with different baud rates and a rate of 38.24K was picked for this
application. A total of 2 pins, one for transmission and one for receiving will be needed on the
microcontroller.
Signal Pin Name
Accelerometer 1 – X RA0
Accelerometer 1 – Y RA1
Accelerometer 2 – X RA2
Accelerometer 2 – Y RA3
Accelerometer 3 – X RA5
Accelerometer 3 – Y RE0
Force Sensor 1 RB1
Force Sensor 2 RB2
Force Sensor 3 RB3
UART Rx RC6
UART Tx RC7
<Table 8.1: Microcontroller pins and associated signals>
-28-
ECE 477 Final Report Spring 2008
<Fig 8.3.0a: The microcontroller (PIC18F4550) schematic>
8.3 Summary
The project has two major input components, the accelerometers/force sensors and the
Bluetooth module. Since the SmartGlove aims to create a portable computer peripheral allowing
for touch-based control, it is required to detect finger movement and finger tapping precisely.
The circuit consideration of the sensors focuses primarily on eliminating noise and amplifying
those sensors’ output. For the other components, it is very important to fully understand how the
circuit design provided by manufacturer works and why each component is needed.
-29-
ECE 477 Final Report Spring 2008
9 PCB Layout Design Considerations
The PCB for this device is important because the SmartGlove depends on three force
sensors and three accelerometers [9.2] to operate correctly. However, all of these sensors are
analog sensors, which make them susceptible to EMI. Therefore the main focus for the PCB
design will be to reduce EMI. The size of the PCB will also be a factor in the PCB design
because it determines how big and bulky the SmartGlove is going to be. A large PCB will make
the packaging of the SmartGlove large and therefore affecting the user from naturally using the
device. As a result, the main goal to achieve with the PCB layout is to make the PCB as small as
possible while keeping EMI at a minimum.
<Fig 9.1. Final PCB layout>
9.1 PCB Layout Design Considerations - Overall
Noise is one of the definitive factors when it comes to the success of this PCB design. Nine
different analog signals are fed into the microcontroller for this project. Ensuring that these
signals remain free from EMI is critical. The Motorola Application note was a key reference on
how to improve the performance of the ATD module by isolating these signals away from power
or ground lines, as well as digital signals which are frequently responsible for corruption of those
signals [9.1].
-30-
ECE 477 Final Report Spring 2008
On the main PCB, several sections were laid out for analog circuitry, battery
power/charging, Bluetooth [9.5] and other components such as pushbuttons and LEDs. Bypass
capacitors are laid throughout the design to reduce EMI from power sources. The crystal
resonator is known to be a big source of EMI [9.1] and this has also been addressed, by keeping
it on the bottom copper layer of the PCB and secluded from surrounding traces.
The analog circuitry used primarily comprised of op-amps [9.3] performing amplifications
on different signals. As suggested in the app note, filters were used for all analog signals coming
in from the accelerometer breakout board and the touch sensors [9.4]. The accelerometer IC has
an internal resistor which can be coupled with a capacitor (of any size) to have any desirable
bandwidth. So, these capacitors were used on the breakout board along with bypass capacitors.
<Fig 9.2. Inverting amplifier>
One important constraint when laying out the PCB was size and it is planned to use a 5” x 3”
board, keeping in mind that it has to be as small as possible. The limited real estate brings the
traces closer together and increases the number of vias used. All the components chosen were
surface mounted which allowed for more room to work with. The power and ground line traces
were kept apart as much as possible and their sizes were kept at a size of 60 mils. In terms of
routing the signals, there were problems due to the limited space and the presence of loops. A
large number of vias were used and the traces were extremely convoluted. This was fixed by
rotating the alignment of the microcontroller by 90o. This reduced the distance of the traces from
the headers to the ATD pins. Other trace widths were kept at the standard size of 12 mils since
most of the current hungry traces were isolated near the battery charger [9.6] circuit area.
Breakout boards are placed with the left side of the main PCB. Those will be cut with a saw
and placed on the tip of the finger. The breakout boards contain three small capacitors with one
-31-
ECE 477 Final Report Spring 2008
resistor on it. The size of the board is 0.3’’ x 0.3’’ and both front side and back side are used.
Since accelerometers are small leadless chip container it is important to make padstacks long
enough for easy soldering.
<Fig 9.3. Breakout Board>
9.2 PCB Layout Design Considerations - Microcontroller
PIC18F4550 Microcontroller is on the center of main PCB and connected with most of the
off-chip components used. The microcontroller is the very crucial part of the entire layouts
because the chip and nearby traces uses largest area. 16 pins out of 44 pins are used. Also, four
11 pins headers with 100 mil spacing surround the microcontroller to ease development. This
will also enable to replace IO pins when an unexpected event happens to the board. All the
external signals are connected through these headers rather than connected directly to the
microcontroller. However, FRB140, surface mount 20 MHz crystal resonator and its passive
circuitry are directly connected to the microcontroller from back side of the microcontroller with
three bypass capacitors. The values and locations of the capacitors near the microcontroller are
carefully determined and those are connected through vias right underneath of the
microcontroller package. In this way, the trace distances from those components to the
microcontroller are minimized and it will guarantee the microcontroller’s correct behavior.
PIC18F4550 reference guide and FRB140 datasheet were used in this process.
-32-
ECE 477 Final Report Spring 2008
<Fig 9.4. PIC18F4550 Microprocessor>
The power and ground traces size to the microcontroller near the headers are 40-mil in order
to support the needed power requirement and all other traces size are kept at the standard 12-mil.
The orientation of microcontroller is chosen to minimize the trace length from the sensor to the
microcontroller. This approach compensate with the distance of TX and RX traces of the
Bluetooth, but sensors inputs are analog and very sensitive to noise. Therefore, minimizing
distances from sensors are chosen over minimizing other distances.
9.3 PCB Layout Design Considerations - Power Supply
The power supply circuit for the SmartGlove consists of a lithium polymer battery, a battery
charging IC, and a USB connector for battery recharging. The lithium polymer battery is used to
power the SmartGlove, while the battery charging IC is used to recharge the battery when there
is a USB connection. All components on the PCB can operate at 5 volts, which makes the PCB
design easier as multiple ranges of voltages will not have to be generated. However, the lithium
polymer battery used in the SmartGlove operates at 4.1 volts. Therefore, a conversion from 4.1
volts to 5 volts is required. The SmartGlove uses the MAX1551 battery charging IC chip to
handle all the voltage related operations. The power supply circuit is designed as recommended
on the MAX1551 data sheet.
The 5 volt trace along with the GND trace is traced around the outer edge of the PCB to
reduce EMI. This is because all of the SmartGlove uses analog circuits to communicate with the
force sensors and accelerometers. Therefore tiny changes in voltage could cause the SmartGlove
-33-
ECE 477 Final Report Spring 2008
to behave incorrectly. The fact that all sensor are located far away from the PCB makes reducing
EMI even more important. Analog circuitry and digital circuitry is also separated to further
reduce EMI.
The SmartGlove uses three small breakout PCBs to accommodate the accelerometers.
These three breakout PCBs are designed to be as small as possible to fit on the tip of three
fingers. Power to these accelerometers will be provided through the main PCB using twisted
wire pairs.
9.4 Summary
PCB design and layout considerations can greatly affect the operation and stability of whole
system. The techniques noted, such as the routing of the power system and the usage of
decoupling capacitors near dynamic components will help to ensure to precisely approximate
movements of fingers from raw acceleration inputs.
10 Software Design Considerations
Since the microprocessor used in the SmartGlove is running at fairly high speed, not being
able to compute all the data is not an issue. Therefore, the focus is to bring out the best user
experience out of the device. The user should not have to suffer from the lack of resolution for
the movement of the mouse cursor nor should they have to wait for an event to happen after they
performed a gesture.
10.1 Software Design Considerations
The SmartGlove is powered by a Microchip PIC18F4550 microcontroller. This
microcontroller has 32KB of Flash and 2k of SRAM[10.1], which should be sufficient to
perform the functions necessary for the SmartGlove. The PIC18F4550 is designed using the
Harvard architecture. Under this architecture, the Data and Program memories use different
busses; therefore, the SRAM and flash memory on the PIC18F4550 do not share the same
address range. Flash has an address range from 0x18h to 0x7FFFh. 0x0 to 0x18 is reserved for
the interrupt service handler and reset logic. SRAM has a data range from 0x0h to FFFh.
Variable declarations will start from 0x0 and grow down to FFFh while the stack starts at 0xFFF
and grows up to 0x0h. Global variables declared statically in SRAM will be used for all major
-34-
ECE 477 Final Report Spring 2008
variables. This includes Force Sensor pressure values, accelerometer values, and various flags
and counters. The stack is used for local variables and parameter passing. Stack overflow
should not be a problem because the majority of the data has been statically declared at compile
time. Most local variables will be temporary variables, loop counters, and buffers. SRAM will
be used for all variables due to the fact that it is fast and the SmartGlove requires fast I/O
operations. Only the application code itself will be present in flash.
The I/O ports used by the SmartGlove comprises of nine ATD ports, the UART interface,
and standard I/O ports for LEDs and push buttons. The accelerometers are mapped to pins RA0
– RA3, RA5, and RE0; force sensors are mapped to pins RB1 – RB3; and the UART interface
used by the Bluetooth module is mapped to pins RC6 – RC7.
All event of the SmartGlove are triggered by the force sensor. If the force sensor is not
active, then the SmartGlove should not do anything. Therefore, using a hybrid approach to
organize code would be reasonable. During normal operation, the SmartGlove will run in a pull
loop that retrieves, processes, and sends data. However, during the even when the SmartGlove is
idle for a set period of time, the microprocessor sleeps to save power. The PIC18F4550 has a
sleep mode in which the microprocessor powers down all major components such as the clock
and on chip peripherals. The microprocessor can then be reawakened by interrupt on a
predefined port pin. Idle time of the SmartGlove is determined by an idle counter that
increments each time the idle flag is set. However, during the time that the microprocessor is
sleeping, it will wait for a force sensor interrupt to reawaken itself. An alternative way to
implement the application will be to use a polling loop without interrupts. This way has its
advantages in that noise in the force sensors can be easily filtered out using a preset minimum
activation force value. All force values retrieved from the force sensors that are below this value
will be considered not active. Therefore, during power save mode, the SmartGlove can stay in
power save mode for a longer amount of time when in an environment of high noise. The hybrid
method of code organization will be at its worst case scenario in terms of power saving when
operating a high noise environment because the force sensor is constantly causing interrupts,
preventing it from going to sleep. However, with the pulling loop method, the microprocessor
cannot go to sleep, therefore, power saving can only be done through lowering of the clock
frequency. On the other hand, due to the architecture of microprocessor and the design of the
SmartGlove, lowering the clock frequency could cause serious side effects. Considering the
-35-
ECE 477 Final Report Spring 2008
possible failure due to lowering the frequency of the microprocessor, the hybrid method was
chosen.
10.2 Software Design Narrative
There are five main code modules that are run by main. These blocks are Force Sensor,
Accelerometer, Bluetooth, Power, and System Functions. All code is written in C using
microchip’s MPLab with C compiler.
The sensors used on the SmartGlove are controlled by two modules, the Force Sensor
module and the Accelerometer module. Both of these modules read data from the ATD
converters located on the PIC18F4550. In terms of code organization, both of these modules use
a pull-loop to read values from the ATD converters. Every time the main program loop loops
through the code, the ATD sensors are read once, depending on which code module is currently
being executed.
The Force Sensor module has two main purposes, retrieve and process. The retrieve
function works simply by retrieving data from the three force sensors and stores them. The
process function then takes the data stored by the retrieve function and determines if any of the
force sensors are active. If the sensors are active, then the force sensor active flag is set and
pressure levels for each of the three force sensor is computed. Pressure level is determined by
the average force over a predefined number of reads from the ATD converter. The final results
are then stored into global variables. If the force sensors are not active, the force sensor flag is
cleared.
The Accelerometer module functions similar to the Force Sensor module. Data is retrieve
from the three accelerometers and motion is determined by the average motion over a predefined
number of reads from the ATD converter. Since the accelerometers used in the SmartGlove are
two axis accelerometers, a total of six sets of data will need to be computed. Therefore, this
module is the most compute intense module in the device. Turning off this module when not
used can help save power.
The Bluetooth module’s main purpose is to send data from the SmartGlove to the
computer. The sending of data through Bluetooth is triggered by a send counter. When the send
counter reaches a curtain number, the Bluetooth module retrieves processed force sensor and
accelerometer data and encodes it to be transferred. Then the data is sent to the Bluetooth chip
-36-
ECE 477 Final Report Spring 2008
through the UART interface to be sent to the computer. The send counter is reset to zero and the
routine is exit. Currently, this module is in its initial coding.
The Power module controls the power state of the device. An idle counter is used here to
indicate the amount of time the device has been idle. Each time the idle flag is set, the idle
counter is incremented. When the idle counter reaches a predefined number, the Power module
switches the device to low power mode which sleeps the microprocessor. When the device is in
low power mode, the microprocessor waits for an interrupt to happen in the event that any of the
three force sensors detect force being applied. When this happens, the idle flag is cleared by the
interrupt and the idle counter is reset to zero. Then the SmartGlove wakes up the microprocessor
and the pull loop can begin.
The System Functions module’s main purpose is to perform miscellaneous tasks that do
not belong to any of the other four modules. For example, reading the various flags to set the
LED indicators. The module also shuts down the device when the battery is running low on
power. The push buttons used to reset the SmartGlove is also handled in this module. Currently,
this module is being coded.
10.3 Summary
The most important part of this software should be the seamless interaction between the
user, the SmartGlove, and the computer. This means no lag, delays, or inaccurate data being
transferred. To achieve this, unnecessary work should be minimized so that most of the
microprocessor’s resources can be used to compute and send data. At the same time, power
saving should also be a major factor in the software design as nobody likes to constantly
recharge their human interface device.
11 Version 2 Changes
There are several improvements that can be made to enhance this product. Distance
calculated by double integrating acceleration proved to be inaccurate and unreliable. Replacing
the accelerometer with a more robust IC and adding a gyroscopic sensor might eliminate this
problem. A company called Gyration also sells a motion-controller IC that interfaces with the
microcontroller using SPI rather than ATD.
-37-
ECE 477 Final Report Spring 2008
The Bluetooth radio was directly mounted on the PCB. The antenna stuck out of the board
and this was a problem while packaging the device. To fix this, the antenna was removed and
this drastically reduced the operating range of the device. On a newer version of this product, a
different Bluetooth radio module with more support and information could be used, both to
improve performance as well as decrease latency that experienced during communication.
The overall surface area of the PCB can be brought down by anywhere between 25 to 50%
by eliminating components such as pushbuttons, LEDs that are primarily used for debugging
purposes and are not essential to the operation of this product. More efficient routing could also
be done to further decrease overall surface area, making the product compact and lightweight.
12 Summary and Conclusions
The SmartGlove project was successful in obtaining all the goals it set out for. The main
reason for its success is its simple design and modular approach to perform singular tasks. The
entire team spent a great deal of time prototyping on breadboard every circuit block, making it
easy to understand the internal workings of every component, as well as debug when irregular
behavior was observed. Soldering techniques, PCB layout and routing, project management,
technical writing and communication skills were built upon or picked up during the course of
this project. Overall, this project provided a great learning experience while reinforcing and
testing all the skills and knowledge that were acquired through the four years here at Purdue.
-38-
ECE 477 Final Report Spring 2008
13 References
[3.1] Microchip, “PIC18F2455/2550/4455/4550 Data Sheet,” [Online Document], January hats 2007,
http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pd f
[3.2] Atmel, “8bit Microcontroller with 64K/128K/256K bytes In-System Programmable hates Flash”, [Online Document], August 2007,
http://www.atmel.com/dyn/resources/prod_documents/doc2549.pdf
[3.3] Infusion Systems, “TouchGlove v1.6-R”, [Online Document], November 2007,http://infusionsystems.com/catalog/product_info.php/products_id/99
[3.4] Immersion, “Wireless Data Glove: The CyberGlove® II System”, [Online Document], hats December 2007,
http://www.immersion.com/3d/products/cyber_glove.php
[3.5] Analog Devices, “Low-Cost Dual-Axis Accelerometer with Duty Cycle Output”, hats [Online Document], 2007,
http://www.sparkfun.com/datasheets/ADXL/ADXL202E_a.pdf
[3.6] STMicroelectronics, “MEMS INERTIAL SENSOR”, [Online Document], 2006,http://www.st.com/stonline/books/pdf/docs/11668.pdf
[3.7] Mitsumi, “Bluetooth Module, WML-C40 Class 1”, [Online Document], 2008,http://www.mitsumi.co.jp/Catalog/pdf/commun_wml_c40_e.pdf
[3.8] Roving Networks, “RN-24 (Class 1/Class 2) Super-Module”, [Online Document], sdfsd2008,
http://www.rovingnetworks.com/documents/RN-24.pdf
[3.9] Tenergy, “Polymer Li-Ion Rechargeable Batteries”, [Online Document], 2008,http://www.all-battery.com/index.asp?PageAction=VIEWPROD&ProdID=580
[4.1] “United States Patent and Trademark Office”, [Online Reference], 2006http://www.uspto.gov
[4.2] “FreePatentsOnline”http://www.freepatentsonline.com
[4.3] “U.S. Patent 5581484: Finger mounted computer input device”http://www.freepatentsonline.com/5581484.html
[4.4] “U.S. Patent 5819206: Method and apparatus for determining position and orientation of a moveable object using accelerometers”
-39-
ECE 477 Final Report Spring 2008
http://www.freepatentsonline.com/5 819206 .html
[4.5] “U.S. Patent 4988981: Computer data entry and manipulation apparatus and method”http://www.freepatentsonline.com/ 4988981.html
[5.1] Department of Defense, “Military Handbook, Reliability Prediction of Electronic Equipment,” [Online Document], Available:http://assist.daps.dla.mil/quicksearch/basic_profile.cfm?ident_number=53939
[5.2] Microchip, “PIC18F2455/2550/4455/4550 Data Sheet”, [Online Document], January 2007, http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
[5.3] MAXIM, “SOT23 Dual-Input USB/AC Adapter 1-Cell Li+Battery Chargers”, [Online Document], 2003, http://datasheets.maxim-ic.com/en/ds/MAX1551-MAX1555.pdf
[5.4] MAXIM, “MAX1555 Reliability Report”, [Online Document], 2003,http://www.maxim-ic.com/reliability/maxim/MAX1555EZK.pdf
[6.1] Wikipedia “Bluetooth” [Online Document] [cited 2008 April 10],http://en.wikipedia.org/wiki/Bluetooth
[6.2] Carpal tunnel syndrome [Online Document] [cited 2008 April 10],http://en.wikipedia.org/wiki/Carpal_tunnel_syndrome
[6.3] Wikipedia “lithium-ion polymer battery” [Online Document] [cited 2008 April 10],http://en.wikipedia.org/wiki/Lithium_polymer
[6.4] FCC, Office of Engineering and Technology, “Radio Frequency Safety FAQs,” 2006 Jan 09, [cited 2006 Oct 04]. http://www.calgold.ca.gov/P2/3672.htm
[6.5] Wikipedia “Restriction of Hazardous Substances Directive” [Online Document] [cited 2008 April 10],http://en.wikipedia.org/wiki/RoHS
[6.6] Hong Kong Waste Reduction Website, https://www.wastereduction.gov.hk/en/workplace/rechargebattery_detail.htm
[6.7] Wikipedia “The Freecycle Network” [Online Document] [cited 2008 April 10],http://en.wikipedia.org/wiki/The_Freecycle_Networ k
[6.8] Security Focus Website [cited 2006 November 9] http:/ /www.securityfocus.com/infocus/1830/ [6.9] Triangle Circuits Website [cited 2004 Jan]http:/ /www.trianglecircuits.com/RoHS.html
-40-
ECE 477 Final Report Spring 2008
[7.1] Infusion Systems, “TouchGlove v1.6-R”, [Online Document], November 2007, http://infusionsystems.com/catalog/product_info.php/products_id/99
[7.2] Immersion, “Wireless Data Glove: The CyberGlove® II System”, [Online Document], December 2007,http://www.immersion.com/3d/products/cyber_glove.php
[7.3] Mellott, Kevin, “Glove Based Input Interfaces”, [Online Document],June 1999, http://www.geocities.com/mellott124/glove1.htm
[7.4] Tenergy, “Polymer Li-Ion Rechargeable Batteries”, [Online Document], 2008, http://www.all-battery.com/index.asp?PageAction=VIEWPROD&ProdID=580
[7.5] Atmel, “8bit Microcontroller with 64K/128K/256K bytes In-System Programmable Flash”, [Online Document], August 2007, http://www.atmel.com/dyn/resources/prod_documents/doc2549.PDF
[7.6] Mitsumi, “Bluetooth Module, WML-C40 Class 1”, [Online Document], 2008, http://www.mitsumi.co.jp/Catalog/pdf/commun_wml_c40_e.pdf
[8.1] Analog Devices, “Low Cost ±1.2 g Dual Axis Accelerometer”, [Online Document], 2004, http://www.analog.com/UploadedFiles/Data_Sheets/ADXL213.pdf
[8.2] Microchip, “PIC18F2455/2550/4455/4550 Data Sheet”, [Online Document], January 2007, http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
[8.3] Analog Devices, “Low-Cost Dual-Axis Accelerometer with Duty Cycle Output”, [Online Document], 2007,
http://www.sparkfun.com/datasheets/ADXL/ADXL202E_a.pdf
[8.4] Analog Devices, “Low Cost, 250 mA Output Single-Supply Amplifiers”, [Online Document], 2002,
http://www.analog.com/UploadedFiles/Data_Sheets/351440644AD853124d.pdf
[8.5] FlexiForce Sensors, Specifications & Featureshttp://www.tekscan.com/flexiforce/specs-flexiforce.html
[8.6] Analog Devices, “Switched-Capacitor Voltage Inverter with Shutdown”, [Online Document], 1999,
http://www.analog.com/UploadedFiles/Data_Sheets/ADM8828_8829.pdf
[8.7] Mitsumi, “Bluetooth Module, WML-C40 Class 1”, [Online Document], 2008, http://www.mitsumi.co.jp/Catalog/pdf/commun_wml_c40_e.pdf
-41-
ECE 477 Final Report Spring 2008
[8.8] MAXIM, “SOT23 Dual-Input USB/AC Adapter 1-Cell Li+Battery Chargers”, [Online Document], 2003,
http://datasheets.maxim-ic.com/en/ds/MAX1551-MAX1555.pdf
[9.1] Freescale, (2006) “System Design and Layout Techniques for Noise Reduction in MCU- Based Systems”http://www.freescale.com/files/microcontrollers/doc/app_note/AN1259.pdf?srch=1
[9.2] Devices, “Low-Cost Dual-Axis Accelerometer with Duty Cycle Output”, [Online Document], 2007,http://www.analog.com/UploadedFiles/Data_Sheets/ADXL213.pdf
[9.3] Analog Devices, “Low Cost, 250 mA Output Single-Supply Amplifiers”, [Online Document], 2002, http://www.analog.com/UploadedFiles/Data_Sheets/351440644AD853124d.pdf
[9.4] FlexiForce Sensors, Specifications & Featureshttp://www.tekscan.com/flexiforce/specs-flexiforce.html
[9.5] “Bluetooth Module, WML-C40 Class 1”, [Online Document], 2008,http://www.mitsumi.co.jp/Catalog/pdf/commun_wml_c40_e.pd f
[9.6] MAXIM, “SOT23 Dual-Input USB/AC Adapter 1-Cell Li+Battery Chargers”, [Online Document], 2003,http://datasheets.maxim-ic.com/en/ds/MAX1551-MAX1555.pdf
[10.1] Microchip, “PIC18F2455/2550/4455/4550 Data Sheet”, [Online Document], January 2007,http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
-42-
ECE 477 Final Report Spring 2008
Appendix A: Individual Contributions
A.1 Contributions of Donghan Ryu:
As a team leader, in general, not only I contributed to help out team members if they
needed me or if any problems occurred, but also took charge of both hardware and software. But,
I believe that we always tried to work on together, and the project was successfully accomplished
by teamwork.
I worked with Yukeun and Shiv on selecting appropriate components. We researched
for many possible components that could be used and read those datasheets. I recommended that
the Bluetooth WML-C40 was most suited for our project after I read datasheet thoroughly
because its wide range and easy interface with other devices using GPIO/USB/UART. WML-
C40 can communicate with other Bluetooth devices within 100m with external antenna and
about 10m without an antenna. Also, I selected PIC18F4550 as our microprocessor because of its
very low power consumption and 11 ATD channels, and delivering moderate computing power
with up to 48 MHz internal frequency.
I believe I played a crucial role in the design of both schematic and PCB layout. I took
charge of designing the PCB layout since I believed that designing PCB alone was more time-
efficient work and also it was interesting to me. The process of converting the schematic of
SmartGlove into PCB layout using Cadence Layout tool was a very time-consuming task. Shiv,
Yukeun and I double checked that all the components had been correctly designed on the
schematic as recommended by datasheet and also made footprints for PCB layout. After getting
feedback from the design review, Yukeun, Shiv, and I added the voltage protection circuit into
both schematic and PCB layout. After finally verifying the changes with Chuck, the final PCB
design had been submitted.
After we received the PCB, to work more efficiently, we determined that Yukeun and
Shiv work on the packaging and I worked on developing software and user interface while Po-
cheng helped out all members and worked on documentation. While working on UART
communication, the problem occurred because of different voltage levels between Bluetooth and
microcontroller. Even though our Bluetooth allows input voltage over 3.3V, it does not output
more than 3.3V. There are two solutions for this problem, putting a level translator or using a
A-1
ECE 477 Final Report Spring 2008
low power version micro controller. I solved this problem by using low power version
microcontroller.
During the last few weeks, I placed most of my focus on fixing bugs in software. I
decided to get around the Windows Com-port issue, and to use one way communication. With
this solution, I found out that it also reduced overall communication delay since it constantly sent
data to the host PC. Accelerometer data processing code used the simple trapezoidal rule. If it
was not accurate enough, a more complex algorithm could have been employed.
A-2
ECE 477 Final Report Spring 2008
A.2 Contributions of Po-Cheng Wang:
The successful completion of our project was a team effort where everyone helped to
complete all sections of the project. We did most of the work as a group and solved most of the
problems as a group.
I worked on the PCB routing which took a lot of time. Our initial version of the PCB had
many design issues. We had analog circuitry crossing digital circuitry with the power and ground
lines traced to locations that needed power without any organization. We made lots of changes
in the redesign of the PCB. Analog circuits are now confined to only the left section of the PCB
with the power traces traced along the outer rim of the PCB. The PIC18F4550 microcontroller
was also rotated for optimal routing. Being not familiar with the layout software, I also had to try
various different settings to get the errors to disappear. One main problem was that the trace
spacing was set too high which led the software to believe that errors existed. I had to go to
4pcb.com to find the fabrication specification to get the correct numbers. Finally, copper pour
was added to the PCB to reduce EM interference.
I also did some work testing the breakout boards for the accelerometers. Initially we were
not getting correct readings from the accelerometers. Using the DMM to test the wires showed
that correct voltage was present that the microprocessor’s pin. It seemed that the microprocessor
was not reading the voltage correctly. This problem could not be solved for a very long time and
was one the main reasons why the accelerometers took so long to get working. It was not until
the last few weeks when we realized that unsecure connection was the fault that caused the
problem.
For the packaging part of the project, I helped think of ways to properly mount the force
sensors and accelerometers onto the glove. If these sensors are placed in non ideal locations,
user experience would degrade a lot. I also helped work on the connectors on the product by
soldering them.
I also helped out with the homework assignments and paperwork related materials. I spent
around 10 hours on the software consideration homework. The patent homework took around 30
hours to complete. I spent the majority of time searching for and reading patents. I was glad that
I spent the time searching for patents because I found a patent which describes our project
completely. The patent even went further in scope then our project by stating that the apparatus
A-3
ECE 477 Final Report Spring 2008
could mimic a keyboard. I also edited, and proofread a lot of the homework assignments written
by other teammates, which helped improve the documents produced by the team. In addition, I
did most of the work for the team homework assignments and documentation because the other
members were busy.
A-4
ECE 477 Final Report Spring 2008
A.3 Contributions of Yukeun Sim:
As I am major in EE, I mainly focused on the hardware and packaging aspects. But, I
also assisted in many areas for teammates. Basically, the project was done by co-working as a
group. But, some of works such as PCB layout and designing schematic were completed by one
member and proved by the other members to minimize errors and save time. For homework,
each member was assigned different homework, but we worked on most of them together.
At the first 2 weeks, Donghan, Shiv and I built a team website and worked on
selecting appropriate components. Since all the components have to be fit into the 64 mm by 55
mm enclosure which will be mounted on the arm, we took into account sizes of all components
while searching for components. We found out the Flexiforce touch sensors, and realized that its
tail can be cut in any size to fit into each finger. I calculated the bandwidth of the accelerometer
which is determined by external capacitors at nodes. I also calculated the noise of accelerometers
at different bandwidths, so that appropriate external capacitor could be selected. I found that
since not only the components were chosen to maximize space efficiency, but also the sensors
are very sensitive and vulnerable to noise, calculation was very important. Final decision of what
components could be selected was made by discussing with team members. As long as I can, I
always tried to attend team meeting to give them advice and share my opinion.
While working on the designing schematic and PCB layout, I made libraries and
footprints for some IC chips, such as ADXL213E, AD8532, and etc. I worked on some parts of
designing schematics. Since PCB layout works could not split, Donghan made initial PCB
layout. After we finished initial schematic designs and PCB layout, I checked if the every
component on the layer is correctly placed and any of components were missing. After staffs
pointed out low and high voltage protection should be added in design review, I and Donghan
searched for voltage protection controllers, MAX4841. We added them to schematic, and made
final version of PCB layout.
Both Shiv and I were in charge of packaging, so I always worked on packaging with
Shiv in the lab. Before soldering IC chips, we tested all of them on the development board, and
once they worked correctly, I soldered them on our PCB. I tested battery IC charger, Bluetooth
communication, and if analog outputs from sensors were correctly read by microprocessor. I
used 9 different potentiometers for testing sensors by building exactly same circuit design as
PCB on a bread board, and checked if the voltage outputs were correct as I expected. After
A-5
ECE 477 Final Report Spring 2008
carefully testing them and checked functionalities, I soldered IC chips one by one. While
working on soldering, I found out some wrong routing on the PCB. I switched Rx and Tx lines
connecting microprocessor to Bluetooth. And, due to Bluetooth’s antenna connector, PCB was
not fit into the enclosure. I took out the antenna connector from Bluetooth. For the case side, I
and Shiv made the holes for B-type USB connector and IDE cable. On the glove side, we glued
both touch sensors and accelerometers on the glove and hooked up all sensors with female
headers.
A-6
ECE 477 Final Report Spring 2008
A.4 Contributions of Shiv Biddanda:Being an EE, my focus was mainly on the hardware aspects of this project. But the
majority of the work was done as a group. We adopted this strategy of having two or more
members on a particular task so that we could minimize errors and maximize productivity. In this
way, I have managed to contribute in a significant way while creating schematics, PCB
footprints and routing, researching and acquiring components, testing and prototyping hardware
as well as helping out in writing software for the microcontroller.
Donghan, Yukeun and I worked closely on getting some code working on Donghan’s
evaluation board. This was a good stepping stone into understanding the architecture of the PIC
Microcontroller and also made our work much easier once our hardware was operational. We
had a head start on most of the groups and ordered a lot of components well ahead of Packaging
homework. We tested a lot of components before hand, and this gave us much more confidence
going into Spring break, right after our PCB design was sent out for fabrication.
Yukeun and I worked on a lot of the hardware together, and we populated most of the
PCB along with the help of Donghan. Along the way, we found multiple errors we probably
would not have caught had we worked alone. We also built several test circuits to make sure our
schematic designs were working according to datasheet and manufacturer specifications.
I researched a fair deal on our Bluetooth radio and it’s AT instruction set. I sent out an
email to the manufacturer of the Bluetooth radio module and they responded by sending me
documentation regarding the operation of the same radio, albeit on a Bluetooth development kit.
I successfully managed to send out data from the microcontroller to the PC wirelessly for the
first time using a terminal program called LynxTerm.
Donghan and I worked on establishing a solid communication stream between the host
computer and the microcontroller. For that purpose we designed our own protocol to allow a
handshake procedure between the two in a request-response kind of system. I worked on the
software for the microcontroller side, while Donghan worked on the software for the PC side.
Yukeun and I also worked closely on all of the packaging on this product. We
conceptualized the entire design and made the decision to use the ribbon cable and parallel port
connectors to interface the glove and the forearm module. We spent a great deal of time making
the cabling neat as well as reliable at the same time.
A-7
ECE 477 Final Report Spring 2008
As far as the documentation was concerned, a lot of the work was delegated to
different members of the team. I did a lot of proofreading which helped out as we managed to
have well written documents to turn in, most of the time. Towards the end of the semester,
Yukeun and I organized a lot of the team meetings, when we had project documentation or a
presentation due.
A-8
ECE 477 Final Report Spring 2008
Appendix B: Packaging
<Figure B2. Forearm Enclosure Layout – Internal View>
B-1
ECE 477 Final Report Spring 2008
<Figure B3. Forearm Enclosure – External View>
<Figure B4. Forearm Enclosure – Side View>
B-2
ECE 477 Final Report Spring 2008
<Figure B5. Glove Layout>
B-3
ECE 477 Final Report Spring 2008
Appendix C: Schematic
<Figure C1. Battery Charger Schematic>
<Figure C2. Microcontroller Schematic>
C-1
ECE 477 Final Report Spring 2008
<Figure C3. Accelerometer Breakout Board>
<Figure C4. Touch Sensor Filter and LEDs>
C-2
ECE 477 Final Report Spring 2008
<Figure C5. Pushbuttons, Crystal>
<Figure C6. Battery, USB, ICD2, Sensor Headers>
C-3
ECE 477 Final Report Spring 2008
<Figure C7. Bluetooth Header>
C-4
ECE 477 Final Report Spring 2008
Appendix D: PCB Layout Top and Bottom Copper
<Figure D1. PCB Top Copper Layer>
<Figure D2. PCB Bottom Copper Layer>
D-1
ECE 477 Final Report Spring 2008
Appendix E: Parts List Spreadsheet
Component PINs PACKAGELength (mm)
Width (mm)
Height (mm)
Area mm^2
Micro Controller PIC18F4550-I/PT 44 TQFP 12 12 1.2 144 Crystal Oscillator FX425B 2 SMD 4 2.5 0.7 1010pF SMD Cap 2 SMD 1.2 0.6 0.1 0.7210pF SMD Cap 2 SMD 1.2 0.6 0.1 0.721Mohm SMD R 2 SMD 1.2 0.6 0.1 0.72 Force Sensor FlexiForce Sensor A201-1 2 NA 0 0 0 0FlexiForce Sensor A201-1 2 NA 0 0 0 0FlexiForce Sensor A201-1 2 NA 0 0 0 0LM324MT/MXCT 14 SOIC/TSSOP 5 6.4 1.1 32ADM8829ARTZ 6 6-ld SOT 23 3.1 3 1.3 0.681uF SMD cap 2 SMD 1.2 0.6 0.1 0.721uF SMD cap 2 SMD 1.2 0.6 0.1 0.72XX ohm SMD R 2 SMD 1.2 0.6 0.1 0.72XX ohm SMD R 2 SMD 1.2 0.6 0.1 0.72XX ohm SMD R 2 SMD 1.2 0.6 0.1 0.72 Accelerometer ADXL203 8 E-8 0 0 0 0ADXL203 8 E-8 0 0 0 0ADXL203 8 E-8 0 0 0 00.05uF SMD cap 2 SMD 1.2 0.6 0.1 0.720.05uF SMD cap 2 SMD 1.2 0.6 0.1 0.720.05uF SMD cap 2 SMD 1.2 0.6 0.1 0.720.05uF SMD cap 2 SMD 1.2 0.6 0.1 0.720.05uF SMD cap 2 SMD 1.2 0.6 0.1 0.720.05uF SMD cap 2 SMD 1.2 0.6 0.1 0.721Mohm SMD R 2 SMD 1.2 0.6 0.1 0.721Mohm SMD R 2 SMD 1.2 0.6 0.1 0.721Mohm SMD R 2 SMD 1.2 0.6 0.1 0.72LM324MT/MXCT 14 SOIC/TSSOP 5 6.4 1.1 32 Bluetooth WML-C40 29 SMD 17.78 12.7 0.3 225 Voltage Regulator 10uF SMD cap 2 SMD 1.2 0.6 0.1 0.7210uF SMD cap 2 SMD 1.2 0.6 0.1 0.7210uF SMD cap 2 SMD 1.2 0.6 0.1 0.7210uF SMD cap 2 SMD 1.2 0.6 0.1 0.72FBR130 Schottky Rectifier to protect circuit( Diodes INC) 2 SMD 3.7 1.7 0.8
E-1
ECE 477 Final Report Spring 2008
LEDs: 3 LEDs for touch, 1 LED for Power, 2 LEDs for TX and RX 1Kohm SMD reg 2 SMD 1.2 0.6 0.1 0.721Kohm SMD reg 2 SMD 1.2 0.6 0.1 0.721Kohm SMD reg 2 SMD 1.2 0.6 0.1 0.721Kohm SMD reg 2 SMD 1.2 0.6 0.1 0.721Kohm SMD reg 2 SMD 1.2 0.6 0.1 0.721Kohm SMD reg 2 SMD 1.2 0.6 0.1 0.721Kohm SMD reg 2 SMD 1.2 0.6 0.1 0.72Green SMD LED 2 SMD 3.2 1.4 0.7 4.48Green SMD LED 2 SMD 3.2 1.4 0.7 4.48Green SMD LED 2 SMD 3.2 1.4 0.7 4.48Yellow SMD LED 2 SMD 3.4 1.8 0.6 4.76Yellow SMD LED 2 SMD 3.4 1.8 0.6 4.76Green/Orange SMD LED 2 SMD 1.5 1.6 0.55 2.4 Power 33Kohm SMD R 2 SMD 1.2 0.6 0.1 0.7210Kohm SMD R 2 SMD 1.2 0.6 0.1 0.72 Power protectionMAX4841 5 SMD 2.0 1.25 1.0 2.5FDG315E 6 SMD 1.8 1.0 0.8 1.8
Switches/Pushbuttons Tact Switch 2 SMD 4.5 4.5 0.4 18.4Tact Switch 2 SMD 4.5 4.5 0.4 18.40.1uF SMD cap for RESET 2 SMD 1.2 0.6 0.1 0.7210Kohm SMD R 2 SMD 1.2 0.6 0.1 0.7210Kohm SMD R 2 SMD 1.2 0.6 0.1 0.7210Kohm SMD R for manual RESET 2 SMD 1.2 0.6 0.1 0.72470ohm SMD R 2 SMD 1.2 0.6 0.1 0.72470ohm SMD R 2 SMD 1.2 0.6 0.1 0.72Jumper for manual RESET 2 SMD 5 2 3 Charger MAX1555 2 SMD 3 2.75 1.1 8.251uF SMD cap 2 SMD 1.2 0.6 0.1 0.721uF SMD cap 2 SMD 1.2 0.6 0.1 0.721uF SMD cap 2 SMD 1.2 0.6 0.1 0.72 USB NDS352P P-cahnnel Logic level enhancement mode field effect transistor 2 SMD 18.40.1uF SMD cap 2 SMD 1.2 0.6 0.1 0.72100Kohm SMD R 2 SMD 1.2 0.6 0.1 0.7233Kohm SMD R 2 SMD 1.2 0.6 0.1 0.72USB Micro Connector 2 SMD 8 5 2.9
Total: 567.03
E-2
ECE 477 Final Report Spring 2008
Appendix F: Software Listing/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: main.c * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file is the main file of SmartGlove project * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/23/2008 Original. ********************************************************************//** I N C L U D E S **********************************************************/#include <p18cxxx.h>
#include <delays.h>#include <stdlib.h> // adds data conversion library#include <string.h> // adds string tools
#include "typedefs.h" // Required#include "io_cfg.h" // Required
#include "UART2Btooth.h"#include "ATD.h"#include "Switch.h"#include "accelerometer.h"
/** V A R I A B L E S ********************************************************/#pragma udataSgState state;extern char str_buffer[100];int dummy_cnt;
char str_give[] = "@GIVE\r";char str_team[] = "@TEAM14PC\r";
char temp[10]; // bluetooth test character bufferint strcpyi;
extern char rcv_end;
// ATD TESTunsigned long testVal;char output_buff[20];
F-1
ECE 477 Final Report Spring 2008
/** P R I V A T E P R O T O T Y P E S ***************************************/static void InitializeSystem(void);void high_interrupt_handler (void);void low_interrupt_handler (void);
/** V E C T O R R E M A P P I N G *******************************************/
#pragma codeextern void _startup (void); // See c018i.c in your C18 compiler dir
#pragma code _RESET_INTERRUPT_VECTOR = 0x00024void _reset (void){ _asm goto _startup _endasm}#pragma code
#pragma code _HIGH_INTERRUPT_VECTOR = 0x00008void _high_ISR (void){
_asm goto high_interrupt_handler _endasm;
}
#pragma code _LOW_INTERRUPT_VECTOR = 0x00018void _low_ISR (void){ _asm goto low_interrupt_handler _endasm;;}#pragma code
/** D E C L A R A T I O N S **************************************************/#pragma code
int Mystrcmp( char* s1, char* s2) {// putrsUSART("hello\r");// putsUSART(s1);// putrsUSART("hello2\r");// putsUSART(s2);
while(*s1 == *s2++ ) {// while ( BusyUSART() ); // putcUSART(*s1);
if ( *s1++ == '\0' ) return 0;}return ( (*s1) - (*(--s2)) );
/*strcpyi = 0;
while( *( s1 + strcpyi ) != NULL && *(s2 + strcpyi) != NULL ) {if ( *( s1 + strcpyi ) == *(s2 + strcpyi ) ) strcpyi++;
F-2
ECE 477 Final Report Spring 2008
else return -1;
}
if ( *( s1 + strcpyi ) != *(s2 + strcpyi) ) return 0;
return 0;*/}
/****************************************************************************** * Function: void main(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: Main program entry point. * * Note: None *****************************************************************************/void main(void){
InitializeSystem();/*// put it into idle mode// i think default slave mode is good enough// putrsUSART ((const far rom char *)"ATUCL\r");// Delay100TCYx( 50 );
// Make sure there is 100ms delay between +++ // and next AT commandputrsUSART ((const far rom char *)"+++\r");
Delay100TCYx( 200 );
putrsUSART ((const far rom char *)"ATMD\r");// Delay100TCYx( 50 );*/
// dummy_cnt = 0;
while(1) {
switch(state ) {case IDLE:
if ( rcv_end == TRUE ) {mLED_2_On();
F-3
ECE 477 Final Report Spring 2008
if ( Mystrcmp(str_buffer,str_team) == 0) {state = RECV_TEAM14PC;
}rcv_end = FALSE;
}break;
case RECV_TEAM14PC:putrsUSART ((const far rom char *)"TEAM14PIC");state = ESTABLISHED;
break;
case ESTABLISHED:// if ( rcv_end == TRUE ) {// if ( Mystrcmp(str_buffer,str_give) == 0) {
state = SEND_DATA;// }// rcv_end = FALSE;// }break;
case SEND_DATA:GetPosition();state = ESTABLISHED;
break;default:break;
}/*switch (state) {
case IDLE:if ( buffer_state == GOTSTRING ) {
if ( Mystrcmp(str_buffer,str_team) == 0) {
state = RECV_TEAM14PC;//mLED_3_Toggle();
}
}break;case RECV_TEAM14PC:
putrsUSART ((const far rom char *)"TEAM14PIC");state = ESTABLISHED;buffer_state = IDLE;
break;case ESTABLISHED:
mLED_3_Toggle();if ( buffer_state == GOTSTRING ) {
if ( Mystrcmp(str_buffer,str_give) == 0) {
state = SEND_DATA;
F-4
ECE 477 Final Report Spring 2008
}buffer_state = IDLE;
}break;case SEND_DATA:
GetPosition();state = ESTABLISHED;buffer_state = IDLE;
break;default:break;
}*/// read X,Y and touch values//GetPosition();
//putrsUSART ((const far rom char *)"AT\r"); // Delay100TCYx( 100 );
// mLED_2_On();
/*// ATD TESTtestVal = (unsigned long)ProcessATD();ltoa(testVal, output_buff);putsUSART(output_buff);putcUSART(' ');
//putcUSART(10);putcUSART(13);*/
/*
itoa(pointX, output_buffer);output_buffer[10]='\r';output_buffer[11]='\n';
putsUSART(output_buffer);putcUSART(10);putcUSART(13);
if ( value > 512 ) {mLED_1_On();
}else {
mLED_1_Off(); }
*/
F-5
ECE 477 Final Report Spring 2008
} //end while
CloseUSART();CloseADC(); // Disable A/D converter
}//end main
/****************************************************************************** * Function: static void InitializeSystem(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: InitializeSystem is a centralize initialization routine. * All required USB initialization routines are called from * here. * * User application initialization routine should also be * called from here. * * Note: Non *****************************************************************************/static void InitializeSystem(void){ OSCCON = 0x70; // =8MHz // ADCON1 |= 0x0F; // Default all pins to digital
ADCON1 |= 0x0F; // Default all pins to analogmInitAllLEDs();
ATDInit();SwitchInit(); UART2BtoothInit();state = IDLE;
// BluetoothInit();// AccelInit();
/* INTCON2 = 0x84; //TMR0 high priority RCONbits.IPEN = 1; //enable priority levels TMR0H = 0; //clear timer TMR0L = 0; //clear timer T0CON = 0x82; //set up timer0 - prescaler 1:8*/
F-6
ECE 477 Final Report Spring 2008
}//end InitializeSystem
#pragma interrupt high_interrupt_handlervoid high_interrupt_handler (void){
if ( PIR1bits.RCIF == 1 ) {_asm goto rx_handler _endasm;
}}
#pragma interrupt low_interrupt_handlervoid low_interrupt_handler (void){
}
F-7
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: ATD.h * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file contains a header for ATD.c * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/23/2008 Original. ********************************************************************/
#ifndef ATD_H#define ATD_H
/** ATD ***********************************************************//* the code belows change the ATD ports to the inputs */#define m_ATD0_ON() TRISAbits.TRISA0=INPUT_PIN;#define m_ATD1_ON() TRISAbits.TRISA1=INPUT_PIN;#define m_ATD2_ON() TRISAbits.TRISA2=INPUT_PIN;#define m_ATD3_ON() TRISAbits.TRISA3=INPUT_PIN;#define m_ATD4_ON() TRISAbits.TRISA5=INPUT_PIN;#define m_ATD5_ON() TRISEbits.TRISE0=INPUT_PIN;#define m_ATD6_ON() TRISEbits.TRISE1=INPUT_PIN;#define m_ATD7_ON() TRISEbits.TRISE2=INPUT_PIN;#define m_ATD8_ON() TRISBbits.TRISB2=INPUT_PIN;#define m_ATD9_ON() TRISBbits.TRISB3=INPUT_PIN;#define m_ATD10_ON() TRISBbits.TRISB1=INPUT_PIN;#define m_ATD11_ON() TRISBbits.TRISB4=INPUT_PIN;#define m_ATD12_ON() TRISBbits.TRISB0=INPUT_PIN;
/* the code belows change the ATD ports to the outputs */#define m_ATD0_OFF() TRISAbits.TRISA0=OUTPUT_PIN;#define m_ATD1_OFF() TRISAbits.TRISA1=OUTPUT_PIN;#define m_ATD2_OFF() TRISAbits.TRISA2=OUTPUT_PIN;#define m_ATD3_OFF() TRISAbits.TRISA3=OUTPUT_PIN;#define m_ATD4_OFF() TRISAbits.TRISA5=OUTPUT_PIN;#define m_ATD5_OFF() TRISEbits.TRISE0=OUTPUT_PIN;#define m_ATD6_OFF() TRISEbits.TRISE1=OUTPUT_PIN;#define m_ATD7_OFF() TRISEbits.TRISE2=OUTPUT_PIN;#define m_ATD8_OFF() TRISBbits.TRISB2=OUTPUT_PIN;#define m_ATD9_OFF() TRISBbits.TRISB3=OUTPUT_PIN;#define m_ATD10_OFF() TRISBbits.TRISB1=OUTPUT_PIN;#define m_ATD11_OFF() TRISBbits.TRISB4=OUTPUT_PIN;#define m_ATD12_OFF() TRISBbits.TRISB0=OUTPUT_PIN;
/** I N C L U D E S **********************************************************/
F-8
ECE 477 Final Report Spring 2008
#include <adc.h>#include "typedefs.h"
/** D E F I N I T I O N S ****************************************************/
/** S T R U C T U R E S ******************************************************/
/** P U B L I C P R O T O T Y P E S *****************************************/void ATDInit(void);unsigned int ProcessATD(void);
#endif //ATD_H
F-9
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: ATD.c * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file contains basic ATD functions. * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/23/2008 Original. ********************************************************************/
/** I N C L U D E S **********************************************************/#include <p18cxxx.h>#include <delays.h>#include "typedefs.h"#include "io_cfg.h" // I/O pin mapping#include "ATD.h"
/** V A R I A B L E S ********************************************************/#pragma udata
//extern byte ub,lb;
/** P R I V A T E P R O T O T Y P E S ***************************************/
/** D E C L A R A T I O N S **************************************************/#pragma codevoid ATDInit(void){ /* // setting port pin as inputs
m_ATD0_ON(); m_ATD1_ON(); m_ATD2_ON();m_ATD3_ON(); m_ATD4_ON(); m_ATD5_ON();m_ATD6_ON(); m_ATD7_ON(); m_ATD8_ON();
*/
m_ATD0_ON(); m_ATD2_ON(); m_ATD3_ON(); m_ATD4_ON(); m_ATD5_ON();m_ATD8_ON();
m_ATD9_ON();m_ATD10_ON();m_ATD11_ON();m_ATD12_ON();
OpenADC(ADC_FOSC_2 & // Fad=Fosc/2 ADCON2(bit2-0)
F-10
ECE 477 Final Report Spring 2008
ADC_RIGHT_JUST & // Right Justified ADCON2(bit7)ADC_12_TAD, // Tacq=12*Tad ok!! ADCON2(bit5-3)ADC_CH0 & ADC_INT_OFF & ADC_REF_VDD_VSS,0b1011);
//SetChanADC(ADC_CH9);Delay10TCYx( 50 );
}//end ATDInit
unsigned int ProcessATD(void){
Delay10TCYx( 50 );ConvertADC(); // Start conversionwhile( BusyADC() ); // Wait for ADC conversionreturn(ReadADC()); // Read result and put in temp
}//end ProcessATD
F-11
ECE 477 Final Report Spring 2008
/*********************************************************************** Purdue ECE477 2008 Spring Project "SmartGlove"*********************************************************************** FileName: Accelerometer.h* Dependencies: See INCLUDES section below* Processor: PIC18* Compiler: C18 2.30.01+* Company: ECE477 2008 Team 14** This file contains a header for Acceleromter.c* Author Date Comment*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* DongHan Ryu 2/11/2008 Original.********************************************************************/
#ifndef ACCELEROMETER_H#define ACCELEROMETER_H
/** Accelerometer ***********************************************************/
/** I N C L U D E S **********************************************************/#include "typedefs.h"
/** D E F I N I T I O N S ****************************************************/#define THRES 4
/** S T R U C T U R E S ******************************************************/
/** P U B L I C P R O T O T Y P E S *****************************************/void GetPosition(void);void transmit_data(void);void AccelInit(void);void MyItoA(unsigned int value);#endif //ACCELEROMETER_H
F-12
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: ATD.c * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file contains functions for acceleromter and position acquirement * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 2/11/2008 Original. ********************************************************************/
/** I N C L U D E S **********************************************************/#include <p18cxxx.h>#include <stdlib.h>#include <delays.h>#include <usart.h>#include <string.h>#include "typedefs.h"#include "io_cfg.h" // I/O pin mapping#include "ATD.h"#include "accelerometer.h"
/** V A R I A B L E S ********************************************************/#pragma udata
#define NUMSAMPLE 8
// acceleration dataunsigned long accelX[3];unsigned long accelY[3];unsigned long touch[3];
// character bufferchar output_buffer[60];char temp_buffer[60];unsigned int i,j;
/** P R I V A T E P R O T O T Y P E S ***************************************/
/** D E C L A R A T I O N S **************************************************/#pragma code
void GetPosition() {
// clearing previous acceleration datafor( i =0; i < 3; ++i) {
accelX[i] = 0; accelY[i] = 0; touch[i] =0;
F-13
ECE 477 Final Report Spring 2008
}
// getting acceleration datafor( i = 0; i < NUMSAMPLE; ++i) {
SetChanADC(ADC_CH0); accelX[0] += (unsigned long)ProcessATD();SetChanADC(ADC_CH12); accelY[0] += (unsigned long)ProcessATD();SetChanADC(ADC_CH9); touch[0] += (unsigned long)ProcessATD();SetChanADC(ADC_CH2); accelX[1] += (unsigned long)ProcessATD();SetChanADC(ADC_CH3); accelY[1] += (unsigned long)ProcessATD();SetChanADC(ADC_CH8); touch[1] += (unsigned long)ProcessATD();SetChanADC(ADC_CH4); accelX[2] += (unsigned long)ProcessATD();SetChanADC(ADC_CH5); accelY[2] += (unsigned long)ProcessATD();SetChanADC(ADC_CH10); touch[2] += (unsigned long)ProcessATD();
}
// averaging acceleration data for( i =0; i < 3 ; ++i) {
accelX[i] /= NUMSAMPLE; accelY[i] /= NUMSAMPLE; touch[i] /= NUMSAMPLE;
}
// sending datatransmit_data();
}
void MyItoA(unsigned int value) {
itoa(value,temp_buffer);if ( value > 999 ) {
output_buffer[j++] = temp_buffer[0];output_buffer[j++] = temp_buffer[1];output_buffer[j++] = temp_buffer[2];output_buffer[j++] = temp_buffer[3];
}else if ( value > 99 ) {
output_buffer[j++] = '0';output_buffer[j++] = temp_buffer[0];output_buffer[j++] = temp_buffer[1];output_buffer[j++] = temp_buffer[2];
}else if ( value > 9 ) {
output_buffer[j++] = '0';output_buffer[j++] = '0';output_buffer[j++] = temp_buffer[0];output_buffer[j++] = temp_buffer[1];
}else {
output_buffer[j++] = '0';output_buffer[j++] = '0';output_buffer[j++] = '0';output_buffer[j++] = temp_buffer[0];
F-14
ECE 477 Final Report Spring 2008
}
}void transmit_data() {
j =0;output_buffer[j++]='D';output_buffer[j++]='T';
for ( i =0; i < 3; ++i) {// output_buffer[j++] = 'X';
MyItoA(accelX[i]);// output_buffer[j++] = 'Y';
MyItoA(accelY[i]);// output_buffer[j++] = 'Z';
MyItoA(touch[i]); }
output_buffer[j++]='\r';output_buffer[j]=00;putsUSART(output_buffer);
/* for ( i = 0; i < j+1; i++) {while(BusyUSART());WriteUSART(output_buffer[i]);
}*/ }
void AccelInit(void) {
}
F-15
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: Switch.h * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file contains the header file for Switch.h * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/23/2008 Original. ********************************************************************/
#ifndef SWITCH_H#define SWITCH_H
/** I N C L U D E S **********************************************************/#include "typedefs.h"
/** D E F I N I T I O N S ****************************************************/
/** S T R U C T U R E S ******************************************************/
/** P U B L I C P R O T O T Y P E S *****************************************/void SwitchInit(void);BOOL Switch2IsPressed(void);BOOL Switch3IsPressed(void);
#endif //ATD_H
F-16
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: Switch.c * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file controlls switches attached to the micro controller * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/23/2008 Original. ********************************************************************/
/** I N C L U D E S **********************************************************/#include <p18cxxx.h>#include "typedefs.h"#include "io_cfg.h" // I/O pin mapping#include "Switch.h"
/** V A R I A B L E S ********************************************************/#pragma udatabyte prev_sw1; // for debouncing
/** P R I V A T E P R O T O T Y P E S ***************************************/
/** D E C L A R A T I O N S **************************************************/#pragma code
void SwitchInit(void){ /* resetting registers */ mInitAllSwitches();
/* initilizing push buttons for debouncing */ prev_sw1 = sw1;
}//end SwitchInit
BOOL Switch2IsPressed(void){ if(sw1 != prev_sw1) { prev_sw1 = sw1; // Save new value if(sw1 == 0) // If pressed return TRUE; // Was pressed }//end if return FALSE; // Was not pressed}//end Switch2IsPressed
F-17
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: UART2Btooth.h * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file is the main file of SmartGlove project * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/29/2008 Original. ********************************************************************/
#ifndef UART2BTOOTH_H#define UART2BTOOTH_H
/** I N C L U D E S **********************************************************/#include <usart.h>#include "typedefs.h"
/** D E F I N I T I O N S ****************************************************/
//#define RBUF_SIZE 25//#define TBUF_SIZE 25
#define UART_BUFFER_SIZE 20
/** S T R U C T U R E S ******************************************************/
typedef enum SgState { IDLE,
RECV_TEAM14PC,SEND_TEAM14PIC,ESTABLISHED,SEND_DATA,
} SgState;
typedef enum BState { IDLE,
RECEIVING,GOTSTRING,
} BState;
/** P U B L I C P R O T O T Y P E S *****************************************/#pragma code
int insertBuffer(void);
F-18
ECE 477 Final Report Spring 2008
void UART2BtoothInit(void);void BluetoothInit(void);void rx_handler (void);int incBmod(int input, static int buf_size);
#endif
F-19
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: UART2Btooth.c * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file contains basic ATD functions. * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/29/2008 Original. ********************************************************************//** I N C L U D E S **********************************************************/#include <p18cxxx.h>#include <delays.h>#include "typedefs.h"#include "io_cfg.h" // I/O pin mapping#include "UART2Btooth.h"
/** V A R I A B L E S ********************************************************/#pragma udata
static char c_temp; //test varstatic int set_flag = 0; // flag for bluetooth test
//static int ctr_buffer;#define BSIZE 100char str_buffer[BSIZE];int bin;char receiving, rcv_end;
extern SgState state;
/** P R I V A T E P R O T O T Y P E S ***************************************/
/** D E C L A R A T I O N S **************************************************/#pragma codevoid BluetoothInit(void) {// putrsUSART ((const far rom char *)"AT\r\n");// putcUSART('A'); putcUSART('T'); putcUSART(13);}
void UART2BtoothInit(void) {
bin = 0; receiving = FALSE;rcv_end = FALSE;
// ctr_buffer = 0; // Buffer index
F-20
ECE 477 Final Report Spring 2008
TRISCbits.TRISC7=INPUT_PIN; // RX LATCbits.LATC7=INPUT_PIN; // RX
TRISCbits.TRISC6=OUTPUT_PIN; // TX
// Initialize USART: 19200, N, 8, 1, no handshake.// Baud rate equation
// Mode Low-speed (BRGH=0)High-speed (BRGH=1)// Asynchronous (ASYNC) Fosc/( 64( X + 1 ))Fosc/( 16( X + 1 ))
// Synchronous (SYNC) Fosc/( 4( X + 1 ))// 48Mhz Clock// 155 => 19.2 K with high baud rate
// 77 => 9.6K with low baud rate// 77 => 38.4 K with high baud rate// 12 => 38.4 K with high baud rate and 8 MHz internal clock // 25 => 19.2 K with high baud rate and 8 MHz internal clock // 3? => 115.2 K with high baud rate and 8 MHz internal clock// 7? => 57.6 K with high baud rate and 8 MHz internal clock
// (3/30/08) 50 or 51 => 9.6 K with high baud rate and 8 MHz internal clock
OpenUSART (USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 12);
/* OpenUSART (USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 155);*/
/* Enable interrupt priority */ RCONbits.IPEN = 1;
/* Make receive interrupt high priority */ IPR1bits.RCIP = 1;
/* Make receive interrupt high priority */ // IPR1bits.TXIP = 1;
/* Enable all high priority interrupts */ INTCONbits.GIEH = 1;
/* Enable all low priority interrupts */ /* it has nothing to do with serial communication */
F-21
ECE 477 Final Report Spring 2008
INTCONbits.GIEL = 1;
/* Display a prompt to the USART */ Delay10TCYx( 8000 );
putrsUSART((const far rom char *)"\r"); putrsUSART((const far rom char *)"\r"); /* putrsUSART((const far rom char *)"+++\r"); Delay100TCYx(8000); putrsUSART((const far rom char *)"ATMD\r"); Delay100TCYx(8000);*/
// idle// putrsUSART ((const far rom char *)"ATUCL\r");
// connect to my laptop// putrsUSART ((const far rom char *)"ATDM,00197EF98629,1101\r");// putrsUSART ((const far rom char *)"AT\r");
/*temp[0] = 'A';temp[1] = 'T';temp[2] = '\r';
temp[3] = 0; putsUSART(temp);*/
}
int insertBuffer(){
if ( c_temp == '@' && rcv_end == FALSE ) {bin = 0;receiving = TRUE;
}else if ( c_temp == '\r' ) {
rcv_end = TRUE;}
if ( receiving == TRUE ) {// empty or have enough space to fill the buffer str_buffer[ bin++ ] = c_temp;
}
if ( rcv_end == TRUE ) {str_buffer[ bin++ ] = 0x00;receiving = FALSE;
}
F-22
ECE 477 Final Report Spring 2008
/*if ( (bin + 1 ) % BSIZE == bout ) {
// full mLED_2_On();
}*/// else {// }
/*if ( fire == FALSE ) {}if ( buffer_state == IDLE ) {
fire = FALSE;if ( c_temp == '@' ) {
ctr_buffer = 0;str_buffer[ctr_buffer++] = c_temp;buffer_state = RECEIVING;mLED_2_On();
}else {
c_temp == 0x00;ctr_buffer = 0;
}}else if ( buffer_state == RECEIVING ) {
fire = FALSE;str_buffer[ctr_buffer++] = c_temp;if ( c_temp == '\r') {
str_buffer[ctr_buffer++] = 0x00;buffer_state = GOTSTRING;mLED_1_Toggle();
}else if ( ctr_buffer > 99 ) {
buffer_state = IDLE;}else {
buffer_state = RECEIVING;}
}
else if ( buffer_state == GOTSTRING ) {fire = TRUE;ctr_buffer = 0;mLED_2_Off();
}*/return 0;
}
#pragma interrupt rx_handlervoid rx_handler (void)
F-23
ECE 477 Final Report Spring 2008
{ /* Get the character received from the USART */ c_temp = ReadUSART(); insertBuffer();
/* Clear the interrupt flag */ PIR1bits.RCIF = 0;}
F-24
ECE 477 Final Report Spring 2008
/********************************************************************* * * Purdue ECE477 2008 Spring Project "SmartGlove" * ********************************************************************* * FileName: typedefs.h * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: ECE477 2008 Team 14 * * This file contains type definitions of various data type * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DongHan Ryu 1/23/2008 Original. ********************************************************************/#ifndef TYPEDEFS_H#define TYPEDEFS_H
typedef unsigned char byte; // 8-bittypedef unsigned int word; // 16-bittypedef unsigned long dword; // 32-bit
typedef union _BYTE{ byte _byte; struct { unsigned b0:1; unsigned b1:1; unsigned b2:1; unsigned b3:1; unsigned b4:1; unsigned b5:1; unsigned b6:1; unsigned b7:1; };} BYTE;
typedef union _WORD{ word _word; struct { byte byte0; byte byte1; }; struct { BYTE Byte0; BYTE Byte1; }; struct {
F-25
ECE 477 Final Report Spring 2008
BYTE LowB; BYTE HighB; }; struct { byte v[2]; };} WORD;#define LSB(a) ((a).v[0])#define MSB(a) ((a).v[1])
typedef union _DWORD{ dword _dword; struct { byte byte0; byte byte1; byte byte2; byte byte3; }; struct { word word0; word word1; }; struct { BYTE Byte0; BYTE Byte1; BYTE Byte2; BYTE Byte3; }; struct { WORD Word0; WORD Word1; }; struct { byte v[4]; };} DWORD;#define LOWER_LSB(a) ((a).v[0])#define LOWER_MSB(a) ((a).v[1])#define UPPER_LSB(a) ((a).v[2])#define UPPER_MSB(a) ((a).v[3])
typedef void(*pFunc)(void);
typedef union _POINTER{ struct {
F-26
ECE 477 Final Report Spring 2008
byte bLow; byte bHigh; //byte bUpper; }; word _word; // bLow & bHigh //pFunc _pFunc; // Usage: ptr.pFunc(); Init: ptr.pFunc = &<Function>;
byte* bRam; // Ram byte pointer: 2 bytes pointer pointing // to 1 byte of data word* wRam; // Ram word poitner: 2 bytes poitner pointing // to 2 bytes of data
rom byte* bRom; // Size depends on compiler setting rom word* wRom; //rom near byte* nbRom; // Near = 2 bytes pointer //rom near word* nwRom; //rom far byte* fbRom; // Far = 3 bytes pointer //rom far word* fwRom;} POINTER;
typedef enum _BOOL { FALSE = 0, TRUE } BOOL;
#define OK TRUE#define FAIL FALSE
#endif //TYPEDEFS_H
F-27
ECE 477 Final Report Spring 2008
< PC code – User Interface >
#ifndef _CONTROL_H_#define _CONTROL_H_
#include "stdafx.h"
void MouseMove(int x, int y);void LeftClick ( void );void RightClick ( void );void LeftDown ( void );void RightDown ( void );void LeftUp ( void );void RightUp ( void );void VScroll ( int delta );void KeyBoardDown (char key );void KeyBoardUp (char key );
#endif
#pragma once
#include "stdafx.h"#include "resource.h"#include "smartGlove_Usermode.h"
#define THRES 3
void mov_end_check();void GetPosition();void calibration(void);void AccelInit(void);void action ();void PrintScreen(void);
//{{NO_DEPENDENCIES}}// Microsoft Visual C++ generated include file.// Used by smartGlove_Usermode.rc//#define IDC_MYICON 2#define IDD_SMARTGLOVE_USERMODE_DIALOG 102#define IDS_APP_TITLE 103#define IDM_ABOUT 104#define IDI_SMARTGLOVE_USERMODE 107#define IDI_SMALL 108#define IDC_SMARTGLOVE_USERMODE 109#define IDR_MAINFRAME 128#define IDR_ACCELERATOR1 129#define IDB_BITMAP2 133#define IDR_ACCELERATOR2 134#define IDR_ACCELERATOR3 135#define ID_KEYRETURN 32773
// Next default values for new objects// #ifdef APSTUDIO_INVOKED#ifndef APSTUDIO_READONLY_SYMBOLS#define _APS_NO_MFC 1#define _APS_NEXT_RESOURCE_VALUE 136#define _APS_NEXT_COMMAND_VALUE 32775
F-28
ECE 477 Final Report Spring 2008
#define _APS_NEXT_CONTROL_VALUE 1000#define _APS_NEXT_SYMED_VALUE 110#endif#endif
#pragma once
#include "resource.h"#include "data_processing.h"
#define ID_CONNECT_BUTTON 1000#define ID_COM_LIST
(ID_CONNECT_BUTTON + 1)#define ID_COM_COMMAND_EDITBOX
(ID_CONNECT_BUTTON + 2)#define ID_COM_DEBUG_BOX
(ID_CONNECT_BUTTON + 3)
typedef struct ComboBoxItem {TCHAR Item[255];ComboBoxItem* Next;
} ComboBoxItem, *pComboBoxItem;
typedef enum SgState {IDLE,SEND_TEAM14PC,RECV_TEAM14PIC,ESTABLISHED,RECV_DATA,SEND_GIVEMEDATA,
} SgState;
int ShowError (LONG lError, LPCTSTR lptszMessage);void GetComPort(void);LONG ComSetup(TCHAR * comportnum);
BOOL UnicodeToAnsi(LPWSTR pszwUniString, LPSTR pszAnsiBuff,DWORD dwAnsiBuffSize);
BOOL AnsiToUnicode(LPSTR pszAnsiString, LPWSTR pszwUniBuff, DWORD dwUniBuffSize);
// stdafx.h : include file for standard system include files,// or project specific include files that are used frequently, but// are changed infrequently//
#pragma once
#include "targetver.h"
#define STRICT
//#define SERIAL_NO_OVERLAPPED
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers// Windows Header Files:
F-29
ECE 477 Final Report Spring 2008
#include <windows.h>#include <Windowsx.h>#include <commctrl.h>
#include <stdio.h>
// for overlapped io#define SERIAL_DEFAULT_OVERLAPPED true
// C RunTime Header Files#include <stdlib.h>#include <malloc.h>#include <memory.h>#include <tchar.h>
#include <ctime>
// TODO: reference additional headers your program requires here#include "control.h"#include "SerialWnd.h"
#pragma once
// The following macros define the minimum required platform. The minimum required platform// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run // your application. The macros work by enabling all features available on platform versions up to and // including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.// Refer to MSDN for the latest info on corresponding values for different platforms.#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.#endif
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.#endif
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.#endif
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.#endif
F-30
ECE 477 Final Report Spring 2008
#include "stdafx.h"#include "control.h"
void KeyBoardDown (char key ){
INPUT Input={0}; Input.type = INPUT_KEYBOARD; Input.ki.wVk = key; Input.mi.dwFlags = 0; SendInput(1,&Input,sizeof(INPUT));
}
void KeyBoardUp (char key ){
INPUT Input={0}; Input.type = INPUT_KEYBOARD; Input.ki.wVk = key; Input.mi.dwFlags = KEYEVENTF_KEYUP; SendInput(1,&Input,sizeof(INPUT));
}void MouseMove (int x, int y ){ double fScreenWidth = GetSystemMetrics( SM_CXSCREEN )-1; double fScreenHeight = GetSystemMetrics( SM_CYSCREEN )-1; double fx = x*(65535.0f/fScreenWidth); double fy = y*(65535.0f/fScreenHeight); INPUT Input={0}; Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE; Input.mi.dx = fx; Input.mi.dy = fy; SendInput(1,&Input,sizeof(INPUT));}
void LeftDown ( void ){ INPUT Input={0}; // left down Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; SendInput(1,&Input,sizeof(INPUT));
}
void RightDown ( void ){ INPUT Input={0}; // right down Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; SendInput(1,&Input,sizeof(INPUT));
}void LeftUp ( void ){ INPUT Input={0}; Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
F-31
ECE 477 Final Report Spring 2008
SendInput(1,&Input,sizeof(INPUT));}
void RightUp ( void ){ INPUT Input={0}; Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP; SendInput(1,&Input,sizeof(INPUT));}
void LeftClick ( void ){ INPUT Input={0}; // left down Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; SendInput(1,&Input,sizeof(INPUT));
// left up ZeroMemory(&Input,sizeof(INPUT)); Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_LEFTUP; SendInput(1,&Input,sizeof(INPUT));}
void RightClick ( void ){ INPUT Input={0}; // right down Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; SendInput(1,&Input,sizeof(INPUT));
// right up ZeroMemory(&Input,sizeof(INPUT)); Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP; SendInput(1,&Input,sizeof(INPUT));}
void VScroll ( int delta ){ INPUT Input={0}; // right down Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_WHEEL; Input.mi.mouseData = delta * WHEEL_DELTA; SendInput(1,&Input,sizeof(INPUT));
}
#include "stdafx.h"#include "data_processing.h"
extern signed int Ax[3],Ay[3],T[3];signed int prevAx[3],prevAy[3],prevT[3];
F-32
ECE 477 Final Report Spring 2008
float Vx[3],Vy[3];float prevVx[3],prevVy[3];
float Px[3],Py[3];float prevPx[3],prevPy[3];
signed int calX[3], calY[3];
int Initx;int Inity;
extern HWND hWndStaticDebug;
void PrintScreen(void) {
static clock_t endwait;static clock_t prev_wait;static int t_cnt = 0;char t[500];
double ftime = ( endwait - prev_wait) / (double)CLOCKS_PER_SEC ;prev_wait = endwait;endwait = clock();
t_cnt++;sprintf_s(t,"vx0 = %f, vy0 = %f, z0 = %d, vx1 = %f, vy1 = %f, z1 = %d, vx2 =
%f, vy2 = %f, z2 = %d <%d> time = <%lf>", Vx[0], Vy[0],T[0], Vx[1], Vy[1],T[1], Vx[2], Vy[2],T[2], t_cnt, ftime );// sprintf_s(t,"x0 = %f, y0 = %f, z0 = %d, x1 = %f, y1 = %f, z1 = %d, x2 = %f, y2 = %f, z2 = %d <%d> time = <%lf>", Px[0], Py[0],T[0], Px[1], Py[1],T[1], Px[2], Py[2],T[2], t_cnt, ftime );
TCHAR tc[500];AnsiToUnicode(t,tc,500);Edit_SetText(hWndStaticDebug,tc);
}
void action () {
char t[500];TCHAR tc[500];
int calfactor = 1;int x = Initx + calfactor * -Vx[1];int y = Inity + calfactor * Vy[1];
// gesturestatic int gesture = 0;
#define TH 900#define TH2 200
// Left Clickif ( T[1] > TH ) {
LeftDown();LeftUp();
}
F-33
ECE 477 Final Report Spring 2008
if ( T[2] > TH && gesture == 0 ) {RightDown();RightUp();
}
// gestureif ( T[2] > TH ) {
gesture = 1;}else if ( gesture != 2) {
gesture = 0;}
if ( T[2] > TH && gesture == 1) {gesture = 2;
}
if ( gesture == 2 && T[2] < TH ) {gesture = 3;
}
if ( gesture == 3 ) {gesture = 0;KeyBoardDown(VK_CONTROL);KeyBoardDown(VK_ESCAPE);
// KeyBoardUp(VK_ESCAPE);// KeyBoardUp(VK_CONTROL);
}
sprintf_s(t,"x = %d, y = %d, Vx[1] = %f, Vy[1] = %f", x, y, Vx[1], Vy[1] );
AnsiToUnicode(t,tc,500);Edit_SetText(hWndStaticDebug,tc);
MouseMove(x,y);Initx = x;Inity = y;
}void mov_end_check() {
unsigned int i = 0;static int counterx[3], countery[3];
for ( i = 0; i < 3 ; i++ ) {if ( Ax[i] == 0 ) { counterx[i]++; } else { counterx[i] = 0; }if ( Ay[i] == 0 ) { countery[i]++; } else { countery[i] = 0; }
//if ( counterx[i] >= 3 ) { Vx[i] = 0; prevVx[i] = 0; calX[i] = Ax[i]; prevAx[i] = Ax[i];}
//if ( countery[i] >= 3 ) { Vy[i] = 0; prevVy[i] = 0; calY[i] = Ay[i]; prevAy[i] = Ay[i];}
if ( counterx[i] >= 3 ) { Vx[i] = 0; prevVx[i] = 0; }if ( countery[i] >= 3 ) { Vy[i] = 0; prevVy[i] = 0; }
}
F-34
ECE 477 Final Report Spring 2008
}
void GetPosition() {
unsigned int i = 0;
// getting acceleration data
// getting offset from the center pointfor ( i = 0; i < 3; i++ ) {
// subtracting the middle valueAx[i] = Ax[i] - calX[i]; Ay[i] = Ay[i] - calY[i];
// reducing noise if ( ( Ax[i] <= THRES ) && ( Ax[i] >= -THRES ) ) {
Ax[i] = 0;}if ( ( Ay[i] <= THRES ) && ( Ay[i] >= -THRES ) ) {
Ay[i] = 0;}
// trapazoidal ruleVx[i] = prevVx[i] + 0.01f * ( ( Ax[i] + prevAx[i] ) / (float)2 );Vy[i] = prevVy[i] + 0.01f * ( ( Ay[i] + prevAy[i] ) / (float)2 );
Px[i] = prevPx[i] + 0.01f * ( ( Vx[i] + prevVx[i] ) / (float)2 );Py[i] = prevPy[i] + 0.01f * ( ( Vy[i] + prevVy[i] ) / (float)2 );
// saving current valuesprevAx[i] = Ax[i];prevVx[i] = Vx[i];prevPx[i] = Px[i];
prevAy[i] = Ay[i];prevVy[i] = Vy[i];prevPy[i] = Py[i];
}
// checking whether there's a movement or not.// it reset the velocity to 0 if there's any movementmov_end_check();
}
void calibration(void) {unsigned int i = 0; // this is a
counter to get many samples
for ( i = 0; i < 3; i++ ) {calX[i] = Ax[i];calY[i] = Ay[i];prevAx[i] = 0;prevAy[i] = 0;
}
F-35
ECE 477 Final Report Spring 2008
} // end of calibration
void AccelInit(void) {
// getting current cursor pointPOINT p;GetCursorPos(&p);
Initx = p.x;Inity = p.y;
// resettingint i = 0;
for ( i = 0; i < 3; i++ ) {Px[i] = 0; Py[i] = 0;Vx[i] = 0; Vy[i] = 0;
prevPx[i] = 0; prevPy[i] = 0;prevVx[i] = 0; prevVy[i] = 0;
}
}
// smartGlove_Usermode.cpp : Defines the entry point for the application.//
#ifndef _RS232_DEBUG_#define _RS232_DEBUG_ 1#endif
#include "stdafx.h"#include "smartGlove_Usermode.h"
SgState pcstate;
#define MAX_LOADSTRING 100
// Global Variables:HINSTANCE hInst; // current instanceTCHAR szTitle[MAX_LOADSTRING]; // The title bar textTCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
// Window handlesHWND hWnd;HWND hWndComboBox;HWND hWndConnectButton;HWND hWndStaticPic;HWND hWndStaticDebug;HWND hWndStaticFrame;
F-36
ECE 477 Final Report Spring 2008
HWND hWndEditBox;
// Logo BITMAPHBITMAP Logo1;
// serial portCSerialWnd* serial;
OVERLAPPED ov = {0};HANDLE hevtStop;HANDLE hevtOverlapped;
// linked listpComboBoxItem pCboxItem;
// indicating whether it is alreaddy connected or notint SerialConnected;
// stringschar* str1 = "@TEAM14PC\r\n";char* str2 = "@GIVE\r\n";char* str3 = "\r";
signed int Ax[3],Ay[3],T[3];
// ----------------------------------------------------------------------------
//
//
BOOL UnicodeToAnsi(LPWSTR pszwUniString, LPSTR pszAnsiBuff,DWORD dwAnsiBuffSize)
{int iRet = 0;
iRet = WideCharToMultiByte(CP_ACP,0,pszwUniString,-1,pszAnsiBuff,dwAnsiBuffSize,NULL,NULL);
return ( 0 != iRet );}
// ----------------------------------------------------------------------------
//
//
BOOL AnsiToUnicode( LPSTR pszAnsiString, LPWSTR pszwUniBuff, DWORD dwUniBuffSize
F-37
ECE 477 Final Report Spring 2008
){
int iRet = 0; iRet = MultiByteToWideChar(
CP_ACP,0,pszAnsiString,-1,pszwUniBuff,dwUniBuffSize);
return ( 0 != iRet );}
void GetComPort(void) {
HKEY hKey = 0;TCHAR buf[255] = {0};TCHAR Name[255] = {0};DWORD dwType = 0;DWORD dwBufSize = sizeof(buf);TCHAR* subkey = _T("HARDWARE\\DEVICEMAP\\SERIALCOMM");int i;
if( RegOpenKey(HKEY_LOCAL_MACHINE,subkey,&hKey) == ERROR_SUCCESS){
dwType = REG_SZ; //\\Device\\BtPort1 //\\Device\\BthModem2for ( i = 0; i < 9 ; ++i) {
swprintf(Name, sizeof(Name), L"\\Device\\BtPort%1d",i);if( RegQueryValueEx(hKey,Name, 0, &dwType, (LPBYTE)buf,
&dwBufSize) == ERROR_SUCCESS){
pComboBoxItem node;node =
(pComboBoxItem)malloc(sizeof(ComboBoxItem));wsprintf( node->Item , L"%s",buf);node->Next = pCboxItem;pCboxItem = node;//MessageBox(hWnd,node->Item, buf, MB_OK);
}}
for ( i = 0; i < 9 ; ++i) {swprintf(Name, sizeof(Name), L"\\Device\\BthModem%1d",i);if( RegQueryValueEx(hKey,Name, 0, &dwType, (LPBYTE)buf,
&dwBufSize) == ERROR_SUCCESS){
pComboBoxItem node;node =
(pComboBoxItem)malloc(sizeof(ComboBoxItem));wsprintf( node->Item , L"%s",buf);node->Next = pCboxItem;pCboxItem = node;//MessageBox(hWnd,buf, buf, MB_OK);
}}
RegCloseKey(hKey);
}
F-38
ECE 477 Final Report Spring 2008
else {// cout << "Can not open key\n";}
// cin.ignore();
return ;}
int ProcessData(char* textbuf, int byteRead) {
static int cnt = 0;static char realbuf[500];static char temp[500];
static int cal_state = 0;
if (cnt >= 500 ) {return 0;
}
memcpy(&realbuf[cnt],textbuf,byteRead);cnt += byteRead;
// MessageBoxA(hWnd,textbuf,"fwfwef",MB_OK);
if ( cnt >= 38 ) {
for ( int i = 0; i < 3; i++) {Ax[i]= 0; Ay[i] = 0; T[i] = 0;
}
if ( realbuf[0] == 'D' && realbuf[1] == 'T' ) {//MessageBox(hWnd,L"fwefew", L"fwefwe", MB_OK);for ( int k = 0; k < 3; k++ ) {
strncpy_s(temp,5,&realbuf[2 + k*12],4);temp[4] = 0x00;Ax[k]=atoi(temp);
strncpy_s(temp,5,&realbuf[6 + k*12],4);temp[4] = 0x00;Ay[k]=atoi(temp);
strncpy_s(temp,5,&realbuf[10 + k*12],4);temp[4] = 0x00;T[k]=atoi(temp);
}
// calibrationif ( cal_state != 0 ) {
GetPosition();//PrintScreen();action();
}else {
cal_state = 1;::calibration(); ::AccelInit();
F-39
ECE 477 Final Report Spring 2008
}
cnt=0;
return 1;
}else {
cnt = 0;return 0;
}
//MessageBoxAhWnd,tchar,L"fwfwef",MB_OK);}return 0;
}
int ShowError (LONG lError, LPCTSTR lptszMessage){
// Generate a message textTCHAR tszMessage[256];wsprintf(tszMessage,_T("%s\n(error code %d)"), lptszMessage, lError);
// Display message-box and return with an error-code::MessageBox(0,tszMessage,_T("Listener"), MB_ICONSTOP|MB_OK);return 1;
}
LONG ComSetup(TCHAR* comportnum) {// open serial portLONG lLastError = ERROR_SUCCESS;
#if _RS232_DEBUG_ == 1
// lLastError = serial.Open(_T("COM8"), hWnd, WM_NULL,0,0,0);;// lLastError = serial->Open(comportnum, hWnd, WM_NULL,0,0,0);;
lLastError = serial->Open(comportnum, hWnd, WM_NULL,0,(DWORD)3000,(DWORD)3000);;if (lLastError != ERROR_SUCCESS)
return ::ShowError(serial->GetLastError(), _T("Unable to open COM-port"));
// Setup the serial port (19200,8N1, which is the default setting)lLastError = serial-
>Setup(CSerial::EBaud38400,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);// lLastError = serial->Setup(CSerial::EBaud256000,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
if (lLastError != ERROR_SUCCESS)return ::ShowError(serial->GetLastError(), _T("Unable to set COM-
port setting"));
// Setup handshaking (default is no handshaking)// lLastError = serial->SetupHandshaking(CSerial::EHandshakeOff); lLastError = serial->SetupHandshaking(CSerial::EHandshakeHardware);
F-40
ECE 477 Final Report Spring 2008
if (lLastError != ERROR_SUCCESS)return ::ShowError(serial->GetLastError(), _T("Unable to set COM-
port handshaking"));
// Register only for the receive event lLastError = serial->SetMask(CSerial::EEventBreak |
CSerial::EEventCTS |
CSerial::EEventDSR |
CSerial::EEventError |//
CSerial::EEventRing |//
CSerial::EEventRLSD |
CSerial::EEventRecv);if (lLastError != ERROR_SUCCESS)
return ::ShowError(serial->GetLastError(), _T("Unable to set COM-port event mask"));
// Use 'non-blocking' reads, because we don't know how many bytes// will be received. This is normally the most convenient mode// (and also the default mode for reading data).
lLastError = serial->SetupReadTimeouts(CSerial::EReadTimeoutNonblocking);
if (lLastError != ERROR_SUCCESS)return ::ShowError(serial->GetLastError(), _T("Unable to set COM-
port read timeout."));
// Create a handle for the overlapped operationshevtOverlapped = ::CreateEvent(0,TRUE,FALSE,0);;if (hevtOverlapped == 0)
return ::ShowError(serial->GetLastError(), _T("Unable to create manual-reset event for overlapped I/O."));
// Setup the overlapped structureov.hEvent = hevtOverlapped;
// Open the "STOP" handlehevtStop = ::CreateEvent(0,TRUE,FALSE,_T("Overlapped_Stop_Event"));if (hevtStop == 0)
return ::ShowError(serial->GetLastError(), _T("Unable to create manual-reset event for stop event."));
// Sleep(1);// serial.Write("+++\r");
return lLastError;#endif
}// Forward declarations of functions included in this code module:ATOM MyRegisterClass(HINSTANCE hInstance);BOOL InitInstance(HINSTANCE, int);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);//INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
F-41
ECE 477 Final Report Spring 2008
LPTSTR lpCmdLine, int nCmdShow){
UNREFERENCED_PARAMETER(hPrevInstance);UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.MSG msg;HACCEL hAccelTable;
// Combo Box item for comport selection pCboxItem = NULL;
TCHAR TextBuf[1000];BYTE abBuffer[1000];
// Initialize global stringsLoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);LoadString(hInstance, IDC_SMARTGLOVE_USERMODE, szWindowClass,
MAX_LOADSTRING);MyRegisterClass(hInstance);
// not connectedSerialConnected = 0;
GetComPort();
serial = new CSerialWnd();
pcstate = IDLE;
// Perform application initialization:if (!InitInstance (hInstance, nCmdShow)){
return FALSE;}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR3));// hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SMARTGLOVE_USERMODE));
// prioritySetPriorityClass(hWnd,REALTIME_PRIORITY_CLASS);
// Main message loop:while(1){
if ( SerialConnected == 1 ) {
if ( pcstate == IDLE) {
Sleep(500);
serial->Write(str1);Sleep(100);pcstate = SEND_TEAM14PC;
}else if ( pcstate == ESTABLISHED ) {
pcstate = SEND_GIVEMEDATA;}
F-42
ECE 477 Final Report Spring 2008
else if ( pcstate == SEND_GIVEMEDATA) {
pcstate = RECV_DATA;
}else if ( pcstate == RECV_TEAM14PIC ) {
pcstate = ESTABLISHED;}
}
if ( GetMessage(&msg, NULL, 0, 0)) {
if ( msg.message == WM_KEYDOWN ) {if ( msg.wParam == VK_ESCAPE ) {
PostMessage(hWnd,WM_DESTROY,0,0);}else if (GetFocus() == hWndEditBox &&msg.wParam
== VK_RETURN ) {Edit_GetText(hWndEditBox,TextBuf,1000-
1);
UnicodeToAnsi(TextBuf,(char*)abBuffer,1000);
serial->Write((char*)abBuffer);serial->Write(str3);
continue;}else if (GetFocus() == hWndStaticDebug ) {
continue;}
}
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)){
TranslateMessage(&msg);DispatchMessage(&msg);
}}else {
break;}
}
delete serial;
return (int) msg.wParam;}
//// FUNCTION: MyRegisterClass()//// PURPOSE: Registers the window class.//// COMMENTS://// This function and its usage are only necessary if you want this code
F-43
ECE 477 Final Report Spring 2008
// to be compatible with Win32 systems prior to the 'RegisterClassEx'// function that was added to Windows 95. It is important to call this function// so that the application will get 'well formed' small icons associated// with it.//ATOM MyRegisterClass(HINSTANCE hInstance){
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;wcex.lpfnWndProc = WndProc;wcex.cbClsExtra = 0;wcex.cbWndExtra = 0;wcex.hInstance = hInstance;wcex.hIcon = LoadIcon(hInstance,
MAKEINTRESOURCE(IDI_SMARTGLOVE_USERMODE));wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
// wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);wcex.hbrBackground = (HBRUSH)(0+1);
// wcex.lpszMenuName = MAKEINTRESOURCE(IDC_SMARTGLOVE_USERMODE);wcex.lpszMenuName = 0;wcex.lpszClassName = szWindowClass;wcex.hIconSm = LoadIcon(wcex.hInstance,
MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);}
//// FUNCTION: InitInstance(HINSTANCE, int)//// PURPOSE: Saves instance handle and creates main window//// COMMENTS://// In this function, we save the instance handle in a global variable and// create and display the main program window.//BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, 500, 200, 400, 500, NULL, NULL, hInstance, NULL);// hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,// CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd) { return FALSE; }
ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd);
return TRUE;}
F-44
ECE 477 Final Report Spring 2008
//// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)//// PURPOSE: Processes messages for the main window.//// WM_COMMAND - process the application menu// WM_PAINT - Paint the main window// WM_DESTROY - post a quit message and return////LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
int wmId, wmEvent;PAINTSTRUCT ps;HDC hdc;int index,textlen;TCHAR *CPortNum;TCHAR *CPortNum2;TCHAR TextBuf[4000];
DWORD dwBytesRead = 0;BYTE abBuffer[4000];
// linked list for combo boxpComboBoxItem node, temp_node;
#if _RS232_DEBUG_ == 1
if (message == CSerialWnd::mg_nDefaultComMsg) { // A serial message occurred
const CSerialWnd::EEvent eEvent = CSerialWnd::EEvent(LOWORD(wParam)); const CSerialWnd::EError eError = CSerialWnd::EError(HIWORD(wParam));
switch (eEvent) {
case CSerialWnd::EEventError: case CSerialWnd::EEventCTS: case CSerialWnd::EEventDSR:
MessageBox(hWnd,L"fefe", L"fefe", MB_OK); break;
case CSerialWnd::EEventRecv: // TODO: Read data from the port
do{
// Read data from the COM-port
serial->Read(abBuffer,sizeof(abBuffer),&dwBytesRead);
if (dwBytesRead > 0){
// TODO: Process the dataabBuffer[dwBytesRead] = 0x00;
AnsiToUnicode( (char*)abBuffer,TextBuf,1000);
F-45
ECE 477 Final Report Spring 2008
TextBuf[dwBytesRead] = 0x0000;
if (1 ) {
//Edit_SetText(hWndStaticDebug,TextBuf);if ( pcstate == IDLE) {
Edit_SetText(hWndStaticDebug,TextBuf);
}
else if ( pcstate == SEND_TEAM14PC ) {
Edit_SetText(hWndStaticDebug,TextBuf);if
( strcmp((char*)abBuffer, "TEAM14PIC") == 0 ) {
pcstate = ESTABLISHED;
}}
else if ( pcstate == RECV_DATA) {
if (ProcessData((char *)abBuffer, dwBytesRead) ) {
pcstate = ESTABLISHED;
}}
}
}}while (dwBytesRead == sizeof(abBuffer));
break;
} // Return successful
return 0; }
#endif
switch (message){case WM_CREATE:
hWndStaticFrame = CreateWindowEx(NULL,L"BUTTON",L"Control", WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
F-46
ECE 477 Final Report Spring 2008
10, 1, 375, 143, hWnd, NULL, hInst, NULL);
if( !hWndStaticFrame ) { MessageBox(hWnd, L"Could not create the static for picture", L"Failed Control Creation", MB_OK); }
hWndStaticPic = CreateWindowEx(NULL,L"STATIC",NULL, WS_CHILD | WS_VISIBLE | SS_BITMAP , 15, 20, 365, 300, hWnd, NULL, hInst, NULL);
if( !hWndStaticPic ) { MessageBox(hWnd, L"Could not create the static for picture", L"Failed Control Creation", MB_OK); }
Logo1 = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP2));SendMessage(hWndStaticPic, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
(LPARAM)Logo1);
hWndStaticDebug = CreateWindowEx(NULL,L"EDIT",NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL | WS_TABSTOP | ES_MULTILINE | ES_WANTRETURN , 10, 152, 375, 300, hWnd, (HMENU)ID_COM_DEBUG_BOX, hInst, NULL);
if( !hWndStaticDebug ) { MessageBox(hWnd, L"Could not create the static for debugging", L"Failed Control Creation", MB_OK); }
hWndComboBox = CreateWindowEx(NULL,L"COMBOBOX",NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_SORT , 155, 112, 136, 60, hWnd, (HMENU)ID_COM_LIST, hInst, NULL);
if( !hWndComboBox ) { MessageBox(hWnd, L"Could not create the combo box", L"Failed Control Creation", MB_OK); }
// deleting linked list
node = pCboxItem;
while( node != NULL) {temp_node = node;node = node->Next;
SendMessage(hWndComboBox, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(temp_node->Item));
//MessageBox(hWnd,temp_node->Item, temp_node->Item, MB_OK);
}
SendMessage(hWndComboBox, CB_SETCURSEL, 0, 0);
hWndEditBox = CreateWindow(L"EDIT",NULL, WS_VISIBLE | WS_CHILD , 15, 112, 128, 22, hWnd, (HMENU)ID_COM_COMMAND_EDITBOX, hInst, NULL);
if( !hWndEditBox ) { MessageBox(hWnd, L"Could not create the Editbox", L"Failed Control
F-47
ECE 477 Final Report Spring 2008
Creation", MB_OK); }
hWndConnectButton = CreateWindow(L"BUTTON",L"Connect", WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON , 300, 112, 80, 25, hWnd, (HMENU)ID_CONNECT_BUTTON, hInst, NULL);
if( !hWndConnectButton ) { MessageBox(hWnd, L"Could not create the button", L"Failed Control Creation", MB_OK); }
break;
case WM_COMMAND:wmId = LOWORD(wParam);wmEvent = HIWORD(wParam);
// Parse the menu selections:switch (wmId){case ID_CONNECT_BUTTON:
switch(wmEvent) {case BN_CLICKED:
Button_Enable(hWndConnectButton,false);
if ( SerialConnected == 0 ) {index =
SendMessage(hWndComboBox,CB_GETCURSEL, 0,0);textlen =
SendMessage(hWndComboBox,CB_GETLBTEXTLEN, 0,0);
CPortNum = (TCHAR *)malloc(sizeof(TCHAR) * (textlen+10));
CPortNum2 = (TCHAR *)malloc(sizeof(TCHAR) * (textlen+10));
SendMessage(hWndComboBox, CB_GETLBTEXT,index,(LPARAM)CPortNum2);
swprintf(CPortNum,textlen+10,L"\\\\.\\%s",CPortNum2);
// MessageBox(hWnd,CPortNum, L"fewfewf", MB_OK);
pcstate = IDLE;
if ( ComSetup(CPortNum) == ERROR_SUCCESS ) {
// now it is connectedSerialConnected = 1;
Button_SetText(hWndConnectButton,L"Disconnect");
} else {SerialConnected = 0;
}free(CPortNum);
F-48
ECE 477 Final Report Spring 2008
free(CPortNum2);}else if ( SerialConnected == 1 ) {
Button_SetText(hWndConnectButton,L"Connect");
serial->Close();
Edit_SetText(hWndStaticDebug,L"Disconnected");
SerialConnected = 0;}Button_Enable(hWndConnectButton,true);
break;default:
break;
}break; // case ID_CONNECT_BUTTON
default:return DefWindowProc(hWnd, message, wParam, lParam);
}break;
case WM_PAINT:hdc = BeginPaint(hWnd, &ps);// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);break;
case WM_DESTROY:
#if _RS232_DEBUG_ == 1if ( SerialConnected == 1 ) {
serial->Close();}
#endif// deleting linked listnode = pCboxItem;
while( node != NULL) {temp_node = node;node = node->Next;free(temp_node);
}
PostQuitMessage(0);break;
default:return DefWindowProc(hWnd, message, wParam, lParam);
}return 0;
}
// stdafx.cpp : source file that includes just the standard includes// smartGlove_Usermode.pch will be the pre-compiled header// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
F-49
ECE 477 Final Report Spring 2008
// and not in this file
F-50
ECE 477 Final Report Spring 2008
Appendix G: FMECA Worksheet
1. FMECA for Power Supply / Charger Block
Failure No.
Failure Mode
Possible Causes Failure Effects Method of Detection
Criticality Remarks
1 Battery Charger IC Failure
Failure of USB_R2, MAX1555_C1, MAX1555_C2, MAX1555_C3, PW_C1 resulting in shorts.
Battery cannot be charged from external USB power source.
PW_LED1 lights up depending on the power supply
High USB line is an alternate source of powering this device. Since it would be rendered useless, the battery is the only power supply.
2 Voltage regulator IC Failure
Failure of Battery charger IC or FDG315N Mosfet.
• Damage to battery• Battery Leakage• Explosion
Observation High Battery very sensitive to charging characteristics and may explode if charging rates are beyond tolerable limits.
G-1
ECE 477 Final Report Spring 2008
2. FMECA for Microcontroller Block
Failure No.
Failure Mode Possible Causes Failure Effects
Method of Detection
Criticality Remarks
1 Dead pic18f4550 – unresponsive
• Failure of power system or supply voltage > 7.5V
• Short on bypass capacitors C_C2, C_C3, C_C4
• Failure of external clock source - crystal FX425B
• Non-programmable• Failure of system
Observation with DMM
High Failure of the microcontroller should not lead to any unpredictable behavior or injury to the user.
3. FMECA for Accelerometer Mini-Board Block
Failure No.
Failure Mode
Possible Causes Failure Effects Method of Detection
Criticality Remarks
1 No output on port pins
• Bypass caps C1-C3 shorted • Open line between glove
and main PCB • IC Damaged due to
extremely quick movement, dropping IC
No analog output to feed into ATD pins.
Observation with DMM
Medium Having a low voltage input into the microcontroller would be interpreted as no movement.
2 Erroneous output readings
• Failure of Analog subsystem block
• Failure of passive components
Noisy output fed into ATD pins
Observation on host PC
Low These noisy readings would be interpreted as incorrect cursor movements on PC
4. FMECA for Analog Block
G-2
ECE 477 Final Report Spring 2008
Failure No.
Failure Mode
Possible Causes
Failure Effects Method of Detection
Criticality Remarks
1 Erroneous output fed into ATD pins
• Failure of AD8354 op-amp
• Failure of AD8532 voltage inverter
Unpredictable output values into ATD pins.
Observation with DMM
Medium • If the inverter amplifier circuit fails, the voltage output would be unpredictable
• If the voltage inverter fails, there would be a negative voltage output which is blocked by diodes.
5. FMECA for Bluetooth Module Block
Failure No.
Failure Mode Possible Causes Failure Effects
Method of Detection
Criticality Remarks
1 Incorrect data on host PC
• Retransmission of data
• Error in packet construction
Unpredictable cursor movements
Observation on host PC
Low None
2 No data • UART Tx error• No Bluetooth
handshake between host PC and radio
No cursor movement
Observation on host PC
Low None
G-3