How to saturate a variable according to my range in RTW embedded coder

Hi, I 'm generating an Auto code using an RTW embedded coder. I'm facing staturation issue when i tested the code. problem is saturating my variable according to my range of that variable is not taking, it takes as per the datatype of variable.
For ex: input variable name : abc
range : [0..255]
datatype: uint8
output variable name: out
range: [0..254]
datatype: uint8
implementation in model is out = abc + 1
generated code for this add block will be like
tmp = abc + 1 ;
if(tmp >255)
{
out = 255;
}else{
out = tmp;
}
Now out variable range will be limited to 255 but i need it till 254
How to set the staturation with my range for an output variable.
please help me!!!
Thanks and Regards, Nithin

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 5월 18일

0 개 추천

What about using the Saturation block at the output?

댓글 수: 1

Hi Kaustubha,
Our Model design rule doesnt allow us to not add stauration block in model, but in addition block i have checked the saturation to overflow and also for outport of add block (i.e) out specifying the range as [0..254] but still code is generated like what i said earlier..
Is there any other option to be checked in model

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by