Wiki source code of Tutorial 1 - als
Last modified by ssm on 2025/01/30 12:05
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | === T1A1: Important Thoughts === | ||
2 | |||
3 | ===== a) a real-time system ===== | ||
4 | |||
5 | The railway is a real-time system because it is a reactive system were the environment causes and dictates the interaction. | ||
6 | |||
7 | Furthermore there are real time constrains for reaction time of the system because a delayed reaction may cause an accident. | ||
8 | |||
9 | ===== b) an embedded system ===== | ||
10 | |||
11 | The railway controller needs special hardware, protocols and embedded processors to interact with components. | ||
12 | |||
13 | It does not need any keyboard or display to run and function correctly. | ||
14 | |||
15 | So it is not a standalone system for a desktop PC but a an embedded system integrated into to the railway. | ||
16 | |||
17 | ===== c) a safety-critical system ===== | ||
18 | |||
19 | It is a safety-critical system because most failures will directly endanger environment and hence people in and around the train. | ||
20 | |||
21 | So if the system crashes or hangs up the environment will not stop as well, so each error has safety-critical aspects. | ||
22 | |||
23 | === T1A2: C Interface === | ||
24 | |||
25 | ===== Plan ===== | ||
26 | |||
27 | (% style="margin-left: 30.0px;" %) | ||
28 | ~1. Leave KH_ST_1 | ||
29 | |||
30 | * Set point 8 straight and 9 to branch | ||
31 | * Power KH_ST_1 and KH_ST_6 forward with 60 | ||
32 | |||
33 | (% style="margin-left: 30.0px;" %) | ||
34 | 2. Pass KIO_LN_1 | ||
35 | |||
36 | * | ||
37 | ** Power KIO_LN_1 foward with 60 | ||
38 | |||
39 | (% style="margin-left: 30.0px;" %) | ||
40 | 3. Goto inner circle and enter IC_ST_1 | ||
41 | |||
42 | * | ||
43 | ** Set point 27 & 28 straight | ||
44 | ** Set point 29 to branch | ||
45 | ** Set point 24 straight | ||
46 | ** Power OC_ST_0 foward with 60 | ||
47 | ** Power IC_ST_4 reverse with 60 | ||
48 | ** Power IC_ST_1 reverse with 60 | ||
49 | |||
50 | (% style="margin-left: 30.0px;" %) | ||
51 | 4. Slow down | ||
52 | |||
53 | * | ||
54 | ** Wait for contact 1 of IC_ST_1 triggered | ||
55 | ** Power IC_ST_1 reverse with 20 | ||
56 | |||
57 | (% style="margin-left: 30.0px;" %) | ||
58 | 5. Stop and wait | ||
59 | |||
60 | * | ||
61 | ** Wait for contact 0 of IC_ST_1 triggered | ||
62 | ** Brake on IC_ST_1 | ||
63 | ** Wait 5 sec | ||
64 | |||
65 | (% style="margin-left: 30.0px;" %) | ||
66 | 6. Leaving IC_ST_1 to outer circle | ||
67 | |||
68 | * | ||
69 | ** Set point 20 straight | ||
70 | ** Set point 16, 17, 18 to branch | ||
71 | ** Power IC_ST_1 reverse with 60 | ||
72 | ** Power IC_ST_0 reverse with 60 | ||
73 | ** Power OC_ST_4 foward with 60 | ||
74 | |||
75 | (% style="margin-left: 30.0px;" %) | ||
76 | 7. Pass KIO_LN_1 | ||
77 | |||
78 | * | ||
79 | ** Power KIO_LN_0 foward with 60 | ||
80 | |||
81 | (% style="margin-left: 30.0px;" %) | ||
82 | 8. Enter KH_ST_1 | ||
83 | |||
84 | * | ||
85 | ** Set point 0 and 1 to branch | ||
86 | ** Set point 2, 3, 4 straight | ||
87 | ** Power KH_ST_0 foward with 60 | ||
88 | ** Power KH_ST_1 foward with 60 | ||
89 | |||
90 | (% style="margin-left: 30.0px;" %) | ||
91 | 9. Slow down | ||
92 | |||
93 | * | ||
94 | ** Wait for contact 0 of KH_ST_1 triggered | ||
95 | ** Power KH_ST_1 forward with 20 | ||
96 | |||
97 | (% style="margin-left: 30.0px;" %) | ||
98 | 10. Stop and wait | ||
99 | |||
100 | * | ||
101 | ** Wait for contact 1 of KH_ST_1 triggered | ||
102 | ** Brake on KH_ST_1 | ||
103 | ** Wait 5 sec | ||
104 | |||
105 | (% style="margin-left: 30.0px;" %) | ||
106 | ~11. Continue at 1. | ||
107 | |||
108 | ===== Code ===== | ||
109 | |||
110 | [[attach:T1A2_Controller.c]] | ||
111 | |||
112 | === T1A3: Reality vs. Simulation === | ||
113 | |||
114 | ===== 1. Differing Expectations ===== | ||
115 | |||
116 | There were no real initial expectations (preventing disappointments). | ||
117 | |||
118 | But I expected modelGUI and controller-simulation to be a bit more stable in cases of restarts after recompiling. | ||
119 | |||
120 | ===== 2. Expected differences between the simulation and the real model railway ===== | ||
121 | |||
122 | * Reactions to e.g. speed changes will not be immediate in the real model railway as they are in the simulation due to physical processes. | ||
123 | * No all trains will have the same behaviors in cases of speed, acceleration and breaking. Each real engine will behave a bit different. | ||
124 | * Unreliable triggering contacts causing inaccuracies in calculation of speed or direction of triggering train. | ||
125 | * Simulation can proceed with errors. On the real model railway an illegal configuration of tracks will cause a short shot or derail. In the simulation such errors are indicated as e.g. E_MOTORMODE_MISMATCH or E_SPEED_MISMATCH but may have no effect on the simulation. | ||
126 | * It is possible to have high acceleration in simulation even if real trains may fall apart. | ||
127 | |||
128 |