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

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?

Related

Publish Procedure Failed - Simulink code generation with TwinCAT Target file

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.

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.

Using MATLAB's diary function in an executable (MATLAB Application Compliler Toolbox)

I've created a code that will be run as an executable. However, the running of an executable has an error that doesn't exist in the MATLAB scripts. Trying to document this, I ran across the "diary" command which seems like an appropriate way of logging the error. Command: diary('LogFile.txt')
However, when running the compiled version, I immediately get a pop up error: LogFile.txt: Cannot open file: permission denied.
I'm getting a bit flummuxed as it appears to be having trouble writing to its own folder. Should I be trying to store to C:\Users, or is there some other glitch I'm running into?
Thanks a lot to 'Daniel' for his suggestion of getenv('appdata'). I would add that my path was ..\AppData\Roaming\ so I would suggest a way of viewing the location of the log file in your gui just to be sure you can find (or that others using your app can find it). Thanks!

Why is matlab's psychtoolbox failing to detect the Screen mexfile when running AssertOpenGL?

I've managed to install the psychtoolbox-3 from the NeuroDebian repository without any explicit errors, but running AssertOpenGL yields this very verbose error message.
My system specs are as follows: Intel-based PC with Ubuntu 12.04 LTS
I've tried adding ~/Documents/MATLAB and all it's subdirectories to the Matlab pathdef, as this is where I pointed the DownloadAdditionsForNeuroDebian function to. Similarly, I've tried adding /usr/share/octave/site/m/psychtoolbox-3/ and it's subdirectories to the matlab path as well.
The error seems to be originating from a failed call to Screen; according to the above error message, Screen can't be found. That having been said, I'm able to run Screen at the Matlab console, although I get this error:
>> Screen
In place of the expected mex file this placeholder file was executed:
Screen
This mex file seems to be missing or inaccessible on your Matlab path or it is dysfunctional:
Screen.*
Hmm. I cannot find the file on your Matlab path?!?
One reason could be that your Matlab path is wrong or not up to date
for the current Psychtoolbox. You may want to run SetupPsychtoolbox to
fix possible path problems.
??? Error using ==> AssertMex at 210
Missing or dysfunctional Psychtoolbox Mex file for this operating system. Read the help text above carefully!!
Error in ==> Screen at 161
AssertMex('Screen.m');
Running SetupPsychtoolbox yields an error that is very similar to the first one.
I tried installing the suggested packages, but they were all already installed -- nothing seems to work.
I have absolutely no idea where to go from here. Does anyone have any suggestions?
The SetupPsychtoolbox command seems to have a bug. What is happening for you (and for me, when I tried this) is that the folder containing Screen.mex is being placed at the bottom of the search path. Here's how to fix;
type "pathtool" at the Matlab commandline
find the PsychtoolboxAddons entry and move it to the top (for me this was /usr/share/psychtoolbox-3/PsychtoolboxAddons)
If you don't have a folder PsychtoolboxAddons you may need to follow the instructions at http://docs.psychtoolbox.org/DownloadAdditionsForNeuroDebian
Don't forget to move your personal Matlab directory to the top also (the SetupPsychtoolbox command moves your personal directory to be underneath it's directories, which is a bit mean).
Save the path. Don't ever run SetupPsychtoolbox again!
Good luck!