Software Three Main Functions Records/Monitors Zero Detection Points Gives our PWM a starting point Data used to dynamically adjust carrier frequency Detects possible faults situations and shuts off PWM accordingly Creates Sine-Triangle PWM Triangle wave carrier frequency (~ 6 kHz) Sine wave generated from sine lookup table Values passed into Compare Registers which control PWM outputs with specified dead-band time (4 us) Controls Power Flow Delta incrementally added over 100 cycles to generate Power Flow
Start System Initialization While (1) Switch State Case 1 Case 2 Case 3 Case 4 Case 5 Default Waiting for Pulse Waiting for Falling Edge Calculations Zero Crossing Analysis PWM State Yes No
Waiting for Pulse Waiting for Falling Edge Calculations Zero Crossing Analysis PWM State Start Phase 1 Falling? Pulse Detected and System Synced? System Synced Record Times/Reset Counters Yes No Set Next State PWM Calculations/ PWM Sync Check Break
Waiting for Pulse Waiting for Falling Edge Calculations Zero Crossing Analysis PWM State Start Pulse Ended? Increment Position/ Decrement Counter Record Times Yes No Set Next State PWM Calculations/ PWM Sync Check Break
Waiting for Pulse Waiting for Falling Edge Calculations Zero Crossing Analysis PWM State Start Half Period? Calculate Time Between Pulses Calculate Pulse Width Yes No Calculate Half Period PWM Calculations/ PWM Sync Check Break Set Next State
Waiting for Pulse Waiting for Falling Edge Calculations Zero Crossing Analysis PWM State Start Decrement Iteration Counter Calculate Actual Zero Crossing with Error Adjust PWM Calculations/ PWM Sync Check Break Set Next State Detect Fault? Yes No System Shutdown
Waiting for Pulse Waiting for Falling Edge Calculations Zero Crossing Analysis PWM State Start Triangle Wave Rising Edge? Convert to Q15 Format Calculate Phase Counts YesNo PWM Calculations/ PWM Sync Check Break Calculate Timings/Update Carrier Frequency Turn on PWM Output Calculate/Load Sin Positions in CMPR Registers Increment Counters