Phase | Arduino Code | Time(seconds) | Total Energy(Joules) |
1 | int marks=-443/goFor(2) | 2.04 | 0.26 |
2 | Reverse(4)/motorSpeed(4,20)
/goToAbsolutePosition(marks) |
12.42 | 57.93 |
3 | brake(0) | 4.98 | 0.24 |
Total Energy Used: | 58.43 |
Table 1: Time used and total energy of three phases.
Figure 1: Energy consumption graph through time.
Figure 2: Energy consumption for three phases.
Arduino Code
int marks= -443; //-443 marks=18ft
goFor(2); //delay before AEV starts moving
reverse(4); //reverses motors so the AEV will go forward
motorSpeed(4,20); //sets all motors to 20% speed
goToAbsolutePosition(marks); //keeps motors running until the 344 marks are counted
brake(0); //Stops all motors
MatLab Code
clc;clear
a=xlsread(‘SomethingElseMeaningful.xlsx’);
vr=a(1,2);
a(1:6,:)=[];
Time=a(:,1)/1000; %This calculates the time
Current=(a(:,2)/1024).*vr.*(1/0.185); %This calculates the current
Voltage=(15*a(:,3))/1024; %This calculates the voltage
Distance=0.0124*a(:,4); %This calculates the distance
pos=0.0124*a(:,5); %This calculates the position
Power=Voltage.*Current; %This calculates the power
n=length(Power);
for j=1:(n-1)
Energy(j)=(Power(j)+Power(j+1))/2*(Time(j+1)-Time(j)); %This calculates the energy
end
EnergyS=sum(Energy(n-1));
figure
plot(Time,Power)
xlabel(‘Time’);
ylabel(‘Power’);
title(‘Power vs Time’);
xR = 1; % Right x-coordinate
xL = .1; % Left x-coordinate
iL = knnsearch(Time,xL); % Element index of left point
iR = knnsearch(Time,xR); % Element index of right point
E_phase_1 = Energy(iL:iR); %Reverse and Delay time
EnergyP1=sum(E_phase_1); %sum energy
fprintf(‘EnergyP1=%f\n’,EnergyP1);
xR = 14; % Right x-coordinate
xL = 2; % Left x-coordinate
iL = knnsearch(Time,xL); % Element index of left point
iR = knnsearch(Time,xR); % Element index of right point
E_phase_2 = Energy(iL:iR); %Set speed
EnergyP2=sum(E_phase_2); %sum energy
fprintf(‘EnergyP2=%f\n’,EnergyP2);
xR = 18; % Right x-coordinate
xL = 14; % Left x-coordinate
iL = knnsearch(Time,xL); % Element index of left point
iR = knnsearch(Time,xR); % Element index of right point
E_phase_3 = Energy(iL:iR);
TotalEnergy=EnergyP2+EnergyP1+EnergyP3; %sum energy for both phases