Quantcast
Channel: MATLAB Central Newsreader - tag:"simulink"
Viewing all 316 articles
Browse latest View live

How to get data out of QNX in Simulink?

$
0
0
Hi, I'm trying to get real-time data out of QNX in Simulink and was curious to know the various methods for doing this.

From briefly looking through the configuration parameters in out model, it seems like DSMLogging is enabled, but does this let us monitor data in real-time while the model is running?

Thanks for your help.

creating structures in base workspace from function (appease from workspace block for 2D arrays)

$
0
0
Hi guys, I need to create structures inside the base workspace from inside one of my functions and populate them with values, the problem is I don't explicitly know the names of the structures. Why? My model uses from workspace blocks, 2D arrays need structure form, as per Mathworks documentation. See below.

%some function
function [SimulationData,Error,Warnings] = ExtractTestCaseData(TestCaseFile,TestCase,OutputType)
.
.
[NumericData,TextData,RawData] = xlsread(TestCaseFile,TestCase);
.
.
%logic to create and populate simulationData structure with data from excel file
.
.
if regularVector
    assignin('base',SimulationData.Input(InputIndex).Name,SimulationData.Input(InputIndex).Values(1,:)); %no problem
elseif 2DArray
    %now what? I need in the base workspace
    %var.time=[TimeValues]
    %var.signals.values=[DataValues]
    %var.signals.dimensions=[DimValues]
    assignin('base',SimulationData.Input(InputIndex).Name,'1');%create signal name with random value, I don't know the value of Name, need to convert to structure form as in the comments
    evalin('base','nameIDontKnow.time=SimulationData.Time;'); %two problems actually, referencing a name I don't know in base workspace and base workspace has no concept of what SimulatinData.Time is, and so on if you catch my drift.
.
.
end

Does anyone have an idea of how to make this work??

Thanks
Dan

    
     
    
 

Re: Building Rapid-Accelerator Target w/ debug info

$
0
0
"Jesse Hopkins" wrote in message <hct3ij$r7l$1@fred.mathworks.com>...
> Is there a way to get the Simulink Rapid-Accelerator target to build with debug info? I've done it before in Accelerator mode by using the command
>
> set_param(bdroot,'AccelMakeCommand','make_rtw OPT_OPTS="-v -g"');
>
> prior to running the model. However, this doesn't seem to apply to Rapid-Accelerator builds? I am trying to debug an inlined S-function of ours that seems to work fine in Accelerator mode, but is crashing the Rapid-Accelerator target.

Does anybody have any info on solutions to this problem? I'm experiencing the exact same thing where an S-function runs fine in Accelerator mode but causes a Floating Point Exception in Rapid Accelerator mode. I'm trying to figure out a way to get the raccel executable to attach to a debugger.

How can I use the inputs, blocks of a Simulink model with Matlab code

$
0
0
Hi,
I want to create a Simulink model with matlab code using inputs, blocks... of another Simulink model.
Does anyone have an idea how can I do it.
Thanks in advance for your suggestions.

Re: S-Function custom code with Simulink Accelerator

$
0
0
Impressing, 10 years are gone and the bug still exist!!

Matlab 2016a still does not support custom code s-functions within model references in accelerator mode.
Why is Mathwork still not able to provide the "SimUserIncludeDirs" or "CustomInclude" parameters to the link process for accelerator mode? Can't imaging anything easier.

Re: S-Function custom code with Simulink Accelerator

$
0
0
On 03/03/2017 9:17 AM, Attila wrote:
...

> Matlab 2016a still does not support custom code s-functions within model
> references in accelerator mode.
> Why is Mathwork still not able to provide the "SimUserIncludeDirs" or
> "CustomInclude" parameters to the link process for accelerator mode?
> Can't imaging anything easier.

Has anybody using Simulink ever submitted the enhancement request formally?

--

(UDP Send) Simulink clarification

$
0
0
I am working in the lane detection using Simulink. I have a modified RC car with Motor and servo. I am sending the simulink Image processing Algorthm to Raspberry(Rpi) to Arduino via RPI Udp packet

(As short):

-A pi camera detecting the lane using Raspberry pi 3 microcontroller in simulink and sending the control command to Arduino (servo) using RPI UDP send. (am running the model EXTERNAL and Play button in simulink ).
As result : The lane recoginition works good detecting the left and right lane (but my udp sending to arduino servo with Little second delay)

For example: If just a simple constant block in simulink to turn motor ON/off using RPI Udp send packet as #Quick# using arduinio. But If i am running at same time as RPI image capturing and RPI UDp send. The udp block sending 2 second delay to Arduino to control motor/servo.I do not knew, why the udp sending Little delay to arduino ?

-Once if we can deploy the model(by simulink coder) to RPI Hardware (by Standalone), whether it can works without delay ?

Kindly need the advise.

PS: If I have forgotten basic information, do not stone me.

Simulink Fatal error (Deploy to Hardware (Raspberry))

$
0
0
Hi to all,

i have a Simulink model which is running by EXTERNAL mode (To target hardware (Raspberry pi 3)) via wireless. Everythinks works good. Once if the model deploy to Hardware I am facing a fatal error (rtiostream_utils.h: No such file or directory) . Could anybody have a idea to overcome with this problem.

My Project(Lane keeping) based on acquiring Live image from pi camera and controlling the RC CAR (Servo position- to keep the vehicle in lane)

Error from code generation in simulink while deploy to Hardware:

### Generating code into build folder: D:\LaneDetection_T2_exe158_ert_rtw
### Invoking Target Language Compiler on LaneDetection_T2_exe158.rtw
### Using System Target File: C:\Program Files\MATLAB\R2016a\rtw\c\ert\ert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file LaneDetection_T2_exe158.h
.
### Writing header file LaneDetection_T2_exe158_types.h
### Writing source file LaneDetection_T2_exe158.c
### Writing header file LaneDetection_T2_exe158_private.h
### Writing header file rtwtypes.h
### Writing source file LaneDetection_T2_exe158_data.c
.
### Writing header file rtmodel.h
### Writing source file ert_main.c
### TLC code generation complete.
### File v4l2_capture.c associated with S-Function 'v4l2_video_capture_sfcn' (used in 'Tamil_LaneDetection_T2_exe158/V4L2 Video Capture') does not exist
### Evaluating PostCodeGenCommand specified in the model
### Using toolchain: GNU GCC Raspberry Pi v1.0 | gmake (64-bit Windows)
### Creating D:\Tamil_LaneDetection_T2_exe158_ert_rtw\Tamil_LaneDetection_T2_exe158.mk' ...
### Building 'LaneDetection_T2_exe158': make -f LaneDetection_T2_exe158.mk all
### Build procedure for model: 'LaneDetection_T2_exe158' aborted due to an error.
Error executing command "touch -c /home/pi/LaneDetection_T2_exe158_ert_rtw/*.*;make -f LaneDetection_T2_exe158.mk all -C /home/pi/LaneDetection_T2_exe158_ert_rtw". Details:

STDERR: rtiostream_interface.c:31:30: fatal error: rtiostream_utils.h: No such file or directory
 #include "rtiostream_utils.h"
                              ^
compilation terminated.
make: *** [rtiostream_interface.c.o] Error 1

 

Re: Simulink Fatal error (Deploy to Hardware (Raspberry))

$
0
0
Hi,

Having quite the same problem.

## File v4l2_capture.c associated with S-Function 'v4l2_video_capture_sfcn' (used in 'funcionou_luz_verde_2/V4L2 Video Capture') does not exist
### Successful completion of build procedure for model: funcionou_luz_verde_2
Build process completed successfully

Any ideas?

Best!

Re: Simulink Fatal error (Deploy to Hardware (Raspberry))

$
0
0
+1.

"Tamilazhagan Loganathan" wrote in message <o9q2ff$3hr$1@newscl01ah.mathworks.com>...
> Hi to all,
>
> i have a Simulink model which is running by EXTERNAL mode (To target hardware (Raspberry pi 3)) via wireless. Everythinks works good. Once if the model deploy to Hardware I am facing a fatal error (rtiostream_utils.h: No such file or directory) . Could anybody have a idea to overcome with this problem.
>
> My Project(Lane keeping) based on acquiring Live image from pi camera and controlling the RC CAR (Servo position- to keep the vehicle in lane)
>
> Error from code generation in simulink while deploy to Hardware:
>
> ### Generating code into build folder: D:\LaneDetection_T2_exe158_ert_rtw
> ### Invoking Target Language Compiler on LaneDetection_T2_exe158.rtw
> ### Using System Target File: C:\Program Files\MATLAB\R2016a\rtw\c\ert\ert.tlc
> ### Loading TLC function libraries
> ### Initial pass through model to cache user defined code
> ### Caching model source code
> ### Writing header file LaneDetection_T2_exe158.h
> .
> ### Writing header file LaneDetection_T2_exe158_types.h
> ### Writing source file LaneDetection_T2_exe158.c
> ### Writing header file LaneDetection_T2_exe158_private.h
> ### Writing header file rtwtypes.h
> ### Writing source file LaneDetection_T2_exe158_data.c
> .
> ### Writing header file rtmodel.h
> ### Writing source file ert_main.c
> ### TLC code generation complete.
> ### File v4l2_capture.c associated with S-Function 'v4l2_video_capture_sfcn' (used in 'Tamil_LaneDetection_T2_exe158/V4L2 Video Capture') does not exist
> ### Evaluating PostCodeGenCommand specified in the model
> ### Using toolchain: GNU GCC Raspberry Pi v1.0 | gmake (64-bit Windows)
> ### Creating D:\Tamil_LaneDetection_T2_exe158_ert_rtw\Tamil_LaneDetection_T2_exe158.mk' ...
> ### Building 'LaneDetection_T2_exe158': make -f LaneDetection_T2_exe158.mk all
> ### Build procedure for model: 'LaneDetection_T2_exe158' aborted due to an error.
> Error executing command "touch -c /home/pi/LaneDetection_T2_exe158_ert_rtw/*.*;make -f LaneDetection_T2_exe158.mk all -C /home/pi/LaneDetection_T2_exe158_ert_rtw". Details:
>
> STDERR: rtiostream_interface.c:31:30: fatal error: rtiostream_utils.h: No such file or directory
> #include "rtiostream_utils.h"
> ^
> compilation terminated.
> make: *** [rtiostream_interface.c.o] Error 1
>
>

Re: Simulink Fatal error (Deploy to Hardware (Raspberry))

$
0
0
P.S. My board is the Arduino Mega 2650.

Re: Simulink Fatal error (Deploy to Hardware (Raspberry))

$
0
0
Bottom of the page here:

https://www.mathworks.com/help/supportpkg/usrpembeddedseriesradio/ug/troubleshooting-hardware-software-co-design.html

Solution is to set the board to external mode.
My board has been working in External mode -
I'm now trying to get it out of External mode.

I first had the warning that,
even though the simulation was set in Normal mode,
the parameter ExtMode was set to 'on' when I tried to build.

I manually set_param('<model>', 'ExtMode', 'off') to fix this,
but this error persists.
I believe the code is not recognizing the conversion back to normal mode,
and I am not sure how to handle this.

Re: Simulink Fatal error (Deploy to Hardware (Raspberry))

$
0
0
My model was a simple:
limited counter --> convert: uint8 --> serial read (COM 0)

Removing the serial read, and letting optimizer build a blank model had same error.

I tried a basic "blinking LED" model file.
This built from external mode.
This built from normal mode.

I pasted the same model blocks into the problematic model file.
This build from normal mode failed.

I made a new blank model,
reconfigured the board settings to what they needed to be,
and built the blinking LED model with success.

I built the original setup, but still without the serial read.
This built from normal mode.

I built the original setup.
This built from normal mode.

I believe the solution is to begin a new model.
I'm sorry that it is not something more intuitive.

Re: unable to build simulink by real time workshop

$
0
0
"hemant chawla" wrote in message <h9l118$bla$1@fred.mathworks.com>...
> i am trying to build viptrackpeople_win by real time workshop . the system target file that i selected is grt.tlc for visual studio 9.0 (ms visual c++ 2008 express edition) .
> viptrackpeople_win
> ### Starting Real-Time Workshop build procedure for model: viptrackpeople_win
> ### Generating code into build directory: C:\Users\Hemant\Documents\MATLAB\viptrackpeople_win_grt_rtw
> ### Invoking Target Language Compiler on viptrackpeople_win.rtw
> tlc
> -r
> C:\Users\Hemant\Documents\MATLAB\viptrackpeople_win_grt_rtw\viptrackpeople_win.rtw
> D:\MATLAB\R2007a\rtw\c\grt\grt.tlc
> -OC:\Users\Hemant\Documents\MATLAB\viptrackpeople_win_grt_rtw
> -ID:\MATLAB\R2007a\rtw\c\grt
> -ID:\MATLAB\R2007a\toolbox\dspblks\dspmex\tlc_c
> -ID:\MATLAB\R2007a\toolbox\simulink\fixedandfloat\tlc_c
> -ID:\MATLAB\R2007a\toolbox\vipblks\vipmex\tlc_c
> -IC:\Users\Hemant\Documents\MATLAB\viptrackpeople_win_grt_rtw\tlc
> -ID:\MATLAB\R2007a\rtw\c\tlc\mw
> -ID:\MATLAB\R2007a\rtw\c\tlc\lib
> -ID:\MATLAB\R2007a\rtw\c\tlc\blocks
> -ID:\MATLAB\R2007a\rtw\c\tlc\fixpt
> -ID:\MATLAB\R2007a\stateflow\c\tlc
> -aEnforceIntegerDowncast=1
> -aFoldNonRolledExpr=1
> -aInlineInvariantSignals=0
> -aInlineParameters=0
> -aLocalBlockOutputs=1
> -aRollThreshold=5
> -aZeroInternalMemoryAtStartup=1
> -aZeroExternalMemoryAtStartup=1
> -aInitFltsAndDblsToZero=1
> -aGenerateReport=0
> -aGenCodeOnly=0
> -aRTWVerbose=1
> -aIncludeHyperlinkInReport=0
> -aLaunchReport=0
> -aForceParamTrailComments=0
> -aGenerateComments=1
> -aIgnoreCustomStorageClasses=1
> -aIncHierarchyInIds=0
> -aMaxRTWIdLen=31
> -aShowEliminatedStatements=0
> -aPrefixModelToSubsysFcnNames=1
> -aIncDataTypeInIds=0
> -aInsertBlockDesc=0
> -aSimulinkBlockComments=1
> -aInlinedPrmAccess="Literals"
> -aTargetFcnLib="ansi_tfl_tmw.mat"
> -aIsPILTarget=0
> -aLogVarNameModifier="rt_"
> -aGenerateFullHeader=1
> -aExtMode=0
> -aExtModeStaticAlloc=0
> -aExtModeTesting=0
> -aExtModeStaticAllocSize=1000000
> -aExtModeTransport=0
> -aRTWCAPISignals=0
> -aRTWCAPIParams=0
> -aGenerateASAP2=0
> -p10000
>
>
> ### Loading TLC function libraries
>
> .....
> ### Initial pass through model to cache user defined code
> ..................
> ### Caching model source code
> ...............................................................................
> ................................................................
> ### Writing header file viptrackpeople_win_types.h
> ### Writing header file viptrackpeople_win.h
> ### Writing source file viptrackpeople_win.c
> ### Writing header file viptrackpeople_win_private.h
> .
> ### Writing header file rtmodel.h
> ### Writing source file viptrackpeople_win_data.c
> ### Writing header file rt_nonfinite.h
> ### Writing source file rt_nonfinite.c
> .
> ### TLC code generation complete.
> .
> ### Processing Template Makefile: D:\MATLAB\R2007a\rtw\c\grt\grt_vc.tmf
> ### Real-Time Workshop build procedure for model: 'viptrackpeople_win' aborted due to an error.
> >>
>
> it outputs following error message :
>
>
> Error building Real-Time Workshop target for block diagram 'viptrackpeople_win'. MATLAB error message:
> Error using ==> issue_inv_comp_env_val_error.p>issue_inv_comp_env_val_error at 47
> Invalid setting for environment variable MSDevDir or DevEnvDir.
> The setting is: 'c:\program files\microsoft visual studio\common\msdev98'
> You can verify the setting by checking for the existence of:
> %DevEnvDir%\..\tools\vsvars32.bat (for Visual C/C++ 7.1)
> %MSDevDir%\..\..\vc98\bin\vcvars32.bat (for Visual C/C++ 6.0)
>
> please guide me how to resolve the error . thanks in advance ..
> hemant

Re: How to reduce step size in SIMULINK

$
0
0
"Phil Goddard" wrote in message <l5kkk6$cvd$1@newscl01ah.mathworks.com>...
> Chances are that you have an inf or nan and hence reducing the step size will make no difference.
> But to do so you use the Solver options on the Simulation->Model Configuration Parameters menu.
>
> Phil.

i am getting the same message .Is there any other methods to resolve this problem

$
0
0
"Phil Goddard" wrote in message <l5kkk6$cvd$1@newscl01ah.mathworks.com>...
> Chances are that you have an inf or nan and hence reducing the step size will make no difference.
> But to do so you use the Solver options on the Simulation->Model Configuration Parameters menu.
>
> Phil.

linking of ga and simulink

$
0
0
i need to implement genetic algorithm in simulink, how can i call my function from simulink matlab function block. please help me
the basic command to implement genetic algorithm in matlab is [x,fval]=ga(@fitnessfunction, no.ofvariables). To implement i need to define a fitness function. But in my simulink model i am using matlab function block which generates mex file. So how can i implement ga in simulink if using matlab function block. can somebody give me an simple example of implementing ga in simulink.

Counting the numbers in a binary

$
0
0
Hi,

I am trying to count the numbers in a binary.

I found this code below on another post. It works great but it only counts the 1's and not the 0's. I am trying to figure out how I can change this code so k = both the 1's and the 0's.

function k = countones(x)
 bb = 2.^(1:20);
 k = 0;
 while x > 0
    x = x - 2^max( find( x >= bb));
    k = k + 1;
 end

Putting this code into a matlab function block and using a constant data block with "bin2dec('10101010')" as the input. My output will be 4, if I can count both the 1's and 0's my output would be 8.

I appreciate any help you guys can provide.

Re: Counting the numbers in a binary

$
0
0
On 04/01/2017 11:13 PM, Steed wrote:
> Hi,
>
> I am trying to count the numbers in a binary.
>
> I found this code below on another post. It works great but it only
> counts the 1's and not the 0's. I am trying to figure out how I can
> change this code so k = both the 1's and the 0's.
>
> function k = countones(x)
> bb = 2.^(1:20);
> k = 0;
> while x > 0
> x = x - 2^max( find( x >= bb));
> k = k + 1;
> end
>
> Putting this code into a matlab function block and using a constant data
> block with "bin2dec('10101010')" as the input. My output will be 4, if I
> can count both the 1's and 0's my output would be 8.

The count of both 0|1 is simply

count=length(x);

where x is the string, no need to convert to numeric as all that does is
remove leading zeros.

 >> length('10101010')
ans =
      8
 >>

The function countones is quite inefficient as well--

 >> countem=@(x) sum(dec2bin(x)=='1')
countem =
     @(x)sum(dec2bin(x)=='1')
 >> countem(170)
ans =
      4
 >>

--

Simulink Lookup Table Input

$
0
0
Dear World,

I am trying to input a vector that is not monotonically increasing as the input of my 1-dimensional lookup table, but cannot find a way to do it. Could anybody provide some assistance? Thank you.
Viewing all 316 articles
Browse latest View live


Latest Images