Publish Procedure Failed - Simulink code generation with TwinCAT Target file - simulink

I would like to develop an application in Matlab/Simulink which will be integrated in TwinCAT by TcCOM modules (code generation with TwinCAT.tlc target file).
I have some problems in the PUBLISH PROCEDURE!!!
First of all, I have to mention that I passed through all the steps mentioned in the TwiCAT – Simulink Handbook (see on page 9: https://download.beckhoff.com/download/document/automation/twincat3/TwinCAT_3_Matlab_Simulink_EN.pdf ). The next steps are accomplished:
Matlab R2015b is installed;
TwinCAT 3 is installed and embedded in Visual Studio 2013;
Microsoft Windows Driver Kit is installed (WinDDK 7600.16385.1)
Twincat 3 Target for Matlab/Simulink (TE1400) is installed and embedded in Matlab;
The necessary licenses are activated;
The application is very basic, it has an INPUT and an OUTPUT block, a SUM and a CONSTANT block.
The Simulink model have been configured as:
Solver: Fixed Step solver (ode3) with 0.005 fixed-step size;
Code Generation: TwinCAT.tlc System target file;
Code Generation -> Tc Build: Publish Module CHECKED
When I try to Build Model, Simulink returns the next error message:
‘Publish Procedure Failed – MGFcn:43’
and
'error MSB3231: Unable to remove directory'
If you need, I can attach the .txt file with the errors.
If I leave the Publish Module UNCHECKED, Simulink generates C++ code without errors. But, I need to have TcCOM modules.
I hope that I delivered all the necessary information.

Related

Where are the files defining NVIC for STM32 in PlatformIO when using CubeMX?

I've recently switched to using PlatformIO for developing for STM32 using the following workflow:
Create a .ioc file using the CubeMX utility
Generate source code and the PlatformIO configuration from that .ioc file from the stm32pio command line utility
Edit, build, and debug using the PlatformIO plug-in for VSCode (Mac)
Overall, this works very well. However, I was previously using the CubeMX code generation in ST's CubeMX IDE, which placed a .s file in the source directory that (as I understand it) defined the NVIC, as well as the default function that was used for exceptions/interrupts that are not explicitly defined (i.e., those handled by their default weak implementations.) I don't see where this is defined in the new workflow. Is this generated dynamically as part of the build process?
The reason I'm asking is (beside wanting a better understanding of the process overall), I'd like to write an interrupt handler for EXTI0, but trigger it as a software interrupt, and not assign a pin to it. If that is not possible, then perhaps the entire point is moot.
I was able to find the answer. These steps might be useful to somebody else who comes across this question. This was done on MacOS, but should be similar to the process for other operating systems.
During the build process, the filename can be seen. It will be prefaced with startup_, followed by the name of the particular chip you're developing for. In my case, the line is
Compiling .pio/build/disco_f072rb/FrameworkCMSISDevice/gcc/startup_stm32f072xb.o
Searching in the .platformio folder of my user directory, I found the matching .s file, which in my case was .platformio/packages/framework-stm32cube/f0/Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/gcc/startup_stm32f072xb.s
The structure of the path leading to the file indicates the particulars of the hardware and frameworks I'm using: STM32Cube framework, a F0 series chip, and the GCC compiler. The easiest way to find this file, and how I was able to find it, is using the find command from the terminal to search the PlatformIO directory.
Reading this file gives the lines I was looking for, defining the names of the functions to be used for exception and interrupt handling, such as the following:
.weak EXTI0_1_IRQHandler
.thumb_set EXTI0_1_IRQHandler,Default_Handler
It seems like, while I am using the CubeMX HAL for some drivers, the basic startup code is done using CMSIS, so it should be the same for HAL, LL, or CMSIS based builds.

Why cannot Simulink find/run precompiled mexw64 files of the toolboxes?

I want to run a Simulink model in real time. So I need the Real time sync block in "Simulink desktop real time" (sldrt) toolbox working. It seems to be correctly installed, also in path. But I always get the error:
Error in S-function 'real_time_test/Real-Time Synchronization': Unable to acquire handle to MATLAB function 'sldrtsync'
Component:Simulink | Category:Blockerror
This error occurs also with the Desktop real time example _sldrtex_vdp_ also see my minimal example that I cannot get working..
In the sldrt directory there are two files:
sldrtsync.mexw64
sldrtsync.tlc
This path is also included in Matlab Path.
API: Win7 64bit
Matlab R2016b
Windows SDK 7.1
Where to look for the solution?

Issue with Embedded Coder Target for Arduino

I am following this MathWorks File Exchange Link. I am having problem while running the myarduino_blink.slx demo.
My MATLAB version is R2015a, and I am using an Arduino Uno. I ran the file setup_custom_target_arduino.m after changing the relevant directory listing and the arduino version in the m file, and I got the output of Arduino on COM 3, which was correct.
After this, I checked the Simulink Library Browser and I had the Custom C/C++ Target Arduino Library will all its modules. Now when I simulate the model, I get the following error:
Error in S-function 'myarduino_blink/Digital Output':
S-Function 'sfunar_digitalOutput' does not exist
Kindly help me out, what could I have done wrong?
Update 1
Ok, I solved the "does not exist" problem. Apparently, no MEX compiler was installed. So I installed the Windows SDK, then re-ran the m file and now I am able to generate the .mex64 files. Now I run into another problem, when I build the simulink model, it gives this error:
Build procedure for model: 'myarduino_blink' aborted due to an error
How to solve this?
setup_custom_target_arduino.m calls build_all_sfunctions.m which should compile all of the S-Functions in the blocks directory. It looks as if that hasn't occurred for some reason. Check in the blocks directory that each of the S-Functions has a .c, .tlc (both of which come with the package) and a .mex64 (which is the compiled version of the .c generated by build_all_sfunctions.m) file.
If they are not there then the setup hasn't executed correctly, and you'll need to compile all of the S-Functions.
If they are there then you most likely have some sort of path issue (although since you say you can see the library in the library browser this seems unlikely).

Matlab standalone app that was compiled using Guide and deploy tool does not work as designed when deployed

I am not sure if this info helps, but my GUI tool has text boxes for user input, push buttons, drop downs, and an axes to show histogram plot.
The deployment machine is a Windows 7 64 bit. The MCR is installed without any issues (using mcr file packaged with the GUI). The GUI opens in deployed machine. However it does not function properly. Just gives beep sound when using any functionality like pressing a button, no error messages are shown.
I ran the exe file through the dependency walker, and it shows the following errors:
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
LAUNCHERMAIN.DLL
(Error opening file. System cannot find the file specified) for all the above.
Run the executable from a dos window in order to obtain all messages that normally would write to matlab console ...
I'm suspecting that some matlab routines used in your buttons were not embedded during compilation (and the beep corresponding to "warning, error in gui callback function "lalala" is undefined).
NB: I don't think there is any issue for missing dll in dependency walker ... else your exe would not run at all and would wrote "Failed to load module".
You are likely missing the Visual Studio redistributable package. Download and install it on the deployed machine.

Running timing simulation in modelsim

I've created a small design in Verilog and now i want to run timing simulation. Since I know how to do it for VHDL files, I figured I'll do it (almost) the same way. Unfortunately, it's not that easy.
I've compiled my design and received .sdo and .vho files. But when I'm trying to run testbench, I receive error:
> vsim work.Sdesign_tb
# vsim work.Sdesign_tb
# Loading work.Sdesign_tb
# ALTERA version supports only a single HDL
# ** Fatal: (vsim-3039) C:/Users/K_impl/Sdesign_tb.v(17): Instantiation of 'sdesign' failed.
# Time: 0 ps Iteration: 0 Instance: /Sdesign_tb File: C:/Users/K_impl/Sdesign_tb.v
# FATAL ERROR while loading design
# Error loading design
It looks like Quartus 12.1 created VHDL files, while I want to simulate Verilog design (and Quartus supports only one VHDL at the same time). So I've tried another way, by adding .sdo files as SDF and then run simulation through "start simulation". But it also showed error (almost the same as above). So how can I bypass it? Or maybe there is another way of running timing simulation for Verilog designs?
You seem to be compiling more than one HDL, probably VHDL and Verilog.
If you go to your project settings in Quartus and make sure it's generating a Verilog netlist, it may solve your problem. Instructions are here.
To run timing simulation you may need to add altera_ver and your device libraries.