ECE 477 Digital Systems Senior Design Project Spring 2008

Homework 9: Software Design Considerations

Due: Friday, March 21, at NOON

Team Code Name: MyRoom Group No. 9

Team Member Completing This Homework: Andrew Hampton

E-mail Address of Team Member:

Evaluation:

SCORE

/

DESCRIPTION

10 /

Excellent – among the best papers submitted for this assignment. Very few corrections needed for version submitted in Final Report.

9 /

Very good – all requirements aptly met. Minor additions/corrections needed for version submitted in Final Report.

8 /

Good – all requirements considered and addressed. Several noteworthy additions/corrections needed for version submitted in Final Report.

7 /

Average – all requirements basically met, but some revisions in content should be made for the version submitted in the Final Report.

6 /

Marginal – all requirements met at a nominal level. Significant revisions in content should be made for the version submitted in the Final Report.

* /

Below the passing threshold – major revisions required to meet report requirements at a nominal level. Revise and resubmit.

* Resubmissions are due within one week of the date of return, and will be awarded a score of “6” provided all report requirements have been met at a nominal level.

Comments:

Comments from the grader will be inserted here.

1.0  Introduction

The purpose of the myRoom project is to create a system that allows for complete room customization for several different users. This allows a single space to be transformed into a unique special area for all members of the household. This is achieved by providing each family member their own RFID tag which allows them to create settings to control the peripherals within the room. For the sake of the prototype that we are developing we are limiting this to a TV, lights, fan, and a stereo. All of these devices will be controlled via infrared transmission with the lights and fan being controlled by an external X10 interface. In order to make this project as flexible as possible we are including an infrared receiver such that our unit can learn new infrared signals in order to communicate to more devices. The on-chip peripherals are an RFID reader, infrared transmitting diodes, infrared receiving diode, and an Ethernet port. The software will be command-driven due to having a natural sequential order in which things should occur, but it will also have to listen to interrupts from the website interface to check for updates.

2.0  Software Design Considerations

2.1  Memory Mapping

The microcontroller that our project is utilizing is the MC9S12NE64. The block diagram of this particular microcontroller can be seen in Appendix C. This particular microcontroller makes use of 64KB of EEPROM and 8KB of SRAM memory. Most of the memory we use will be within the EEPROM section of memory making use of its non-volatile state to store the instruction memory, and all stored variables such as the user settings, and the infrared codes associated with those settings.

2.2  External Interface Mapping

The external interfaces will be mapped in the following way. The RFID reader which utilizes RS232 as its communication protocol will be mapped to SCI0_RXD. The infrared receiver is mapped to SCI1_RXD while the infrared transmitters are mapped to SCI1_TXD. We have a pushbutton attached to the reset pin in order to implement the ability to reset the microcontroller. The Ethernet interface is found on the EPHY ports.

2.3  Utilization of Integrated Peripherals

The software that we are developing will make use of two of the major build in peripherals located on-chip. These are the Serial Communication Interface (SCI) module and the Ethernet Physical Transceiver (EPHY) module. The SCI module will need to be implemented differently for each part that it is communicating with. For the RFID reader on port SCI0_RXD we need to initialize it to a baud rate of 9600 with receiving enabled. One of the advantages to this particular microcontroller is that it comes equipped with infrared capability. For both instances of using the infrared diodes we must enable the infrared decoder, and set it to receiving or transmitting respectively.

2.4  Organization of Application Code

The application code itself will be command driven being a mix between a state machine and an interrupt driven implementation. Appendix A shows the general flow of our main program. As this shows the program is very sequential, but interrupts will be necessary to determine when an RFID tag comes into range.

2.5  Debugging

In order to accommodate some provisions for debugging our code we will be using a few LEDs to communicate the status of our project. These same LEDs are the only direct communication with the user for the IR code learning module as well. Through illumination different sets of LEDs it should be possible to effectively discover what is happening within our code.

3.0  Software Design Narrative

Our application code is comprised of a single file that contains several functions to accomplish the desired goals. Below is a narrative for each of the individual functions. Flowcharts of the specific functions can be found in Appendix A, and a hierarchal view of the entire application code can be found in Appendix B.

3.1  Main Function

The purpose of our main function is to first initialize all of the registers to the correct initial value for all of the onboard peripheral interfaces then enter into a program loop. This program loop initially waits for an interrupt to be generated indicated that an RFID tag has been read. Once this happens the particular tag ID will be stored for use. The website interface will make use of the most recent tag scanned to assist in preparing settings. The most recent tag is also used in a lookup routine to find the associated settings for that particular user. If there are no settings then an error will be generated, and the program will return to waiting for an RFID tag to be scanned. The settings must be updated through the website before the program will continue onward. If there are settings associated with that RFID tag then the system will check if it has the appropriate IR codes available. If the codes are unavailable then it will enter the IR code learning module. Once the IR learning module has completed the program will loop back to where the presence of IR codes was checked. If there are IR codes available then the program will go through a transmitting program that will transmit the necessary IR codes to the devices. Once this has completed the program will begin once again waiting for an RFID tag to be scanned. So far this function has only been outlined in pseudo-code.

3.2  IR Learning Module

The purpose of the IR learning module code is to learn the IR codes that are needed to communicate to the devices within the room. Once it is determined that we need to learn the IR codes this function will wait for a pushbutton input indicating that the user is prepared to communicate the IR codes via a remote control. The module will then receive the IR code and store it. Once that code has been stored it will look at the settings to determine if all of the necessary codes have been received. If there are additional codes that need to be input then the program will return waiting for the pushbutton to be pushed to signify that the next IR code will be input shortly. Once all of the IR codes have been entered and saved the function will exit. This function is also only in the pseudo-code stage.

3.3  Website Module

The purpose of the website module is to enable the user to enter their preferred settings. The first thing this module will do is to check if there has been an RFID card scanned. If no code has been scanned yet then an error message stating that a card must first be scanned will be displayed. Once an RFID tag has been scanned then the website will go through a series of options. It will ask if the user would like to apply settings for each individual component. If the user would like to specify settings for a particular component then the website interface will get those specific settings otherwise it will continue down the list of available components available. Once all the settings have been applied, the module will save those settings, and return to waiting for an RFID tag to be scanned. This process takes lowest priority once a tag has been scanned or once the IR code learning process has began. This function is still in the development stage.

3.4  Transmission Module

This code module is simply the output of the IR codes through the IR transmission diodes. There will be an experimental delay between transmissions of different codes in order to ensure that each code is received appropriately. After this completes the function will exit, and the main function will once again be waiting for an RFID tag to be scanned.

4.0  Summary

The above outlined code should work in an efficient manner due to state machine implementation which allows the presence of an RFID tag to provide an interrupt. The overall result should allow for a smooth running implementation of our application to truly make the myRoom into the complete room control system that is strived for.


List of References

[1]  Freescale.com, “MC9S12NE64V1 Data Sheet,” [Online Document], unknown publication date, [accessed March 19, 2008], http://cobweb.ecn.purdue.edu/~477grp9/documents/MC9S12NE64V1.pdf

[2]  Sparkfun.com, “ID-12-Datasheet,” [Online Document], unknown publication date, [accessed March 19, 2008],

http://www.sparkfun.com/datasheets/Sensors/ID-12-Datasheet.pdf


Appendix A1: Flowchart/Pseudo-code for Main Program

Appendix A2: Flowchart/Pseudo-code for IR Learning Module

Appendix A3: Flowchart/Pseudo-code for Website Module


Appendix B: Hierarchical Block Diagram of Code Organization

Appendix C: Block Diagram of MC9S12NE64V1 Microcontroller

-10-