Today i was wondering, how i can live stream images from my camera, which does not support winvideo, but comes with a custom SDK into MATLAB/Simulink.
How-i-fixed-it:
I used the Image Acquisition Toolbox™ Adaptor Kit to create an adaptor to create a custom adaptor (C++-DLL) using Visual Studio, like described here:
http://www.mathworks.de/de/help/imaq/creating-custom-adaptors.html
Description: The Adaptor Kit is a C++ framework that you use to create an adaptor to support new Hardware.
There are some open source KINECT imaq adaptor projects out as well to receive Microsoft KINECT RGB and depth data in MATLAB:
http://matkinect.sourceforge.net and http://sourceforge.net/projects/matkinect/
Here's a video that shows it working: http://www.youtube.com/watch?v=njstg3jnCg0
http://www.mathworks.com/matlabcentral/newsreader/view_thread/297204
This blog is about problems i encountered in everyday life and how i fixed them or worked around them. Sometimes i also just post things to let people out there know about something i think it might be of interest for others than me....
Showing posts with label Simulink. Show all posts
Showing posts with label Simulink. Show all posts
Wednesday, November 6, 2013
Thursday, June 27, 2013
How to exchange data with a running SIMULINK model from MATLAB workspace?
I have a SIMULINK model to filter and process sensor data. I wanted to access some of model data from MATLAB workspace while the model was running.
How-i-fixed-it:
In my simulink model i added a non-blocking UDP receive block, a triggered subsystem ad a UDP send block.
The Status output of the UDP receive block triggers the subsystem which contains the UDP send block and received as Input the model data i want to send to the workspace.
In the workspace i create a UDP object to communicate with the UDP blocks in the SIMULINK model.
When the model is running, i send just a single byte on UDP from Workspace to the UDP Receive to Trigger the send. Next step is to read the desired number of bytes from the udp port in the workspace.
I found out, that the timing of this solution is not very performant. When the model is very busy (or at least the CPU is), then there can be significant delays in the model sending out the data on UDP. I think this does not work for real-time Systems, but it's a simple solution to get it working.
How-i-fixed-it:
In my simulink model i added a non-blocking UDP receive block, a triggered subsystem ad a UDP send block.
The Status output of the UDP receive block triggers the subsystem which contains the UDP send block and received as Input the model data i want to send to the workspace.
In the workspace i create a UDP object to communicate with the UDP blocks in the SIMULINK model.
When the model is running, i send just a single byte on UDP from Workspace to the UDP Receive to Trigger the send. Next step is to read the desired number of bytes from the udp port in the workspace.
I found out, that the timing of this solution is not very performant. When the model is very busy (or at least the CPU is), then there can be significant delays in the model sending out the data on UDP. I think this does not work for real-time Systems, but it's a simple solution to get it working.
Monday, May 27, 2013
Matlab Simulink Coder Compile Error _sfun.bat not found
I started to learn about Matlab Simulink Coder automatic C-Code Generation today. I followed the steps described in the very helpful tutorial Jose Carlos Molina Fraticelli (http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20120014980_2012014792.pdf), but when i wanted to run the model, i got a Simulink error message, that a file called "modelname_sfun.bat" was not found.
How-I-fixed-it:
The problem was caused by an incorrect setup of the C-Compilers on my system. I had multiple versions of Visual Studio installed on my computer and it seems like after a couple of update steps of Visual Studio and Matlab, Matlab got confused.
I had to rerun "mex -setup" from the Matlab command line and selected the Compiler Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
After that, the model compiled OK and i was able to run it.
How-I-fixed-it:
The problem was caused by an incorrect setup of the C-Compilers on my system. I had multiple versions of Visual Studio installed on my computer and it seems like after a couple of update steps of Visual Studio and Matlab, Matlab got confused.
I had to rerun "mex -setup" from the Matlab command line and selected the Compiler Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
After that, the model compiled OK and i was able to run it.
Subscribe to:
Posts (Atom)