%% ************************************************************************
% Model         :   Resolver example
% Description   :   Set Parameters for resolver example
% File name     :   mcb_resolver_init.m
% Copyright 2019-2020 The MathWorks, Inc.

PWM5_frequency = 160e3;
processor_frequency = 90e6;
PWM5_period = floor(processor_frequency/PWM5_frequency);
sine_wave_frequency = 10e3;
array_size = PWM5_frequency/sine_wave_frequency;
sine_table_input = 0:2*pi/16:(2*pi-2*pi/16);
output_phase_offset = -2*pi*2/16;
sine_table_input = output_phase_offset + sine_table_input;
output_gain = .3;
sine_table = floor(sin(sine_table_input)*PWM5_period/2*output_gain+PWM5_period-PWM5_period/2*output_gain);
duty_cycle_table = Simulink.Signal;
duty_cycle_table.CoderInfo.StorageClass = 'ExportedGlobal';
duty_cycle_table.DataType = 'uint16';
duty_cycle_table.Dimensions = 16;
duty_cycle_table.InitialValue = ['[' num2str(sine_table) ']'];
ADC_result_array = Simulink.Signal;
ADC_result_array.CoderInfo.StorageClass = 'ExportedGlobal';
ADC_result_array.DataType = 'uint16';
ADC_result_array.Dimensions = 64;
% duty_cycle_table.Value = sin(sine_table)*PWM5_period/2+PWM5_period/2;
% [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
