force sensor measurements
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								mat/apa95ml_5kg_1a_2s.mat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mat/apa95ml_5kg_1a_2s.mat
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								mat/apa95ml_5kg_2a_1s.mat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mat/apa95ml_5kg_2a_1s.mat
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								mat/apa95ml_5kg_2s_1a.mat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mat/apa95ml_5kg_2s_1a.mat
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										120
									
								
								matlab/runtest.m
									
									
									
									
									
								
							
							
						
						
									
										120
									
								
								matlab/runtest.m
									
									
									
									
									
								
							@@ -2,55 +2,111 @@ tg = slrt;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
%%
 | 
					%%
 | 
				
			||||||
f = SimulinkRealTime.openFTP(tg);
 | 
					f = SimulinkRealTime.openFTP(tg);
 | 
				
			||||||
mget(f, 'apa95ml.dat');
 | 
					mget(f, 'apa95ml.dat', 'data');
 | 
				
			||||||
% remove file on RT-target
 | 
					 | 
				
			||||||
% removefile(f, 'C:\data\data_001.dat')
 | 
					 | 
				
			||||||
close(f);
 | 
					close(f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%% Convert the Data
 | 
					%% Convert the Data
 | 
				
			||||||
data = SimulinkRealTime.utils.getFileScopeData('apa95ml.dat').data;
 | 
					data = SimulinkRealTime.utils.getFileScopeData('data/apa95ml.dat').data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					u = data(:, 1); % Input Voltage [V]
 | 
				
			||||||
 | 
					y = data(:, 2); % Output Displacement [m]
 | 
				
			||||||
 | 
					v = data(:, 3); % Output Voltage (Force Sensor) [V]
 | 
				
			||||||
 | 
					t = data(:, 4); % Time [s]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					save('../mat/apa95ml_5kg_1a_2s.mat', 'u', 't', 'y', 'v');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%%
 | 
					%%
 | 
				
			||||||
figure;
 | 
					figure;
 | 
				
			||||||
subplot(1,2,1);
 | 
					subplot(1,2,1);
 | 
				
			||||||
plot(data(:, 3), data(:, 1))
 | 
					plot(t, u)
 | 
				
			||||||
subplot(1,2,2);
 | 
					subplot(1,2,2);
 | 
				
			||||||
plot(data(:, 3), data(:, 2))
 | 
					plot(t, y)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%%
 | 
				
			||||||
 | 
					load('../mat/apa95ml_5kg_10V.mat', 'u', 't', 'y');
 | 
				
			||||||
 | 
					ht = load('../mat/huddle_test.mat', 'u', 't', 'y');
 | 
				
			||||||
 | 
					u = u - mean(u);
 | 
				
			||||||
 | 
					y = y - mean(y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%%
 | 
				
			||||||
 | 
					[pxx, f] = pwelch(y, win, [], [], 1/Ts);
 | 
				
			||||||
 | 
					[pht, ~] = pwelch(ht.y, win, [], [], 1/Ts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					figure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					hold on;
 | 
				
			||||||
 | 
					plot(f, pxx);
 | 
				
			||||||
 | 
					plot(f, pht);
 | 
				
			||||||
 | 
					hold off;
 | 
				
			||||||
 | 
					set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
				
			||||||
 | 
					ylabel('PSD'); xlabel('Frequency [Hz]');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%%
 | 
					%%
 | 
				
			||||||
run setup;
 | 
					run setup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
win = hann(ceil(0.1/Ts));
 | 
					win = hann(ceil(0.1/Ts));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[tf_est, f] = tfestimate(data(:, 1), data(:, 2), win, [], [], 1/Ts);
 | 
					[tf_est, f] = tfestimate(u, y, win, [], [], 1/Ts);
 | 
				
			||||||
[co_est, ~] = mscohere(data(:, 1), data(:, 2), win, [], [], 1/Ts);
 | 
					[co_est, ~] = mscohere(u, y, win, [], [], 1/Ts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%%
 | 
					%%
 | 
				
			||||||
  figure;
 | 
					figure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  hold on;
 | 
					hold on;
 | 
				
			||||||
  plot(f, co_est, 'k-')
 | 
					plot(f, co_est, 'k-')
 | 
				
			||||||
  set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
					set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
				
			||||||
  ylabel('Coherence'); xlabel('Frequency [Hz]');
 | 
					ylabel('Coherence'); xlabel('Frequency [Hz]');
 | 
				
			||||||
  hold off;
 | 
					hold off;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%%
 | 
					%%
 | 
				
			||||||
  figure;
 | 
					figure;
 | 
				
			||||||
  ax1 = subplot(2, 1, 1);
 | 
					ax1 = subplot(2, 1, 1);
 | 
				
			||||||
  hold on;
 | 
					hold on;
 | 
				
			||||||
  plot(f, abs(tf_est), 'k-', 'DisplayName', 'Identified')
 | 
					plot(f, abs(tf_est), 'k-', 'DisplayName', 'Identified')
 | 
				
			||||||
  set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
					set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
				
			||||||
  ylabel('Amplitude'); xlabel('Frequency [Hz]');
 | 
					ylabel('Amplitude'); xlabel('Frequency [Hz]');
 | 
				
			||||||
  legend();
 | 
					hold off;
 | 
				
			||||||
  hold off;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ax2 = subplot(2, 1, 2);
 | 
					ax2 = subplot(2, 1, 2);
 | 
				
			||||||
  hold on;
 | 
					hold on;
 | 
				
			||||||
  plot(f, 180/pi*angle(-tf_est), 'k-')
 | 
					plot(f, 180/pi*unwrap(angle(-tf_est)), 'k-')
 | 
				
			||||||
  set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
					set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
				
			||||||
  ylabel('Phase'); xlabel('Frequency [Hz]');
 | 
					ylabel('Phase'); xlabel('Frequency [Hz]');
 | 
				
			||||||
  legend();
 | 
					hold off;
 | 
				
			||||||
  hold off;
 | 
					
 | 
				
			||||||
  
 | 
					linkaxes([ax1,ax2], 'x');
 | 
				
			||||||
  linkaxes([ax1,ax2], 'x');
 | 
					xlim([10, 5000]);
 | 
				
			||||||
  xlim([10, 5000]);
 | 
					
 | 
				
			||||||
 | 
					%%
 | 
				
			||||||
 | 
					win = hann(ceil(10/Ts));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[tf_est, f] = tfestimate(u, v, win, [], [], 1/Ts);
 | 
				
			||||||
 | 
					[co_est, ~] = mscohere(u, v, win, [], [], 1/Ts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%%
 | 
				
			||||||
 | 
					figure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					hold on;
 | 
				
			||||||
 | 
					plot(f, co_est, 'k-')
 | 
				
			||||||
 | 
					set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
				
			||||||
 | 
					ylabel('Coherence'); xlabel('Frequency [Hz]');
 | 
				
			||||||
 | 
					hold off;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%%
 | 
				
			||||||
 | 
					figure;
 | 
				
			||||||
 | 
					ax1 = subplot(2, 1, 1);
 | 
				
			||||||
 | 
					hold on;
 | 
				
			||||||
 | 
					plot(f, abs(tf_est), 'k-', 'DisplayName', 'Identified')
 | 
				
			||||||
 | 
					set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
				
			||||||
 | 
					ylabel('Amplitude'); xlabel('Frequency [Hz]');
 | 
				
			||||||
 | 
					hold off;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ax2 = subplot(2, 1, 2);
 | 
				
			||||||
 | 
					hold on;
 | 
				
			||||||
 | 
					plot(f, 180/pi*unwrap(angle(-tf_est)), 'k-')
 | 
				
			||||||
 | 
					set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
				
			||||||
 | 
					ylabel('Phase'); xlabel('Frequency [Hz]');
 | 
				
			||||||
 | 
					hold off;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					linkaxes([ax1,ax2], 'x');
 | 
				
			||||||
 | 
					xlim([10, 5000]);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										77
									
								
								runtest.m
									
									
									
									
									
								
							
							
						
						
									
										77
									
								
								runtest.m
									
									
									
									
									
								
							@@ -1,77 +0,0 @@
 | 
				
			|||||||
tg = slrt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%%
 | 
					 | 
				
			||||||
f = SimulinkRealTime.openFTP(tg);
 | 
					 | 
				
			||||||
mget(f, 'apa95ml.dat', 'data');
 | 
					 | 
				
			||||||
close(f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%% Convert the Data
 | 
					 | 
				
			||||||
data = SimulinkRealTime.utils.getFileScopeData('data/apa95ml.dat').data;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
u = data(:, 1);
 | 
					 | 
				
			||||||
y = data(:, 2);
 | 
					 | 
				
			||||||
t = data(:, 3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
save('mat/apa95ml_5kg_10V.mat', 'u', 't', 'y');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%%
 | 
					 | 
				
			||||||
figure;
 | 
					 | 
				
			||||||
subplot(1,2,1);
 | 
					 | 
				
			||||||
plot(t, u)
 | 
					 | 
				
			||||||
subplot(1,2,2);
 | 
					 | 
				
			||||||
plot(t, y)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%%
 | 
					 | 
				
			||||||
load('mat/apa95ml_5kg_10V.mat', 'u', 't', 'y');
 | 
					 | 
				
			||||||
ht = load('mat/huddle_test.mat', 'u', 't', 'y');
 | 
					 | 
				
			||||||
u = u - mean(u);
 | 
					 | 
				
			||||||
y = y - mean(y);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%%
 | 
					 | 
				
			||||||
[pxx, f] = pwelch(y, win, [], [], 1/Ts);
 | 
					 | 
				
			||||||
[pht, ~] = pwelch(ht.y, win, [], [], 1/Ts);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
figure;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
hold on;
 | 
					 | 
				
			||||||
plot(f, pxx);
 | 
					 | 
				
			||||||
plot(f, pht);
 | 
					 | 
				
			||||||
hold off;
 | 
					 | 
				
			||||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
					 | 
				
			||||||
ylabel('PSD'); xlabel('Frequency [Hz]');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%%
 | 
					 | 
				
			||||||
run setup;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
win = hann(ceil(10.1/Ts));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[tf_est, f] = tfestimate(u, y, win, [], [], 1/Ts);
 | 
					 | 
				
			||||||
[co_est, ~] = mscohere(u, y, win, [], [], 1/Ts);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%%
 | 
					 | 
				
			||||||
figure;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
hold on;
 | 
					 | 
				
			||||||
plot(f, co_est, 'k-')
 | 
					 | 
				
			||||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
					 | 
				
			||||||
ylabel('Coherence'); xlabel('Frequency [Hz]');
 | 
					 | 
				
			||||||
hold off;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%%
 | 
					 | 
				
			||||||
figure;
 | 
					 | 
				
			||||||
ax1 = subplot(2, 1, 1);
 | 
					 | 
				
			||||||
hold on;
 | 
					 | 
				
			||||||
plot(f, abs(tf_est), 'k-', 'DisplayName', 'Identified')
 | 
					 | 
				
			||||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
					 | 
				
			||||||
ylabel('Amplitude'); xlabel('Frequency [Hz]');
 | 
					 | 
				
			||||||
hold off;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ax2 = subplot(2, 1, 2);
 | 
					 | 
				
			||||||
hold on;
 | 
					 | 
				
			||||||
plot(f, 180/pi*unwrap(angle(-tf_est)), 'k-')
 | 
					 | 
				
			||||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
 | 
					 | 
				
			||||||
ylabel('Phase'); xlabel('Frequency [Hz]');
 | 
					 | 
				
			||||||
hold off;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
linkaxes([ax1,ax2], 'x');
 | 
					 | 
				
			||||||
xlim([10, 5000]);
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user