Ok so I decided to feel productive I'd write what it would take to create a simple cruise control for my route first to get more familiar with the challenges of this project. Since it wouldn't upload the matlab file I decided to just copy and paste code here since its fairly short...
%Cruise Control
%Ryan Noe
clear all
clc
% Vehicle Constants
mass = 1157; %kg
Cd = 0.32;
Crr = 0.01;
FA = 2.21; %m^2
engine_efficiency = 0.25;
% Energy in One Gallon of Gasoline
EofG = 120381873; %Joules per Gallon
% Atmospheric Conditions
density = 1.23; %kg/m^3
gravity = 9.81; %m/s^2
% Set a velocity you would like to maintain.
velocity = 30;
% Reads in the Data from an Excel file.
theta = xlsread('H:\Desktop\Honda Fit\route_home_oneway.xls', 'sheet1', 'e2:e46');
dist = xlsread('H:\Desktop\Honda Fit\route_home_oneway.xls', 'sheet1', 'g2:g46');
% Transposes Matrices from Rows to Columns
theta = theta.';
dist = dist.';
% Simple FOR loop to determine Force, Energy, and Power required to
% maintain Velocity.
for q = 1:length(theta)
EF(q) = Crr*gravity*mass*cos(theta(q))+Cd*FA*(.5)*density* (velocity^2)+gravity*mass*sin(theta(q));
EE(q) = EF(q)*dist(q);
EP(q) = EF(q)*velocity;
end
% Gas Mileage running Cruise Control and NOT STOPPING at Stops
ActualEnergyUsed = sum(EE)/engine_efficiency;
AmountofGasUsed = ActualEnergyUsed/EofG;
SumDist = sum(dist);
Miles = SumDist*3.28/5280;
MPG = Miles/AmountofGasUsed;
% Plots
diffcounter = 1:length(theta);
plot(diffcounter-1, EP)
*** The % signs are notes in the code... the rest is VERY straight forward.
For the ones that don't have much coding experience, the XLSREAD just reads in from my excel file.
The FOR loop just loops through each of my sections of the road.
Note that some of the energy applied is negative (rolling down hills), this is 'captured' by the system somehow (not a very nice representation.. I know). But its fun to play with. Try starting up a file and plugging this in and see if it works in Octave (DCB). Also attached is the excel file that I read my info from.
|