Last change
on this file since 992 was
926,
checked in by Rafael de Pelegrini Soares, 12 years ago

Added a simple open/close timer sample

File size:
587 bytes

Line  

1  

2  using "types"; 

3  

4  FlowSheet sample_timer 

5  PARAMETERS 

6  Timer as Switcher(Valid = ["closed", "opened"], Default = "closed"); 

7  

8  TimeOpened as time_sec; 

9  TimeClosed as time_sec; 

10  

11  VARIABLES 

12  Clock as Real; 

13  flow as flow_vol; 

14  

15  SET 

16  TimeOpened = 2*'s'; 

17  TimeClosed = 4*'s'; 

18  

19  EQUATIONS 

20  

21  switch Timer 

22  case "closed": 

23  flow = 0 * 'm^3/h'; 

24  

25  diff(Clock) = 1/TimeClosed; 

26  when Clock > 1 switchto "opened"; 

27  

28  case "opened": 

29  flow = 1 * 'm^3/h'; 

30  

31  diff(Clock) = 1/TimeOpened; 

32  when Clock < 0 switchto "closed"; 

33  end 

34  

35  INITIAL 

36  Clock = 0; 

37  

38  OPTIONS 

39  TimeStep = 0.1; 

40  end 

41  

Note: See
TracBrowser
for help on using the repository browser.