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" .....
"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!