Engineering System Design

 How to model a timer/countdown in statechart?

Jump to  Best Answer
Tung Nguyen's profile image
Tung Nguyen posted Mon November 25, 2024 10:16 PM

Hello guys,

I want to make for example, an attribute named: attTime & when light On, attTime will be counting down by 1 each second, after attTime hit 0, transition to light Off. Like picture below.

I tried to set [attTime = 0] but the simulation seems to end right away.

Thanks in advance.

steve rooks's profile image
steve rooks  Best Answer

Try ==
= is assignment 

== is equivalence 

Andy Lapping's profile image
Andy Lapping IBM Champion

Also consider using a condition - 'null' triggered transitions are not generally recommended.

Markus Nordstrand's profile image
Markus Nordstrand

This is how I did it: