Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » indieflunk
  • » Profile

Posts

Posts

Jan-25-20 12:48:44
I want use a Counter in my dual slope ADC. So i want use the Counter in Modelica Liberary in...

the output of Counter (digital) is always 'unknown' (2). It should be '0' (3) or '1'(4). So i check the Model, and the problem is at the first JK FilpFlop. But i don't know why the 'Q' output is always 'unknown'.  And I simulation the the counter3 (Counter with 3 bits lang output),the output is all right Hier is the output course of Counter and Counter3.  Can someone tell me, whether the Counter is wrong.

Jan-17-20 16:41:38
Category: Programming

I try to write a Block decoder, which a part of ADC is. The Input and output are digital vector, which consist of logic '1' or '0'. the input vector is 1023bits (1023=2^10-1) lang and the output vector is 10 bits lang, when the ADC 10 bits has.

the ideal of the decoder is: First, i get the number of '1' in input vector. Than I use the function div() and mod() to change the numeber in decimal system to binary system. For the Rest of Digitaloutput i give all bits '0'.

But the compiler said that " The given system is mixed-determined. [index > 3] Please checkout the option "--maxMixedDeterminedIndex". "

Than I deleted the initial algorithm and put it in algorithm. But the Output don't have beginvalue and 'Chattering detected around time 0..9.22009327831e-011 (100 state events in a row with a total time delta less than the step size 0.002). This can be a performance bottleneck. Use -lv LOG_EVENTS for more information. The zero-crossing was: div(decoder1.a, 2, 2)'


```
block decoder
  parameter Integer Res(min = 1, start = 10, fixed = true);
  parameter Integer Step(min = 1, start = 1023, fixed = true);
  //Resolution
  Modelica.Electrical.Digital.Interfaces.DigitalInput result[Step] annotation(
    Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Digital.Interfaces.DigitalOutput Binary[Res] annotation(
    Placement(visible = true, transformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Integer a;
  Integer b;
  import L = Modelica.Electrical.Digital.Interfaces.Logic;
  Modelica.Electrical.Digital.Interfaces.DigitalInput De_clk annotation(
    Placement(visible = true, transformation(origin = {-6, 98}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-6, 98}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

initial algorithm
  for i in 1:Res loop
    Binary[i] := L.'0';
  end for;

algorithm
  a := 0;
  b := 0;
  if De_clk == L.'1' or De_clk == L.'H' then
    for i in 1:Step loop
      if result[i] == L.'1' then
        a := a + 1;
      end if;
    end for;
    while div(a, 2) <> 0 loop
      when mod(a, 2) == 1 then
        Binary[Res - b] := L.'1';
      end when;
      when mod(a, 2) == 0 then
        Binary[Res - b] := L.'0';
      end when;
      a := div(a, 2);
      b := b + 1;
    end while;
    Binary[Res - b] := L.'1';
  end if;
  if Res - b - 1 > 0 then
    for i in 1:Res - b - 1 loop
      Binary[i] := L.'0';
    end for;
  end if;
equation

end decoder;
```
I don't have a ideal to fixed. Should i write the initial algorithmus or not?

Jan-17-20 16:34:56
I want write a block,which generate a vector with logic value.But compiler say, The given system...
Category: Programming

i delete the initial algrorithm and it does work. thank!

Jan-16-20 21:19:38
I want write a block,which generate a vector with logic value.But compiler say, The given system...
Category: Programming

I want write a block,which generate a vector with logic value.But compiler say, The given system is mixed-determined.   [index > 3].  I have no idea, how can i fix the bug. Can someone give me a suggest.

model vektor_maker

import L = Modelica.Electrical.Digital.Interfaces.Logic;
parameter Integer Step(start=1023);
parameter Integer Anzahl(start=500);
Modelica.Electrical.Digital.Interfaces.DigitalOutput out[Stufe] annotation(
    Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

initial algorithm

for i in 1:Step loop
  out[i]:= L.'0';
end for;

algorithm

  if Anzahl <= Step then
    for i in 1:Anzahl loop
    out[i] := L.'1';
  end for;
for i in Anzahl+1:Step loop
out[i] := L.'0';
end for;
   end if;
   
  if Anzahl > Step then
    for i in 1:Step loop
      out[i] := L.'1';
    end for;
  end if;

equation

end vektor_maker;


Thanks in advance.

Jan-16-20 20:57:28
i want to write a block to make vector with logic(Digitaloutput). But the compiler say, "...
Category: Programming

model vektor_maker
import L = Modelica.Electrical.Digital.Interfaces.Logic;
parameter Integer Step(start=1023);
parameter Integer Anzahl(start=500);
Modelica.Electrical.Digital.Interfaces.DigitalOutput out[Stufe] annotation(
    Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

initial algorithm

for i in 1:Step loop
  out[i]:= L.'0';
end for;

algorithm

  if Anzahl <= Step then
    for i in 1:Anzahl loop
    out[i] := L.'1';
  end for;
for i in Anzahl+1:Step loop
out[i] := L.'0';
end for;
   end if;
   
  if Anzahl > Step then
    for i in 1:Step loop
      out[i] := L.'1';
    end for;
  end if;

equation



end vektor_maker;

  • Index
  • » Users
  • » indieflunk
  • » Profile
You are here: