clc;
close all;
clearvars;

% The moter plot samples at the PWM freq of the drive
motor_pilot_sample_freq = 16000; % Hz
ina229evm_sample_time = 3.156 * 10^-3; % seconds


ina229evm_data = readtable('../INA229EVM LOGS/500RPM_EC60PressureTestMotor_INA229EVM_7_29_2025.csv');
motor_pilot_data = readtable('../MotorPilotLogs/500RPM_EC60PressureTestMotorPilotLog_7_29_2025.csv');

% Extract data
time_motor_pilot = (0:height(motor_pilot_data)-1) / motor_pilot_sample_freq;
time_ina229evm = (0:height(ina229evm_data)-1) * ina229evm_sample_time;

i_q_meas = motor_pilot_data.I_Q_MEAS(:);
%i_d_meas = motor_pilot_data.I_D_MEAS(:);
%i_alpha_meas = motor_pilot_data.I_ALPHA_MEAS(:);
%i_beata_meas = motor_pilot_data.I_BETA_MEAS(:);


v_bus_meas = ina229evm_data.EVM1VBUSResults_V_(:);
i_bus_meas = ina229evm_data.EVM1CURRENTResults_A_(:);
%power_bus_meas = ina229evm_data.EVM1POWERResults_W_(:);
%energy_bus_meas = ina229evm_data.EVM1ENERGYResults_J_(:);
%charg_bus_meas = ina229evm_data.EVM1CHARGEResults_C_(:);

plot(time_motor_pilot, i_q_meas);
hold on;
plot(time_ina229evm, i_bus_meas);
hold off;