Home

TABLE OF CONTENTS

image

Contents

1. ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 If right arrow pressed else if BitRdPortl PBDR 4 Left_Right 1 If Down Arrow Pressed else if BitRdPortl PBDR 2 Up_Down 1 If Up Arrow Pressed else if BitRdPortl PBDR 3 Up_Down 1 Function Left_Right Parameters short int inc increment decrement for message index Description Increments or Decrements the index to the message being displayed on the LCD This is triggered by an interrupt from a left or right keypad press It then updates the message on the LCD display with the new index void Left_Right short int inc extern message_index extern message_top Add increment decrement to the message index message_index inc If decrement took below 0 wrap to top message if message_index 1 message_index message_top f increment took above top message wrap to 0 if message_index gt message_top message_index 0 Refresh the message on the LCD Display refresh_message Function Up Down Parameters short int inc Increment Decrement for target fridge temp Description Increments or Decrements the target temperature for the refrigerator This will be compared with actual temperature to control the compressor It then updates the temperature display on the LCD void Up_Down short int inc 14 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 ext
2. interrupt to control Temperature Control Module void initialize_timerB Timer A1 Time Constant Register Set to longest delay possible This will serve was the clock for timer B WrPortl TAT1R amp TAT1RShadow OxFF Timer B Constrol Register Timer B Clocked by Timer A1 Timer B interrupt set to priority 3 WrPortl TBCR amp TBCRShadow 0x07 Timer B Match 1 Register Set to largest count match to delay as long as possible desire a one minute total delay after global counting WrPortl TBM1R NULL Oxff WrPortl TBL1R NULL Oxff Function _ initialize_ex_interrupts Parameters NONE Description Sets initial control registers for the external interrupts These interrupts will be triggered by the keypad local user interface and the RFID push button Inside fridge void initialize_ex_interrupts Interrupt O Control Register Set port E 0 to interrupt on falling edge Since used for keypad set to interrupt priority 1 WrPortl lIOCR amp lOCRShadow 0x05 Interrupt 1 Control Register Set port E 1 to interrupt on falling edge Since used for RFID pushbutton set to interrupt priority 2 of 20 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 WrPortl 11CR amp 11 CRShadow 0x06 class auto Main Function Run Initialization functions and then wait for an interrupt void main initialize the LCD di
3. ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 TABLE OF CONTENTS Intro ti ade do ea 2 Software Desig nCoOnS Sra OASIS A ae aves 2 Memory VTL Tece e e ele wt wd E din a E GENE 2 Memory Sections Mapping recursos iria tiro aiii ice feas 3 Startup Codi 4 Organization of Embedded Application CoOde ooooocnnncccnoncccnonaccnoncnonnncnononaconnnnnos 5 Software DESTINA dias 5 Rey mad Control Mode a o nace op i SS 5 RFID Control Modules sonoras dentista 6 Temperature Control Module ccs sicccsssspesstinssacccessscvensaavccseeesntcatenteasannerevsvesannceess 7 WEP SCEV ET A e E 8 Software Documentados 10 Keypad Control Module Flow Chart ooooonnncccnnccccnoncccnoncnonnnccnnnnncnonnccnonnncnnnncanns 10 RFID Control Module Flow Chart ooocoocccnnccccnonccononccononccononccnnnnccnnnnccnnnnccnnnnnos 11 Temperature Control Module Flow Chart ooooonnncccnoncccnoncccooncncnnnccnnonncccnnnaninnnos 12 LISTE OL A a a nO ais 13 Referencia as Na 21 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Introduction The Cold as Ice fridge is an intelligent refrigerator that consists of an inventory system to keep track of its contents a digital thermostat system to control the temperature within the refrigerator and a web and LCD interface to allow for user interaction All of the refrigerator s functionality will be controlled by a microcontroller The microcontroller will be reading interpreting and storing informatio
4. RShadow 0x01 pulse_lIcd delayHalfMs 3 Entry mode set disable shift of display set moving direction WrPortl PADR amp PADRShadow 0x06 pulse_lIcd Turn on display cursor blinking and on 18 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 WrPortl PADR amp PADRShadow 0x0C pulse_lIcd Refresh displays with initial defaults refresh_temp refresh_message void initialize_serial TimerA control status register Timer A interrupt disable Enable main clock for timer A WrPortl TACSR amp TACSRShadow 0x01 Timer A Control Register Set all clocks clocked by PCLK 2 set Interrupt for timers disabled WrPortl TACR amp TACRShadow 0x00 Time Constant Register for A7 A4 11d which gives a baud rate 57600 for serial port D A WrPortl TAT7R amp TAT7RShadow Ox0B WrPortl TAT4R amp TAT4RShadow Ox0B Serial Port D Control Register Asynchronous disable rcv input Asynch 8 bit mode disable interrupts a WrPortl SDCR amp SDCRShadow 0x20 Serial Port A Control Register clocked start byte xmit operation disable rcv input clocked mode internal clock disable interrupts Bi WrPortl SACR 8 SACRShadow 0x8C Function initialize_timerB Parameters NONE 19 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Description Initialize registers to set Timer B to work for
5. Using serial port D send a read request packet to the RFID scanner Wait for the RFID scanner to send back a confirmation packet telling us that it received the read request ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Read Data Wait for the RFID scanner to send back information that was received from the RFID tag of the product scanned Grab the product identification number from the information read Pulse the buzzer to notify the user that the product was correctly scanned Check Inventory Scan the inventory array to find the corresponding struct for the product identification number When the correct struct is located check to see if the Valid data is equal to zero indicating if it is already in the inventory or not Remove From Inventory If the product scanned has a Valid value other than zero it is in the inventory The user is now removing it from the refrigerator Therefore set the corresponding product s Valid value to non zero and exit the module Add To Inventory If the product scanned has a Valid value of zero it is not yet in the inventory The user is now adding it to the refrigerator Therefore set the corresponding product s Valid value to 0 and exit the module Temperature Control Module As mentioned above this module is called by an interrupt with priority 3 This interrupt is triggered using Timer B Increment Counter Due to the lack of time that can be set between interrupt
6. and PB2 PB4 Each bit will directly correspond to one of the keys Therefore the decode step only needs to figure out if it was a right left button or an up down button Left Right Button Press If the press is a left or right arrow button then the index for the messages array is incremented decremented This message index is a global variable pointing to the correct information message to be displayed on the LCD Refresh LCD Message Use the message index to grab the correct message string from the message array Send the corresponding information over Parallel Port A to the LCD to display the newly indexed message Up Down Button Press If an up or down key press is detected then the module must increment decrement the thermostat temperature This is the global variable which controls the temperature inside of the refrigerator Update LCD Thermostat Temperature Grab the new thermostat temperature and using Parallel Port A refresh the temperature displayed on the LCD to reflect the change This thermostat temperature will eventually be used to control the internal temperature of the refrigerator in the Temperature Control module RFID Control Module As mentioned above this module is called by the external interrupt with priority 2 This interrupt is triggered by the external push button located by the RFID scanner inside the refrigerator A press to this button indicates that the user wants to scan ina product Send Read Request
7. be broken up into four modules Keypad Control RFID Control Temperature Control and the Web Server The Keypad Control module will have the highest priority of the three The interrupt will be an external interrupt triggered when a change is detected on one of the keypad lines This module will control the local user interface The RFID Control module has the second highest priority This interrupt is triggered by RFID pushbutton which indicates that a user wants to scan an object The Temperature Control module has the lowest priority of all of the interrupts It is triggered by Timer B However this module can also be called by the web server Unlike the rest of the application code the web server is not interrupt driven It runs using the Dynamic C costate functionality This allows the software to have multi threading type capabilities Because of this the web server functionality appears to be completely separate from our main controlling function However this code can also call on other functions that are sometimes controlled through interrupts Software Design Narrative Keypad Control Module As mentioned above this module is called following an interrupt of the highest priority The interrupt is triggered by the local user pressing a key on the keypad ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Decode Keys As soon as this key press is detected the control module scans in the key bits located on PBO
8. e remote user to view what is inside the fridge Display Warning Messages Traverse the message array and display each warning message to the web page This will allow the remote user to be informed if something in the fridge has expired or something else has occurred Recipe Entering Tool Display all of the currently acceptable items for the fridge along with check boxes for each one Also display a text box with the label Recipe Name When the user clicks the Enter button add a recipe to the array with bits corresponding to the checked items set and the correct name This will allow the user to enter a recipe into the database Recipe Query Display buttons with the names of all the recipes in the recipe database When the corresponding button is clicked display the items needed by that recipe which are not in the inventory ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Software Documentation E gt Keypad Int Yes Left Right No Adj Therm Setting Refresh LCD Therm Disp Adj Array Index Mes Disp Indexed Message Figure 2 Keypad Control Module Flow Chart 10 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 E E RFID Push Button Send Read Request Check Inventory Add To Inventory Remove From Inventory Figure 3 RFID Control Module Flow Chart cT ECE 477 Digital Systems Senior Design Project Gr
9. ermore our webserver and constants will also be found here No temporary data will be found in flash gt SRAM SRAM has a virtually unlimited number of writes reads available on it Therefore this is where you will find our variable portion of memory All temporary function variables the inventory database and the recipe database will be stored in this memory ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 The Dynamic C compiler handles a lot of the memory mapping which removes the messy job of manually mapping the memory The following figure shows how the Rabbit 2200 maps the information to memory 1 Xmem Segment Interrupt Vectors Watch Code RAM Stack Segment Estero a Vectors Data Segment Root Data oxchoo Pe Xmem Code from Xmem Segment Flash Memory A Site Base Segment ER RRA Root Code OTRA Root Code DICO A A etter 0x0000 0x00009 Logical Address Space Physical Address Space Figure 1 RCM 2200 Memory Mapping As you can see in Figure 1 flash memory starts at address 0x00000 and SRAM begins at address 0x80000 Furthermore we can also see how it maps the constants and program code into flash while mapping the variables and stack to SRAM Startup Code When the REM 2200 is powered on initialization code generated by the Dynamic C compiler is the first thing that is run This initialization code takes care of the me
10. ern temp_targ Increment Decrement Target temperature for the compressor temp_targ inc Refresh the temperature displays on the LCD refresh_temp E REESE Se OA See SARE ERR EEE LEER ESE tee ee EERIE RARER Function refresh_message Parameters none Description Will display the messages message_index on the LCD EXERARLRRA NARA e E e FE HEEE e E e ENANA RARA RARA RA RANA RENE ERAN AER ERLE LER ERERERERREES void refresh_message extern char messages 5 20 extern short int message_index int i Move cursor WrPortl PDB3R NULL 0 lt lt 3 WrPortl PDB4R NULL 0 lt lt 4 WrPortl PADR amp PADRShadow 0x94 pulse_lIcd Write string WrPortl PDB3R NULL 1 lt lt 3 for i 0 i lt 20 i WrPortl PADR amp PADRShadow messages message_index i pulse_Ica return ERA ESAERE ER ARERS EERE EARS ER REAR EERE LERSAES RR AESESS EAS REED TRERER ELAR EEE Function refresh_temp Parameters none Description Will convert the global variables temp_real and temp_targ integers to ASCII values It then updates the temperature display on the LCD in the form real temp target temp EERE LE REREESA RENEE A E REA SEERA ER ESS EARLE EEE E SERA DEERE SE void refresh_temp 15 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 extern temp_real temp_targ int mstemp_real lstemp_real int mstemp_targ lstemp_targ Convert real temp to i
11. liable 5 mS only use this if approximations are tolerable void delayHalfMs int delay loop counter int i j Delay Loop for i 0 i lt delay i for j 0 i lt 650 i void initialize _Icd extern int temp_real extern int temp_targ extern short int message_index extern short int message_top extern char messages 5 20 set initial defaults temp_real 10 temp_targ 10 message_index 0 message_top 0 strncpy messages 0 COLD AS ICE FRIDGE 20 Convert the I O ports Disable slave port which makes Port A an output and PORT E not have SCS signal af WrPortl SPCR amp SPCRShadow 0x84 WrPortl PDFR amp PDFRShadow 0x00 ma eae ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Set Port D Drive Control Register for all port to be driven high or low WrPortl PDDCR amp PDDCRShadow 0x00 Set Port D Data Direction Register 1 output O input Bits 3 4 5 output WrPortl PDDDR amp PDDDRShadow 0x38 Initialization sequence delayHalfMs 30 WrPortl PDDR amp PDDRShadow 0x20 WrPortl PADR 4 PADRShadow 0x30 pulse_Ica delayHalfMs 9 pulse_lIcd delayHalfMs 1 pulse_lIcd Interface 8 bits 2 lines font set WrPortl PADR amp PADRShadow 0x3C pulse_lIcd Set display off WrPortl PADR amp PADRShadow 0x08 pulse_lIcd Display Clear WrPortl PADR amp PAD
12. ll be using two main data structures First of all we need to be able to store the items in the inventory A simple structure array is going to be used in order to store this information The structure is composed of four data members shown below and will be used to form an array of the items ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 typdef struct Inv_Item char ID_LENGHT char PRODUCT_NAME int Exp_Date short int Valid Inv_Item Inventory POSSIBLE_ITEMS_ NUMBER The second main data structure needed is one to hold the recipes in our database In order to optimize the recipe database we decided to make use of bitwise comparisons to figure which ingredients are used for the specific recipe Bit 0 of this field will correspond to Inventory 0 This will allow for quick comparison when a recipe is queried We will use a short integer to hold the bits to compare An array of these recipes will make up the recipe database The data structures for the recipe database are shown below typdef struct Rec_Item char CHAR_NAME_LENGTH short int Ingredients Rec_Item Recipe_Database Possible_Recipes Memory Sections Mapping As mentioned before the memory is made up of two main sections Flash and SRAM gt Flash Flash has a limited write life Therefore we have to minimize the number of writes we perform to this memory Due to this constraint we will store all of our program code here Furth
13. mory mapping Once this routine completes our first initialization code is run This code sets the control registers on the RCM 2200 to allow for external communication as well as configures the external peripherals The following configurations need to be made to set up the I O of the RCM module 1 2 3 4 5 6 Set Parallel Port A to bytewide output for LCD data lines Set Port D bits 3 5 to output bits for LCD control Set Port B bits 0 2 4 to input bits for Keypad Set EO to external interrupt with priority 1 for keypad Set El to external interrupt with priority 2 for RFID Pushbutton Set Serial Port D to be asynchronous serial port for RFID communication Mis ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 7 Set Serial Port A to clocked serial port for temperature chip communication 8 Set Timer A to give 57600 baud rate to Serial Ports A and B 9 Set Timer B to cause interrupt of priority 3 with the slowest rate possible to read temperature 10 Set PB7 to be output bit to drive the relay for compressor control Furthermore the following steps need to be taken to initialize the external peripherals 1 Run LCD initialization routine 2 Run RFID initialization routine 3 Run temperature chip initialization routine Organization of Embedded Application Code As mentioned previously except for the web server the application control is completely interrupt driven The embedded software can
14. n given by a Radio Frequency Identification RFID device operating a web server to allow for remote user control driving the LCD panel to allow for local user control and monitoring the temperature within the refrigerator and in turn controlling the compressor to keep the temperature within a user specified range Local user interaction will consist of the user being able to control the thermostat as well as the refrigerator displaying warning messages such as an expired product Remote user interaction will consist of the user s ability to control the thermostat as well as see the contents inside The Cold as Ice fridge is a microprocessor based system that is completely interrupt driven The interrupts will be generated by the user keypad RFID push button and internal timers Furthermore a web server will be ran which will provide remote functionality to the user The most important software considerations are storage space communicating with peripherals and maintaining the refrigerator inventory Software Design Considerations Memory Models The microcontroller controlling the Cold as Ice fridge is the RCM 2200 module This module was chosen because of its simplicity along with its Ethernet port and functionality However because of this choice we are left with limited memory The RCM 2200 module comes equipped with only 256K of flash and 128K of SRAM Therefore we must be very careful in how our data is stored Our design wi
15. ndividal ASCII chars mstemp_real temp_real 10 48 Istemp_real temp_real 10 48 Convert target temp to individual ASCII chars mstemp_targ temp_targ 10 48 Istemp_targ temp_targ 10 48 Move cursor WrPortl PDB3R NULL 0 lt lt 3 WrPortl PDB4R NULL 0 lt lt 4 WrPortl PADR 4 PADRShadow 0x8D pulse_lIcd Real temp WrPortl PDB3R NULL 1 lt lt 3 WrPortl PADR amp PADRShadow char mstemp_real pulse_lIcd WrPortl PADR amp PADRShadow char Istemp_real pulse_Ica WrPortl PADR amp PADRShadow OxDF pulse_lIcd WrPortl PADR amp PADRShadow pulse_lIcd Target temp WrPortl PADR amp PADRShadow char mstemp_targ pulse_lIcd WrPortl PADR amp PADRShadow char Istemp_targ pulse_lIcd WrPortl PADR amp PADRShadow OxDF pulse_lIcd return EAR REPRE RR ERA ERLE EE ER EEE ELLE AEE ERE A ERLE RARER EEL Function pulse_Icd Parameters none Description Will pulse the LCD chip enable for 5 ms then return to normal 16 ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 e a a aioe EREEREER EENAA void pulse_lca WrPortl PDB5R NULL 0 lt lt 5 delayHalfMs 1 WrPortl PDB5R NULL 1 lt lt 5 return Function delayHalfMs Parameters int delay Number of half miliseconds to delay Description Delay the microprosessor 5 milliseconds NOTE This is not a re
16. p 11 Fall 2004 E a Timer B Read Current Temp Info Compresso On Yes Temp gt Therm 1 No Yes Turn On Comp Set Flag Turn Off Comp Set Flag Figure 4 Temperature Control Module Flow Chart fe ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Listing of Fridge c AER EERE REE REEL SOI EEE File Fridge c Authors Matt Compton Andrew Whipple Description This file contains the initialization routines as well as the Keypad Control Software Module Modifications Date Modifier Description a 11 10 04 Matt Compton Piecing together code segments for initial file E creation A N Global Variables int temp_real temp_targ char messages 5 20 short int message_index short int message_top Function Prototypes void initialize_ex_interrupts void initialize_timerB void initialize_serial void initialize_Icd void delayHalfMs int void pulse_Icd void refresh_temp void refresh_message void Up_Down short int void Left_Right short int interrupt keypad_isr Function keypad_isr Parameters NONE Description Interrupt subroutine for a keypad press This is triggered by bit EO connected to the CH line on the keypad debouncer This checkes which key is pressed and calls the correct function interrupt keypad_isr f left arrow pressed if BitRdPortl PBDR 0 Left_Right 1 13
17. perature is less than the thermostat temperature 1 the compressor has cooled the fridge down to the desired temperature Turn off the compressor and clear the global compressor bit to let the system know it is off Exit the module Turn On Compressor and Set Flag If the temperature is greater than the thermostat temperature 1 the temperature inside the fridge has exceeded the desired temperature Therefore turn the compressor on to begin cooling the fridge and set the global compressor bit to let the system know that the compressor is now on Exit the module Web Server The web server is the only module that is not interrupt driven As stated earlier it is run using the costate functionality in Dynamic C which causes the program to act as if it is multi threaded Therefore the web server runs in the background and is independent of the flow of all other modules ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Thermostat Temperature Control Display two buttons on the web page One of these buttons will correspond to increasing the thermostat temperature and the other to decreasing the temperature Then when one of these buttons is pressed the corresponding function from the Temperature Control module can be called Contents Listing Traverse the inventory array checking the Valid value of every item If the Valid value is not zero display the item and its information on the web page This will allow th
18. s triggered by Timer B we must increment a counter This counter is going to be a global value detailing how much time has passed between temperature sensor reads Therefore after incrementing the counter we must check to see if it is at a value that confirms a minute has passed A minute was chosen in between temperature reads in order to protect the compressor from rapid power change If the counter does not indicate a minute has passed exit the module ECE 477 Digital Systems Senior Design Project Grp 11 Fall 2004 Read Current Temperature Info Read the current temperature reading coming from the Temperature Sensor chip over Serial Port A Store this data in a global variable to represent the current temperature inside the fridge Update LCD Temperature Grab the new current fridge temperature and using Parallel Port A refresh the temperature displayed on the LCD to reflect the change Check Compressor Status Check the global bit to see if the compressor is on If the compressor is on then check to see if the current temperature is less than the thermostat temperature 1 The minus one adds a tolerance to the desired temperature If the compressor is currently off then check to see if the current temperature is greater than the thermostat temperature 1 Again the plus one adds a tolerance to the desired temperature If neither of these conditions are true exit the module Turn Off Compressor and Clear Flag If the tem
19. splay initialize_Ica initialize the serial ports initialize_serial initialize the external interrupts initialize _ex_interrupts initialize timer b and its corresponding interrupt initialize_timerB List of References 1 Z World Dynamic C For Rabbit Semiconductor Microprocessors Integrated C Development System User s Manual http www zworld com documentation docs manuals DC DCUserManual DCPUM p df 21

Download Pdf Manuals

image

Related Search

Related Contents

Olympus Camedia D-540 Zoom Digital Camera  modalités - Académie d`Orléans  COLOR SECTOR SCANNING SONAR  Philips 23PF4321 23" LCD HD Ready widescreen flat TV  PumpDrive S  SMC Networks EliteConnect SMC2536W-AG2 User's Manual  - S&S Cycle  InfinityCam user manual  User manual Upright bikeProDyaco-20140509-new display  none 8239255776 Instructions / Assembly  

Copyright © All rights reserved.
Failed to retrieve file