Capacitive Shunt Sensing Game Controller System Software Design - - PowerPoint PPT Presentation
Capacitive Shunt Sensing Game Controller System Software Design - - PowerPoint PPT Presentation
Capacitive Shunt Sensing Game Controller System Software Design By: Marcin Lobrow Western Washington University 2010 General System Design MCU: CY8C3866AXI-040ES2 Bus frequency 24 MHz 64Kb Flash, 2Kb RAM System Memory
General System Design
MCU: CY8C3866AXI-040ES2
- Bus frequency 24 MHz
- 64Kb Flash, 2Kb RAM
System Memory Requirements
- 500 bytes Flash
- 4Kb RAM
Resources Used
- 25 GPIO, USB D+, D- Pins
Kernel Selection
- Simple Time Slice Kernal
- 10 ms Slice Period
- Easy Design
- Round Robin Scheduling
- Equal Priority Among Task
- 3 Tasks
- 2 ISR
Tasks & ISR
Tasks
1) Scan Capacitive Sensors Task 2) Angular Pitch Calculation Task 3) UI Button Task
Interrupt Service Routine (ISR)
1) Start DMA transfer of Memory to USB 2) Pause DMA transfer of Memory to USB
State Diagram
STATE 3 UI BUTTON TASK IDLE STATE 1 SCAN CAPACITIVE SENSORS STATE 2 PERFORM ANGULAR CALCULATION
TASK1 TASK1 COMPLETE TASK2 TASK2 COMPLETE TASK3 TASK3 COMPLETE
Initialization
- System Initialization
- Initialize Capacitive Sensors
- Initialize Dynamic Memory Allocation
- Initialize USB
- Set Initial State
- Period
- One Execution
- Execution Time
- Approx 10 ms
Scan Capacitive Sensors Task
Description:
- Scans the 4 Capacitive Sensors
- Places Raw Data into Memory
- Period: 10ms (Periodic)
- Execution Time: 1 ms (max)
Angular Pitch Calculation Task
Description:
- Calculates Angle of Users Hand
- Calculates Constant Baseline For Signal
- Calculates Change above Baseline Signal
- Stores Delta in Memory
- If Delta, Set DMA ISR
- Drives LED Array
- Period: 10 ms (Periodic)
- Execution Time: 5ms (max)
UI Button Task
Description:
- Scans ports for User Button Presses
- Starts USB Communications with Start Button
- Ends USB Communications with End Button
- Sets ISR with Pause Button
- Period: 100 ms (Periodic)
- Execution Time: 1us (max)
Interrupt Service Routines
Description:
- DMA_START_ISR
- Starts DMA Data Transfer to USB
- Triggered by Movement of Hand Above Sensors
- DMA_STOP_ISR
- Stops (Pauses) DMA Data Transfer to USB
- Triggered Pause UI Button
- Period: 20ms (min) (Sporadic)
- Execution time: 100 us (max)
CPU load
L max = (1ms) + (5ms) + (1us) + (200us) (10ms) (10ms) (100ms) (20ms) L max = 60.1% L average = < 50.0 %
Modules
Module Tasks & ISR Public Functions and Data main.c InitializeGC() WaitForSlice() UITask() CapSense_Start() CapSense_Stop() ScanPort() DriveLEDs() SensorController.c ScanCapSensors() DMA_Start_ISR() DMA_Stop_ISR() CapSense_CSD_ScanSlot() CapSense_CSD_ReadSlot() SensorCalculation.c CalculateCapSensors() CalculateBaseline() CalculateDelta()
Overall Data Flow
TimeSlicer
Initialization
ScanCapSensor Module
USB Modules
CalculateCapSensor Module
UI Button Task main.c Check Port Update LEDs DMA_START_ISR DMA_STOP_ISR DMA
ScanCapSensor Data Flow
main.c
SensorTop TimeSlice(Task1) Ts =1ms
SensorController.c
ScanCapSensors() SensorRight SensorBottom SensorLeft StoreRawData()
CalculateCapSensor Data Flow
main.c
SensorTopRaw TimeSlice(Task2) Ts =5ms
SensorCalculation.c
CalculateCapSensors() SensorRightRaw SensorBottomRaw SensorLeftRaw UpdateBaseline() UpdateDetla()
Dynamic Memory Allocation Data Flow Diagram
USB DMA_START_ISR DMA_STOP_ISR DMA SensorRightDelta SensorLeftDelta SensorTopDelta SensorBottomDelta
Questions?
System Software Design By: Marcin Lobrow Western Washington University 2010