From 52c797620624f507d3695c7ca6b04f01453f079d Mon Sep 17 00:00:00 2001 From: Martin Prudek Date: Wed, 20 May 2015 15:24:38 +0200 Subject: [PATCH] Matlab script to read logs commented. --- pmsm-control/test_sw/tools/readLog.m | 77 ++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/pmsm-control/test_sw/tools/readLog.m b/pmsm-control/test_sw/tools/readLog.m index 1dfb6eb..6885cb9 100644 --- a/pmsm-control/test_sw/tools/readLog.m +++ b/pmsm-control/test_sw/tools/readLog.m @@ -1,19 +1,54 @@ -% cte logy vyutvorene na raspberry -cd('/home/warg/logy') -C=dlmread('logs.log') -limits=[1.25 1.55]*10000; -set_lim=0; +% cte logy vyutvorene na Raspberry Pi +% +% Format prichozich dat +% LOG(1,:) cas +% LOG(2,:) pozice +% LOG(3,:) PWM1 +% LOG(4,:) PWM2 +% LOG(5,:) PWM3 +% LOG(6,:) duty +% LOG(7,:) pozadovana rychlost +% LOG(8,:) skutecna rychlost +% LOG(9,:) ch1 (pwm1) +% LOG(10,:) ch2 (pwm2) +% LOG(11,:) ch0 (pwm3) +% +%-------------------------------------------------------------------------- +%% Nacitani souboru +%cd('/home/warg/logy'); + +LOG=dlmread('logs.log'); +%LOG=dlmread('spd_old_val_10_duty_step_100.log'); +%LOG=dlmread('duty100_step.log'); +%LOG=dlmread('spd100_step2.log'); + + + + + +%% jen rychlost +hold on; +plot(LOG(1,:),LOG(7,:),'LineWidth',1); +plot(LOG(1,:),LOG(8,:),'LineWidth',1); +legend('Požadovaná rychlost','Aktuální rychlost','Location','southeast'); +title('Aktuální a požadovaná rychlost'); +xlabel('Čas [ms]'); +ylabel('Rychlost [IRC/50ms]'); + + +%% vykresli vse + +limits=[1.65 1.9]*10000; +set_lim=1; pozice=0; plotc=3; -do_save=0; -name='duty100_step.pdf'; fig=figure; if pozice subplot(plotc,1,1); hold on; - plot(C(1,:),C(2,:),'LineWidth',2); + plot(LOG(1,:),LOG(2,:),'LineWidth',2); legend('pozice'); title('Závislost polohy na čase'); xlabel('Čas [ms]'); @@ -27,8 +62,8 @@ end; subplot(plotc,1,1); hold on; -plot(C(1,:),C(7,:),'LineWidth',1); -plot(C(1,:),C(8,:),'LineWidth',1); +plot(LOG(1,:),LOG(7,:),'LineWidth',1); +plot(LOG(1,:),LOG(8,:),'LineWidth',1); legend('Požadovaná rychlost','Aktuální rychlost','Location','southeast'); title('Aktuální a požadovaná rychlost'); xlabel('Čas [ms]'); @@ -39,10 +74,10 @@ end; subplot(plotc,1,2); hold on; -plot(C(1,:),C(3,:),'LineWidth',1); -plot(C(1,:),C(4,:),'LineWidth',1); -plot(C(1,:),C(5,:),'LineWidth',1); -plot(C(1,:),C(6,:),'LineWidth',1); +plot(LOG(1,:),LOG(3,:),'LineWidth',1); +plot(LOG(1,:),LOG(4,:),'LineWidth',1); +plot(LOG(1,:),LOG(5,:),'LineWidth',1); +plot(LOG(1,:),LOG(6,:),'LineWidth',1); legend('pwm1','pwm2','pwm3','šířka plnění','Location','northwest'); title('Šířka plnění a její přepočet na PWM'); xlabel('Čas [ms]'); @@ -53,9 +88,9 @@ end; subplot(plotc,1,3); hold on; -plot(C(1,:),C(9,:),'LineWidth',1); -plot(C(1,:),C(10,:),'LineWidth',1); -plot(C(1,:),C(11,:),'LineWidth',1); +plot(LOG(1,:),LOG(9,:),'LineWidth',1); +plot(LOG(1,:),LOG(10,:),'LineWidth',1); +plot(LOG(1,:),LOG(11,:),'LineWidth',1); legend('ch1 (pwm1)','ch2 (pwm2)','ch0 (pwm3)','Location','southwest'); title('Záznamy proudů'); xlabel('Čas [ms]'); @@ -64,10 +99,8 @@ if set_lim xlim(limits); end; +%% ulozi - -if do_save - pause(5); % set(fig, 'InvertHardcopy', 'off'); - saveas(fig, name); -end; \ No newline at end of file + saveas(fig, 'rlt_spd_100_step.pdf'); + \ No newline at end of file -- 2.39.2