%**************************************************************************
% Project     : Levitron
% Autor       : Stefan Wicki
% Filename    : Init_Current_Controller.m
% Startdate   :  3.07.07
% Enddate     :  3.07.07
% Version     : 1.0
%**************************************************************************
%
% used functions:     -
%
% input files:        - 
% 
% output files:       - 
%
%**************************************************************************
%
% global variables:   - 
%
%**************************************************************************


clc;  clear all; %close all;

%--------------------------------------------------------------------------
% Input Voltage:
%--------------------------------------------------------------------------

U_IN    =   [0 0.2 0.2 0.3 0.3 0.2 0.2 0.5 0.5 0 0];

t_IN    =   [0 0.01e-3 5e-3 5.01e-3 10e-3 10.01e-3 15e-3 15.01e-3 25e-3 25.01e-3 30e-3];


%--------------------------------------------------------------------------
% Initalization of all Values of the current controller:
%--------------------------------------------------------------------------

% Summation
R211    =   10e3;
R224    =   1.8e3;
R212    =   10e3;

% PI-Controller
R229    =   220;
R213    =   220e3;
C215    =   22e-9;

% PWM-Generator
UDC     =   12;     %DC Link Voltage
Udpp    =   3.5;    %Peak-to-Peak Voltage of the Triangle Generator

% Coil
RCU     =   5.7;    %Copper Resistor of Coil
L       =   35e-3;  %Inductance of Coil

% Current Measurement
R230    =   0.47;   %Shunt
R226    =   1.8e3;  %Current Amplifier
R214    =   10e3;   %Current Amplifier

%--------------------------------------------------------------------------
% Simualtion of Modell:
%--------------------------------------------------------------------------

sim('Current_Controller',30e-3);

%--------------------------------------------------------------------------
% Plotting of Results:
%--------------------------------------------------------------------------

figure
subplot(211),plot(Time, Ref_Current,'LineWidth',2 );
grid on
ylabel('Input Voltage [V]')

subplot(212),plot(Time, Current,'r','LineWidth',2 );
grid on
ylabel('Output Current [A]')


%------------------------------------------------------------------------------
% ENDE
%------------------------------------------------------------------------------
