Opened 4 years ago

Last modified 3 years ago

#6079 new defect

Conflict between modelica_synchronous and pulse source

Reported by: p.van.der.hulst@… Owned by: Karim Adbdelhak
Priority: high Milestone:
Component: Backend Version:
Keywords: Cc: bernhard.thiele@…

Description

Hi,
I implemented a wrapping counter using the modelica_synchronous framework. There is also a pulse source in the same model, with the same period value.
The presence of this source triggers the problem:

Instead of incrementing at the same frequency as the pulse source, the counter doesn't increment until the 7th period.
A hold function behind the wrapping counter outputs impulses, so something is going very wrong.
After working properly for 7 periods, the counter stops
See the attached image.
When the pulse source is removed or set to a different period, the wrapping counter behaves as expected.

Does anyone have a clue what's happening here?

Best regards,
Paul van der Hulst

Attachments (2)

wrapping_counter.png (17.4 KB ) - added by p.van.der.hulst@… 4 years ago.
Graphical output of erroneous model
Malcolm3.mo (827 bytes ) - added by p.van.der.hulst@… 4 years ago.
The model showing the problem

Download all attachments as: .zip

Change History (6)

by p.van.der.hulst@…, 4 years ago

Attachment: wrapping_counter.png added

Graphical output of erroneous model

by p.van.der.hulst@…, 4 years ago

Attachment: Malcolm3.mo added

The model showing the problem

comment:1 by Francesco Casella, 4 years ago

I tried to run the test case in Dymola. This is the outcome

Continuous time parts and discrete parts don't decompose for:
Clock_0.isTicking
cSample.isTicking
y

Equations:
equation
when cSample then
y = (if time <= 0 or previous(y) == 5 then 1 else previous(y)+1);
end when;
cSample = Clock_0;
Clock_0 = Clock(period);

Decomposition in base clocks failed.
See the file dsmodelBaseClockDecomposition0.mof.

----------- dsmodelBaseClockDecomposition0.mof file
// Base-clock decomposition
// An erroneous non-decomposible partition of continuous time and discrete time parts.
// 
// clock variables
  Clock_0
  cSample
// clock equation
  cSample = Clock_0;
  Clock_0 = Clock(period);
// unknowns
  y
// equation
  when cSample then
    y = (if time <= 0 or previous(y) == 5 then 1 else previous(y)+1);
  end when;
// 
// 
// Continuous time partition.
// 
// unknowns
  yhold
// equation
  yhold = hold(y);
// 
// 
// Continuous time partition.
// 
// unknowns
  phi1.count
  phi1.T_start
  phi1.T_width
  phi1.y
// equation
  when integer((time-phi1.startTime)/phi1.period) > pre(phi1.count) then
    phi1.count = pre(phi1.count)+1;
    phi1.T_start = time;
  end when;
  phi1.y = phi1.offset+(if time < phi1.startTime or phi1.nperiod == 0 or 
    phi1.nperiod > 0 and phi1.count >= phi1.nperiod then 0 else (if time < 
    phi1.T_start+phi1.T_width then phi1.amplitude else 0));
  phi1.T_width = 0.01*(phi1.period*phi1.width);

I am not too familiar with clocked systems, I hope this helps

comment:2 by Francesco Casella, 4 years ago

Cc: bernhard.thiele@… added
Component: *unknown*Backend
Milestone: Future1.17.0
Owner: changed from somebody to Karim Adbdelhak

comment:3 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:4 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.