Code covered by the BSD License  

Highlights from
Tested WF4 to Equivalent WF5A Transformation Calculator

image thumbnail

Tested WF4 to Equivalent WF5A Transformation Calculator

by

 

This tool transforms WF4 test results into an equivalent WF5A transient

WF4toWF5A_convert(varargin)
function varargout = WF4toWF5A_convert(varargin)
% WF4TOWF5A_CONVERT M-file for WF4toWF5A_convert.fig
%      WF4TOWF5A_CONVERT, by itself, creates a new WF4TOWF5A_CONVERT or raises the existing
%      singleton*.
%
%      H = WF4TOWF5A_CONVERT returns the handle to a new WF4TOWF5A_CONVERT or the handle to
%      the existing singleton*.
%
%      WF4TOWF5A_CONVERT('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in WF4TOWF5A_CONVERT.M with the given input arguments.
%
%      WF4TOWF5A_CONVERT('Property','Value',...) creates a new WF4TOWF5A_CONVERT or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before WF4toWF5A_convert_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to WF4toWF5A_convert_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help WF4toWF5A_convert

% Last Modified by GUIDE v2.5 08-Jan-2013 15:22:51

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @WF4toWF5A_convert_OpeningFcn, ...
                   'gui_OutputFcn',  @WF4toWF5A_convert_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before WF4toWF5A_convert is made visible.
function WF4toWF5A_convert_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to WF4toWF5A_convert (see VARARGIN)

% Choose default command line output for WF4toWF5A_convert
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes WF4toWF5A_convert wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = WF4toWF5A_convert_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function Voc1_Callback(hObject, eventdata, handles)
% hObject    handle to Voc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Voc1 as text
%        str2double(get(hObject,'String')) returns contents of Voc1 as a double


% --- Executes during object creation, after setting all properties.
function Voc1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Voc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Isc1_Callback(hObject, eventdata, handles)
% hObject    handle to Isc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Isc1 as text
%        str2double(get(hObject,'String')) returns contents of Isc1 as a double


% --- Executes during object creation, after setting all properties.
function Isc1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Isc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function vpeak1_Callback(hObject, eventdata, handles)
% hObject    handle to vpeak1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of vpeak1 as text
%        str2double(get(hObject,'String')) returns contents of vpeak1 as a double


% --- Executes during object creation, after setting all properties.
function vpeak1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to vpeak1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function eq5a1_Callback(hObject, eventdata, handles)
% hObject    handle to eq5a1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of eq5a1 as text
%        str2double(get(hObject,'String')) returns contents of eq5a1 as a double


% --- Executes during object creation, after setting all properties.
function eq5a1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to eq5a1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end





% --- Executes during object creation, after setting all properties.
function Calculate_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Calculate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% --- Executes on button press in Calculate.
function Calculate_Callback(hObject, eventdata, handles)
% hObject    handle to Calculate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%%%Get variables from GUI
voc=str2double(get(handles.Voc1,'String'));
isc=str2double(get(handles.Isc1,'String'));
vpeak=str2double(get(handles.vpeak1,'String'));

if (voc==0);
    set(handles.error_msg,'FontSize',14.0)
    set(handles.error_msg,'String','Open Circuit Voltage of WF4 have a value');
    return;    
elseif (isc==0);
    set(handles.error_msg,'FontSize',14.0)
    set(handles.error_msg,'String','Short Circuit Current of WF4 have a value');
    return;
elseif (vpeak==0);
    set(handles.error_msg,'FontSize',14.0)
    set(handles.error_msg,'String','Measured Peak Voltage have a value');
    return;
else
    set(handles.error_msg,'String','');
end

 
%This script transforms double exponential lightning waveforms from
%DO-160 at levels provided by user input to the WF5A from DO-160 containing
%the equivalent energy and assuming a constant LRU clamping voltage. 
%The peak voltage level of the resulting WF5A is output.



t=[1e-7:1e-7:1e-3];     
vo=voc./0.9166;
vapplied=vo*(exp(-11300*t)-exp(-670000*t));     %WF4 equation

for k=1:length(vapplied);       %Using peak voltage from the TSO report, 
                                %assuming LRU will clamp to this voltage
                                %(vpeak) under all transients is a basic
                                %assumption for this script.
    if vapplied(k)<vpeak;
        vinput(k)=vapplied(k);
    else
        vinput(k)=vpeak;
    end
end
zsrc=voc/isc;                   %Calculate source impedance of WF being converted
I=(vapplied-vinput)./zsrc;      %calculate current of WF being converted

papplied=vinput.*I;             %Power applied to LRU
energy=trapz(t,papplied);       %Energy to the LRU. The WF conversion is
                                %based on creating a WF5A that delivers the
                                %same amount of energy to the LRU assumming
                                %vpeak is constant.

% *** Conversion ***

t_lgt=[1e-7:1e-7:1e-3];
energy5a=0;
voc5a=0;

while (energy5a<energy);
    voc5a=voc5a+1;
    vo5a=voc5a./0.4006;
    vapplied5a=vo5a*(exp(-13000*t_lgt)-exp(-41000*t_lgt)); 
        for k=1:length(vapplied5a);                               
            if vapplied5a(k)<vpeak;
                vinput5a(k)=vapplied5a(k);
            else
                vinput5a(k)=vpeak;
            end
        end
    I5a=(vapplied5a-vinput5a)./1;
    P5a=vinput5a.*I5a;
    energy5a=trapz(t_lgt,P5a);
end


%%%Output results to GUI

set(handles.eq5a1,'String',round(voc5a));

Contact us