Conserve-A-Watt System Software Design Justin Rapozo
General System Description MC9S12DP512 – 24MHz Bus Frequency – 16K bytes RAM, 4K bytes EEPROM, 512K bytes Flash EEPROM Memory Required – 2K bytes RAM – 36K bytes Flash EEPROM Kernel Used – MicroC/OS-II – 1 ms tick period
Tasks Start Task UI Task Key Task Energy Meter Task
Start Task Creates the User Interface Task, Energy Metering Task, and Key Task – Priority: 4 – Period: Once (at startup) – Execution Time: ~1s
Energy Metering Task Handles measuring energy usage of the device under test. – Irms – Vrms Calculates Preal. Calculates energy consumption in kWh. Handles the storing and deleting of energy consumption. – Priority: 5 – Period: 1ms – Execution Time: 200µs
Key Task Checks for key presses so as to give the user options – Priority: 6 – Period: 5ms – Execution Time: ≤ 5µs
UI Task Handles user inputs and Displays real time/saved energy measurements. – Priority: 7 – Period: 500ms – Execution Time: 4ms (max)
CPU Load EnergyMeterTask Load: 200µs/1ms = 0.2 KeyTask Load: 5µs/5ms = 0.01 UITask Load: 4ms/500ms = Total CPU Load(Max) = = x 100% = 21.8% Average CPU Load = 20.8%
Modules ModuleTask(s)Public Functions and Data EnergyMain.cStartTask UITask KeyTask N/A Meter.cEnergyMeterTaskData: Irms, Vrms, Preal, kWh ProgFEEprom.cN/AFuntions: ConfigFECLKDIV(), FEEsectModify(), FEESectErase(), FEEWordWrite() ProjectLCD.cN/AFunctions: LcdCommand(), LcdInitialize(), LcdPutChar(), LcdMoveCursor(), LcdPutStrg() AtoD.cN/AFunctions: AtoDInitialize(), ReadCurrent(), ReadVoltage()
Main Dataflow Hardware EnergyMain.c Hardware Meter.c ReadCurrent() ReadVoltage() KeyTask EnergyMeterTask ButtonsLCD UITask Key Energy Flag
A to D Dataflow AtoD.c A/D Converter AtoDI/O AtoDInitialize() 1ms ReadCurrent() PAD00 PAD01 ReadVoltage() ATDCTL5 ADR0DR0H ADR0DR1H AN0-1 A/D
FlashEEPROM Dataflow FlashEEPROM UITask EnergyMeterTask EnergyMain.c Meter.c Hardware EnergyMutex Key
Questions? Comments?