EE 477 Final Report s3
Total Page:16
File Type:pdf, Size:1020Kb
ECE 477 Final Report Spring 2007
Team Code Name: SmartShopper Team ID: 2
Team Members (#1 is Team Leader):
#1: John Sweeney Signature: ______Date: ______
#2: Stevi Wood Signature: ______Date: ______
#3: Tera Wong Signature: ______Date: ______
#4: Jeff Richards Signature: ______Date: ______ECE 477 Final Report Fall 2006
REPORT EVALUATION
Component/Criterion Score Multiplier Points Abstract 0 1 2 3 4 5 6 7 8 9 10 X 1 Project Overview and Block Diagram 0 1 2 3 4 5 6 7 8 9 10 X 2 Team Success Criteria/Fulfillment 0 1 2 3 4 5 6 7 8 9 10 X 2 Constraint Analysis/Component Selection 0 1 2 3 4 5 6 7 8 9 10 X 2 Patent Liability Analysis 0 1 2 3 4 5 6 7 8 9 10 X 2 Reliability and Safety Analysis 0 1 2 3 4 5 6 7 8 9 10 X 2 Ethical/Environmental Impact Analysis 0 1 2 3 4 5 6 7 8 9 10 X 2 Packaging Design Considerations 0 1 2 3 4 5 6 7 8 9 10 X 2 Schematic Design Considerations 0 1 2 3 4 5 6 7 8 9 10 X 2 PCB Layout Design Considerations 0 1 2 3 4 5 6 7 8 9 10 X 2 Software Design Considerations 0 1 2 3 4 5 6 7 8 9 10 X 2 Version 2 Changes 0 1 2 3 4 5 6 7 8 9 10 X 1 Summary and Conclusions 0 1 2 3 4 5 6 7 8 9 10 X 1 References 0 1 2 3 4 5 6 7 8 9 10 X 2 Appendix A: Individual Contributions 0 1 2 3 4 5 6 7 8 9 10 X 4 Appendix B: Packaging 0 1 2 3 4 5 6 7 8 9 10 X 2 Appendix C: Schematic 0 1 2 3 4 5 6 7 8 9 10 X 2 Appendix D: Top & Bottom Copper 0 1 2 3 4 5 6 7 8 9 10 X 2 Appendix E: Parts List Spreadsheet 0 1 2 3 4 5 6 7 8 9 10 X 2 Appendix F: Software Listing 0 1 2 3 4 5 6 7 8 9 10 X 2 Appendix G: FMECA Worksheet 0 1 2 3 4 5 6 7 8 9 10 X 2 Technical Writing Style 0 1 2 3 4 5 6 7 8 9 10 X 8 CD of Project Website 0 1 2 3 4 5 6 7 8 9 10 X 1 TOTAL
Comments:
-ii- ECE 477 Final Report Fall 2006
TABLE OF CONTENTS
Abstract 1 1.0 Project Overview and Block Diagram 1 2.0 Team Success Criteria and Fulfillment 3 3.0 Constraint Analysis and Component Selection 4 4.0 Patent Liability Analysis 6 5.0 Reliability and Safety Analysis 9 6.0 Ethical and Environmental Impact Analysis 11 7.0 Packaging Design Considerations 15 8.0 Schematic Design Considerations 17 9.0 PCB Layout Design Considerations 20 10.0 Software Design Considerations 22 11.0 Version 2 Changes 24 12.0 Summary and Conclusions 25 13.0 References 27 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
-iii- ECE 477 Final Report Fall 2006
Abstract
The SmartShopper is an intelligent shopping system designed to make shopping more efficient to save the customer time and money and make their experience more enjoyable. The SmartShopper does this by providing real-time navigation instructions to a shopper and using the carts sensors to support the shopper. A SmartShopper enhanced cart also allows a shopper to speed checkout by keeping a record of the contents and value of the items in the cart.
1.0 Project Overview and Block Diagram
The SmartShopper system will enhance the shopping experience of a customer in any traditional retail store when added to a standard shopping cart. The system includes a control and display module and a variety of sensors and subsystems to create an intelligent system around the shopping experience. A customer would use a secure digital (SD) card to upload a shopping list to the SmartShopper’s control and display module. The SmartShopper would then provide instructions on how to best navigate the store to retrieve all the items on the shopping list. Instructions displayed on a character liquid crystal display (LCD) on the handlebar control module would guide the customer around the store by the most efficient route. The system will also use radio frequency identification (RFID) tags throughout the store and on the retail items themselves to provide location information to the SmartShopper system. As the customer adds items from his or her list to the SmartShopper enabled cart he or she can use the same RFID system to easily add items to the SmartShopper’s intelligent basket system. The efficiency of the SmartShopper system will reduce hassle and shopping time for the customer and enable a smoother operation of any retail store.
-1- ECE 477 Final Report Fall 2006
Figure 1.1 Block Diagram of the SmartShopper System
-2- ECE 477 Final Report Fall 2006
Figure 1.2 SmartShopper Intelligent Shopping System Installed on a Cart
2.0 Team Success Criteria and Fulfillment
The Project Specific Success Criteria approved for our SmartShopper project are the following: • An ability to encode and decode product location in a store based on a static map. • An ability to read and decode a shopping list from an SD card. • An ability to calculate an “optimal path” for retrieving items from a shopping list. • An ability to list the sequence of navigation steps necessary to retrieve the items on the desired shopping list. • An ability for the cart to determine its absolute location within the store.
The SmartShopper system meets all of the PSSCs outlined for our project. The SmartShopper can successfully detect the presence or absence of an SD card in its card slot. It is able to search the contents of the SD card for information that the system needs to locate items
-3- ECE 477 Final Report Fall 2006 throughout the store and to load the customer’s unique shopping list. With this information the SmartShopper capably decides upon the most efficient path through the store based upon the user’s needs. It also lists the steps necessary to move from item to item on the list and determine whether the cart is properly following the route designated or is detouring. If the customer detours the cart alerts the customer and advises the customer as to the proper course to their item. Once items are found, the cart is also capable of scanning the items into a contents list and keeping an up-to-date subtotal of the value of the cart’s contents. The SmartShopper performs all the PSSC functionality required and exceeds expectations by providing more flexibility and information to the customer.
3.0 Constraint Analysis and Component Selection
Various design considerations had to be considered when selecting components for the SmartShopper. These included power consumption and available memory. The SmartShopper is a battery powered device. This makes power consumption one of the primary design constraints. The device should be able to operate through at least one business day without requiring the batteries to be replaced or recharged. Another important consideration is memory; stores with a large inventory will require a considerable amount of memory for storing tag information and descriptions for each item.
3.1 Computation Requirements Computation requirements did not play a major roll in our component selection. The most computation intensive tasks include reading the file system and data from the SD card, as well as sorting the list of items in order along an optimal path. Each of these are done immediately upon insertion of the SD card and will not be done again until the card is removed and the next customer uses the SmartShopper.
3.2 Interface Requirements The SmartShopper will communicate with the user through a character LCD and four available pushbuttons. The LCD display requires an available SCI port running at 9600 baud. The four pushbuttons will be active low. Pull-up resistors will be used and the buttons will be connected to ground.
-4- ECE 477 Final Report Fall 2006
3.3 On-Chip Peripheral Requirements The microcontroller will be interfacing with numerous external modules. These include an SD card, character LCD, and RFID reader. One SPI port will be required to interface with the SD card. The SPI connected to the SD card will be operating at 400khz, the minimum required to be supported by all SD cards. In addition to SPI, two SCI ports are required for the character LCD and the RFID reader. Each of these devices will be communicating at 9600 bps.
3.4 Off-Chip Peripheral Requirements The only off-chip peripherals required by the SmartShopper are the SCI to RS-232 level translators. These ICs were obtained from Maxim-IC and are required for both the LCD and RFID module. They also allow for serial connection to a PC during manufacturing or testing, but is not a feature available to the user.
3.5 Power Constraints The SmartShopper will be powered by a series of AA batteries to obtain 12V. Voltage dividers are used to convert this voltage to both 5V and 3.3V. 5V is required by the microcontroller, and the LCD. 3.3V is used only to power the SD card. With the LCD off, current draw from the 12V supply is ~.02A. With the LCD powered the current increases to ~.1A. 2500mAh AA rechargeable batteries are readily available from Energizer. 2500mAh should allow the device to remain on continuously for more than 1 day, or remain in standby with the LCD off for approximately 5 days. The 12 V power level supplies the RFID equipment.
3.6 Packaging Constraints For the SmartShopper project prototype a simplified packaging is being used. A similar design could be applied to standard shopping carts as well as any human powered cart designed for transporting items in a commercial environment. The packaging needs to be durable enough to withstand everyday use and minor impact should the shopper accidentally run the cart into something.
3.7 Cost Constraints
-5- ECE 477 Final Report Fall 2006
Currently there is no market for products similar to our design. However, it is a task that’s done every day by many people around the world. We expect our final product to cost us $300 to design. It’s hard to measure how much a convenience is worth to the user, especially when there aren’t any similar products to compare to. If we assume the average user would be willing to pay an extra dollar for the added convenience and the cart was used just 10 times per day, in less than 30 days the cart will have paid for itself.
3.8 Component Selection Rationale When choosing a microcontroller we focused on 2 companies, Atmel and Freescale. With Atmel we primarily looked at the ATmega32 and with Freescale we focused on the MC9S12XA512. Our design requires a SPI port for communicating with the SD card, two SCI ports for interfacing with the character LCD and RFID module, and at least 4 available GPIO pins for the pushbuttons. It should also include an ample amount of memory for a large database of items.
4.0 Patent Liability Analysis
There are two particular items on the market today that perform similar functions as the SmartShopper; however, the SmartShopper will focus more on navigating the store and locating items rather than on the promotions and deals at the current supermarket and the shopping history of customers. Also, the packaging of the SmartShopper is significantly different; rather than consisting of a removable add-on unit for a cart, the SmartShopper would be a specialized shopping cart available for purchase or would require permanent modifications to existing shopping carts.
4.1 Results of Patent and Product Search Only one U.S. Patent was found while searching the United States Patent Office website for any patent liabilities associated with the design of the SmartShopper; however, two commercial products were also found which have similar functionality.
4.1.1 United States Patent number 7,156,303, filed September 23, 2005: Shopping System and Method [1]
-6- ECE 477 Final Report Fall 2006
A shopping system that locates items based on RFID tags is held under US Patent 7,156,303 [1]. As listed in the abstract of this patent, the shopping system and method includes an “item recording computer for recording item identification information associated with an item selected for purchase by a shopper in a store, for recording identifying information about the shopper from an RFID identifier carried by the shopper, and for storing the item identification information in a data file associated with the identifying information of the shopper” [1]. There are different shopping methods listed in the patent, with variations on how the payments are processed. Payments can be processed by using payment information associated with a shopper in the data file and automatically applying the payment as each item is received, after all items are received, and with or without the use of a checkout computer [1]. The claims also include variations on how item information is identified, with an RFID reader, bar code reader, or keyboard [1].
4.1.2 U-Scan Shopper by Fujitsu Transaction Solutions Inc. [2] No additional U.S. patents were found that related to the SmartShopper; however, Fujitsu Transaction Solutions, Inc. has obtained Klever Marketing’s non-U.S. patents in the creation of their U-Scan Shopper [2]. The U-Scan Shopper is a shopping aide in the form of a computer mounted on the handlebar of a shopping cart [2]. It incorporates item- scanning with the use of a barcode, item location, and downloadable shopping lists from the store’s website [2]. None of these functions incorporate the same technology as the SmartShopper, but the final product is very similar.
4.1.3 Shopping Buddy by IBM and Cuesol [3,4,5] Another commercially available product is the Shopping Buddy by IBM and Cuesol. This shopping assistant can send an electronic order to the deli via Wi-Fi technology and locate specific items on a shopping list with the use of navigational beacons throughout the store [3,4]. It can also keep a running total of the items after scanning them via a barcode scanner as well as remember buying history based customer identification with the scan of a customer’s loyalty card. [3]
-7- ECE 477 Final Report Fall 2006
IBM has given all of the intellectual property involved in the Shopping Buddy to the Association of Retail Technology Standards (ARTS) [5]. This allows there to be an industry-wide standard on the compilation of item pricing and listings.
4.2 Analysis of Patent Liability The SmartShopper literally infringes upon U.S. Patent 7,156,303, with the main aspect of both systems focusing on the use of an RFID reader to retrieve and compile information while shopping. The actual information collected varies; under this patent, the information recorded, stored, and read is not solely information on the products themselves but additionally on the shopper. For example, the information collected from the shopper includes payment information (i.e. credit card or bank account information) which is automatically applied to the items. Another difference between the shopping system patent and the SmartShopper also involves a computer and server under the patent. In the SmartShopper design, all of the information on the products will be embedded. There is no literal infringement between the SmartShopper and the U-Scan Shopper, and there are too many differences to cover an infringement under the doctrine of equivalence. The technology used in the U-Scan to scan items is a barcode, while the SmartShopper uses RFID tags. Although the U-Scan Shopper provides information on item location, no actual technological means are identified. The information supplied on item location probably identifies the isle number, although there is no source to verify this. The SmartShopper uses RFID tags to assist in detection of aisle locations. Under the doctrine of equivalents, the function is not substantially performed in the same way. The U-Scan Shopper has a large focus on promotional items and advertisement, as well as the self-scanning payment. In the SmartShopper design, the focus is to make shopping as easy as possible, without additional distractions. The Shopping Buddy’s functionality is significantly similar to that of the SmartShopper, specifically relating to item location. Although the systems use different technology to locate items, both the Shopping Buddy and the SmartShopper utilize some form of tracking system in item location; therefore, this could be a violation under the doctrine of equivalence. Also, both systems keep a running total of the price of all items.
-8- ECE 477 Final Report Fall 2006
4.3 Action Recommended It is critical to resolve any literal patent infringements before completion of the design. Because of this, the SmartShopper team would need to either purchase the patent or pay licensing fees to use the shopping system and method. This would ensure that no financial loss would ensue based on the infringement of this patent in the future. As there is no infringement on the U-Scan Shopper, no action needs to be done here; however, there are infringements related with the Shopping Buddy. This is probably a result of ARTS trying to create and industry-wide standard, there may be no fee associated. 4.4 Summary The only literal patent infringement is under U.S. Patent 7,156,303, which deals with the shopping method of using RFID readers to identify and compile information on items. The SmartShopper does not infringe on patents concerning Fujitsu’s U-Scan shopper; however, there is a violation under the doctrine of equivalence with the Shopping Buddy. Both the patent infringement and commercial product infringement can be easily resolved by paying fees to those holding the intellectual property rights.
5.0 Reliability and Safety Analysis
Although an assessment of this device points to a low failure rate, the major circuitry of the design has been inspected to ensure the safety of its consumers. In this reliability and safety analysis, the components in this design that are believed to have the highest failure rate are evaluated. The number of failures per million hours and Mean Time To Failure (MTTF) are calculated for these components. Additionally a Failure Mode, Effects and Criticality Analysis (FMECA) is performed to assess the significance and consequences of each possible failure. The components seen as the most likely to fail are the step-down converter, RFID reader, and microcontroller. In light of this, the above circuitry has been analyzed by calculating the failure rate and suggesting possible improvements.
5.1.1 Step-Down Converter: TI TPS5420 Texas Instrument’s TPS5420 step-down converter has a 5.9058 failures per million hours. The failure of this component could be of high or low criticality. The failure of this part will cause the SmartShopper to cease working. This device failure
-9- ECE 477 Final Report Fall 2006
could simply be a nuisance to the customer and thus be a lower criticality failure. However, if the failure of the power converter causes heat damage to the product or even fire this would be of high criticality.
5.1.2 RFID Reader: Intersoft TR-RO1 The Intersoft TR-RO1 RFID reader that is being used in the design of the SmartShopper is a module. It is seen as one of the most complex and important components in the design and was therefore distinguished as a candidate for failure analysis. Unfortunately, not enough documentation was found in order to perform a complete analysis. The Military Handbook of Reliability and Prediction of Electronic Equipment does not cover the analysis of modules, and the product’s data sheet does not provide information on the individual RFID reader chipset [6].
5.1.3 Microcontroller: Freescale MC9S12XA512 Given that the microcontroller of the SmartShopper handles the main functionality, the failure of this component will cause the product to cease operation. Consequently, the Freescale MC9S12XA512 microcontroller was analyzed using the model for microcircuits, gate/logic arrays and microprocessors as presented in the Military Handbook of Reliability Prediction of Electronic Equipment, section 5.1. The failure rate of the microcontroller is 9.184 failures per million hours. The malfunction of this module is seen as low criticality, because it merely causes the functioning of the product to stop. The acceptable rate for a low critical failure is 10-5; therefore, the failure rate of this element of the design is not a significant concern.
5.2 Failure Mode, Effects, and Criticality Analysis (FMECA) For the FMECA analysis, the schematic for the SmartShopper has been divided into six sections: power circuitry/step-down converter (A), RFID reader and circuitry (B), microcontroller (C), liquid crystal display (D); shown in Appendix G. As the analysis shows, in Appendix B, most of the possible failures are of low criticality, causing at most a malfunction of the product. The criticality levels are defined in the following way: low criticality is a malfunction of the product and should occur with a probability of less than 10-5; high criticality
-10- ECE 477 Final Report Fall 2006 includes a possible injury of a user and should occur with a probability of less than 10-9. All of the failures are predicted to occur within the specified probability, with the exception of the possible high criticality failure of the step-down converter.
5.3 Summary The SmartShopper is a product with a fairly low failure rate. The highest failure rate of the components analyzed in the reliability and safety analysis above is 9.184 failures per million hours, that of the microcontroller. As the microcontroller has only failures of low criticality, this does not generate any concerns. There is merely one component which has a possible high criticality failure, the step-down converter. Overall, the SmartShopper has a reliable, safe design; therefore, not many changes are required to improve this aspect of the product.
6.0 Ethical and Environmental Impact Analysis
The SmartShopper system is created with many expectations in mind and product functionality is not the only aspect that must be considered in its design. Ethical considerations must be taken into account. Its designers must reduce any potential hazard to safe levels as well as ensure proper testing of the device to meet certain ethical standards prior to release and sale to public. The environmental impact that the production and use of our device will have must also be thoughtfully considered.
6.1 Ethical Impact Analysis
6.1.1 Product Safety The SmartShopper system must maintain a level of acceptable safety for all its users. The SmartShopper system is not expected to be high risk to maintain or to use on a regular basis. It has no moving parts and uses low levels of power, but it is still important to ensure that its power supply does not endanger the customer through overheating or creating any other disturbance. Additionally, the product package must not create any safety hazard. The PCBs must be fully contained so that no circuitry is exposed, and the packaging must not be sharp or dangerous to install onto the cart itself. The access to the battery compartment needs to be sealed securely, to guarantee that children and adults are not able to easily access the battery or power terminals.
-11- ECE 477 Final Report Fall 2006
Additionally, any wiring used along the cart should be embedded into the cart or securely fastened to keep any choking or tripping hazard within acceptable levels. Individual component concerns have previously been addressed in the FEMCA section 5.1. Additionally, the SmartShopper uses RF (Radio Frequency) technology through the use of subsystems of the SmartShopper. The SmartShopper company needs to be aware of FCC (Federal Communications Commission) regulations regarding these technologies and their uses. While the company will not be manufacturing any of the RF transmitting devices they will be an embedded component of the system and will have to meet EMI (Electromagnetic Interference) standards required [7].
6.1.2 Product Quality One of the most obvious ethical issues that will be addressed in the design of the SmartShopper system is the overall quality of the product. The SmartShopper must be durable and work properly to meet the customer’s expectations. While providing products that are free of known defects and issues is obviously sensible business practice it is also a matter of ethical conduct. The SmartShopper company cannot, in good conscience, sell a product that does not perform its function of assisting the retailers’ customers well each time it is used. To provide customers with the quality products they expect we need to thoroughly test our product before release, performing environmental testing, stress testing, drop testing, and HALT (Highly Accelerated Life Testing). All to ensure its ruggedness in different environments, climates, altitudes and over the entirety of the products expected life. The product must also be sold with a clear understanding of the expected life of the product and the expected life of the product’s batteries. Any known bugs should be addressed before release of the product. Upgrades to the product must be facilitated in a reasonable manner in order to maintain good customer relations and to uphold good, ethical business practices. Shake testing and drop testing will be especially important since the system will be mounted throughout a shopping cart that will be banged against other carts, cars, parking lot light posts. Even once a product has been released for sale continued testing must take place to maintain a high level of product quality to make sure that future customers receive a product as good as the first product off the assembly line and to maintain and build a
-12- ECE 477 Final Report Fall 2006
reputation for quality at the SmartShopper company. Additionally, as the PCBs are manufactured, in-line circuit testing should be performed on each board to confirm that each board has been built to quality standards. Basic functionality, such as power levels, ground connections and other simple signals can be tested without appreciably slowing the manufacturing process.
6.1.3 Product Privacy The SmartShopper system gathers and uses data from customers to enhance and assist their shopping experience at retailers’ stores. While this data may be gathered and used in some form for the retailers to improve their product offerings and store arrangement it must be gathered in an anonymous way. Only general shopping habits from a large population should be available for retailers to view so that the privacy of each individual retail customer is not infringed upon. The SmartShopper system may also be used to save customer preferences in some fashion or to compile data over a period of time externally on the SD card each customer would use or in some other fashion. Any such data or saved preferences should be sufficiently encrypted and protected, especially in the event that the SmartShopper is used as a larger system to facilitate payment or checkout as credit and debit card numbers would then be involved in the data transaction. Even with encryption provided with the system, retail customers should be notified through simple warning labels or a warning notice on the LCD panel that their information may be stored or used anonymously and encrypted so that they understand the minimal risks involved and make an informed choice.
6.2 Environmental Impact Analysis
6.2.1 Considerations During Production Throughout the SmartShopper’s life it will have an impact upon the environment. The manufacturing process requires creation of not just the primary PCB with its control and interface circuitry but the product also requires interface with several ancillary modules which require PCBs. By requiring that SmartShopper component suppliers use parts that are RoHS (Reduction of Hazardous Substances) compliant we can reduce the
-13- ECE 477 Final Report Fall 2006
impact profile of the device during manufacture [8]. It would also be highly beneficial to require each of the subsystem PCBs be manufactured using the same standards. This way the use of hazardous materials is reduced all along the supply chain, not just at our final assembly point. Because several of the components will be packaged separately and positioned throughout the cart there will be several small component packages. Each subsystem will be designed to reduce profile and materials chosen to be reusable or recyclable to reduce landfill impact at the end of the products lifecycle. Each of these small packages is likely to be a plastic and injection-molded. Intelligent design of the package can reduce waste in the manufacturing process.
6.2.2 Considerations for Useable Life of the Product During the products usable life its module nature will enable simple replacement of subcomponents if upgrades are needed or if portions of the product fail. It will not be necessary to replace the entire SmartShopper system if, for instance, the digital compass module fails or the RFID reader needs an upgrade to one with larger range or increased sensitivity. The largest environmental concern during the projects useful life will be its constant use of battery power. The system will use rechargeable batteries to increase the useful life of the batteries, but it is expected that the batteries will reach the end of their useful life before the product does. Both the battery holder on the SmartShopper and the SmartShopper’s battery pack will be labeled with instructions to properly dispose of the batteries in order to reduce the chance that hazardous materials are exposed to the environment in a landfill.
6.2.3 Considerations For Disposal Once the SmartShopper concludes its useful life the plastic housing and the PCB components inside can each be recycled separately to some extent. Even to the extent that the PCB cannot be whole reused in some fashion it must still be disposed of with care so that the materials therein do not become a danger to people. In order to encourage the retailers to dispose of the SmartShopper in an environmentally friendly
-14- ECE 477 Final Report Fall 2006
manner the SmartShopper corporation will incentivize this behavior by offering a discount on a new version of the SmartShopper system to replace the worn-out device if disposed of properly. The SmartShopper company also needs to be aware of any existing laws pertaining to the disposal of rechargeable batteries if it chooses to use certain battery technologies [4]. In this way the company can encourage loyalty to its products by keeping repeat customer’s and also encouraging environmentally friendly behavior.
6.3 Summary
The SmartShopper must be produced to meet the expectations of many people. The retailers who use the product also expect it to be a good value for their money, durable, and bug- free. The customers of the retailers expect that their privacy will be maintained throughout the use of the SmartShopper system. Most importantly, both parties expect that the SmartShopper will be safe to use. All of us, the SmartShopper company, the retailers and the end users all expect that the SmartShopper will not harm the environment in which all people live and that as the creators of such a product that the SmartShopper company will do its utmost to keep the environmental impact of this product to a minimum. Significant product testing must take place to meet these expectations. Additionally, the design and manufacturing processes must be responsible in their use of resources and their effect upon the earth. Clear and helpful labeling must be used on the packaging to communicate any dangers of the product and for its most efficient use. With all of these things kept in mind, the SmartShopper company will meet the ethical and environmental expectations of its customers and itself. These practices will lead to fair and honestly earned profits as well.
7.0 Packaging Design Considerations
The SmartShopper system will be added to a standard shopping cart and will be designed to enhance to shopping experience with as little change as possible to customer’s expectations of a shopping cart. The SmartShopper system should be seen as an enhancement to a typical shopping cart, but it should not take away from the cart’s ability to perform its primary task of carrying goods nor should it appear to overwhelm the customer with technology during their routine shopping experience. The packaging of the SmartShopper system will be a key component in managing these two critical aspects of the SmartShopper’s design.
-15- ECE 477 Final Report Fall 2006
7.1 Project Packaging Specifications Two RFID readers have been incorporated in the design of the SmartShoppers. A larger RFID antenna will be attached to the bottom of the cart, underneath the bottom rack. The SmartShopper will use this reader to track the cart’s position throughout the store. The reader will be enclosed to prevent damage to the antenna or tampering. The reader module will also be located in a small enclosure and attached to the bottom of the shopping cart. A secondary RFID antenna will be attached near the handle bar and used to scan items into the basket of goods that the customer is purchasing. This antenna will also be enclosed to prevent damage. The entire RFID system will be attached to the cart so as to make it as unobtrusive as possible but still provide the best sensing capabilities to the system. The control functions of the SmartShopper, as well as the LCD display will be placed within an enclosure mounted on the handlebar of the shopping cart. It is this portion of the system that the customer will most associate with the system itself, as the other SmartShopper subsystems will be working in the background without the customer’s knowledge. The SmartShopper should not make the cart more difficult to control, more uncomfortable to handle, or interfere with the customer’s ability to use the cart’s upper basket or child seat. With these requirements in mind the SmartShopper’s control and display enclosure will be as small as possible to reduce interference in using the cart. In order to create a weather-resistant product, each component enclosure will be weather- resistant. The enclosures will also need to be durable enough to withstand the impacts caused by colliding with objects in the store and parking lot. Additionally, the placement of the components of the SmartShopper system must not interfere with the ability of carts to be stacked within one another for storage as this is a critical feature of a standard cart design and the loss of this capability would be unacceptable to our retail customers.
7.2PCB Footprint Layout Some of the major components of the SmartShopper design, mentioned above, will need to be placed directly on a printed circuit board (PCB); these components include the microcontroller (Freescale MC9S12XA512), the RS232 driver used with the RFID module, the headers that will be used to communicate with the RFID module, the SD card connector and the
-16- ECE 477 Final Report Fall 2006 relay used to toggle between RFID antennas. The Freescale MC9S12XA512 microcontroller comes in 80, 112, and 144-pin packages [9]. The 112-pin footprint was chosen for this design in order to have the number of communication ports needed. The corresponding RS232 driver has surface mount and thru hole options; for the purpose of debugging, the thru hole package was chosen. The initial footprint of the PCB, shown in Appendix D as Figure D.1, is 3.937”x 5.758”. These dimensions include additional spacing between the main components, which will allow for additional circuitry such as capacitors, resistors and debugging components. The size of the PCB also allows space in the chosen enclosure for padding and other components such as the RFID reader.
8 Schematic Design Considerations
Several subsystems that are being designed for this project include the microcontroller, a RFID reader, an LCD screen and battery power components. The SD card reader acts as the input to the SmartShopper device and the LCD acts as the output to the system, providing shopping instructions to the customer. The RFID system helps the cart navigate the store and also provide additional information to the user about the details of their purchases. The microcontroller manages all aspects of the systems decoding and encoding of user information taking the customer’s list and translating that into precise instructions on how to navigate the store. Finally, the batteries provide the power and a step-down converter will convert it to the proper voltage levels.
8.2 Theory of Operation The SmartShopper consists of a series of subsystems related to navigation, information input and output and power management which must be interfaced carefully in order to effectively provide the feedback and information a customer will require when using the device.
8.2.1 LCD screen Instructions will be provided to the customer using the SmartShopper on an LCD screen. The SmartShopper will incorporate the use of a MOS-AL202A type LCD screen manufactured by Matrix Orbital. These screens are small enough, approximately 3” by 6” [10], that it can be mounted to the handle bar of the cart. Further, the screens only
-17- ECE 477 Final Report Fall 2006
require 9mA of power (at 5V) without the use of a backlight, which will be necessary given the need to run on battery power. Matrix Orbital’s LCD modules have the additional advantage of needing significantly fewer signal lines than old LCD screens. Only transmit and receive lines are needed apart from power and ground [1], allowing for the use of a smaller microcontroller.
8.2.2 RFID reader The SmartShopper PCB interfaces with an Intersoft TR-RO2 reader. This reader requires from 9 to 12 V which will be supplied directly from the batteries [6], without conversion. The voltage input range allows for some fluctuation in the power level as the batteries drain without interruption of the operation of the module. The reader requires 60 mA of current [6], which makes this subsystem one of the highest power requirements of the system.
8.2.3 Microcontroller The microcontroller inside the SmartShopper will be interfacing with a number of critical peripheral devices. The choice of the Freescale MC9S12XA512 was made because of the need for communication ports; one SPI connection for the SD card reader [9] and several SCI ports. While the need for so communication ports dictated the primary consideration of the microcontroller memory requirements were not far behind. The MC9S12XA512 has 512 k of Flash memory, enough to handle the requirements of our navigation optimization program [9].
8.2.4 Power Supply Two separate Texas Instruments TPS5420 Step-down converters will be used to provide the 5 V and 3.3 V power levels to the SmartShopper’s PCB [11]. The TPS5420 is capable of accepting a wide voltage range from 5.5 to 36 V; this will allow our 12V battery supply to continue to supply voltage even as the batteries drain over time. The part is capable of a 2 A continuous output, well above the requirements of the system drawing 150 mA. The part is also very efficient when the proper components are
-18- ECE 477 Final Report Fall 2006
selected. Additionally, using an 8-pin SOIC package, allows the total size of the PCB to remain small.
8.3 Hardware Design Narrative The SmartShopper system will be using one SPI block as well as two SCI blocks and several general I/O pins to communication with its peripherals. The SD card reader will interface with SPI1, on port H. Our design leaves two additional SPI ports available for further expansion using additional sensing technologies or interfaces in the future. The use of SPI enables fast and reliable communication with our peripherals with a minimum of communication lines. The LCD module will require a serial interface, as will the RFID reader module, so two of the SCI blocks on the MC9S12XA512 will be used for that purpose. These SCI blocks reside on port S of the microcontroller. Pins on port ATD0 will be used for their GPIO, interfacing with the customer selected pushbutton controls. This port was chosen for this purpose because the analog-to-digital conversion capabilities of the microcontroller will not be needed for this project and there is a secondary ATD port. Thus, in the event that ATD capabilities are needed there is still the availability of the secondary port. All unused port pins will be mapped to convenient connector blocks for use in later development in the project and a 6-pin BDM port will be created on the board for easy use of the background debug mode capabilities of the microcontroller [12]. Properly selected capacitors will be needed for the operation of the microcontroller’s external clock; this external operation is depicted in Appendix C. This clock will run the microcontroller at 25MHz [13]. Additional SPI and SCI communication ports will be output to headers for use during development or future expansion of the product.
8.4 Summary With the systems outlined in this report the SmartShopper will be fully capable of assisting the smooth navigating a store environment given the customer’s needs. Information provided by the RFID reader and the digital compass will alert the SmartShopper to the customer’s progress throughout the store and enable it to better provide the instructions needed to quickly and easily find all the items required. The careful design of the system with power considerations taken
-19- ECE 477 Final Report Fall 2006 into account should enable the SmartShopper to run for several hours, enough for even a long shopping trip.
9.0 PCB Layout Design Considerations
The SmartShopper is a shopping cart system designed to make commercial shopping trips more efficient and effortless for the user. The user loads a shopping list via an SD card, and the cart then displays a list of navigational directions on a LCD screen mounted on the handlebar of the cart. While traveling the store notification is given when the user enters an aisle with an item on their list. The SmartShopper will be battery-operated, so the system must provide all required power rails as well as consume the minimum amount of power. Since most of the peripherals will be off-board, the PCB must have space for the connectors needed to interface with these devices. Placement for additional components required for the power supply must also be considered. Additionally, trace widths on particular paths need to be wide enough to carry higher amounts of current.
9.1 PCB Layout Design Considerations - Overall Since most of the peripherals are off-board, the layout will need to accommodate a number of connectors. The RFID reader will be placed on the side of the cart and will connect to a 4-pin 0.100 inch header on the PCB [6]. The LCD will be a part of the main module mounted on the handlebar of the shopping cart and will interface to the PCB with a 4-pin 0.100 inch header [14]. Because the depth of the main module is a fixed size and the LCD module is approximately 1” thick, this header will be placed on the PCB directly under where the LCD module will be mounted to the box. This will make sure that there is enough space to run the connector between the two boards. Three voltages will be required to operate the device: 3.3 V, 5.0 V, and 12.0 V. The 12.0 V power rail will be used to power the RFID reader. The reader pulls 60 mA of current [6]. Although the current is not very high, the trace widths will be a minimal of 10 mils [10] to ensure that no traces will burn up during operation. The 3.3 V and 5.0 V power levels will be achieved using two Texas Instruments TPS5420D Step-Down Converters. Additional components are required for proper operation of the circuit, such as decoupling capacitors,
-20- ECE 477 Final Report Fall 2006 resistors, and inductors [11, 18]. The trace widths for the 3.3 V and 5.0 V outputs will also be approximately at a minimum of 10 mils to provide sufficient trace widths for the supplied load [10], although no devices with current ratings over 24 mA will be powered using either voltage rail.
9.2 PCB Layout Design Considerations - Microcontroller For proper PCB layout of the microcontroller, several ceramic decoupling capacitor considerations are required; the decoupling capacitors must be as close as possible to the corresponding pins [9]. The VSSR pin should serve as the control point of the ground star, and VSSPLL must be directly connect to Vssr. There should be low ohmic low inductance connections between VSS1, VSS2, and VSSR [9]. The trace widths will be a wide and the length will be as short as possible to ensure this. The trace lengths of VSSPLL, EXTAL, and XTAL will be as short as possible, and the occupied board area for C7, C8, and Q1 (the crystal) as small as possible [9]. No other signals or power supply traces should be located underneath the area occupied by C7, C8, and Q1 and the connection from them to the MCU [9]. Traces from the power supply should first be routed to the VDDA/VSSA pins [9], then to the rest of the power supply pins on the microcontroller. The recommended values of the capacitors are small enough that 0805 size surface-mount capacitors can be used. Lastly, the oscillator circuit for the microcontroller must be low-noise [9]. Therefore, this will remain somewhat isolated from the rest of the PCB devices.
9.3 PCB Layout Design Considerations - Power Supply The RFID reader can operate from 9.0 – 12.0 volts, so this power source will come straight from the battery pack. As no other devices on the PCB will be using the 12.0 V power rail, this will be isolated from the rest of the system. Also, the connector for the RFID reader will be close to the 12.0 V supply, eliminating further noise by reducing the trace lengths. The TPS5420D step-down converters used to achieve the 3.3 V and 5.0 V power levels has many additional components to reach the desired voltages. A bypass capacitor is placed as close to the input voltage pin, and the loop area formed by this capacitor and the ground pin should be minimal. A ground layer should be placed underneath the ground pin to connect to the anode of the catch diode. The PH pin of the device should be connected to the
-21- ECE 477 Final Report Fall 2006 output inductor, catch diode, and boot capacitor. The inductor should be close to the PH pin, and the area under it should be minimized to prevent capacitive coupling. To minimize the output current loop, the catch diode should be placed close to the component. The boot capacitor should be close to the device, and the conductor trace lengths should be minimized. The output filter capacitors between the VOUT and GND should be minimal length. The loop formed by the PH pin, Lout, Cout, and GND should be as small as possible. To connect VOUT to VSENSE, use a resistor divider network to set the desired output voltage.
9.4 Summary While our design is fairly simple, there are many considerations to take into account when layout out the printed circuit board. The many off-board components in the SmartShopper PCB design require several connectors to be placed on-board. Also, trace widths of the three power rails will be a minimum width of 10 mils to ensure sufficient current flow. There are many placement considerations of capacitors for the microcontroller. Many of the trace lengths need to be short to decrease noise, and certain trace widths need to be small to reduce any additional resistance. Furthermore, the oscillator circuit must be isolated to decrease noise from other parts of the PCB layout. The TPS5420D step-down converters have many additional components with specific considerations. The locations of supported components are crucial for proper operation of these devices.
10.0 Software Design Considerations
Many considerations were taken into account when designing the software for the Smart- Shopper. With no GPS type tracking system an intelligent form of checkpoints along with heading information from the digital compass will be used to keep track of the carts current location within the store. Primary communication with the shopper will be through a 20 character, 2 line LCD display attached to the handle of the cart. Messages will need to be concise and formatted in such a way as to fit reasonably on the display. The Smart-Shopper will rely primarily on input from external modules to respond to the user, this means the majority of actions and responses will be handled by software on the microcontroller.
-22- ECE 477 Final Report Fall 2006
10.1 Software Design Considerations The MC9S12XA512 from Freescale is the primary microcontroller for the system. It will interface with the LCD, RFID module, and SD card. The LCD and RFID module are both interfaced via SCI ports on the microcontroller. The SD card one of the available SPI ports. With the exception of the RFID module, all of the other devices we can poll for data only when we need it. Polling loops will be use to read files from the SD card. Since the RFID module needs constant monitoring an interrupt will be used. The majority of the code will be triggered by the RTI interrupt. It will act as a large state machine keeping track of the current status of the device and what needs done next. Each of the 2 SCI ports will be setup at 9600bps with interrupts enabled for the RFID module (SCI0). The corresponding control and baud rate registers are located as shown in the table below. SCI0BDH 0x000000C8 SCI1BDH 0x000000D0 SCI0BDL 0x000000C9 SCI1BDL 0x000000D1 SCI0CR1 0x000000CA SCI1CR1 0x000000D2 SCI0CR2 0x000000CB SCI1CR2 0x000000D3 SCI0SR 0x000000CC SCI1SR 0x000000D4 SCI0D 0x000000CF SCI1D 0x000000D7
BDH and BDL for each SCI port will be initialized to allow for 9600 baud operation. CR2 will then be initialized to enable each SCI port, along with enabling interrupts for received data on SCI0. SPI registers are located as follows. SPI1CR1 0x000000F0 SPI2CR1 0x000000F8 SPI1CR2 0x000000F1 SPI2CR2 0x000000F9 SPI1BR 0x000000F2 SPI2BR 0x000000FA SPI1SR 0x000000F3 SPI2SR 0x000000FB SPI1D 0x000000F5 SPI2D 0x000000FD
CR1 and CR2, control registers 1 and 2 for each SPI port will be initialized to enable bi- directional communication on the SPI port and leave all related interrupts disabled. The SD protocol requires that all SD cards be able to communicated at a minimum of 400khz in when in SPI mode. SPI1BR will be setup for a clock speed just under 400khz. Reading a heading from
-23- ECE 477 Final Report Fall 2006 the digital compass only requires sending and receiving a few bytes on SPI2. With no mass data transfers necessary SPI2BR will be initialized to its lowest speed for maximum compatibility. Once an SD card has been connected a state machine will be used to keep track of the status of the system and handle the majority of all status and location updates. This state machine will be triggered from an RTI subroutine every millisecond. This design choice is based on the way in which the RFID reader operates. When a tag is in range the RFID module continuously sends its ID to the microcontroller. The only useful tags will be any tag that is being read in for the first time, these tags will specify either a new item being added to the cart or a new location marker has been reached. An RTI subroutine will poll the RFID reader for new tags every millisecond, making updates to the carts inventory and location.
10.2 Software Design Narrative Software for the Smart-Shopper is broken up into two main areas, software related to reading the FAT32 file system and downloading the shopping list, and software related to shopping and adding items. This code is included in sd.c and shop.c respectively. Each of the sd and shop files contain a global status variable, sdStatus and shopStatus as well as a function consisting of a large switch statement based on the current status. This creates a large state machine which loops through each individual step of reading from the sd card or updating the location / item list based on the last RFID tag scanned. Main.c also includes its own status variable for the RTI interrupt. It begins by waiting until an SD card has been detected at which point it continuously calls the sd function located in sd.c. Once the sd card has been successfully read rtiStatus is incremented and the RTI interrupt begins continuously calling the shop function located in shop.c indefinitely until the SD card is removed.
11.0 Version 2 Changes
The SmartShopper 2.0 will contain new features meant to improve the product and the intelligent shopping experience for retail customers. Discoveries made assembling a working prototype taught the design team about how to create an even better system in the future. Additional hardware that became necessary, including an external relay for antenna control could be added to the PCB. USB circuitry originally designed into the system could be removed to
-24- ECE 477 Final Report Fall 2006 make room for circuitry meant to reduce the number of external modules that the SmartShopper depends upon. Control circuitry for the RFID antennas could be added to the primary PCB and thus reduce the total number of boards present in the system. In turn, this would reduce the complexity of the system by reducing the number of separate enclosures for components. Features for wireless checkout, enabled by either Zigbee or Bluetooth protocols could further automate and improve the SmartShopper. Debugging circuitry, necessary during development, could also be taken off the board and this should allow for the board size to decrease. A larger, touch-screen LCD might replace the character LCD display and the four control buttons on the main enclosure. This change would be largely cosmetic but would probably be expected by costumers comfortable with interacting with such screens in checkout lines regularly. These modifications would decrease the size and cost of the SmartShopper, increase its features to further improve a customer’s shopping experience and make maintenance, installation and daily use even easier.
12.0 Summary and Conclusions
Throughout a busy semester our team was able to bring a product idea from concept to advanced prototype. Our team persevered through the challenges of managing a project of broad scope and continued to narrow our focus and work towards the goal of creating an intelligent shopping system without losing time becoming mired in technical challenges with specific technologies. Our team learned how to cooperate well and discuss alternative technical solutions to problems that faced the project and to manage conflicting ideas well. Our team learned efficiency in performing the work needed and was able to perform good development work over the course of the project enabling a better transition to work with our final PCB. Despite some technical issues our team transitioned very well from using separate development work to dealing with the problems of full system functionality. As our team learned from experience over the semester the project changed directions several times, avoiding unnecessary hazards and streamlining our prototype to a very efficient system which accomplishes the project requirements, adds more user functionality than originally outlined and yet accomplishes these goals with fewer subsystems than originally
-25- ECE 477 Final Report Fall 2006 thought. The SmartShopper system is an excellent prototype of an intelligent shopping system and is robust enough to prove the feasibility of the real world use of just such a system.
-26- ECE 477 Final Report Fall 2006
13.0 References
[1] T.G. Holzman. “Shopping System and Method.” U.S. Patent 7,156,303, Jan. 2, 2007
[2] “Scan in your own trolley with Fujitsu U-Scan Shopper,” [Online article], (July 20, 2005), [cited February 1, 2007], Available at http://www.fujitsu.com/au/news/pr/archives/2005/20050720-02.html
[3] “Stop & Shop to roll out new intelligent shopping carts from IBM and Cuesol,” [Online article], (October 13, 2004), [cited January 23, 2007], Available at: http://www- 03.ibm.com/industries/retail/doc/content/news/pressrelease/1162561101.html
[4] “Tough Problems Solved,” [Online article], [cited January 23, 2007], Available at: http://domino.research.ibm.com/odis/odis.nsf/pages/solution.10.html
[5] M. Lamonica, “IBM aims to satisfy data-hungry shoppers,” [Online article], (Aug. 8, 2005) [cited February 1, 2007], Available at http://news.com.com/IBM+aims+to+satisfy+data- hungry+shoppers/2100-7345_3-5823169.html
[6] “TR-RO1-oem,” [Online Data Sheet], [cited February 13, 2007], Available at: http://www.intersoft-us.com/dnload/trro1oem.pdf
[7] RFID Gazette, “RFID regulations by FCC” [Online Document], [7 December 2005], http://www.rfidgazette.org/2005/12/rfid_regulation.html
[8] “RoHS,” [Online Document], [2005] , http://www.rohs.gov.uk/
[9] “MC9S12XDP512 Data Sheet,” [Online datasheet], [cited February 8, 2007], Available at: http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S12XDP512V2.pdf
[10] “MOS-AL-202A Technical Manual,” [Online datasheet], [cited February 8, 2007], Available at: http://www.matrixorbital.ca/manuals/MOS_series/MOS-AL202C/MOS- AL202C_100.pdf
[11] Texas Instruments, “5.5-V to 36-V, 2-A Step-Down Swift(TM) Converter,” [Online datasheet], [cited March 2, 2007], Available at: http://www.ti.com/lit/gpn/tps5420
[12] Freescale, “Background Debug Module V4,” [Online Zip File], October 2005, http://www.freescale.com/webapp/sps/site/prod_summary.jsp? code=MC9S12A512&fsrch=1
[13] Freescale, “OSC Block User Guide V 2.03,” [Online Zip File], February 12, 2003, http://www.freescale.com/webapp/sps/site/prod_summary.jsp? code=MC9S12A512&fsrch=1
-27- ECE 477 Final Report Fall 2006
[14] “Trace Width Calculator”, Available at: http://www.pcbco.com.au/tracecalc.html
-28- ECE 477 Final Report Fall 2006
Appendix A: Individual Contributions
A.1 Contributions of John Sweeney:
I spent considerable time searching for components and development modules for the project. Many components were never used, such as motor control and several different power supply possibilities, including low-drop out regulators and dual output supplies. I called and e- mailed multiple vendors and manufacturers throughout the course of the project searching for the best possible components that could be sampled or loaned to our project. Through the course of this work I was able to obtain free motors, a free digital compass module with development kit, a free BDM programmer module, and free Zigbee wireless development kit. I performed the schematic design for the project and used OrCAD to capture each of the subsystems of the PCB. This work included several versions of the power supply design and all of the different module interface systems. For each of the power supply options we explored the power supply subsystem was redesigned, including all the external circuitry. Time was spent going through four different power supply iterations and sampling parts for each of these designs. Most of the integrated circuits needed to have parts created uniquely for the design of our SmartShopper and I diagrammed all of these parts aside from the microprocessor itself. I designed the board with the maximum flexibility possible, adding extra connections to SCI and SPI ports and leaving the widest variety of additional peripherals available, choosing ports based on the flexibility of the port in supporting the possible use of peripherals such as ATD, timer, and the greatest number of serial interfaces possible. This was done so that changes made to the design later could be effected using the board without significant change, and this did become useful many times later in the project. After the hardware design was completed I compiled a bill of materials for the board and made sure that the part numberings on the schematic were in order and matched the bill of material. Finally, I searched out distributors and ordered all the components for the project, save a handful. Along with Jeff I spent time performing prototype development of the digital compass module, the Zigbee wireless modules, the RFID module and antennas and the LCD display. Using the development board we purchased we were able to test a significant portion of the separate systems using code before the arrival of our PCB. We were able to determine early in
A-1 ECE 477 Final Report Fall 2006 the project that we needed a different RFID module than we originally discovered based on range tests. I performed the principle work on the packaging of the project, doing the work to carve, drill, file and otherwise modify the individual enclosures for the system. I constructed most of the connectors and cabling for the project, both for testing and for the final product. I also made it my responsibility to keep the bench area organized and all of the equipment organized and the materials arranged in a useful manner to increase productivity. I spent a good deal of time helping with hardware troubleshooting on the PCB when several different issues arose, including problems with the power supply and issues with the microcontroller. When the need arose for a relay circuit to toggle between the two antennas I quickly designed, built and tested the system within a day to allow the product to continue smoothly. Finally, as team leader I tried to communicate with all the members of our team, especially when our team chose to perform work individually and report back to the team at a later date. Whenever one or two individuals needed to work in the laboratory I would try to also attend, to provide support and answer hardware questions but also to keep abreast of the ongoing work in different areas of the project. This was especially true later in the project, while Jeff and Tera were working diligently on the software I would try to work in lab on the packaging and connectors and be available even when my work in lab was not always needed.
A.2 Contributions of Stevi Wood:
At the beginning of the SmartShopper design process, I researched various components necessary for the completion of the project, with a focus on the RFID reader and the USB controller and connector. Tera was able to obtain a free sample of an RFID reader and a few tags from Texas Instruments, but the range of this device was too short to read aisle tags used to detect the absolute location of the SmartShopper within the store. I began researching RFID readers and tags from Intersoft Corporation, and after discussions with an engineer from Intersoft I was able to purchase long-range RFID tags, an RFID reader, and a suitable antenna for these aisle tags. Short-range RFID tags as well as a smaller antenna were purchased to read the individual items. For the USB part of the design, I requested free samples of a USB controller from Maxim. A USB Type-A female connector was also purchased. In the end product, the use
A-2 ECE 477 Final Report Fall 2006 of a USB flash drive to store the shopping list was eliminated due to a lack of time debugging the many problems we ran in to, and the final media type used to hold the shopping list was a SD card. The main section of the project that I worked on was the PCB design. Due to its ease in creating footprints, I originally used a freeware PCB layout software, FreePCB. After our initial PCB design and mid-semester design review, I decided to switch to the OrCAD Layout software for its design rule checking capabilities and compatibility with the schematic software. This required me to spend a lot of time creating the footprints alone, as well as updating many parts of the schematic that were not originally created properly (component pin names and numbers, unconnected pins, etc.). In the end, the additional time spent correcting the schematic and comparing the schematic design to the component datasheets led to a decrease in the amount of problems of the fabricated PCB. The power supply was completely changed in this version of the design, so I worked with John to ensure that the proper circuit was designed in the schematic software. The step-down converters chosen to achieve the 3.3 and 5 V rails required specific layout considerations, mainly a large ground plane underneath the device as well as particular placement of certain components (capacitors, inductors, and a diode). We also decided to eliminate many of the microcontroller test points that we knew would not be needed, such as the pulse width modulator port on the microcontroller. The final PCB design had more efficient routing as well as a more thought-out design. After the PCB arrived, I spent time populating the PCB for the initial round of testing. Each section of the design (power supply, microcontroller, RS-232 level translators, etc.) was individually populated and tested. John and I spent quite a bit of time trying to get the power circuitry to output the proper voltages. In the end, it was discovered that the reference designators of the input capacitor and inductor were switched, and after we swapped these components we were able to obtain the required 3.3 and 5 V rails. Then I populated the microcontroller and supported components, which worked using Jeff’s test code. The only other problem found on the PCB design was an unrouted ground pin on the USB controller, which Jeff easily fixed. The rest of the components were also populated and tested, and worked as expected. After the PCB was complete, my time on the project was spent on documentation. I wrote the senior design report, completed the poster for the design, and helped proof-read many of the other documents. Along with Tera and John, I also helped shoot footage for the video
A-3 ECE 477 Final Report Fall 2006 demonstration. John and I then edited the video for presentation to the EE270 lecture for bonus credit. I also worked on the presentation slides for this bonus demonstration. Along with other team members, we were able to successfully demonstrate all five of our project specific success criteria on the Friday before the final due date.
A.3 Contributions of Tera Wong:
In the initial design stages of the project, our team decided to work mainly as a group. The first step we took was to create a list of components and divide the list among the group members to research; each part was given to two people to research so that we would have a variety of parts to choose from. The parts I began researching were Bluetooth and the microcontroller. Later I took on the role of searching for a new dual voltage step-down converter and RFID module as well as sampling an RFID reader. After component selection had been completed the team split up to perform separate roles; John and Stevi took charge of the hardware, while Jeff and I were in charge of the software. When deciding which homework each person was going to do, I chose the Packaging Specifications and Design homework along with the Reliability and Safety Analysis homework. In writing the Packaging homework, it became my duty to make all the decisions on and order the packaging that we would be using to enclose the major components of our design, which included the enclosures of the main module, RFID module and small antenna as well as the buttons and power switch. The Reliability and Safety Analysis homework was far more difficult than the Packaging Specifications homework. In doing this homework, I chose the components that I felt were most significant to the design and met with Professor Johnson to discuss the Failure Modes Effects and Criticality Analysis (FMECA) that I had laid out. Other than doing my own homework, I was a helping hand to anyone in our team who needed a proof-reader to check over his/her homework. I would respond with grammar corrections as well as suggestions where I thought that ideas could be communicated more clearly. In preparation for the design review, I updated the block diagram to reflect the design changes that we had made since homework 2. I also took slides from each individual member of the team and compiled the final presentation to be used in the design review.
A-4 ECE 477 Final Report Fall 2006
At this point it was time to start working on the software. Jeff and I made up the software team of the project, with Jeff as the lead as he had already laid out some structural ideas. We worked first to layout the main functionality of the project using the RFID, compass, and LCD. Lastly we worked with the USB, which we had infinitely many problems with. As the deadline for the project got closer, the team decided to change the project specific criteria to remove the USB from the project and add an SD card in its place. I wrote up the design change form and made sure that it got to Professor Meyer for review. Jeff and I finished up the software and debugging in time to present to ECE270 as a bonus, a presentation which the whole team helped put together in one form or another. Once the project was functioning properly, I designed the logo and layout for the main module and helped assemble the product on the shopping cart that was borrowed from Wal-Mart. Additionally, I took the responsibility of the User Manual, which includes step-by-step instructions, complete with pictures. As a whole, I feel that we worked well together as a team and that responsibilities were delegated pretty fairly.
A.4 Contributions of Jeff Richards:
My largest contributions to the project came in the areas of software design and system debugging. At the beginning of the semester I played a more passive role in many of the design choices and component selection. I offered my advice and recommendations but most of the part sampling, specific component selection and layout choices were made by other members of the group. John handled the majority of parts orders and sampling, as well as the schematic for the project. Stevi took over in converting the schematic to our PCB layout. Tera and I then put most of the work into the software portion of the project. A development board with our micro was among the first things we made sure to order and get in. As soon as we began receiving some of the various external modules I began writing test code to learn how each of the modules interfaces with the development board. At this time I was also testing software on the Zigbee wireless modules. We originally planned on using these to transfer information regarding the items in the cart to the register upon completion of the shopping trip. This idea was eventually discarded after having serious problems implementing USB and being left with little time.
A-5 ECE 477 Final Report Fall 2006
After the PCB arrived most of my work focused on retesting each of the individual modules with it connected through the PCB. With no modifications to the previous test code used for the LCD, it was up and running as expected. Connecting and testing the RFID module was also successful. The digital compass took a longer to get operational. Tera and I spent most of the time testing and debugging the digital compass. The compass was not one of the modules that had been previously tested with our development board. It had been connected to a pc to verify functionality, but had not been interfaced with our microcontroller. I found some test code for reading the various data from the modules and it was re-written to suit our specific needs. Once the code was working and successful data could be received this was not the end of the problems. The device was working; however, it was only working intermittently. Many more hours were spent troubleshooting this until we tried cleaning the PCB with flux cleaner which seemed to solve the problem. The only device left to test was the USB controller and our ability to read and write to a USB drive. Tera and I also spent most of the time testing and the USB controller. It didn’t take long to establish communication with the USB controller, but getting the controller to talk to a USB drive proved to be a much greater challenge. Approximately two weeks were spent troubleshooting the controller and we were never able to do more than detect when a USB device had been connected. At this point the decision was made to discard the USB drive and use an SD card instead. I had an old 5 in 1 card reader I no longer used that I was willing to take the SD card connector out of so that we could get started working with the SD card right away. After I had removed the connector from the old reader and soldered new wires to it, Tera and I began our attempts to communicate with an SD card. Within a day we were already able to detect when an SD card had been connected and read a block of data from it. The next step was to learn about the FAT32 file system. Previously, I had already found and read through a website which explained the structure and basics of reading from a FAT32 file system. This website proved to be a great resource and our basic, read only, implementation of the FAT32 file system was finished within a couple days. The next and final step was to write the software to bring everything together. By now it had already got to the weekend before dead week. USB testing had caused the project to be pushed back way more than expected and the race was on to finish everything in time. Tera and
A-6 ECE 477 Final Report Fall 2006
I both spent many long nights designing the software and managed to finish just in time for the 270 bonus presentation and to have our PSSC’s checked off during dead week.
A-7 ECE 477 Final Report Fall 2006
Appendix B: Packaging
Figure B.1 Top View of Product Packaging
B-1 ECE 477 Final Report Fall 2006
Figure B.2 Side View of Product Packaging
B-2 ECE 477 Final Report Fall 2006
Appendix C: Schematic
Figure C.1 Power Supply Schematic Section
C-1 ECE 477 Final Report Fall 2006
Figure C.2 RS 232 Level Translator Schematic Section
Figure C.3 Microcontroller Schematic Section
C-2 ECE 477 Final Report Fall 2006
Figure C.4 USB Controller Schematic Section (On Board; No Longer Used)
C-3 ECE 477 Final Report Fall 2006
Appendix D: PCB Layout Top and Bottom Copper
Figure D.1 Printed Circuit Board Top Copper Layer (with silkscreen)
D-1 ECE 477 Final Report Fall 2006
Figure D.2 Printed Circuit Board Bottom Copper Layer
D-2 ECE 477 Final Report Fall 2006
Appendix E: Parts List Spreadsheet
F-1 ECE 477 Final Report Fall 2006
Appendix F: Software Listing main.c #include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Function Declarations *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Global Variables *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// RTI Related static unsigned int rtiDiv; // RTI Divisor static unsigned int rtiI; // RTI count 0-Div static unsigned int wait; // Wait, rti cycles static unsigned char rtiStatus; // Status static unsigned char rfidN; //current character of tag being read in static unsigned int rfidDisable; // Test, debugging purposes static unsigned char nextStatus; static unsigned char prevStatus; static char tempLine1[160]; static char tempLine2[160]; static char tempLine1Scroll; static char tempLine2Scroll; // LCD static char lcdContrast;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Main *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * void main(void) { // Status Variables rtiStatus = 0; sdStatus = 0; shopStatus = 0; addStatus = 0;
F-2 ECE 477 Final Report Fall 2006
nextStatus = 0; prevStatus = 0; rfidDisable = 0; tempLine1Scroll = 0; tempLine2Scroll = 0; lcdContrast = 0xFF; //disable IRQ IRQCR = 0x00; // Init Ports initTags(); RTIInit(); SCI3Init(); SCI1Init(); SCI0Init(); SPI1Init(); ATDInit(); buttonInit(); lcdInit(); // Enable interrupts and wait EnableInterrupts; for(;;) { __RESET_WATCHDOG(); /* feeds the dog */ } /* wait forever */ }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Interrupts *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// RTI #pragma CODE_SEG __NEAR_SEG NON_BANKED interrupt void RTI_ISR(void) { // clear RTIF bit CRGFLG = 0x80; if (rfidDisable > 0) { rfidDisable--; } if (wait > 0) { wait--; } else { if (rtiI > rtiDiv) rtiI = 0; if (rtiI == 0) { wait = 250; // Reset if (!(PTM&0x02) && !(PTM&0x01)) { rtiStatus = 0; sdStatus = 0; shopStatus = 0; addStatus = 0; }
F-3 ECE 477 Final Report Fall 2006
// Backlight Off else if (!(PTM&0x02) && !(PTJ&0x40)) { writeChar2LCD(0xFE); writeChar2LCD(0x46); prevStatus = 0; } // Backlight On else if (!(PTM&0x02) && !(PTJ&0x80)) { writeChar2LCD(0xFE); writeChar2LCD(0x42); prevStatus = 0; } // Decrease Contrast else if (!(PTM&0x01) && !(PTJ&0x40)) { if (lcdContrast > 0x10) lcdContrast -= 0x10; writeChar2LCD(0xFE); writeChar2LCD(0x91); writeChar2LCD(lcdContrast); nextStatus = 0; } // Increase Contrast else if (!(PTM&0x01) && !(PTJ&0x80)) { if (lcdContrast < 0xF0) lcdContrast += 0x10; writeChar2LCD(0xFE); writeChar2LCD(0x91); writeChar2LCD(lcdContrast); nextStatus = 0; } // SD Card Detect else if(!(PT1AD0&0x01) && sdStatus == 0 && rtiStatus > 0) { writeLine1("Card Detected",0); writeLine2("Please Wait...",0); sdStatus++; wait = 1000; } // Possible SD Card Remove else if ((PT1AD0&0x01) && sdStatus > 0 && rtiStatus > 0) { rtiStatus = 10; sdStatus = 0; shopStatus = 0; addStatus = 0; } // Add Item, button else if (!(PTJ&0x80) && addStatus == 0 && shopStatus > 0) { doAddRem = 1; addStatus++; } else if ((PTJ&0x80) && addStatus == 1 && shopStatus > 0) { addStatus++; } // Rem Item, button
F-4 ECE 477 Final Report Fall 2006
else if (!(PTJ&0x40) && addStatus == 0 && shopStatus > 0) { doAddRem = 0; addStatus++; } else if ((PTJ&0x40) && addStatus == 1 && shopStatus > 0) { addStatus++; } // Price button else if (!(PTM&0x01) && shopStatus > 0 && nextStatus == 0) { nextStatus = 1; } else if ((PTM&0x01) && shopStatus > 0 && nextStatus == 1) { initStr(tempLine1,160); initStr(tempLine2,160); copyStr(line1Text, tempLine1, strLength(line1Text)); copyStr(line2Text, tempLine2, strLength(line2Text)); tempLine1Scroll = line1Scroll; tempLine2Scroll = line2Scroll; if(nCTags == 0) { writeLine1("Nothing in cart.",0); writeLine2("",0); } else displayCart(); wait = nCTags*2000+5000; nextStatus++; } else if (nextStatus == 2) { initStr(line1Text,160); initStr(line2Text,160); copyStr(tempLine1, line1Text, strLength(tempLine1)); copyStr(tempLine2, line2Text, strLength(tempLine2)); line1Scroll = tempLine1Scroll; line2Scroll = tempLine2Scroll; nextStatus = 0; } // Cart button else if (!(PTM&0x02) && shopStatus > 0 && prevStatus == 0) { prevStatus = 1; } else if ((PTM&0x02) && shopStatus > 0 && prevStatus == 1) { initStr(tempLine1,160); initStr(tempLine2,160); copyStr(line1Text, tempLine1, strLength(line1Text)); copyStr(line2Text, tempLine2, strLength(line2Text)); tempLine1Scroll = line1Scroll; tempLine2Scroll = line2Scroll; if(nCTags == 0) { writeLine1("Price: ",0); writeLine2("$0.00",0); } else displayPrice(); wait = 5000; prevStatus++;
F-5 ECE 477 Final Report Fall 2006
} else if (prevStatus == 2) { initStr(line1Text,160); initStr(line2Text,160); copyStr(tempLine1, line1Text, strLength(tempLine1)); copyStr(tempLine2, line2Text, strLength(tempLine2)); line1Scroll = tempLine1Scroll; line2Scroll = tempLine2Scroll; prevStatus = 0; } // Add & Rem Item else if (addStatus > 0) { addFunc(); } else { switch (rtiStatus) { case 0: // Greeting writeLine1(" * SmartShopper *",0); writeLine2(" Waiting for Card",0); rtiStatus++; wait = 2000; break; case 1: sdFunction(); wait = 0; break; case 2: shopFunc(); wait = 0; break; case 10: writeLine1("Have A Nice Day!",0); writeLine2("2007 SmartShopper by John Sweeney, Tera Wong, Stevi Wood and Jeff Richards",1); wait = 16000; rtiStatus++; break; case 11: rtiStatus = 0; sdStatus = 0; shopStatus = 0; addStatus = 0; break; default: // Error, reset rtiStatus rtiStatus = 0; break; } } } rtiI++;
F-6 ECE 477 Final Report Fall 2006
} // Update LCD if (lcdScrollN > lcdScrollRate) lcdScrollN = 0; if (lcdScrollN == 0) { updateLCD(); } lcdScrollN++; }
// PC #pragma CODE_SEG __NEAR_SEG NON_BANKED interrupt void SCI3_ISR(void) { // Receive Data back from PC (zigbee) unsigned char c; c = SCI3SR1; c = SCI3DRL; if (c == '!') { // Reset sd writeLine1("* * * Reset * * *",0); writeLine2("",0); rtiStatus = 0; sdStatus = 0; shopStatus = 0; addStatus = 0; wait = 3000; } }
// Test ISR, for debugging #pragma CODE_SEG __NEAR_SEG NON_BANKED interrupt void TEST_ISR(void) { writeLine1("* * * Test ISR * * *",0); writeLine2("",0); }
// RFID #pragma CODE_SEG __NEAR_SEG NON_BANKED interrupt void SCI0_ISR(void) { char c; c = SCI0SR1; c = SCI0DRL; if(!rfidDisable){ if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) { rfidBuffer[rfidN] = c; rfidN++; } else if (rfidN >= 10) { writeStr2PC("\r\nTag Read"); copyStr(rfidBuffer, rfidTag, 10); rfidN = 0; rfidDisable = 5000; }
F-7 ECE 477 Final Report Fall 2006
} } sd.c
#include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Function Declarations * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void sdFunction(void); static unsigned char xfer(const char); static void sdEnable(void); static void sdDisable(void); static unsigned char sendCommand(unsigned char, unsigned long, unsigned char); static unsigned char sdReadBlock(unsigned long, unsigned char *); static void getItemLst(void); static void getIDB(void); static void getLTags(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Global Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static unsigned char sdStatus; static unsigned char disableSS; static unsigned long fs_addr; static unsigned char fs_data[512]; //data from file static unsigned long fs_mbr_addr; static unsigned char fs_mbr[512]; static unsigned long fs_vol_addr; static unsigned char fs_vol[512]; static unsigned int fs_BPS; // Bytes per Sector static unsigned char fs_SPC; // Sectors per Cluster static unsigned int fs_RS; // Reserved Sectors static unsigned char fs_NF; // Number of Fats static unsigned long fs_SPF; // Sectors per Fat static unsigned long fs_Root; // Root Directory First Cluster static unsigned long fs_Fat; // Fat Location static unsigned long fs_Cluster; // Cluster Location static unsigned long fs_Dir; // Dir Location static unsigned long fs_File; // File Location
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * SD Main * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
F-8 ECE 477 Final Report Fall 2006 static void sdFunction() { char c; int n; int i; switch (sdStatus) { // * * * Wait For Device * * * case 0: // Wait for card break; case 1: // Wait sdStatus++; break; // * * * SD Init * * * case 2: // Power Supply Ramp Up Time writeStr2PC("\r\nPower Supply Ramp Up"); n = 20; while (n > 0) { c = xfer(0xFF); n--; } sdStatus++; break; case 3: // Send GO_IDLE_STATE writeStr2PC("\r\nSending Idle Command"); c = sendCommand(0x00,0,0x95); sdStatus++; break; case 4: // Send Op_Cond writeStr2PC("\r\nSending Op Cond Command"); c = sendCommand(0x01,0,0x95); sdStatus++; break; case 5: // Send App Command, ignore result writeStr2PC("\r\nSending App Command"); c = sendCommand(0x37,0,0xFF); sdStatus++; break; case 6: // Send Op_Cond writeStr2PC("\r\nSending Op Cond Command"); c = sendCommand(0x29,0,0x95); // TODO: speedup clock sdStatus++; break; // * * * Read Filesystem * * * case 7:
F-9 ECE 477 Final Report Fall 2006
//Read MBR fs_mbr_addr = 0; writeStr2PC("\r\nReading MBR"); c = sdReadBlock(fs_mbr_addr, fs_mbr); sdStatus++; break; case 8: // Print MBR Data sdStatus++; break; case 9: // Get Volume start addr fs_vol_addr = 0; fs_vol_addr += fs_mbr[457]; fs_vol_addr *= 256; fs_vol_addr += fs_mbr[456]; fs_vol_addr *= 256; fs_vol_addr += fs_mbr[455]; fs_vol_addr *= 256; fs_vol_addr += fs_mbr[454]; sdStatus++; break; case 10: // Read Vol ID writeStr2PC("\r\nReading Vol ID"); c = sdReadBlock(fs_vol_addr, fs_vol); sdStatus++; break; case 11: // Print Volume ID data sdStatus++; break; case 12: // Get Values fs_BPS = fs_vol[12]*256 + fs_vol[11]; fs_SPC = fs_vol[13]; fs_RS = fs_vol[15]*256 + fs_vol[14]; fs_NF = fs_vol[16]; fs_SPF = (((fs_vol[39]*256) + fs_vol[38])*256 + fs_vol[37])*256 + fs_vol[36]; fs_Root = (((fs_vol[47]*256) + fs_vol[46])*256 + fs_vol[45])*256 + fs_vol[44]; fs_Fat = fs_vol_addr + fs_RS; fs_Cluster = fs_vol_addr + fs_RS + (fs_NF * fs_SPF); sdStatus++; break; case 13: // Root Dir Location fs_Dir = fs_Cluster + ((fs_Root - 2) * fs_SPC); sdStatus = 20; break; // * * * ITEMDB.LST * * * case 20:
F-10 ECE 477 Final Report Fall 2006
// Search for and read ItemDB writeStr2PC("\r\nSearching for ItemDB"); // Increment status early this time sdStatus++; // Read dir until file is found, or end of root cluster for (n = 0; n < fs_SPC; n++) { c = sdReadBlock(fs_Dir+n, fs_data); for (i = 0; i < 16; i++) { if (!strCompare(&fs_data[32*i], "ITEMDB LST", 11)) { // Get File addr fs_File = (((fs_data[32*i+21]*256) + fs_data[32*i+20])*256 + fs_data[32*i+27])*256 + fs_data[32*i+26] - 2; fs_File *= fs_SPC; fs_File += fs_Cluster; return; } } } // If we made it here file was not found, check for locdb.lst, status = 30 sdStatus = 30; break; case 21: // Read ItemDB writeStr2PC("\r\nReading ItemDB"); c = sdReadBlock(fs_File, fs_data); sdStatus++; break; case 22: getIDB(); sdStatus = 30; writeStr2PC("\r\nItemDB Loaded"); break; // * * * LOCDB.LST * * * case 30: // Search for and read Location DB writeStr2PC("\r\nSearching for LocDB"); // Increment status early this time sdStatus++; // Read dir until file is found, or end of root cluster for (n = 0; n < fs_SPC; n++) { c = sdReadBlock(fs_Dir+n, fs_data); for (i = 0; i < 16; i++) { if (!strCompare(&fs_data[32*i], "LOCDB LST", 11)) { // Get File addr fs_File = (((fs_data[32*i+21]*256) + fs_data[32*i+20])*256 + fs_data[32*i+27])*256 + fs_data[32*i+26] - 2; fs_File *= fs_SPC; fs_File += fs_Cluster; return; } } }
F-11 ECE 477 Final Report Fall 2006
// If we made it here file was not found, check for shopping.lst, status = 40 sdStatus = 40; break; case 31: // Read LocDB writeStr2PC("\r\nReading LocDB"); c = sdReadBlock(fs_File, fs_data); sdStatus++; break; case 32: getLTags(); sdStatus = 40; writeStr2PC("\r\nLocDB Loaded"); break; // * * * SHOPPLING.LST * * * case 40: // Search for and read Shopping list writeStr2PC("\r\nSearching for Shopping list"); // Increment status early this time sdStatus++; // Read dir until file is found, or end of root cluster for (n = 0; n < fs_SPC; n++) { c = sdReadBlock(fs_Dir+n, fs_data); for (i = 0; i < 16; i++) { if (!strCompare(&fs_data[32*i], "SHOPPINGLST", 11)) { // Get File addr fs_File = (((fs_data[32*i+21]*256) + fs_data[32*i+20])*256 + fs_data[32*i+27])*256 + fs_data[32*i+26] - 2; fs_File *= fs_SPC; fs_File += fs_Cluster; return; } } } // If we made it here file was not found, increment status again sdStatus = 50; break; case 41: // Read Shopping list writeStr2PC("\r\nReading Shopping list"); c = sdReadBlock(fs_File, fs_data); sdStatus++; break; case 42: getItemLst(); sdStatus++; writeStr2PC("\r\nShopping List Loaded"); break; case 43: rtiStatus++; sdStatus++;
F-12 ECE 477 Final Report Fall 2006
break; case 50: writeLine1("Item List Missing",0); writeLine2("",0); sdStatus++; break; default: break; } }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * SD Tools * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static unsigned char xfer(const char s) { char r; // Send Char while (!(SPI1SR & 0x20)); // Wait for output buffer empty SPI1DR = s; // Recieve while (!(SPI1SR & 0x80)); // Wait for read buffer full r = SPI1DR; return r; } static void sdEnable() { PT1AD0 = PT1AD0&0xBF; } static void sdDisable() { PT1AD0 = PT1AD0|0x40; } static unsigned char sendCommand(unsigned char command, unsigned long addr, unsigned char crc) { unsigned long addr2; unsigned char addrB[4]; unsigned char n = 20; // Max recieve attempts unsigned char r = 0xFF; // Response // Addr addr2 = 0; addr2 += (addr&0xFF00FF00)>>8; addr2 += (addr&0x00FF00FF)<<8; addr2 *= 512; addrB[0] = (addr2&0x000000FF); addrB[1] = (addr2&0x0000FF00)>>8; addrB[2] = (addr2&0x00FF0000)>>16; addrB[3] = (addr2&0xFF000000)>>24; // Xfer if (disableSS == 0)
F-13 ECE 477 Final Report Fall 2006
sdEnable(); xfer(0xFF); xfer(command|0x40); xfer(addrB[0]); xfer(addrB[1]); xfer(addrB[2]); xfer(addrB[3]); xfer(crc); xfer(0xFF); while (r == 0xFF && n > 0) { r = xfer(0xFF); n--; } if (disableSS == 0) sdDisable(); if (n == 0) { writeStr2PC("\r\nSD Command Timeout"); sdStatus = 0; } else if (r != 0x00 && r != 0x01) { writeStr2PC("\r\nSD Error"); sdStatus = 0; } return r; } static unsigned char sdReadBlock(unsigned long addr, unsigned char *buf) { unsigned int i; unsigned char r;
sdEnable(); // Send the read command disableSS = 1; r = sendCommand(0x11, addr, 0xFF); disableSS = 0; if(r != 0) // ABORT: invalid response for read single command return 1; // Now wait for the "Start Block" token (0xFE) i = 20; // Timeout do { r = xfer(0xFF); i--; } while(r != 0xFE && i > 0); if (i == 0) { writeStr2PC("\r\nSD Read Timeout"); sdStatus = 0; } // Read off all the bytes in the block for(i = 0; i < 512; ++i) { r = xfer(0xFF);
F-14 ECE 477 Final Report Fall 2006
*buf = r; buf++; } // Read CRC bytes r = xfer(0xFF); r = xfer(0xFF); sdDisable(); // Following a read transaction, the SD Card needs 8 clocks after the end // bit of the last data block to finish up its work. xfer(0xFF); return 0; }
//take shopping list data read from SD card //and add it to the iTags database on the chip static void getItemLst() { unsigned int i = 0; nITags = 0; while(fs_data[i] != '*') { initStr(&iTags[nITags * 32], 32); copyStr(&fs_data[i], &iTags[nITags * 32], 10); copyStr("xxx.", &iTags[nITags * 32 + 16], 4); i += 12; nITags++; } getInfo(); }
//take item data read from SD card //and add it to the iDB database on the chip static void getIDB() { unsigned int i = 0; nIDB = 0; while(fs_data[i] != '*') { initStr(&iDB[nIDB * 32], 32); copyStr(&fs_data[i], &iDB[nIDB * 32], 32); i += 34; nIDB++; } }
//take location tag information read from SD card //and add it to the iTags database on the chip static void getLTags() { unsigned int i = 0; nLTags = 0; while(fs_data[i] != '*') { initStr(&lTags[nLTags * 32], 32); copyStr(&fs_data[i], &lTags[nLTags * 16], 16); i += 18; nLTags++;
F-15 ECE 477 Final Report Fall 2006
} } isr_vectors.c extern void near RTI_ISR(void); extern void near SCI3_ISR(void); extern void near TEST_ISR(void); extern void near SCI0_ISR(void);
#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */ __interrupt void UnimplementedISR(void) { TEST_ISR(); /* Unimplemented ISRs trap.*/ //asm BGND; } typedef void (*near tIsrFunc)(void); const tIsrFunc _vect[] @0xFF80 = { /* Interrupt table */ UnimplementedISR, /* vector 63 */ UnimplementedISR, /* vector 62 */ UnimplementedISR, /* vector 61 */ UnimplementedISR, /* vector 60 */ SCI3_ISR, /* SCI3 */ UnimplementedISR, /* vector 58 */ UnimplementedISR, /* vector 57 */ UnimplementedISR, /* vector 56 */ UnimplementedISR, /* vector 55 */ UnimplementedISR, /* vector 54 */ UnimplementedISR, /* vector 53 */ UnimplementedISR, /* vector 52 */ UnimplementedISR, /* vector 51 */ UnimplementedISR, /* vector 50 */ UnimplementedISR, /* vector 49 */ UnimplementedISR, /* vector 48 */ UnimplementedISR, /* vector 47 */ UnimplementedISR, /* vector 46 */ UnimplementedISR, /* vector 45 */ UnimplementedISR, /* vector 44 */ UnimplementedISR, /* vector 43 */ UnimplementedISR, /* vector 42 */ UnimplementedISR, /* vector 41 */ UnimplementedISR, /* vector 40 */ UnimplementedISR, /* vector 39 */ UnimplementedISR, /* vector 38 */ UnimplementedISR, /* vector 37 */ UnimplementedISR, /* vector 36 */ UnimplementedISR, /* vector 35 */ UnimplementedISR, /* vector 34 */
F-16 ECE 477 Final Report Fall 2006
UnimplementedISR, /* vector 33 */ UnimplementedISR, /* vector 32 */ UnimplementedISR, /* vector 31 */ UnimplementedISR, /* vector 30 */ UnimplementedISR, /* vector 29 */ UnimplementedISR, /* vector 28 */ UnimplementedISR, /* vector 27 */ UnimplementedISR, /* vector 26 */ UnimplementedISR, /* vector 25 */ UnimplementedISR, /* vector 24 */ UnimplementedISR, /* vector 23 */ UnimplementedISR, /* vector 22 */ UnimplementedISR, /* vector 21 */ SCI0_ISR, /* SCI0 */ UnimplementedISR, /* vector 19 */ UnimplementedISR, /* vector 18 */ UnimplementedISR, /* vector 17 */ UnimplementedISR, /* vector 16 */ UnimplementedISR, /* vector 15 */ UnimplementedISR, /* vector 14 */ UnimplementedISR, /* vector 13 */ UnimplementedISR, /* vector 12 */ UnimplementedISR, /* vector 11 */ UnimplementedISR, /* vector 10 */ UnimplementedISR, /* vector 09 */ UnimplementedISR, /* vector 08 */ RTI_ISR, /* RTI */ UnimplementedISR, /* vector 06 */ UnimplementedISR, /* vector 05 */ UnimplementedISR, /* vector 04 */ UnimplementedISR, /* vector 03 */ UnimplementedISR, /* vector 02 */ UnimplementedISR, /* vector 01 */ //_Startup /* Reset vector */ }; portInit.c
#include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Function Declarations * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void RTIInit(void); static void SCI3Init(void); static void SCI1Init(void); static void SPI1Init(void); static void ATDInit(void);
F-17 ECE 477 Final Report Fall 2006 static void buttonInit(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Port Init Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// RTI static void RTIInit(void) { // Port Init RTICTL = 0x1F; CRGINT = 0x80; // Other Variables rtiDiv = 0; rtiI = 0; wait = 0; }
// Zigbee (PC) static void SCI3Init(void) { SCI3BDL = (unsigned char)((16000000UL /* OSC freq */ / 2) / 9600 /* baud rate */ / 16 /*factor*/); SCI3CR2 = 0x2C; }
// LCD static void SCI1Init(void) { // Port Init SCI1BDL = (unsigned char)((16000000UL /* OSC freq */ / 2) / 9600 /* baud rate */ / 16 /*factor*/); SCI1CR2 = 0x2C; // Other Variables initStr(line1Text,160); line1Scroll = -5; line1N = -5; initStr(line2Text,160); line2Scroll = -5; line2N = -5; lcdScrollRate = 200; lcdScrollN = 0; }
// RFID static void SCI0Init(void) { SCI0BDL = (unsigned char)((16000000UL /* OSC freq */ / 2) / 9600 /* baud rate */ / 16 /*factor*/); SCI0CR2 = 0x2C;
rfidN = 0; initStr(rfidTag,16); initStr(rfidLast,16); initStr(rfidBuffer,16); }
F-18 ECE 477 Final Report Fall 2006
// SD static void SPI1Init(void) { // Port Init SPI1CR1 = 0x5C; SPI1CR2 = 0x00; SPI1BR = 0x77; MODRR = 0x20; //Module Routing Register to enable SCK1 on PH2 // Other Variables disableSS = 0; }
// ATD Header static void ATDInit(void) { //bit 7 - relay control //bit 6 - slave select for sd //bit 0 - sd detect ATD0DIEN = 0x3F; DDR1AD0 = 0xC0; PER1AD0 = 0x3F; }
// Add, Rem, Next, Prev Buttons static void buttonInit(void) { // Add, Rem: Port J bits 7,6 DDRJ = 0x00; PERJ = 0xC0; // Next, Prev: Port M bits 0,1 DDRM = 0x00; PERM = 0x03; } static void lcdInit(void) { // Clear Display writeChar2LCD(0xFE); writeChar2LCD(0x58); // Contrast writeChar2LCD(0xFE); writeChar2LCD(0x91); writeChar2LCD(0xFF); // LCD On writeChar2LCD(0xFE); writeChar2LCD(0x42); } output.c
#include
F-19 ECE 477 Final Report Fall 2006
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Function Declarations * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void writeStr(const char *); static void writeChar(const char); static void writeStr2PC(const char *); static void writeChar2PC(const char); static void writeStr2LCD(const char *); static void writeChar2LCD(const char); static void printChar(unsigned char); static void printInt(int); static void sPrintInt(char *,int); static void printBits(unsigned char); static void printHex(unsigned char); static void printLong(unsigned long); static void printStr(char *, int); static void updateLCD(); static void writeLine1(char *, unsigned char); static void writeLine2(char *, unsigned char); static void displayPrice(void); static void displayCart(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Global Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static char line1Text[160]; static unsigned char line1Scroll; static char line1N; static char line2Text[160]; static unsigned char line2Scroll; static char line2N; static unsigned int lcdScrollRate; static unsigned int lcdScrollN;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Output Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Output String static void writeStr(const char *text) { writeStr2PC(text); //writeStr2LCD(text); }
// Output Character static void writeChar(const char c) { writeChar2PC(c); //writeChar2LCD(c); }
F-20 ECE 477 Final Report Fall 2006
// Output String 2 PC static void writeStr2PC(const char *text) { while (*text != '\0') { while (!(SCI3SR1 & 0x80)); // wait for output buffer empty SCI3DRL = *text++; } }
// Output Character 2 PC static void writeChar2PC(const char c) { while (!(SCI3SR1 & 0x80)); // wait for output buffer empty SCI3DRL = c; }
// Output String 2 LCD static void writeStr2LCD(const char *text) { while (*text != '\0') { while (!(SCI1SR1 & 0x80)); // wait for output buffer empty SCI1DRL = *text++; } }
// Output Character 2 LCD static void writeChar2LCD(const char c) { while (!(SCI1SR1 & 0x80)); // wait for output buffer empty SCI1DRL = c; }
// Prints a character as a decimal number static void printChar(unsigned char c) { char c1,c2,c3; c3 = c%10; c = (c-c3)/10; c2 = c%10; c = (c-c2)/10; c1 = c; writeChar(c1+'0'); writeChar(c2+'0'); writeChar(c3+'0'); }
// Prints a character as a decimal number static void sPrintChar(char *str, unsigned char c) { char c1,c2,c3;
F-21 ECE 477 Final Report Fall 2006
c3 = c%10; c = (c-c3)/10; c2 = c%10; c = (c-c2)/10; c1 = c; str[0] = c1+'0'; str[1] = c2+'0'; str[2] = c3+'0'; }
// Prints an integer as a string static void printInt(int i) { int n = 0; char c[10]; if (i == 0) writeChar('0'); while (i > 0) { c[n++] = i%10; i -= i%10; i /= 10; } for (i = n-1; i >= 0; i--) { writeChar(c[i] + '0'); } }
// Prints an integer as a string static void sPrintInt(char *str, int i) { int n = 0; char c[10]; if (i == 0) writeChar('0'); while (i > 0) { c[n++] = i%10; i -= i%10; i /= 10; } for (i = n-1; i >= 0; i--) { str[0] = c[i]+'0'; str++; } }
// Print individual bits of a character static void printBits(unsigned char c) { char b[8]; b[0] = c%2; c = (c-(c%2))/2; b[1] = c%2; c = (c-(c%2))/2; b[2] = c%2;
F-22 ECE 477 Final Report Fall 2006
c = (c-(c%2))/2; b[3] = c%2; c = (c-(c%2))/2; b[4] = c%2; c = (c-(c%2))/2; b[5] = c%2; c = (c-(c%2))/2; b[6] = c%2; c = (c-(c%2))/2; b[7] = c; writeChar(b[7]+'0'); writeChar(b[6]+'0'); writeChar(b[5]+'0'); writeChar(b[4]+'0'); writeChar(b[3]+'0'); writeChar(b[2]+'0'); writeChar(b[1]+'0'); writeChar(b[0]+'0'); }
// Print Character as Hex static void printHex(unsigned char c) { char h[2]; // Get hex values h[0] = c%16; c = (c-h[0])/16; h[1] = c; // Format for display if (h[0] < 10) h[0] += '0'; else h[0] += 'A' - 10; if (h[1] < 10) h[1] += '0'; else h[1] += 'A' - 10; writeChar(h[1]); writeChar(h[0]); }
// Print Character as Hex static void sPrintHex(char *str, unsigned char c) { char h[2]; // Get hex values h[0] = c%16; c = (c-h[0])/16; h[1] = c; // Format for display if (h[0] < 10) h[0] += '0'; else h[0] += 'A' - 10; if (h[1] < 10) h[1] += '0'; else h[1] += 'A' - 10; str[0] = h[1]; str[1] = h[0]; }
F-23 ECE 477 Final Report Fall 2006
// Prints a Long as a String // TODO, possible errors static void printLong(unsigned long l) { unsigned int n = 0; unsigned char c[20]; if (l == 0x00000000) writeChar('0'); while (l != 0x00000000) { c[n++] = l%10; l -= l%10; l /= 10; } for (n; n >= 0; n--) { writeChar(c[n] + '0'); } }
// Print N characters of Str static void printStr(char *str, int n) { int i; for (i = 0; i < n; i++) { writeChar(str[i]); } }
// Update LCD static void updateLCD() { int i,n; writeStr2LCD("\r\n\r\n"); if (line1Scroll) { // Reset line1N if (line1N > strLength(line1Text)) line1N = -5; // Set n if (line1N < 0) n = 0; else n = line1N; // Print portion of string for (i = 0; i < 19; i++) { if (line1Text[n+i] == '\0') break; writeChar2LCD(line1Text[n+i]); } line1N++; } else { writeStr2LCD(line1Text); } writeStr2LCD("\r\n"); if (line2Scroll) { // Reset line2N if (line2N > strLength(line2Text)) line2N = -5; // Set n
F-24 ECE 477 Final Report Fall 2006
if (line2N < 0) n = 0; else n = line2N; // Print portion of string for (i = 0; i < 19; i++) { if (line2Text[n+i] == '\0') break; writeChar2LCD(line2Text[n+i]); } line2N++; } else { writeStr2LCD(line2Text); } }
// Set Line1 for LCD static void writeLine1(char *str, unsigned char scroll) { initStr(line1Text,160); copyStr(str, line1Text, strLength(str)); line1Scroll = scroll; writeStr2PC("\r\n\r\n"); writeStr2PC(str); line1N = -5; }
// Set Line2 for LCD static void writeLine2(char *str, unsigned char scroll) { initStr(line2Text,160); copyStr(str, line2Text, strLength(str)); line2Scroll = scroll; writeStr2PC("\r\n"); writeStr2PC(str); line2N = -5; }
//scroll function for LCD static void scrollItems() { int i,j,cnt; j = 0; cnt = 0; initStr(line2Text,160); for (i = 0; i < nITags; i++) { if (iTags[i*32+10] == (isle&0x7F) && (iTags[i*32+14]&0x80) == 0) { if(cnt > 0) { copyStr(", ",&line2Text[j],2); j += 2; } sPrintDesc(&line2Text[j], &iTags[i*32+16]); cnt++; j = strLength(line2Text); } }
F-25 ECE 477 Final Report Fall 2006
line2Scroll = 1; } static void displayPrice(){ int d,c; initStr(line2Text, 160); copyStr("$",line2Text, 1); c = totPrice%100; d = (totPrice-c)/100; writeLine1("Subtotal: ",0); sPrintInt(&line2Text[1],d); copyStr(".",&line2Text[strLength(line2Text)],1); sPrintInt(&line2Text[strLength(line2Text)],c); line2Scroll = 0; } static void displayCart() { int i,j,cnt; j = 0; cnt = 0; writeLine1("Cart Contents: ",0); initStr(line2Text,160); printInt(nCTags); for (i = 0; i < nCTags; i++) { if(cnt > 0) { copyStr(", ",&line2Text[j],2); j += 2; } sPrintDesc(&line2Text[j], &cTags[i*32+16]); cnt++; j = strLength(line2Text); } line2Scroll = 1; } tools.c
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Function Declarations * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void copyStr(char *, char *, int); static unsigned char strCompare(char *, char *, int); static void initStr(char *, int); static int str2Int(char *); static int strLength(char *);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Misc Tools * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
F-26 ECE 477 Final Report Fall 2006
// Copy str1 to str2 static void copyStr(char *str1, char *str2, int n) { int i; for (i = 0; i < n; i++) { str2[i] = str1[i]; } }
//Compare str1 with str2 returns 0 if they are equal static unsigned char strCompare(char *str1, char *str2, int len) { int i; for(i = 0; i < len; i++) if(str1[i] != str2[i]) return 1; return 0; } static void initStr(char *str, int n) { int i; for (i = 0; i < n; i++) { str[i] = '\0'; } } static int str2Int(char *str) { int i = 0; i += str[0]; i *= 256; i += str[1]; return i; } static int strLength(char *str){ int count = 0; while(str[count] != '\0') count++; return count--; } rfid.c
#include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Function Declarations *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void initTag(char *); static int compareTags(const char *, const char *); static void copyLTag(const char *, char *);
F-27 ECE 477 Final Report Fall 2006 static void printTagID(const char *); static void printLTags(void); static void printITags(void,int); static void printIDB(void); static void getLTagInfo(void); static void printDesc(const char *); static void sPrintDesc(char *, const char *);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Global Declarations *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** RFID Functions *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Init Tag static void initTag(char *tag) { int i; for (i = 0; i < 12; i++) { tag[i] = 0x00; } } // Compares tags static int compareTags(const char *tag1, const char *tag2) { int i; for (i = 0; i < 10; i++) { if (tag1[i] > tag2[i]) { return 1; } if (tag1[i] < tag2[i]) { return -1; } } return 0; } // Copies a tag static void copyLTag(const char *source, char *destination) { int i; for (i = 0; i < 16; i++) { destination[i] = source[i]; } } // Outputs a tag static void printTagID(const char *tag) { int i; for (i = 0; i < 10; i++) { writeChar(tag[i]); } } // Prints all location tags
F-28 ECE 477 Final Report Fall 2006 static void printLTags() { int i; unsigned char c; for (i = 0; i < nLTags; i++) { // Tag ID writeStr("\r\nID:"); printTagID(&lTags[i*16]); // Isle c = lTags[i*16+10] & 0x7F; writeStr(" Isle:"); printChar(c); // Left || Right if (lTags[i*16+10] & 0x80) writeStr(" Left"); else writeStr(" Right"); } } // Prints all item tags static void printITags(char *db, int numItems) { int i,j; for (i = 0; i < numItems; i++) { // Tag ID writeStr("\r\nID:"); printTagID(&db[i*32]); // Isle writeStr(" Isle:"); printChar(db[i*32+10]); // ~Location writeStr(" Loc:"); printChar(db[i*32+11]); // In Cart writeStr(" In Cart:"); printChar(db[i*32+14]); // Description j = 0; writeStr(" Desc:"); printDesc(&db[i*32+16]); } } // Prints all item tags in DataBase static void printIDB() { int i,j; for (i = 0; i < nIDB; i++) { // Tag ID writeStr("\r\nID:"); printTagID(&iDB[i*32]); // Isle writeStr(" Isle:"); printChar(iDB[i*32+10]); // ~Location
F-29 ECE 477 Final Report Fall 2006
writeStr(" Loc:"); printChar(iDB[i*32+11]); // Description j = 0; writeStr(" Desc:"); printDesc(&iDB[i*32+16]); } } static void getLTagInfo(){ int i; for (i = 0; i < nLTags; i++){ if (!strCompare(rfidTag, &lTags[i * 16], 10)) { copyStr(&lTags[i * 16], rfidTag, 16); return; } } } static void printDesc(const char *c) { int i = 0; while (c[i] != '.') { writeChar(c[i]); i++; } } static void sPrintDesc(char *str, const char *c) { int i = 0; while (c[i] != '.') { str[0] = c[i]; str++; i++; } } shop.c
#include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Function Declarations *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void shopInit(void); static void shopFunc(void); static void addFunc(void); static void getInfo(void); static void sortItems(void); static void genInstr(void);
F-30 ECE 477 Final Report Fall 2006 static void addToCart(char *, int, int); //keeps track of items added to cart and running total bill static int remCTags(char *); static int searchIDB(char *); static void setAddBit(char *,int); static unsigned char gotAllItems(void); static void switchCheckpoints(void); static void initTags(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Global Variables *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//Instructions: Isles static unsigned char instCheckpoints[256]; static unsigned char instCurCheckpoint; static unsigned char instCheckpointCount; static unsigned char shopStatus; static unsigned char addStatus; static unsigned char doAddRem; static int nCartItems; //num items in cart from shopping list static int lastDisplayedItem; static int totPrice; //running total bill static int nCTags; //number of items that have been added to cart static char cTags[30*32]; //item tags of collected items static unsigned char isle; static unsigned char nextIsle;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Shop *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void shopFunc() { int i; switch (shopStatus) { // * * * Init * * * case 0: // Init nCTags = 0; nCartItems = 0; instCurCheckpoint = 0; isle = 0; sortItems(); totPrice = 0; shopStatus++; break; case 1: // First Instruction writeLine1("List Loaded",0); writeLine2("Go to aisle ",0); sPrintChar(&line2Text[12],iTags[10]);
F-31 ECE 477 Final Report Fall 2006
shopStatus++; break; case 2: // Init finished, goto change isle area shopStatus = 10; break; // * * * Change Isles * * * case 10: // Find next isle user needs to enter for (i = 0; i < nITags; i++) { if (!(iTags[32*i+14]&0x80)) { nextIsle = iTags[32*i+10]; shopStatus++; return; } } // All items have been collected shopStatus = 40; break; case 11: // Reset RFID Tag initStr(rfidTag,10); shopStatus++; break; case 12: // Wait for a new tag if (rfidTag[9] != '\0' && strCompare(rfidTag,rfidLast,10)) { shopStatus++; } break; case 13: // Verify tag is a location tag, read info if so copyStr(rfidTag,rfidLast,10); for (i = 0; i < nLTags; i++) { if (!strCompare(rfidTag,&lTags[16*i],10)) { copyStr(&lTags[16*i],rfidTag,16); shopStatus++; return; } } // Tag isn't a location tag, go back shopStatus -= 2; break; case 14: // Determine what to do with location tag if ((rfidTag[10]&0x7F) == nextIsle) { // Reached next isle writeLine1("Reached isle ",0); writeLine2("",0); sPrintChar(&line1Text[13],nextIsle); shopStatus++;
F-32 ECE 477 Final Report Fall 2006
return; // Prevent isle from being updated, needed to generate turn direction } else if (((isle&0x7F) <= (rfidTag[10]&0x7F) && (rfidTag[10]&0x7F) < nextIsle) || ((isle&0x7F) >= (rfidTag[10]&0x7F) && (rfidTag[10]&0x7F) > nextIsle)) { // On route to next isle, go back and wait for next tag shopStatus -= 3; } else { // Off course writeLine1("You're Off Track",0); writeLine2("Go to aisle ",0); sPrintChar(&line2Text[12],nextIsle); shopStatus -= 3; } isle = rfidTag[10]; break; case 15: // Turn direction if ((isle&0x7F) < nextIsle) { if (rfidTag[10]&0x80) { writeLine2("Turn right",0); } else { writeLine2("Turn left",0); } } else { if (rfidTag[10]&0x80) { writeLine2("Turn left",0); } else { writeLine2("Turn right",0); } } isle = rfidTag[10]; shopStatus = 20; wait = 3000; break; // * * * In an Isle * * * case 20: // Check if items have been collected for (i = 0; i < nITags; i++) { if (!(iTags[32*i+14]&0x80)) { if (iTags[32*i+10] > (isle&0x7F)) { // All tags in this isle have been collected shopStatus = 30; return; } else { // Display items to collect writeLine1("Find these items:",0);
F-33 ECE 477 Final Report Fall 2006
scrollItems();
shopStatus++; return; } } } // All items have been collected shopStatus = 40; break; case 21: //check to see if an aisle tag is scanned if so go to case 14 if (rfidTag[9] != '\0' && strCompare(rfidTag,rfidLast,10)) { // Verify tag is a location tag, read info if so copyStr(rfidTag,rfidLast,10); for (i = 0; i < nLTags; i++) { if (!strCompare(rfidTag,&lTags[16*i],10)) { copyStr(&lTags[16*i],rfidTag,16); shopStatus = 14; return; } } } // Check if items in current isle have been collected for (i = 0; i < nITags; i++) { if (iTags[32*i+10] == (isle&0x7F) && !(iTags[32*i+14]&0x80)) { return; } } // Items have been collected shopStatus = 30; break; // * * * Leaving an isle * * * case 30: // Inform user all items in isle have been collected writeLine1("Items in this isle have been collected",1); writeLine2("Continue on",0); shopStatus++; break; case 31: // Find next isle user needs to enter for (i = 0; i < nITags; i++) { if (!(iTags[32*i+14]&0x80)) { nextIsle = iTags[32*i+10]; shopStatus++; return; } } // All items have been collected shopStatus = 40; break;
F-34 ECE 477 Final Report Fall 2006
case 32: // Reset RFID tag initStr(rfidTag,10); shopStatus++; case 33: // Wait for next tag if (rfidTag[9] != '\0' && strCompare(rfidTag,rfidLast,10)) { shopStatus++; } break; case 34: // Verify tag is a location tag copyStr(rfidTag,rfidLast,10); for (i = 0; i < nLTags; i++) { if (!strCompare(rfidTag,&lTags[16*i],10)) { copyStr(&lTags[16*i],rfidTag,16); shopStatus++; return; } } shopStatus -= 2; break; case 35: // Tag should be from the end of current isle if ((rfidTag[10]&0x7F) == (isle&0x7F)) { if (rfidTag[10]&0x80) { writeLine1("Turn right.",0); } else { writeLine1("Turn left.",0); } writeLine2("Go to aisle ",0); sPrintChar(&line2Text[12],nextIsle); shopStatus = 11; } else if ((rfidTag[10]&0x7F) == nextIsle) { // Tag is from the next isle we need to be in writeLine1("Aisle: ",0); sPrintChar(&line1Text[7],nextIsle); if (rfidTag[10]&0x80) { writeLine2("Turn right",0); } else { writeLine2("Turn left",0); } wait = 3000; shopStatus = 20; } else { // Tag is not from cur isle, print generic instruction
F-35 ECE 477 Final Report Fall 2006
if (((isle&0x7F) <= (rfidTag[10]&0x7F) && (rfidTag[10]&0x7F) < nextIsle) || ((isle&0x7F) >= (rfidTag[10]&0x7F) && (rfidTag[10]&0x7F) > nextIsle)) { // On route to next isle writeLine1("Continue to",0); writeLine2("aisle ",0); sPrintChar(&line2Text[6],nextIsle); shopStatus = 11; } else { // Off course writeLine1("You're Off Track",0); writeLine2("Go to aisle ",0); sPrintChar(&line2Text[12],nextIsle); shopStatus = 11; } } isle = rfidTag[10]; break; // * * * All items collected * * * case 40: // Tell user they have everything writeLine1("You have everything",0); writeLine2("Go to checkout",0); shopStatus++; break; case 41: // Wait forever break; default: break; } } static void addFunc() { int tagId; switch (addStatus) { // * * * Prepare to add * * * case 0: // Default, wait for !Add break; case 1: // Wait for Add to return high break; case 2: // Toggle Relay PT1AD0 = PT1AD0|0x80; addStatus = 10; break; // * * * Add Item * * * case 10: // Prompt User to scan item, and reset rfidTags
F-36 ECE 477 Final Report Fall 2006
writeLine1(" Scan Item:",0); writeLine2("",0); initStr(rfidTag,10); addStatus++; break; case 11: // Wait for scan if (rfidTag[9] != '\0') { tagId = searchIDB(rfidTag); if(tagId == -1) { //writeLine2(" Invalid Item",0); copyStr(rfidTag,rfidLast,10); } else { ////writeStr("\r\nScanned: "); //printStr(rfidTag, 10); addToCart(rfidTag, tagId, doAddRem); shopStatus = 20; addStatus++; } } break; default: // Reset Status & Relay copyStr(rfidTag,rfidLast,10); addStatus = 0; PT1AD0 = PT1AD0&0x7F; break; } }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Item Functions *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * static void getInfo() { int i, j; for(i = 0; i < nITags; i++) { for(j = 0; j < nIDB; j++) { if(compareTags(&iTags[i * 32], &iDB[j * 32]) == 0) { copyStr(&iDB[j * 32], &iTags[i * 32], 32); break; } } } } static void sortItems() { int i, done; char tempTag[32]; done = 0; while (done == 0) {
F-37 ECE 477 Final Report Fall 2006
done = 1; for (i = 0; i < nITags-1; i++) { if (iTags[i*32 + 10] > iTags[(i+1)*32 + 10]) { copyStr(&iTags[i*32], tempTag, 32); copyStr(&iTags[(i+1)*32], &iTags[i*32], 32); copyStr(tempTag, &iTags[(i+1)*32], 32); done = 0; } } } } static void genInstr(){ int i,n; unsigned char isle, lIsle; unsigned char isles[127]; n = 0; lIsle = 0; for (i = 0; i < nITags; i++) { isle = iTags[i*32 + 10] & 0x7F; if (isle != lIsle) { isles[n++] = isle; } lIsle = isle; } for (i = 0; i < n; i++) { if (i%2 == 0) { instCheckpoints[i*2] = isles[i]; instCheckpoints[i*2+1] = isles[i] | 0x80; } else { instCheckpoints[i*2] = isles[i] | 0x80; instCheckpoints[i*2+1] = isles[i]; } } instCheckpointCount = n*2; // Print Checkpoints /*//writeStr("\r\n"); for (i = 0; i < instCheckpointCount; i++) { //writeStr("\r\nCheckpoint "); printInt(i); //writeStr(": Isle:"); printChar(instCheckpoints[i] & 0x7F); if (instCheckpoints[i] & 0x80) //writeStr(" Left"); else //writeStr(" Right"); }*/ }
F-38 ECE 477 Final Report Fall 2006 static void addToCart(char *tag, int index, int addRem){ //add item addRem = 1, remove item addRem = 0 if(addRem == 1) { //add item totPrice += str2Int(&iDB[index*32 + 12]); copyStr(&iDB[index*32], &cTags[nCTags * 32], 32); nCTags++; setAddBit(tag, addRem); //printITags(&cTags, nCTags); ////writeStr("\r\n"); initStr(line2Text,160); sPrintDesc(line2Text, &iDB[index*32 + 16]); copyStr(" added", &line2Text[strLength(line2Text)], 6); line2Scroll = 0; //printITags(iTags, nITags); } else { //remove item if(remCTags(tag) != 1) { ////writeStr("\r\n"); initStr(line2Text,160); sPrintDesc(&line2Text[0], &iDB[index*32 + 16]); copyStr(" not in cart",&line2Text[strLength(line2Text)],12); line2Scroll = 0; } else { totPrice -= str2Int(&iDB[index*32 + 12]); setAddBit(tag, addRem); //printITags(&cTags, nCTags); ////writeStr("\r\n"); initStr(line2Text,160); sPrintDesc(&line2Text[0], &iDB[index*32 + 16]); copyStr(" removed",&line2Text[strLength(line2Text)],8); line2Scroll = 0; } } } static int remCTags(char *tag) { int i = 0; int j = 0; while(i < nCTags){ if(compareTags(tag, &cTags[i * 32]) == 0) { for(j = i; j < nCTags; j++) copyStr(&cTags[(j+1)*32], &cTags[j*32], 32); nCTags--; return 1; } i++; } return 0; } static int searchIDB(char *tag){ int i = 0;
F-39 ECE 477 Final Report Fall 2006
while(i < nIDB) { if(!strCompare(tag, &iDB[i*32], 10)) return i; i++; } return -1; } static void setAddBit(char *tag, int addRem) { int i, j,found; found =0; //used to see if there is still an item of tag still in the cart for(i = 0; i < nITags; i++) { if(!strCompare(tag,&iTags[i*32], 10)) { if(addRem == 1) { iTags[i*32+14] = iTags[i*32+14]|0x80; //found = 1; } else { for(j = 0; j < nCTags; j++) { if(!strCompare(tag,&cTags[j*32], 10)) found = 1; //else found = 0; } if(!found) iTags[i*32+14] = iTags[i*32+14]&0x7F;//if no longer in cart zero bit } } } } static unsigned char gotAllItems(){ int i; for(i = 0; i < nITags; i++) if(!(iTags[i*32 + 14]&0x80)) return 0; return 1; } static void switchCheckpoints (){ int i; for (i = 0; i < instCheckpointCount; i++) { instCheckpoints[i] = instCheckpoints[i]^0x80; } } tags.c
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // *** Global Variables *** // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Current and Last Tag read extern unsigned int rfidDisable; //enables (1) and disables (0) the rfid interupt static char rfidBuffer[16]; // RFID buffer for new tags static char rfidTag[16]; // Last RFID tag read static char rfidLast[16]; // Used to check if rfidTag is a new tag
F-40 ECE 477 Final Report Fall 2006
// Location Tags and Item DB #pragma push /* remember current segment definitions (to be restored below) */ #pragma DATA_SEG __RPAGE_SEG PAGED_RAM /* these variables will be allocated in segment PAGED_RAM through the RPAGE register */ static int nLTags; // # of tags static char lTags[30 * 16]; // 30 Tags, size 16 static int nIDB; static char iDB[30 * 32]; // Item DB static int storeHeading; //Item Tags static int nITags; static char iTags[10 * 32]; // Item Tags //Items colleced in cart static int nCTags; //number of items that have been added to cart static char cTags[30*32]; //item tags of collected items #pragma pop /* reset segment definitions to previous state */
extern.h
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Main.c Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern unsigned int rtiDiv; extern unsigned int rtiI; extern unsigned int wait; extern unsigned char rtiStatus; extern unsigned char rfidN; extern unsigned char relayStatus; extern unsigned char cardStatus;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Output.c Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern void writeStr(const char *); extern void writeChar(const char); extern void writeStr2PC(const char *); extern void writeChar2PC(const char); extern void writeStr2LCD(const char *); extern void writeChar2LCD(const char); extern void printChar(unsigned char); extern void sPrintChar(char *, unsigned char); extern void printInt(int); extern void printBits(unsigned char); extern void printHex(unsigned char); extern void sPrintHex(char *, unsigned char);
F-41 ECE 477 Final Report Fall 2006 extern void printLong(unsigned long); extern void printStr(char *, int); extern void updateLCD(); extern void writeLine1(char *, unsigned char); extern void writeLine2(char *, unsigned char); static void displayPrice(void); static void displayCart(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Output.c Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern char line1Text[160]; extern unsigned char line1Scroll; extern char line1N; extern char line2Text[160]; extern unsigned char line2Scroll; extern char line2N; extern unsigned int lcdScrollRate; extern unsigned int lcdScrollN;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Tools.c Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern void copyStr(char *, char *, int); extern unsigned char strCompare(char *, char *, int); extern void initStr(char *, int); extern int str2Int(char *); static int strLength(char *);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Tags.c Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern char rfidBuffer[16]; extern char rfidTag[16]; extern char rfidLast[16]; extern int nITags; extern char iTags[10 * 32]; extern int nCTags; extern char cTags[30 * 32]; extern int nLTags; extern char lTags[30 * 16]; extern int nIDB; extern char iDB[30 * 32]; extern int storeHeading;
F-42 ECE 477 Final Report Fall 2006
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * SD.c Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern void sdFunction(void); extern unsigned char xfer(const char); extern void sdEnable(void); extern void sdDisable(void); extern unsigned char sendCommand(unsigned char, unsigned long, unsigned char); extern unsigned char sdReadBlock(unsigned long, unsigned char *); extern void getItemLst(void); extern void getIDB(void); extern void getLTags(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * SD.c Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern unsigned char sdStatus; extern unsigned char disableSS; extern unsigned long fs_addr; extern unsigned char fs_data[512]; //data from file extern unsigned long fs_mbr_addr; extern unsigned char fs_mbr[512]; extern unsigned long fs_vol_addr; extern unsigned char fs_vol[512]; extern unsigned int fs_BPS; // Bytes per Sector extern unsigned char fs_SPC; // Sectors per Cluster extern unsigned int fs_RS; // Reserved Sectors extern unsigned char fs_NF; // Number of Fats extern unsigned long fs_SPF; // Sectors per Fat extern unsigned long fs_Root; // Root Directory First Cluster extern unsigned long fs_Fat; // Fat Location extern unsigned long fs_Cluster; // Cluster Location extern unsigned long fs_Dir; // Dir Location extern unsigned long fs_File; // File Location
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Compass.c Function * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern char SPITransmit(char); extern void getHeading(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Compass.c Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern int compHeading; extern char compHeadingTMP[5]; extern int compHeadingN; extern int compNextHeading; extern int compVariance;
F-43 ECE 477 Final Report Fall 2006
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Shop.c Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern void shopInit(void); extern void shopFunc(void); extern void addFunc(void); extern void getInfo(void); extern void sortItems(void); extern void genInstr(void); extern void addToCart(char *, int, int); extern int remCTags(char *); extern int searchIDB(char *); extern void setAddBit(char *,int); extern unsigned char gotAllItems(void); extern void switchCheckpoints(void); extern void initTags(void);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * Shop.c Variables * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern unsigned char instCheckpoints[256]; extern unsigned char instCurCheckpoint; extern unsigned char instCheckpointCount; extern unsigned char shopStatus; extern unsigned char addStatus; extern unsigned char doAddRem; extern int nCartItems; extern int lastDisplayedItem; extern int totPrice; extern unsigned char isle;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * RFID.c Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * extern void initTag(char *); extern int compareTags(const char *, const char *); extern void copyLTag(const char *, char *); extern void printTagID(const char *); extern void printLTags(void); extern void printITags(char *,int); extern void printIDB(void); extern void getLTagInfo(void); extern void printDesc(const char *); extern void sPrintDesc(char *, const char *); sdOutput.c // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
F-44 ECE 477 Final Report Fall 2006
// * * * SD Output Functions * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Print Block Data - used for debugging static void printBlock(unsigned char *ptr, unsigned int size) { unsigned int i; unsigned char base; writeStr("\r\nAddr Base: +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F"); for (i = 0; i < size; i++) { if (i%16 == 0) { base = (char) ((i-(i%16))/16); writeStr("\r\n "); printHex(base); writeStr(": "); } printHex(*ptr); writeChar(' '); ptr++; } }
F-45 ECE 477 Final Report Fall 2006
E-1 ECE 477 Final Report Spring 2006
Appendix G: FMECA Worksheet
Failure Failure Mode Possible Causes Failure Effects Method of Criticality Remarks No. Detection Potential injury to the Failure of C , R , D , 6 3 1 Overheating or customer overheating Output voltage is D , D , D , R , R , R , A1 2 3 4 4 5 8 improper Observation High leads to fire. Could also over spec R , L , L , C , C , 9 1 2 12 11 functioning cause damage to other C , C , R , R , C , C 10 9 6 7 7 8 components of design.
Failure of C6, R3, D1, Output voltage is D , D , D , R , R , R , Improper A2 2 3 4 4 5 8 Observation Low under spec R9, L1, L2, C12, C11, functioning C10, C9, R6, R7, C7, C8
System has no A3 No output voltage Failure of BT , C Observation Low 1 6 power
Potential injury to the Overheating or customer overheating Short of the Failure of bypass A4 improper Observation High leads to fire. Could also battery capacitor (C ) 6 functioning cause damage to other components of design. Unable to locate Faulty wire The RFID tags are not specific items on connection to header; located throughout the B1 No input shopping list, which Observation Low Faulty RFID module; store. Microcontroller was input by Failure of U receives no data. 6 customer
G-1 ECE 477 Final Report Spring 2006
Faulty wire Items on shopping connection to header; The wrong RFID could list not found or B2 Incorrect output Faulty RFID module; Observation Low be passed to the wrong item Failure of U , C , microcontroller 6 20 indicated as found C17, C16, C18, C19
No input from Faulty USB Shopping list is not C1 USB memory connector; Failure of Observation Low loaded stick Y1, R1, R2, C3, C4, C5
Incorrect input Failure of C , C , C , Shopping list is not C2 2 1 5 Observation Low voltage level U4 loaded
Failure of internal Jumbled LCD D1 Incorrect output microcontroller Observation Low display circuitry, software
Constant output Unchanging LCD D2 Failure of Y , C , C Observation Low value 6 14 15 display
No output to LCD D3 Failure of I/O pins Nothing on LCD Observation Low display
G-2 ECE 477 Final Report Spring 2006
No power or Failure of U , bypass D4 incorrect input 4 Nothing on LCD Observation Low capacitor voltage levels
Reset signal Failure of R , CW Intermittent display D5 12 3, Observation Low flickering software on LCD
Instructions are not The user will have to Faulty wire E1 No output updated Observation Low push a button for the connection to header automatically next instruction.
The user will have to Instructions are not push a button for the updated at next instruction. And E2 Incorrect output Out of calibration Observation Low appropriate time or product might possibly not at all give incorrect instructions. Faulty I/O Impossible to connection; Faulty No characters on see/read the F1 LCD; Failure of U , Observation Low LCD 3 directions being U , , C , C , C , C , 6 20 17 16 18 given. C19 Faulty I/O Impossible to Invalid characters connection; Faulty comprehend the F2 Observation Low on LCD LCD; Failure of U3, directions being U6, C17, C16, C18, C19 given.
G-3