Code covered by the BSD License  

Highlights from
SAE Paper Demo: Model-Based Design of Hybrid Electric Vehicles

image thumbnail

SAE Paper Demo: Model-Based Design of Hybrid Electric Vehicles

by

 

07 Nov 2010 (Updated )

Demo files to accompany the paper by the same name

determinePowerFlow(Eng_Planet_Power, Sun_Gen_Power, Gen_Bat_Power,...
function powerFlow = determinePowerFlow(Eng_Planet_Power, Sun_Gen_Power, Gen_Bat_Power,...
                  Bat_Mot_Power, Gen_Mot_Power, Mot_Ring_Power,...
                  Ring_Diff_Power, Diff_LTir_Power, Diff_RTir_Power)
              
threshold = 0.1; %kW


%Check to see if engine is outputting power
i=1;
if(Eng_Planet_Power>threshold)
    powerFlow.arr{i} = 5;
    powerFlow.dir{i} = 1;
    i=i+1;
    if(Sun_Gen_Power>threshold)
        powerFlow.arr{i} = 4;
        powerFlow.dir{i} = 1;
        if(Eng_Planet_Power-threshold > Sun_Gen_Power) 
            %Some power is directly reaching the differential or to motor from the engine
            if((Ring_Diff_Power>threshold) && (Mot_Ring_Power < -threshold))
                powerFlow.arr{i} = [4 6 3];
                powerFlow.dir{i} = [1 1 -1];
            else
                if(Ring_Diff_Power>threshold)
                    powerFlow.arr{i} = [4 6];
                    powerFlow.dir{i} = [1 1];
                end
                if(Mot_Ring_Power < -threshold)
                    powerFlow.arr{i} = [4 3];
                    powerFlow.dir{i} = [1 -1];
                end
            end
            
        end
        i=i+1;
        
        if(Gen_Bat_Power>threshold)
            powerFlow.arr{i} = 1;
            powerFlow.dir{i} = 1;
            i=i+1;
        end
        
        if((abs(Bat_Mot_Power)>threshold) && (abs(Gen_Mot_Power)>threshold))
            powerFlow.arr{i} = [2 9];
            if(Bat_Mot_Power<0)
                powerFlow.dir{i}(1) = -1;
            else
                powerFlow.dir{i}(1) = 1;
            end
            if(Gen_Mot_Power<0)
                powerFlow.dir{i}(2) = -1;
            else
                powerFlow.dir{i}(2) = 1;
            end
            i=i+1;
        else
            if(abs(Bat_Mot_Power)>threshold)
                powerFlow.arr{i} = 2;
                if(Bat_Mot_Power<0)
                    powerFlow.dir{i} = -1;
                else
                    powerFlow.dir{i} = 1;
                end
                i=i+1;
            elseif(abs(Gen_Mot_Power)>threshold)
                powerFlow.arr{i} = 9;
                if(Gen_Mot_Power<0)
                   powerFlow.dir{i} = -1;
                else
                   powerFlow.dir{i} = 1;
                end
                i=i+1;
                
            end
        end
        
        if(Mot_Ring_Power>threshold)
            powerFlow.arr{i} = 3;
            powerFlow.dir{i} = 1;
            i=i+1;
        end
        
        if(Ring_Diff_Power>threshold)
            powerFlow.arr{i} = 6; powerFlow.dir{i} = 1; i=i+1;
            powerFlow.arr{i} = [7 8]; powerFlow.dir{i} = [1 1]; i=i+1;
        end
    else
        %Generator not being driven so no supply of power from gen 
        %Check if battery is supplying power
        if(Bat_Mot_Power>threshold)
            powerFlow.arr{i} = 2;
            powerFlow.dir{i} = 1;
            i=i+1;
        end
        if(Mot_Ring_Power>threshold)
            powerFlow.arr{i} = 3;
            powerFlow.dir{i} = 1;
            i=i+1;
        end
        if(Ring_Diff_Power>threshold)
            powerFlow.arr{i} = 6; powerFlow.dir{i} = 1; i=i+1;
            powerFlow.arr{i} = [7 8]; powerFlow.dir{i} = [1 1]; i=i+1;
        end
    end
else
    %Either battery is providing power or there is breaking
    if(Bat_Mot_Power>threshold)
        if Gen_Mot_Power > threshold
            if Sun_Gen_Power > threshold
                powerFlow.arr = {[2 9],3,4,6,[7 8]};
                powerFlow.dir = {[1 1],1,1,1,[1 1]};
            elseif Sun_Gen_Power < -threshold
                powerFlow.arr = {[2 9 1],3,4,6,[7 8]};
                powerFlow.dir = {[1 1 -1],1,-1,1,[1 1]};
            else
                powerFlow.arr = {[2 9],3,4,6,[7 8]};
                powerFlow.dir = {[1 1],1,-1,1,[1 1]};
            end
        else
            powerFlow.arr = {2,3,6,[7 8]};
            powerFlow.dir = {1,1,1,[1 1]};
        end
    else
        %no driving power. must be braking. 
        if((Diff_LTir_Power <-threshold) && (Diff_RTir_Power <-threshold))
            powerFlow.arr = {[7 8],6,3,2};
            powerFlow.dir = {[-1 -1],-1,-1,-1};
        else
            powerFlow.arr = {};
            powerFlow.dir = {};
        end
    end
end



              

Contact us