acme-002.awl 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. DATA_BLOCK DB 1
  2. TITLE =
  3. AUTHOR : Xaadem
  4. VERSION : 0.1
  5. STRUCT
  6. OUT_FIL : REAL := 2.000000e+001; //Filter OUTPUT
  7. END_STRUCT ;
  8. BEGIN
  9. OUT_FIL := 2.000000e+001;
  10. END_DATA_BLOCK
  11. FUNCTION FC 170 : WORD
  12. TITLE =SCALING VALUES
  13. //
  14. AUTHOR : SEA
  15. FAMILY : CONVERT
  16. NAME : SCALE
  17. VERSION : 2.0
  18. VAR_INPUT
  19. IN : INT ; // input value to be scaled
  20. HI_LIM : REAL ; // upper limit in engineering units
  21. LO_LIM : REAL ; // lower limit in engineering units
  22. BIPOLAR : BOOL ; // 1=bipolar; 0=unipolar
  23. END_VAR
  24. VAR_OUTPUT
  25. OUT : REAL ; // result of the scale conversion
  26. END_VAR
  27. VAR_TEMP
  28. IN_REAL : REAL ; // input value as a REAL number
  29. K1 : REAL ; // low limit for input value
  30. K2 : REAL ; // high limit for input value
  31. SPAN : REAL ; // HI_LIM - LO_LIM
  32. TEMP1 : REAL ; // temporary result
  33. END_VAR
  34. BEGIN
  35. NETWORK
  36. TITLE =
  37. //
  38. // set K1 and K2 constants based upon BIPOLAR
  39. //
  40. SET ; // if(BIPOLAR=0)
  41. A #BIPOLAR; // .
  42. JC EL01; // {
  43. L 0.000000e+000; // K1=0
  44. T #K1; // .
  45. JU EI01; // } else {
  46. EL01: L -2.764800e+004; // K1=-27648.0
  47. T #K1; // .
  48. EI01: NOP 0; // }
  49. L 2.764800e+004; // K2=+27648.0
  50. T #K2; // .
  51. //
  52. // convert input (IN) to real
  53. //
  54. L #IN; // ACC1=IN
  55. ITD ; // convert to double integer
  56. DTR ; // convert to real
  57. T #IN_REAL; // IN_REAL-IN as a real
  58. //
  59. // determine SPAN = HI_LIM - LO_LIM
  60. //
  61. L #HI_LIM; // SPAN=HI_LIM-LO_LIM
  62. L #LO_LIM; // .
  63. -R ; // .
  64. T #SPAN; // .
  65. //
  66. // If the input value is outside the K1 and K2 range, the output
  67. // is clamped to the nearer of either the LO_LIM or the HI_LIM
  68. // and an error is logged. If the input value is exactly at a limit the
  69. // output will be set to the computed limit with no error returned.
  70. //
  71. L #IN_REAL; // if(IN_REAL<K1)
  72. L #K1; // .
  73. >=R ; // .
  74. JC EL02; // {
  75. L 8; // error
  76. T #RET_VAL; // .
  77. L #SPAN; // if(SPAN<0)
  78. L 0.000000e+000; // .
  79. <R ; // .
  80. JCN EL03; // {
  81. L #HI_LIM; // ACC1=HI_LIM
  82. JU EI03; // } else {
  83. EL03: L #LO_LIM; // ACC1=LO_LIM
  84. EI03: NOP 0; // }
  85. T #OUT; // OUT=ACC1
  86. JU FAIL; // error
  87. EL02: POP ; // } else {
  88. L #K2; // if(IN_REAL>K2)
  89. <=R ; // .
  90. JC EI04; // {
  91. L 8; // error
  92. T #RET_VAL; // .
  93. L #SPAN; // if(SPAN<0)
  94. L 0.000000e+000; // {
  95. <R ; // .
  96. JCN EL05; // .
  97. L #LO_LIM; // ACC1=LO_LIM
  98. JU EI05; // } else {
  99. EL05: L #HI_LIM; // ACC1=HI_LIM
  100. EI05: NOP 0; // }
  101. T #OUT; // OUT=ACC1
  102. JU FAIL; // error
  103. EI04: NOP 0; // }
  104. NOP 0; // }
  105. //
  106. // scale the input
  107. //
  108. L #K2; // TEMP1=K2-K1
  109. L #K1; // .
  110. -R ; // .
  111. T #TEMP1; // .
  112. L #IN_REAL; // IN_REAL-K1
  113. L #K1; // .
  114. -R ; // .
  115. L #TEMP1; // divide by TEMP1
  116. /R ; // .
  117. L #SPAN; // multiply by SPAN
  118. *R ; // .
  119. L #LO_LIM; // add LO_LIM
  120. +R ; // .
  121. T #OUT; // OUT=scale(IN_REAL)
  122. //
  123. // set BR bit : no error-set BR bit to 1; with error-set BR bit to 0.
  124. //
  125. L 0; // return error code 0
  126. T #RET_VAL; //
  127. SET ; // RLO = 1 (NO ERROR)
  128. JU SVBR; //
  129. FAIL: CLR ; // RLO = 0 (ERROR)
  130. SVBR: SAVE ; // BR = RLO
  131. END_FUNCTION
  132. FUNCTION FC 185 : VOID
  133. TITLE =F I L T E R
  134. { Know_How := '1' }
  135. AUTHOR : Xaadem
  136. NAME : FILTER
  137. VERSION : 0.1
  138. VAR_INPUT
  139. XE : REAL ; //Input Word
  140. FAC_PERCENT : REAL ; //Smoothing factor in %
  141. INIT : BOOL ; //Initialisation flag, should be set during CPU start-up
  142. END_VAR
  143. VAR_OUTPUT
  144. XA : REAL ; //Output of measuring value which is smoothed
  145. END_VAR
  146. VAR_IN_OUT
  147. AUX : REAL ; //Auxiliary word
  148. END_VAR
  149. VAR_TEMP
  150. MD232 : REAL ; //Temporary value
  151. MD204 : REAL ; //Temporary value
  152. MD208 : REAL ; //Temporary value
  153. MD212 : REAL ; //Temporary value
  154. MD216 : REAL ; //Temporary value
  155. MD220 : REAL ; //Temporary value
  156. AUX1 : REAL ; //Temporary value
  157. END_VAR
  158. BEGIN
  159. NETWORK
  160. TITLE =read XE input
  161. L #XE;
  162. T #MD232;
  163. NOP 0;
  164. NETWORK
  165. TITLE =
  166. AN #INIT;
  167. JC M001;
  168. NETWORK
  169. TITLE =Initialisation !!
  170. M003: L #XE;
  171. T #XA;
  172. NOP 0;
  173. NETWORK
  174. TITLE =Initialisation !!
  175. L #MD232;
  176. T #AUX;
  177. NOP 0;
  178. NETWORK
  179. TITLE =Jump to the end
  180. A M 20.1;
  181. JC M002;
  182. NETWORK
  183. TITLE =Old and new value are equal
  184. M001: A( ;
  185. L #MD232;
  186. L #AUX;
  187. ==R ;
  188. ) ;
  189. JNB _001;
  190. L #MD232;
  191. T #XA;
  192. _001: NOP 0;
  193. NETWORK
  194. TITLE =Old and new value are equal
  195. L #MD232;
  196. L #AUX;
  197. ==R ;
  198. SAVE ;
  199. BEC ;
  200. NETWORK
  201. TITLE =If Fac_Prozent > 0 ==> XA=Xe
  202. L #FAC_PERCENT;
  203. L 0.000000e+000;
  204. <R ;
  205. JC M003;
  206. NETWORK
  207. TITLE =If Fac_Prozent > 100 ==> XA=Xe
  208. L #FAC_PERCENT;
  209. L 1.000000e+002;
  210. >R ;
  211. JC M003;
  212. NETWORK
  213. TITLE =B=XE-XA
  214. L #MD232;
  215. L #AUX;
  216. -R ;
  217. T #MD204;
  218. NOP 0;
  219. NETWORK
  220. TITLE =Move factor into temporary word
  221. L #FAC_PERCENT;
  222. T #MD212;
  223. NOP 0;
  224. NETWORK
  225. TITLE =B*Factor
  226. L #MD212;
  227. L #MD204;
  228. *R ;
  229. T #MD216;
  230. NOP 0;
  231. NETWORK
  232. TITLE =B*Factor / 100
  233. L #MD216;
  234. L 1.000000e+002;
  235. /R ;
  236. T #MD220;
  237. NOP 0;
  238. NETWORK
  239. TITLE =XANew = AUX+(B*Factor% / 100)
  240. L #AUX;
  241. L #MD220;
  242. +R ;
  243. T #AUX;
  244. NOP 0;
  245. NETWORK
  246. TITLE =XAnew = AUXnew
  247. L #AUX;
  248. T #XA;
  249. NOP 0;
  250. NETWORK
  251. TITLE =End of block
  252. M002: A M 20.1;
  253. SAVE ;
  254. BEC ;
  255. END_FUNCTION
  256. ORGANIZATION_BLOCK OB 1
  257. TITLE = "Main Program Sweep (Cycle)"
  258. AUTHOR : Xaadem
  259. VERSION : 0.1
  260. VAR_TEMP
  261. OB1_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)
  262. OB1_SCAN_1 : BYTE ; //1 (Cold restart scan 1 of OB 1), 3 (Scan 2-n of OB 1)
  263. OB1_PRIORITY : BYTE ; //Priority of OB Execution
  264. OB1_OB_NUMBR : BYTE ; //1 (Organization block 1, OB1)
  265. OB1_RESERVED_1 : BYTE ; //Reserved for system
  266. OB1_RESERVED_2 : BYTE ; //Reserved for system
  267. OB1_PREV_CYCLE : INT ; //Cycle time of previous OB1 scan (milliseconds)
  268. OB1_MIN_CYCLE : INT ; //Minimum cycle time of OB1 (milliseconds)
  269. OB1_MAX_CYCLE : INT ; //Maximum cycle time of OB1 (milliseconds)
  270. OB1_DATE_TIME : DATE_AND_TIME ; //Date and time OB1 started
  271. Value : REAL ;
  272. AIXX : REAL ;
  273. OUTfilter : REAL ;
  274. END_VAR
  275. BEGIN
  276. NETWORK
  277. TITLE =
  278. A M 0.0;
  279. = L 32.0;
  280. BLD 103;
  281. CALL FC 170 (
  282. IN := IW 512,
  283. HI_LIM := 1.000000e+005,
  284. LO_LIM := 0.000000e+000,
  285. BIPOLAR := L 32.0,
  286. RET_VAL := MW 2,
  287. OUT := #Value);
  288. NOP 0;
  289. NETWORK
  290. TITLE =
  291. A M 20.0;
  292. = L 32.0;
  293. BLD 103;
  294. CALL FC 185 (
  295. XE := #Value,
  296. FAC_PERCENT := 9.000000e+001,
  297. INIT := L 32.0,
  298. XA := #OUTfilter,
  299. AUX := #AIXX);
  300. NOP 0;
  301. NETWORK
  302. TITLE =
  303. L #OUTfilter;
  304. L 2.000000e+001;
  305. +R ;
  306. T DB1.DBD 0;
  307. NOP 0;
  308. END_ORGANIZATION_BLOCK