Message Boards Message Boards

0
|
8560 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

how to define a variable of type digital output

Posted 10 years ago

i want to allot a value of 1 or 0 to the digital output y in the following text view

model aaa2
  Modelica.Blocks.Interfaces.RealInput u 
  Modelica.Electrical.Digital.Interfaces.DigitalOutput y 
algorithm
  if u > 2 ^ 2 then
    y := logic ('1');
  elseif u < 2 ^ 2 then
    y := logic ('0');
  end if 
end aaa2;
Attachments:
POSTED BY: manu gaurav
3 Replies
Posted 10 years ago

If you insist on using an algorithm section inside a model, then this is one way to do it:

  if u > 4 then
    y := y.'1';
  elseif u < 4 then
    y := y.'0';
  end if;
POSTED BY: Johan Rhodin

no john, if you will see this is not a block, but the modelica language script. the question is how in script i can allot a logic value '1' to a digital signal

POSTED BY: manu gaurav
Posted 10 years ago

Hi Manu,

In the pasted Modelica text you are using a DigitalOutput. If this is what you want the Modelica.Electrical.Digital.Converters.RealToLogic converts between a real valued signal and a digital interface.

In the attached model you are using RealInput and BooleanOutput that seems to be constructed to switch between true and false depending on a threshold value (2^2) Is that the type of component you want? If so, I'd recommend to use the Modelica.Blocks.Logical.GreaterEqualThreshold component instead, which does that.

POSTED BY: Johan Rhodin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract