%% Example Data Loading and Plotting Script

clear; close all;

fname = 'SingleExecution_20180508124758.hdf5';
data = load_testbed(fname)

% I know its at 1600 kHz, and each mean is 160 samples (10Hz state machine
% rate)
samplerate = 1600;
n_samples  = 160;
dt_raw = 1/samplerate;
dt_avg = n_samples/samplerate;

% Elapsed Time
t_raw = (1:length(data.raw_current_motor))*dt_raw;
t_avg = (1:length(data.mean_current_shifter))*dt_avg-dt_avg/2; %center the average

% Plot Analog Data
figure()
subplot(311)
plot(t_raw, data.raw_current_motor, t_avg, data.mean_current_shifter);
ylabel('Current (A)');
legend('raw','mean')
title(['Analog Data From: ' strrep(fname,'_', '\_')] )

subplot(312)
plot(t_raw, data.raw_voltage_motor, t_avg, data.mean_voltage_shifter);
ylabel('Voltage (V)');
legend('raw','mean')

subplot(313)
plot(t_raw, data.raw_position_shifter, t_avg, data.mean_voltage_string_pot);
ylabel('Voltage (V)');
legend('raw','mean')
xlabel('Time (s)')


