Turbine Flow Meter
Kevin HooksSenior Design Project
Overview
• Micro Controller• Kernel, Tasks, CPU Load• Data Flow Diagrams• State Machine Diagrams• Module, Public Tasks, Functions and Variables• Questions?
Micro Controller
• HC9S12DP512• 16-bit device • 512K bytes Flash EEPROM, 14K bytes RAM, 4K
bytes of EEPROM• 2 SCI , 3 SPI, 8-channel IC/OC ECT, two 8-
channel, 10-bit ADC, 8 channel PWM, 29 GPIO, 20 GPIO with interrupts
• 24 MHz Bus Frequency
Micro Controller
• About < 300 Kbytes Flash EEPROM• 1 SCI • 1 SPI• 2 IC/IOC (1 input capture, 1 Pulse
Accumulator)
Kernel
• Time Slicing• Period of 1s• Total Tasks 5• 1 Interrupts
Tasks
• LCD_Update• Pulse_Count• Period_Count• Thermo_Get• Calculate_Values
LCD_Update
• Checks for Display Units• Compares Current LCD Value with new LCD
Value• If different then update LCD display• Run Time ~10ms max, ~1ms Average• CPU Load ~ 10ms/1s = 10% max, ~1ms/1s =
1% average
Pulse_Count
• Counts Pulses for 10ms• Stores Value in public variable *Pulse_Val• Run Time ~10ms• CPU Load ~10ms/1s = 10%, should always be
10ms
Period_Count
• Counts the period of one pulse • Stores value in public Variable *Period_Val• Run Time Varies based on Frequency (Max of
1ms at frequency of 10kHz average of .5ms at 50kHz)
• CPU Load ~1ms/1s = 1% max, ~.5ms/1s = .5% average
Thermo_Get
• Performs an SPI read for one 16-bit value from the MAX6675 and stores into variable Thermo_Val. Only 12 bits are used so it will need to be masked.
• At 24MHz clock the runtime is max ~10uS• CPU Load = ~10us/1s =.001%
Calculate_Values
• Receives variables from each get task and performs a series of calculations to provide one final 8-bit result New_Value
• Checks for variable set by touch screen ISR to determine calculations for correct units
• Run Time ~10us• CPU Load = ~10us/1s = .001%
Get_Touch ISR
• If a screen touch is detected, jump to ISR• This ISR simply sets a variable to a specific
value. This will be used to determine unit display
• Run Time is ~1uS
Final CPU Load
• Max CPU Load = 10ms/1s + 10ms/1s + 1ms/1s + 1us/1s + 1us/1s = 21.002%
• Average CPU Load = 16.502%
Data Flow Diagram: LCD_Update Task
Data Flow Diagram: Pulse_Count
Data Flow Diagram: Period_Count
Data Flow Diagram: Thermo_Get
Data Flow Diagram: Calculate_Values
Data Flow Diagram: SCI_Read_Isr
State Diagram for UI
Initial State
Modules, Tasks, Public DataModules Tasks Public Functions and Data
Main.c WaitForSlice(),
LCD.cModified from Trevor Wilcox
LCD_Update() Prev_ValDisp_Val()Get_Touch()Compare_Val()SCI_read_Isr()
Calculation.c Calculate_values() New_ValUnit_Val
OCDelay.cTodd MortonSPI.c Thermo_Get() Thermo_Val
ECT.c Pulse_Count(), Period_Count()
Pulse_Val, Period_Val
9S12DP256Start.cTodd Morton
Questions?