diff --git a/.gitignore b/.gitignore index 527db77..8df43c8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,9 @@ *.xml *_slrt_rtw/ +# data +data/ + # Windows default autosave extension *.asv diff --git a/readme.org b/readme.org index a0c9581..46e21dc 100644 --- a/readme.org +++ b/readme.org @@ -6,10 +6,10 @@ We first copy the =dat= file from the target computer to the host computer: #+begin_src matlab -tg=slrt; -f=SimulinkRealTime.openFTP(tg); -mget(f, 'DATA_001.dat'); -close(f); + tg=slrt; + f=SimulinkRealTime.openFTP(tg); + mget(f, 'DATA_001.dat', 'local_folder'); + close(f); #+end_src We then import the =dat= file to the workspace: @@ -21,14 +21,21 @@ We then import the =dat= file to the workspace: * Commands with the target object https://fr.mathworks.com/help/xpc/api/simulinkrealtime.target.html +| Connect | No Yes | +| Status | stopped runing | +| start | Start execution of real-time application on target computer | +| stop | Stop execution of real-time application on target computer | + + | tg.viewTargetScreen | Show target computer screen | + | ping | Test communication between development and target computers | | reboot | Restart target computer | | close | Close connection between development and target computers | + | load | Download real-time application to target computer | | unload | Remove real-time application from target computer | -| start | Start execution of real-time application on target computer | -| stop | Stop execution of real-time application on target computer | + | addscope | Create a scope of specified type | | getscope | Return scope identified by scope number | | remscope | Remove scope from target computer | @@ -50,3 +57,22 @@ https://fr.mathworks.com/help/xpc/api/simulinkrealtime.target.html | getProfilerData | Retrieve profile data object | | resetProfiler | Reset profiling service state to Ready | | getDiskSpace | Return free space and total space on the drive, in bytes | + +* FTP access to the target computer +https://fr.mathworks.com/help/xpc/api/simulinkrealtime.openftp.html?s_tid=doc_ta + +First run the following commands to have the =FTP= Object: +#+begin_src matlab + tg=slrt; + f=SimulinkRealTime.openFTP(tg); +#+end_src + +Then, the =f= object can be used to access the filesystem on the target computer. +| cd | | | +| dir | | | +| mget | Used to download data from the target host | =f.mget('data.dat', 'local_folder')= | +| mkdir | | | +| mput | | | +| rename | | | +| rmdir | | | +| close | | | diff --git a/slip-ring-test/mat/data_001.mat b/slip-ring-test/mat/data_001.mat new file mode 100644 index 0000000..19fa897 Binary files /dev/null and b/slip-ring-test/mat/data_001.mat differ diff --git a/slip-ring-test/readme.org b/slip-ring-test/readme.org new file mode 100644 index 0000000..0397295 --- /dev/null +++ b/slip-ring-test/readme.org @@ -0,0 +1 @@ +* TODO Register data on the computer diff --git a/slip-ring-test/run_test.m b/slip-ring-test/run_test.m new file mode 100644 index 0000000..70dce49 --- /dev/null +++ b/slip-ring-test/run_test.m @@ -0,0 +1,48 @@ +tg = slrt; + +%% TODO - Build this application if updated + +%% +if tg.Connected == "Yes" + if tg.Status == "stopped" + %% Load the application + tg.load('test'); + + %% Run the application + tg.start; + pause(10); + tg.stop; + + %% Load the data + f = SimulinkRealTime.openFTP(tg); + mget(f, 'data/data_001.dat'); + close(f); + end +end + +%% Convert the Data +data = SimulinkRealTime.utils.getFileScopeData('data/data_001.dat').data; + +t = data(:, end); +x1 = data(:, 1); +x2 = data(:, 2); + +save('mat/data_001.mat', 't', 'x1', 'x2'); + +%% Plot the data +figure; +hold on; +plot(t, x1); +plot(t, x2); +hold off +xlabel('Time [s]'); +ylabel('Voltage [V]'); + +%% Compute the PSD +dt = t(2)-t(1); + +window_L = ceil(length(x1)/10); +window_han = .5*(1 - cos(2*pi*(1:window_L)'/(window_L+1))); + +[pxx, f] = pwelch(x1, window_han, 0, [], 1/dt); + diff --git a/slip-ring-test/test.slx b/slip-ring-test/test.slx index 51d258d..1e6fbc4 100644 Binary files a/slip-ring-test/test.slx and b/slip-ring-test/test.slx differ