• Processor in the Loop (PIL) issues using the MPLAB Simulink Blockset
2020/10/13 03:30:05
Hello everyone,

I am trying to implement the PIL feature of MPLAB Simulink Blockset using a dsPIC33CH Dev Board (chip: dsPIC33CH512MP508). To be more precise I have already implemented the power stage of a buck converter in Simulink (plant block) and I would like to check the controller's behavior on the dsPIC target with the buck converter plant.

I tried two methods by 1. Using the model reference block and 2. using the subsystem block. They both failed..

1. I read the thread "On Processor in the Loop (PIL) using the Blockset" in which ASabir and Lubin implemented DCM Control project with the PIL feature. I downloaded the examples and used them out of the box only changing the master block and configuring the UART block. UART works fine and I am able to program the chip and even run external mode without issues.

- On ASabir's version, after a successfull built, I get the following error:

"An error occurred while calling into the SIL or PIL target connectivity implementation" .....

...."Compiling: C:/PROGRA~1/MATLAB/R2019b/toolbox/rtw/targets/pil/c/coder_assumptions_data_stream.c"

"gmake: *** No rule to make target `MCHP_pil_main.o', needed by `PI_Controller.elf'. Stop.".

- On Lubin's version i get the error :

### BUILD_MODE model_reference ### Creating library ...

"C:/PROGRA~1/MICROC~1/xc16/v1.60/bin/xc16-ar" -r -omf=elf rtwshared_lib.a mul_s32_hiSR.o mul_s32_loSR.o mul_wide_s32.o

C:\PROGRA~1\MICROC~1\xc16\v1.60\bin\bin/elf-ar.exe: mul_s32_hiSR.o: No such file or directory

gmake: *** [rtwshared_lib.a] Error 255

Error(s) encountered while building "rtwshared"

- I even built the model from scratch and I got the same error as ASabir's version. I noticed that both errors have something to do with rtw library. Is there a way to resolve this issue? Maybe it has something to do with bad translation to current Matlab and MPLAB blockset versions? (I use MatlabR2019b and MPLAB Blockset v3.47 - XC16 v1.60 Compiler)

2. I then tried using the subsystem block and copy everything there. As I couldn't find a tutorial on how the PIL is implemented with the subsystem block in this forum, I followed some general rules mentioned here: "https://www.mathworks.com/help/supportpkg/armcortexa/ug/use-pil-to-verify-numerical-accuracy-of-executable.html". After a successful built, the code actually run but not on the target. To check this I tried to light up a LED using digital write block inside the subsystem block and nothing happened. I even removed the board from the laptop and the code continued as nothing happened.

Is it possible that someone out there has working PIL examples with the current versions of Matlab and MPLAB blockset? Using PIL can speed up the designing process by tons and I really want to be able to fix those issues.

Nevertheless, a big thank you to Lubin and all the developers working on the MPLAB Simulink Blockset. Your work is very much appreciated!

2020/10/22 12:22:58

Great that External Mode works. 
Usually, PIL and External Mode works either both or none. However there are few tiny update to be done on the blockset to make it fully compatible with recent matlab release for PIL. This is in the pipe.
Please note however that PIL is slow to execute.
Usually, simulation and embedded code provide exact same results except in very few cases ; Until you are in one of these few cases, you might not bother running PIL test. Simulation is much faster.
PIL is interesting to measure precise calculation time on the target for various simulink subsystem ; for time critical applications.
PIL is also interresting for numerical sensitive algorithms, or when generated code is known for not providing an exact same result than simulation. Below are two examples:
  • Matrix computation like eigen values calculation, Singular Value Decomposition... might differ (embedded result might be less accurate than simulation due to simplified implementation).
  • Use of Code Replacement Library might also provide different results but for dsPIC, the embedded result is equal or more accurate than the simulation result.
2020/10/26 11:13:46
Hello everyone and Lubin
I'm having a problem to run a PIL with the MPLAB Simulink Blockset.
I am trying to do a verification test for a filter through a PIL. Generally speaking, I'm trying to do a similar PIL example available to the MPLAB Blockset, however using the dsPIC33CK Curiosity development kit Board.
The target dsPIC is the dsPIC33CK256MP508 with the dsPIC33CK Curiosity development Board kit. My current goal is to learn how to use the MPLAB Simulink package support to correctly perform a PIL in the future.
I read and tried to follow the steps in the topic that ASabir and Lubin implemented DCM Control project with the PIL feature “On Processor in the Loop (PIL) using the Blockset”. As suggested by Lubin in the topic, I followed the basic instructions for configuring the model.
I can't do the simulation and I find the same error message as Coriolis_effetc. Maybe my problem is the same as Coriolis_effetc... However, I could also notice that the “Enter Libraries” and 3Header Include Path” fields in the Configuration Parameters=>dsPIC options are not filled in like the example provided by the blockset.
### BUILD_MODE model_reference ### Creating library ... "C:/PROGRA~1/MICROC~1/xc16/v1.60/bin/xc16-ar" -r -omf=elf rtwshared_lib.a mul_s32_hiSR.o mul_wide_s32.o C:\PROGRA~1\MICROC~1\xc16\v1.60\bin\bin/elf-ar.exe: mul_s32_hiSR.o: No such file or directory gmake: *** [rtwshared_lib.a] Error 255 Error(s) encountered while building "rtwshared"
Does MPLAB Simulink blockset support PIL for the CK family dsPIC or the problem is compatibility of MPLAB Blockset with the version of Matlab?
For information, I am using MATLAB 2020a et version 3.47 of MPLAB Device Blocks for Simulink.
Thank you very much for your attention!
2020/10/26 13:17:06
Hi Guila,
There is likely an issue with recent matlab release which need our focus for PIL. I do not think it is specific with dsPIC CK but with slight change in Matlab way to proceed.
I get PIL working with R2020b but with a model created with an older matlab release thus I suspect I would not work if I start a new model from scratch.
We'll check that in the next comming weeks.
Thanks for reporting the issue.
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account