MultiCore Programming on Raspberry Pi via Simulink

11 Ansichten (letzte 30 Tage)
Derk Gonschor
Derk Gonschor am 27 Jan. 2023
Verschoben: Joel Van Sickel am 13 Apr. 2023
Hi everyone,
i am currently developing a model in simulink with three different main functions (let's call them A,B,C for now), where one of them is running at a different sample time as the other ones. However, I tried to simulate this system on the Raspberry Pi via external mode but got a lot of overruns and a high cpu load. Now, I am trying to split the model, so that for example functions A and B are executed on one core and function C is executed on another core.
For this, I used this article from Mathworks, but I think that you can't actually assign one task to a core but just specify the periodic execution. As a result I could reduce the cpu load to a maximum of 40% but still get a lot of overruns (imo, this also contradicts itself).
As a second approach, I tried this article but I think this is not possible for Raspberry Pis since I can not add and assign cores in the concurrent execution tab.
My goal is to assign each task to a core on the raspberry and see the cpu load on the raspberry pi.
Did someone try this before or can help me?
Many thanks in advance!

Antworten (1)

Nakul Khadilkar
Nakul Khadilkar am 3 Feb. 2023
Verschoben: Joel Van Sickel am 13 Apr. 2023
Hello Derk,
Thanks for the detailed explanation of your steps. Multi core programming from a Simulink model with different sample times is indeed what is showcased in the article you linked above.
  1. Would you mind checking the example mentioned there on your hardware and seeing if that worked?
  2. Could you clarify what you mean by three differnt main functions? Would it be possible for you to share the SImulink model?
Also, I suggest you try steps mentioned in the Partition Simulink Model Using Explicit Partitioning section of the article to understand how to map the periodic tasks to each core via the concurrent panes UI dialog. The key is to group the simulink blocks with the same rate into subsystems which can then be put into a concurrent execution hierarchy.
Regards,
Nakul Khadilkar
  1 Kommentar
Derk Gonschor
Derk Gonschor am 3 Feb. 2023
Verschoben: Joel Van Sickel am 13 Apr. 2023
Hello Nakul,
thanks a lot for your help!
  • to 1.: I checked the example model mentioned in the article and it worked just fine up to my point of understanding
  • to 2.: I am basically developing an FFT function, which I now divided into the following three main functions: (1) This represents the electrical grid and is a programmable sine wave generator (2) This function creates a buffer or window of n signals which is filled by the sine generator signal (3) finally, the FFT receives the window and analyzes the signal
  • I already tried the Partion Simulink Model Using Explicit Partioning section of the article. Here I created an atomic subsystem for each of the functions (1), (2) and (3) and set a periodic cycle. While functions (1) and (2) are supposed to run at one common periodic time, function (3) is supposed to run at a different period. This looks like this now:
  • This is executable on the Raspberry Pi but I can not draw the necessary conclusions from it. As mentioned, I would like to see, how much computing power each function / atomic subsystem needs and I want to see the effects of different period lengths of the FFT subsystem.
  • Sadly, I cannot see on the Raspberry which task needs which amount of computing power. Further changing the periodic lengths and adding multiple FFTs in paralel doesn't seem to change much
Here the results shown by raspberry pi for one FFT every 50 ms
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1489 root -39 0 46400 1188 1052 R 47,7 0,0 0:55.56 Raspberry_split
1492 root -41 0 46400 1188 1052 S 14,0 0,0 0:16.53 Raspberry_split
1493 root -42 0 46400 1188 1052 S 8,3 0,0 0:09.55 Raspberry_split
Here the results shown by raspberry pi for two FFTs every 50 ms
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1650 root -39 0 46476 2288 1972 R 83,3 0,1 0:37.04 Raspberry_split
1653 root -41 0 46476 2288 1972 R 13,3 0,1 0:06.01 Raspberry_split
1654 root -42 0 46476 2288 1972 S 7,7 0,1 0:03.40 Raspberry_split
Here the results shown by raspberry pi for three FFTs every 50 ms
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1731 root -39 0 46552 2200 1876 R 95,0 0,1 0:28.22 Raspberry_split
1734 root -41 0 46552 2200 1876 R 17,3 0,1 0:05.10 Raspberry_split
1735 root -42 0 46552 2200 1876 S 7,6 0,1 0:02.24 Raspberry_split
Here the results shown by raspberry pi for one FFT every 200 ms
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3669 root 20 0 62840 2288 1976 R 96,0 0,1 1:17.04 Raspberry_split
3663 root -39 0 62840 2288 1976 R 43,9 0,1 0:35.71 Raspberry_split
3667 root -41 0 62840 2288 1976 S 14,3 0,1 0:11.34 Raspberry_split
Here the results shown by raspberry pi for two FFT every 200 ms
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3876 root 20 0 54704 2264 1940 R 96,7 0,1 0:18.98 Raspberry_split
3871 root -39 0 54704 2264 1940 R 82,0 0,1 0:16.27 Raspberry_split
3874 root -41 0 54704 2264 1940 S 13,7 0,1 0:02.76 Raspberry_split
Here the results shown by raspberry pi for three FFT every 200 ms
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3998 root 20 0 54788 2316 2000 R 99,9 0,1 0:48.20 Raspberry_split
3993 root -39 0 54788 2316 2000 R 95,0 0,1 0:46.86 Raspberry_split
3996 root -41 0 54788 2316 2000 S 18,0 0,1 0:08.89 Raspberry_split
Many thanks in advance and sorry for the long message :)
Best regards,
Derk

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by