From: Martin Prudek Date: Sun, 17 May 2015 10:45:39 +0000 (+0200) Subject: Added MATLAB script to visualize logs. X-Git-Url: https://rtime.felk.cvut.cz/gitweb/fpga/rpi-motor-control.git/commitdiff_plain/3a89c80960f9748654f024df662c6994ff4f03a5 Added MATLAB script to visualize logs. --- diff --git a/pmsm-control/test_sw/tools/readLog.m b/pmsm-control/test_sw/tools/readLog.m new file mode 100644 index 0000000..1dfb6eb --- /dev/null +++ b/pmsm-control/test_sw/tools/readLog.m @@ -0,0 +1,73 @@ +% cte logy vyutvorene na raspberry +cd('/home/warg/logy') +C=dlmread('logs.log') +limits=[1.25 1.55]*10000; +set_lim=0; +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); + legend('pozice'); + title('Závislost polohy na čase'); + xlabel('Čas [ms]'); + ylabel('Poloha IRC'); + if set_lim + xlim(limits); + end; +end; + +%rychlost + +subplot(plotc,1,1); +hold on; +plot(C(1,:),C(7,:),'LineWidth',1); +plot(C(1,:),C(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]'); +if set_lim + xlim(limits); +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); +legend('pwm1','pwm2','pwm3','šířka plnění','Location','northwest'); +title('Šířka plnění a její přepočet na PWM'); +xlabel('Čas [ms]'); +ylabel('Šířka plnění [bity]'); +if set_lim + xlim(limits); +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); +legend('ch1 (pwm1)','ch2 (pwm2)','ch0 (pwm3)','Location','southwest'); +title('Záznamy proudů'); +xlabel('Čas [ms]'); +ylabel('Proud'); +if set_lim + xlim(limits); +end; + + + +if do_save + pause(5); + % set(fig, 'InvertHardcopy', 'off'); + saveas(fig, name); +end; \ No newline at end of file