Skip to content

Commit

Permalink
update dataplots, setupguide, and dbc
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbrook committed Mar 5, 2024
1 parent 64e1d09 commit 63a2124
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 7 deletions.
93 changes: 89 additions & 4 deletions dataPlots.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
% Usage:
% 1. Load the data struct into the Workspace
% 2. Run individual sections of the script to plot the desired data
%% Constants
dyno_tire_diameter = 20.5; %ish inches
normal_tire_diameter = 18;
tire_diameter = normal_tire_diameter; % set to the right tire size when plotting
gear_ratio = 10/30;

%% Torque, Vehicle Speed, Current
figure
Expand All @@ -14,7 +19,7 @@
busVoltage = S.D1_DC_Bus_Voltage;
motor_speed = S.D2_Motor_Speed;
vehicle_speed_mph = motor_speed;
vehicle_speed_mph(:,2) = motor_speed(:,2).*(10/30).*0.000284091.*pi.*60;
vehicle_speed_mph(:,2) = motor_speed(:,2).*gear_ratio.*tire_diameter.*pi.*60 / 63360;
hold on
plot(motor_speed(:,1),motor_speed(:,2)./100);
plot(busCurrent(:,1),busCurrent(:,2)./2);
Expand Down Expand Up @@ -100,6 +105,9 @@
ylabel('Temperature (C)')
title('Cooling Loop Temperature Plots')

%% Torque vs RPM
plot_y_vs_y(S.D2_Motor_Speed,S.D2_Torque_Feedback,'Motor Speed (RPM)','Torque Feedback (Nm)','Feedback Torque vs Motor RPM')

%% Accumulator Cell Temperatures
% TODO: Add the polynomial function since the "temp" on CAN is a voltage
figure
Expand Down Expand Up @@ -234,7 +242,7 @@
consumption = cumtrapz(current(:,1),current(:,2));
consumption = [current(:,1),consumption./3600];
distance = cumtrapz(motorSpeed(:,1),motorSpeed(:,2)); %Rotations
distance = [motorSpeed(:,1),(distance./2.9)*pi*0.4572./1000]; %Kilometers
distance = [motorSpeed(:,1),(distance./3)*pi*(tire_diameter/39.37)./1000]; %Kilometers

% Data uniqueness
for i = 1:length(distance(:,1))
Expand Down Expand Up @@ -290,8 +298,85 @@
xlabel('Current')
ylabel('Voltage')
title('Accumulator Voltage Drop Analysis')

%% VectorNAV IMU data plot goes here


%% Corner Node Data Plot Goes Here
%% Corner Node Data Plot Goes Here

%% Plot function defs
% this can plot two Y-axis vs each other
function p = plot_y_vs_y(series1,series2,series1name,series2name,ptitle)
for i = 1:length(series1(:,1))
series1(i,1) = series1(i,1) + i/100000000;
end
for i = 1:length(series2(:,1))
series2(i,1) = series2(i,1) + i/100000000;
end
time2 = series2(:,1);
values2 = series2(:,2);
time1 = series1(:,1);
values1 = series1(:,2);
% Interpolate values of the second matrix onto the time points of the first matrix
interpolated_values2 = interp1(time2, values2, time1);

% Plot the values
figure
hold on
plot(values1, interpolated_values2, '.');
xlabel(series1name);
ylabel(series2name);
title(ptitle);

end
%% Plot function 3d
% This does not work well lmao
function q = plot_three_series(series1,series2,series3,xyzlabel,ptitle)


for i = 1:length(series1(:,1))
series1(i,1) = series1(i,1) + i/100000000;
end
for i = 1:length(series2(:,1))
series2(i,1) = series2(i,1) + i/100000000;
end
for i = 1:length(series3(:,1))
series3(i,1) = series3(i,1) + i/100000000;
end

time1 = series1(:,1);
values1 = series1(:,2);
time2 = series2(:,1);
values2 = series2(:,2);
time3 = series3(:,1);
values3 = series3(:,2);
% Interpolate values of the second matrix onto the time points of the first matrix
interpolated_values2 = interp1(time2, values2, time1);
interpolated_values3 = interp1(time3,values3,time1);
% Define the threshold value
threshold = 10;

% Find the indices where interpolated_values2 is above the threshold
indices = interpolated_values3 >= threshold;
filtered_values1 = values1(indices);
filtered_interpolated_values2 = interpolated_values2(indices);
filtered_values3 = interpolated_values3(indices);
% Plot the values in 3D
plot3(filtered_values1, filtered_interpolated_values2, filtered_values3, '.');
xlabel(xyzlabel(1));
ylabel(xyzlabel(2));
zlabel(xyzlabel(3));
title(ptitle);
% Create a meshgrid for the filtered values
[X, Y] = meshgrid(filtered_values1, filtered_interpolated_values2);
numel(filtered_values1)
numel(filtered_interpolated_values2)
% Create a matrix for the Z values
Z = repmat(filtered_values3, [numel(filtered_values1), numel(filtered_interpolated_values2)]);

% Create the surf plot
surf(X, Y, Z);
xlabel('Values from Matrix 1');
ylabel('Interpolated Values from Matrix 2');
zlabel('Values from Matrix 3');
title('3D Surface Plot of Three Matrices');
end
34 changes: 31 additions & 3 deletions dbc-files/ksu_ev_can.dbc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION "2f49c8c
VERSION "480b0af
"


Expand Down Expand Up @@ -56,8 +56,8 @@ BO_ 202 VCU_BOARD_READINGS_TWO: 8 vcu
SG_ VCU_SDC_VOLTAGE : 0|16@1+ (1,0) [0|65535] "bits" Vector__XXX

BO_ 198 VCU_WHEELSPEED_READINGS: 8 vcu
SG_ RPM_FR : 32|32@1+ (0.01,0) [0|4294967296] "rpm" Vector__XXX
SG_ RPM_FL : 0|32@1+ (0.01,0) [0|4294967296] "rpm" Vector__XXX
SG_ RPM_FR : 16|16@1- (1,0) [-32768|32767] "rpm" Vector__XXX
SG_ RPM_FL : 0|16@1- (1,0) [-32768|32767] "rpm" Vector__XXX

BO_ 195 VCU_STATUS: 7 vcu
SG_ VCU_DISTANCE_TRAVELLED : 40|16@1+ (1,0) [0|65535] "meters" Vector__XXX
Expand Down Expand Up @@ -422,6 +422,10 @@ BO_ 514 BMS_Current_Limit: 8 Vector__XXX
CM_ "can bus of KSU motorsports vehicles";
CM_ BU_ vcu "the vehicle control unit";
CM_ BO_ 196 "VCU analog pedal readings";
CM_ SG_ 196 STEERING "steering angle sensor voltage";
CM_ SG_ 196 BSE1 "brake pedal travel sensor voltage";
CM_ SG_ 196 APPS2 "accelerator pedal sensor 2 voltage reading";
CM_ SG_ 196 APPS1 "accelerator pedal sensor 1 voltage reading";
CM_ BO_ 201 "VCU PCB health readings";
CM_ SG_ 201 VCU_5V_VOLTAGE "VCU pcb voltage sense of the 5v rail";
CM_ SG_ 201 VCU_BSPD_VOLTAGE "VCU pcb voltage sense of the BSPD signal to close relay";
Expand All @@ -435,7 +439,22 @@ CM_ SG_ 202 VCU_SDC_VOLTAGE "VCU pcb voltage sense of the shutdown circuit input
CM_ BO_ 198 "VCU wheel speed sensor readings";
CM_ SG_ 198 RPM_FR "front right wheel speed sensor";
CM_ SG_ 198 RPM_FL "front left wheel speed sensor";
CM_ BO_ 195 "Vehicle Control Unit Status message";
CM_ SG_ 195 VCU_DISTANCE_TRAVELLED "distance travelled in current driving session";
CM_ SG_ 195 VCU_TORQUE_MODE "VCU torque mode setting ";
CM_ SG_ 195 VCU_MAX_TORQUE "max torque setting in Newton-meters";
CM_ SG_ 195 VCU_LAUNCH_CONTROL_ACTIVE "1 if launch control is active, 0 if not";
CM_ SG_ 195 VCU_SOFTWARE_OK "currently unused";
CM_ SG_ 195 VCU_ACTIVATE_BUZZER "1 if the buzzer is activated, 0 if not";
CM_ SG_ 195 VCU_ENERGY_METER_PRESENT "1 if the energy meter is present, 0 if not";
CM_ SG_ 195 VCU_INVERTER_POWERED "1 if the inverter is powered, 0 if not";
CM_ SG_ 195 VCU_STATEMACHINE_STATE "0 = STARTUP, 1 = TS NOT ACTIVE, 2 = TS ACTIVE, 3 = ENABLING INVERTER, 4 = WAIT RTD SOUND, 5=RTD";
CM_ SG_ 195 VCU_ACCEL_BRAKE_IMPLAUSIBLE "1 if the accel and brake plausibility is tripped";
CM_ SG_ 195 VCU_BSPD_BRAKE_HIGH "1 if the brake is above the bspd trip threshold";
CM_ SG_ 195 VCU_BSPD_CURRENT_HIGH "1 if the acc current is above the bspd trip threshold";
CM_ SG_ 195 VCU_BRAKE_ACTIVE "1 if the brake is active (above 'vcu_brake_active_threshold')";
CM_ SG_ 195 VCU_BRAKE_IMPLAUSIBLE "1 if the brake is implausible, 0 if not";
CM_ SG_ 195 VCU_ACCEL_IMPLAUSIBLE "1 if the accel pedal is implausible, 0 if not";
CM_ SG_ 195 VCU_SHUTDOWN_E_OK_HIGH "(UNUSED) Shutdown loop voltage at point E, high = good";
CM_ SG_ 195 VCU_SOFTWARE_OK_HIGH "(UNUSED) VCU heartbeat status, high = good";
CM_ SG_ 195 VCU_SHUTDOWN_D_OK_HIGH "(UNUSED) Shutdown loop voltage at point D, high = good";
Expand All @@ -448,16 +467,25 @@ CM_ BO_ 200 "information on the running vcu firmware and system on-timer";
CM_ SG_ 200 vcu_project_is_dirty "if the compiled fw had uncommitted changes (1) or not (0)";
CM_ SG_ 200 vcu_project_on_main "if the compiled fw was from main branch (1) or not (0)";
CM_ SG_ 200 vcu_on_time_seconds "time in seconds which the VCU has been powered on and running";
CM_ SG_ 200 vcu_fw_version "short hash of the firmware on VCU ";
CM_ BO_ 602 "information on the running acu firmware and system on-timer";
CM_ SG_ 602 acu_project_is_dirty "if the compiled acu fw had uncommitted changes (1) or not (0)";
CM_ SG_ 602 acu_project_on_main "if the compiled acu fw was from main branch (1) or not (0)";
CM_ SG_ 602 acu_on_time_seconds "time in seconds which the acu has been powered on and running";
CM_ SG_ 602 acu_fw_version "short hash of the firmware on ACU";
CM_ SG_ 199 vcu_pedals_settings_MUX "mux signal for VCU pedal threshold information message";
CM_ BO_ 235 "status of buttons on the dash";
CM_ SG_ 235 dash_button6status "status of button6 on dash (1 = pressed)";
CM_ SG_ 235 dash_button5status "status of button5 on dash (1 = pressed)";
CM_ SG_ 235 dash_button4status "status of button4 on dash (1 = pressed)";
CM_ SG_ 235 dash_button3status "status of button3 on dash (1 = pressed)";
CM_ SG_ 235 dash_button2status "status of button2 on dash (1 = pressed)";
CM_ SG_ 235 dash_button1status "status of button1 on dash (1 = pressed)";
CM_ BO_ 236 "information on the running dash firmware and system on-timer";
CM_ SG_ 236 dash_project_is_dirty "if the compiled dash fw had uncommitted changes (1) or not (0)";
CM_ SG_ 236 dash_project_on_main "if the compiled dash fw was from main branch (1) or not (0)";
CM_ SG_ 236 dash_on_time_seconds "time in seconds which the dash has been powered on and running";
CM_ SG_ 236 dash_fw_version "short hash of the firmware on dash ";
CM_ BO_ 26 "raw ADC voltage reading of module1 cells 1-6";
CM_ BO_ 27 "raw ADC voltage reading of module1 cells 6-12";
CM_ BO_ 42 "raw ADC voltage reading of module2 cells 1-6";
Expand Down
Binary file modified readmepics/Parser setup and run guide.pdf
Binary file not shown.

0 comments on commit 63a2124

Please sign in to comment.