Newer
Older
SCADA / plc / GRFICS_Workstation_Docs / Documents / attack / build / plc.st
root on 8 May 2022 16 KB playing with modbus day #1
  1. TYPE
  2. LOGLEVEL : (CRITICAL, WARNING, INFO, DEBUG) := INFO;
  3. END_TYPE
  4.  
  5. FUNCTION_BLOCK LOGGER
  6. VAR_INPUT
  7. TRIG : BOOL;
  8. MSG : STRING;
  9. LEVEL : LOGLEVEL := INFO;
  10. END_VAR
  11. VAR
  12. TRIG0 : BOOL;
  13. END_VAR
  14.  
  15. IF TRIG AND NOT TRIG0 THEN
  16. {{
  17. LogMessage(GetFbVar(LEVEL),(char*)GetFbVar(MSG, .body),GetFbVar(MSG, .len));
  18. }}
  19. END_IF;
  20. TRIG0:=TRIG;
  21. END_FUNCTION_BLOCK
  22.  
  23.  
  24.  
  25. FUNCTION_BLOCK python_eval
  26. VAR_INPUT
  27. TRIG : BOOL;
  28. CODE : STRING;
  29. END_VAR
  30. VAR_OUTPUT
  31. ACK : BOOL;
  32. RESULT : STRING;
  33. END_VAR
  34. VAR
  35. STATE : DWORD;
  36. BUFFER : STRING;
  37. PREBUFFER : STRING;
  38. TRIGM1 : BOOL;
  39. TRIGGED : BOOL;
  40. END_VAR
  41.  
  42. {extern void __PythonEvalFB(int, PYTHON_EVAL*);__PythonEvalFB(0, data__);}
  43. END_FUNCTION_BLOCK
  44.  
  45. FUNCTION_BLOCK python_poll
  46. VAR_INPUT
  47. TRIG : BOOL;
  48. CODE : STRING;
  49. END_VAR
  50. VAR_OUTPUT
  51. ACK : BOOL;
  52. RESULT : STRING;
  53. END_VAR
  54. VAR
  55. STATE : DWORD;
  56. BUFFER : STRING;
  57. PREBUFFER : STRING;
  58. TRIGM1 : BOOL;
  59. TRIGGED : BOOL;
  60. END_VAR
  61.  
  62. {extern void __PythonEvalFB(int, PYTHON_EVAL*);__PythonEvalFB(1,(PYTHON_EVAL*)(void*)data__);}
  63. END_FUNCTION_BLOCK
  64.  
  65. FUNCTION_BLOCK python_gear
  66. VAR_INPUT
  67. N : UINT;
  68. TRIG : BOOL;
  69. CODE : STRING;
  70. END_VAR
  71. VAR_OUTPUT
  72. ACK : BOOL;
  73. RESULT : STRING;
  74. END_VAR
  75. VAR
  76. py_eval : python_eval;
  77. COUNTER : UINT;
  78. ADD10_OUT : UINT;
  79. EQ13_OUT : BOOL;
  80. SEL15_OUT : UINT;
  81. AND7_OUT : BOOL;
  82. END_VAR
  83.  
  84. ADD10_OUT := ADD(COUNTER, 1);
  85. EQ13_OUT := EQ(N, ADD10_OUT);
  86. SEL15_OUT := SEL(EQ13_OUT, ADD10_OUT, 0);
  87. COUNTER := SEL15_OUT;
  88. AND7_OUT := AND(EQ13_OUT, TRIG);
  89. py_eval(TRIG := AND7_OUT, CODE := CODE);
  90. ACK := py_eval.ACK;
  91. RESULT := py_eval.RESULT;
  92. END_FUNCTION_BLOCK
  93.  
  94.  
  95. FUNCTION_BLOCK scale_to_real
  96. VAR_INPUT
  97. raw_input_value : UINT;
  98. END_VAR
  99. VAR_OUTPUT
  100. scaled_real : REAL;
  101. END_VAR
  102. VAR_INPUT
  103. real_max : REAL;
  104. real_min : REAL;
  105. END_VAR
  106. VAR
  107. raw_max : UINT := 65535;
  108. raw_min : UINT := 0;
  109. rate : REAL;
  110. offset : REAL;
  111. END_VAR
  112.  
  113. rate := (real_max - real_min) / UINT_TO_REAL(raw_max - raw_min);
  114. offset := real_min - UINT_TO_REAL(raw_min)*rate;
  115. scaled_real := UINT_TO_REAL(raw_input_value)*rate + offset;
  116. END_FUNCTION_BLOCK
  117.  
  118. FUNCTION_BLOCK scale_to_uint
  119. VAR_INPUT
  120. real_in : REAL;
  121. END_VAR
  122. VAR_OUTPUT
  123. uint_out : UINT;
  124. END_VAR
  125. VAR
  126. DIV1_OUT : REAL;
  127. MUL4_OUT : REAL;
  128. REAL_TO_UINT6_OUT : UINT;
  129. END_VAR
  130.  
  131. DIV1_OUT := DIV(real_in, 100.0);
  132. MUL4_OUT := MUL(DIV1_OUT, 65535.0);
  133. REAL_TO_UINT6_OUT := REAL_TO_UINT(MUL4_OUT);
  134. uint_out := REAL_TO_UINT6_OUT;
  135. END_FUNCTION_BLOCK
  136.  
  137. FUNCTION_BLOCK composition_control
  138. VAR
  139. a_in_purge_real : REAL := 47.00;
  140. END_VAR
  141. VAR_INPUT
  142. a_in_purge : UINT := 32000;
  143. END_VAR
  144. VAR
  145. a_setpoint_real : REAL := 47.00;
  146. END_VAR
  147. VAR_INPUT
  148. a_setpoint : UINT := 32000;
  149. curr_pos : UINT := 16000;
  150. END_VAR
  151. VAR
  152. valve_pos_real : REAL := 25.0;
  153. pos_update_real : REAL := 0.0;
  154. valve_pos_nominal : REAL := 25.0;
  155. END_VAR
  156. VAR_OUTPUT
  157. new_pos : UINT := 16000;
  158. END_VAR
  159. VAR
  160. composition_k : REAL := 1.0;
  161. composition_ti : REAL := 99.0;
  162. cycle_time : TIME := T#50ms;
  163. scale_to_real3 : scale_to_real;
  164. scale_to_real2 : scale_to_real;
  165. scale_to_uint0 : scale_to_uint;
  166. comp_max : REAL := 100.0;
  167. comp_min : REAL := 0.0;
  168. pos_max : REAL := 100.0;
  169. pos_min : REAL := 0.0;
  170. scale_to_real0 : scale_to_real;
  171. SUB45_OUT : REAL;
  172. MUL46_OUT : REAL;
  173. ADD42_OUT : REAL;
  174. LIMIT44_OUT : REAL;
  175. END_VAR
  176.  
  177. scale_to_real3(raw_input_value := a_in_purge, real_max := comp_max, real_min := comp_min);
  178. a_in_purge_real := scale_to_real3.scaled_real;
  179. scale_to_real2(raw_input_value := a_setpoint, real_max := comp_max, real_min := comp_min);
  180. a_setpoint_real := scale_to_real2.scaled_real;
  181. SUB45_OUT := SUB(a_setpoint_real, a_in_purge_real);
  182. MUL46_OUT := MUL(SUB45_OUT, composition_k);
  183. pos_update_real := MUL46_OUT;
  184. scale_to_real0(raw_input_value := curr_pos, real_max := pos_max, real_min := pos_min);
  185. valve_pos_real := scale_to_real0.scaled_real;
  186. ADD42_OUT := ADD(valve_pos_real, pos_update_real);
  187. LIMIT44_OUT := LIMIT(pos_min, ADD42_OUT, pos_max);
  188. scale_to_uint0(real_in := LIMIT44_OUT);
  189. new_pos := scale_to_uint0.uint_out;
  190. END_FUNCTION_BLOCK
  191.  
  192. FUNCTION_BLOCK initialize_sp
  193. VAR CONSTANT
  194. flow_sp_c : UINT := 13107;
  195. a_sp_c : UINT := 65535;
  196. press_sp_c : UINT := 65535;
  197. over_sp_c : UINT := 65535;
  198. level_sp_c : UINT := 65535;
  199. END_VAR
  200. VAR_OUTPUT
  201. flow_sp : UINT;
  202. a_sp : UINT;
  203. press_sp : UINT;
  204. over_sp : UINT;
  205. level_sp : UINT;
  206. END_VAR
  207. VAR
  208. MOVE3_OUT : UINT;
  209. MOVE7_OUT : UINT;
  210. MOVE11_OUT : UINT;
  211. MOVE15_OUT : UINT;
  212. MOVE19_OUT : UINT;
  213. END_VAR
  214.  
  215. MOVE3_OUT := MOVE(a_sp_c);
  216. a_sp := MOVE3_OUT;
  217. MOVE7_OUT := MOVE(flow_sp_c);
  218. flow_sp := MOVE7_OUT;
  219. MOVE11_OUT := MOVE(over_sp_c);
  220. over_sp := MOVE11_OUT;
  221. MOVE15_OUT := MOVE(level_sp_c);
  222. level_sp := MOVE15_OUT;
  223. MOVE19_OUT := MOVE(press_sp_c);
  224. press_sp := MOVE19_OUT;
  225. END_FUNCTION_BLOCK
  226.  
  227. FUNCTION_BLOCK pressure_control
  228. VAR
  229. pressure_real : REAL := 2700.0;
  230. END_VAR
  231. VAR_INPUT
  232. pressure : UINT := 58981;
  233. END_VAR
  234. VAR
  235. pressure_sp_real : REAL := 2700.0;
  236. END_VAR
  237. VAR_INPUT
  238. pressure_sp : UINT := 58981;
  239. curr_pos : UINT := 30000;
  240. END_VAR
  241. VAR
  242. valve_pos_real : REAL := 39.25;
  243. pos_update_real : REAL := 0.0;
  244. valve_pos_nominal : REAL := 39.25;
  245. END_VAR
  246. VAR_OUTPUT
  247. valve_pos : UINT := 25886;
  248. END_VAR
  249. VAR
  250. pressure_k : REAL := 20.0;
  251. pressure_ti : REAL := 999.0;
  252. cycle_time : TIME := T#50ms;
  253. scale_to_real5 : scale_to_real;
  254. scale_to_real4 : scale_to_real;
  255. scale_to_uint0 : scale_to_uint;
  256. pressure_max : REAL := 3200.00;
  257. pressure_min : REAL := 0.0;
  258. pos_min : REAL := 0.0;
  259. pos_max : REAL := 100.0;
  260. scale_to_real0 : scale_to_real;
  261. SUB57_OUT : REAL;
  262. MUL60_OUT : REAL;
  263. SUB53_OUT : REAL;
  264. LIMIT55_OUT : REAL;
  265. END_VAR
  266.  
  267. scale_to_real5(raw_input_value := pressure, real_max := pressure_max, real_min := pressure_min);
  268. pressure_real := scale_to_real5.scaled_real;
  269. scale_to_real4(raw_input_value := pressure_sp, real_max := pressure_max, real_min := pressure_min);
  270. pressure_sp_real := scale_to_real4.scaled_real;
  271. SUB57_OUT := SUB(pressure_sp_real, pressure_real);
  272. MUL60_OUT := MUL(SUB57_OUT, pressure_k);
  273. pos_update_real := MUL60_OUT;
  274. scale_to_real0(raw_input_value := curr_pos, real_max := pos_max, real_min := pos_min);
  275. valve_pos_real := scale_to_real0.scaled_real;
  276. SUB53_OUT := SUB(valve_pos_real, pos_update_real);
  277. LIMIT55_OUT := LIMIT(pos_min, SUB53_OUT, pos_max);
  278. scale_to_uint0(real_in := LIMIT55_OUT);
  279. valve_pos := scale_to_uint0.uint_out;
  280. END_FUNCTION_BLOCK
  281.  
  282. FUNCTION_BLOCK flow_control
  283. VAR
  284. flow_k : REAL := 1.0;
  285. flow_ti : REAL := 999.0;
  286. flow_td : REAL := 0.0;
  287. END_VAR
  288. VAR_INPUT
  289. product_flow : UINT := 6554;
  290. END_VAR
  291. VAR
  292. product_flow_real : REAL := 100.0;
  293. cycle_time : TIME := T#50ms;
  294. pos_update_real : REAL := 0.0;
  295. curr_pos_real : REAL := 60.9;
  296. END_VAR
  297. VAR_OUTPUT
  298. new_pos : UINT := 35000;
  299. END_VAR
  300. VAR_INPUT
  301. curr_pos : UINT := 35000;
  302. END_VAR
  303. VAR
  304. flow_set_real : REAL := 100.0;
  305. END_VAR
  306. VAR_INPUT
  307. flow_set_in : UINT := 6554;
  308. END_VAR
  309. VAR
  310. scale_to_real0 : scale_to_real;
  311. scale_to_real1 : scale_to_real;
  312. flow_max : REAL := 500.0;
  313. flow_min : REAL := 0.0;
  314. pos_min : REAL := 0.0;
  315. pos_max : REAL := 100.0;
  316. scale_to_real2 : scale_to_real;
  317. scale_to_uint0 : scale_to_uint;
  318. SUB59_OUT : REAL;
  319. MUL60_OUT : REAL;
  320. ADD58_OUT : REAL;
  321. LIMIT40_OUT : REAL;
  322. END_VAR
  323.  
  324. scale_to_real0(raw_input_value := product_flow, real_max := flow_max, real_min := flow_min);
  325. product_flow_real := scale_to_real0.scaled_real;
  326. scale_to_real1(raw_input_value := flow_set_in, real_max := flow_max, real_min := flow_min);
  327. flow_set_real := scale_to_real1.scaled_real;
  328. SUB59_OUT := SUB(flow_set_real, product_flow_real);
  329. MUL60_OUT := MUL(SUB59_OUT, flow_k);
  330. pos_update_real := MUL60_OUT;
  331. scale_to_real2(raw_input_value := curr_pos, real_max := pos_max, real_min := pos_min);
  332. curr_pos_real := scale_to_real2.scaled_real;
  333. ADD58_OUT := ADD(curr_pos_real, pos_update_real);
  334. LIMIT40_OUT := LIMIT(pos_min, ADD58_OUT, pos_max);
  335. scale_to_uint0(real_in := LIMIT40_OUT);
  336. new_pos := scale_to_uint0.uint_out;
  337. END_FUNCTION_BLOCK
  338.  
  339. FUNCTION_BLOCK level_control
  340. VAR_INPUT
  341. liquid_level : UINT;
  342. level_sp : UINT := 30000;
  343. curr_pos : UINT;
  344. END_VAR
  345. VAR_OUTPUT
  346. new_pos : UINT;
  347. END_VAR
  348. VAR
  349. cycle_time : TIME := T#50ms;
  350. level_k : REAL := 10.0;
  351. level_ti : REAL := 99999.0;
  352. scale_to_real0 : scale_to_real;
  353. level_max : REAL := 100.0;
  354. level_min : REAL := 0.0;
  355. pos_max : REAL := 100.0;
  356. pos_min : REAL := 0.0;
  357. level_real : REAL := 44.18;
  358. pos_real : REAL := 47.0;
  359. pos_update_real : REAL := 0.0;
  360. sp_real : REAL := 44.18;
  361. scale_to_real1 : scale_to_real;
  362. scale_to_real2 : scale_to_real;
  363. scale_to_uint0 : scale_to_uint;
  364. SUB32_OUT : REAL;
  365. MUL33_OUT : REAL;
  366. SUB30_OUT : REAL;
  367. LIMIT25_OUT : REAL;
  368. END_VAR
  369.  
  370. scale_to_real0(raw_input_value := liquid_level, real_max := level_max, real_min := level_min);
  371. level_real := scale_to_real0.scaled_real;
  372. scale_to_real1(raw_input_value := curr_pos, real_max := pos_max, real_min := pos_min);
  373. pos_real := scale_to_real1.scaled_real;
  374. scale_to_real2(raw_input_value := level_sp, real_max := level_max, real_min := level_min);
  375. sp_real := scale_to_real2.scaled_real;
  376. SUB32_OUT := SUB(sp_real, level_real);
  377. MUL33_OUT := MUL(SUB32_OUT, level_k);
  378. pos_update_real := MUL33_OUT;
  379. SUB30_OUT := SUB(pos_real, pos_update_real);
  380. LIMIT25_OUT := LIMIT(pos_min, SUB30_OUT, pos_max);
  381. scale_to_uint0(real_in := LIMIT25_OUT);
  382. new_pos := scale_to_uint0.uint_out;
  383. END_FUNCTION_BLOCK
  384.  
  385. FUNCTION_BLOCK scale_to_signed
  386. VAR_INPUT
  387. input_uint : UINT;
  388. END_VAR
  389. VAR_OUTPUT
  390. output_int : INT;
  391. END_VAR
  392. VAR
  393. DIV3_OUT : UINT;
  394. ABS8_OUT : UINT;
  395. UINT_TO_INT9_OUT : INT;
  396. END_VAR
  397.  
  398. DIV3_OUT := DIV(input_uint, 2);
  399. ABS8_OUT := ABS(DIV3_OUT);
  400. UINT_TO_INT9_OUT := UINT_TO_INT(ABS8_OUT);
  401. output_int := UINT_TO_INT9_OUT;
  402. END_FUNCTION_BLOCK
  403.  
  404. FUNCTION_BLOCK pressure_override
  405. VAR
  406. pressure_real : REAL := 2700.0;
  407. END_VAR
  408. VAR_INPUT
  409. pressure : UINT := 58981;
  410. curr_sp : UINT := 58981;
  411. END_VAR
  412. VAR
  413. curr_sp_real : REAL := 2700.0;
  414. product_sp_real : REAL := 100.0;
  415. sp_update : REAL := 0.0;
  416. product_sp_nominl : REAL := 100.0;
  417. END_VAR
  418. VAR_OUTPUT
  419. product_sp : UINT := 13107;
  420. END_VAR
  421. VAR
  422. override_sp_real : REAL := 2900.0;
  423. END_VAR
  424. VAR_INPUT
  425. override_sp : UINT := 63350;
  426. END_VAR
  427. VAR
  428. override_k : REAL := 1.0;
  429. override_ti : REAL := 99999.0;
  430. cycle_time : TIME := T#50ms;
  431. scale_to_real7 : scale_to_real;
  432. pressure_max : REAL := 3000.0;
  433. pressure_min : REAL := 0.0;
  434. flow_max : REAL := 500.0;
  435. flow_min : REAL := 0.0;
  436. scale_to_real0 : scale_to_real;
  437. SUB86_OUT : REAL;
  438. MUL87_OUT : REAL;
  439. MAX84_OUT : REAL;
  440. ADD85_OUT : REAL;
  441. LIMIT67_OUT : REAL;
  442. DIV73_OUT : REAL;
  443. MUL75_OUT : REAL;
  444. REAL_TO_UINT79_OUT : UINT;
  445. END_VAR
  446.  
  447. scale_to_real7(raw_input_value := pressure, real_max := pressure_max, real_min := pressure_min);
  448. pressure_real := scale_to_real7.scaled_real;
  449. SUB86_OUT := SUB(override_sp_real, pressure_real);
  450. MUL87_OUT := MUL(SUB86_OUT, override_k);
  451. MAX84_OUT := MAX(MUL87_OUT, 0.0);
  452. sp_update := MAX84_OUT;
  453. scale_to_real0(raw_input_value := curr_sp, real_max := flow_max, real_min := flow_min);
  454. curr_sp_real := scale_to_real0.scaled_real;
  455. ADD85_OUT := ADD(curr_sp_real, sp_update);
  456. LIMIT67_OUT := LIMIT(50.0, ADD85_OUT, 150.0);
  457. product_sp_real := LIMIT67_OUT;
  458. DIV73_OUT := DIV(product_sp_real, 500.0);
  459. MUL75_OUT := MUL(DIV73_OUT, 65535.0);
  460. REAL_TO_UINT79_OUT := REAL_TO_UINT(MUL75_OUT);
  461. product_sp := REAL_TO_UINT79_OUT;
  462. END_FUNCTION_BLOCK
  463.  
  464. PROGRAM main
  465. VAR
  466. flow_control0 : flow_control;
  467. first_run : BOOL := True;
  468. END_VAR
  469. VAR
  470. flow_set : UINT;
  471. a_setpoint : UINT;
  472. pressure_sp : UINT;
  473. override_sp : UINT;
  474. level_sp : UINT;
  475. END_VAR
  476. VAR
  477. composition_control0 : composition_control;
  478. scale_to_signed0 : scale_to_signed;
  479. END_VAR
  480. VAR
  481. f1_valve_pos : UINT;
  482. f1_flow : UINT;
  483. f2_valve_pos : UINT;
  484. f2_flow : UINT;
  485. purge_valve_pos : UINT;
  486. purge_flow : UINT;
  487. product_valve_pos : UINT;
  488. product_flow : UINT;
  489. pressure : UINT;
  490. level : UINT;
  491. a_in_purge : UINT;
  492. b_in_purge : UINT;
  493. c_in_purge : UINT;
  494. f1_valve_sp : UINT;
  495. f2_valve_sp : UINT;
  496. purge_valve_sp : UINT;
  497. product_valve_sp : UINT;
  498. END_VAR
  499. VAR
  500. product_valve_safe : UINT := 0;
  501. purge_valve_safe : UINT := 65535;
  502. f1_valve_safe : UINT;
  503. f2_valve_safe : UINT;
  504. pressure_control0 : pressure_control;
  505. END_VAR
  506. VAR
  507. hmi_pressure : INT;
  508. hmi_level : INT;
  509. hmi_f1_valve_pos : INT;
  510. hmi_f1_flow : INT;
  511. hmi_f2_valve_pos : INT;
  512. hmi_f2_flow : INT;
  513. hmi_purge_valve_pos : INT;
  514. hmi_purge_flow : INT;
  515. hmi_product_valve_pos : INT;
  516. hmi_product_flow : INT;
  517. scan_count : UINT;
  518. END_VAR
  519. VAR
  520. scale_to_signed1 : scale_to_signed;
  521. scale_to_signed2 : scale_to_signed;
  522. scale_to_signed3 : scale_to_signed;
  523. scale_to_signed4 : scale_to_signed;
  524. scale_to_signed5 : scale_to_signed;
  525. scale_to_signed6 : scale_to_signed;
  526. scale_to_signed7 : scale_to_signed;
  527. scale_to_signed8 : scale_to_signed;
  528. scale_to_signed9 : scale_to_signed;
  529. pressure_override0 : pressure_override;
  530. level_control0 : level_control;
  531. END_VAR
  532. VAR_EXTERNAL
  533. run_bit : BOOL;
  534. END_VAR
  535. VAR
  536. run_bit0 : BOOL := True;
  537. initialize_sp0 : initialize_sp;
  538. ADD87_OUT : UINT;
  539. GE91_OUT : BOOL;
  540. MOVE92_ENO : BOOL;
  541. MOVE92_OUT : UINT;
  542. END_VAR
  543.  
  544. initialize_sp0(EN := first_run);
  545. IF initialize_sp0.ENO THEN
  546. first_run := FALSE; (*reset*)
  547. END_IF;
  548. IF initialize_sp0.ENO THEN
  549. flow_set := initialize_sp0.flow_sp;
  550. END_IF;
  551. IF initialize_sp0.ENO THEN
  552. a_setpoint := initialize_sp0.a_sp;
  553. END_IF;
  554. IF initialize_sp0.ENO THEN
  555. pressure_sp := initialize_sp0.press_sp;
  556. END_IF;
  557. IF initialize_sp0.ENO THEN
  558. override_sp := initialize_sp0.over_sp;
  559. END_IF;
  560. IF initialize_sp0.ENO THEN
  561. level_sp := initialize_sp0.level_sp;
  562. END_IF;
  563. flow_control0(product_flow := product_flow, curr_pos := f1_valve_pos, flow_set_in := flow_set);
  564. f1_valve_sp := flow_control0.new_pos;
  565. pressure_control0(pressure := pressure, pressure_sp := pressure_sp, curr_pos := purge_valve_pos);
  566. purge_valve_sp := pressure_control0.valve_pos;
  567. composition_control0(a_in_purge := a_in_purge, a_setpoint := a_setpoint, curr_pos := f2_valve_pos);
  568. f2_valve_sp := composition_control0.new_pos;
  569. pressure_override0(pressure := pressure, curr_sp := flow_set, override_sp := override_sp);
  570. flow_set := pressure_override0.product_sp;
  571. level_control0(liquid_level := level, level_sp := level_sp, curr_pos := product_valve_pos);
  572. product_valve_sp := level_control0.new_pos;
  573. scale_to_signed0(input_uint := pressure);
  574. hmi_pressure := scale_to_signed0.output_int;
  575. scale_to_signed1(input_uint := level);
  576. hmi_level := scale_to_signed1.output_int;
  577. scale_to_signed2(input_uint := f1_valve_pos);
  578. hmi_f1_valve_pos := scale_to_signed2.output_int;
  579. scale_to_signed3(input_uint := f2_valve_pos);
  580. hmi_f2_valve_pos := scale_to_signed3.output_int;
  581. scale_to_signed4(input_uint := purge_valve_pos);
  582. hmi_purge_valve_pos := scale_to_signed4.output_int;
  583. scale_to_signed5(input_uint := product_valve_pos);
  584. hmi_product_valve_pos := scale_to_signed5.output_int;
  585. scale_to_signed6(input_uint := f1_flow);
  586. hmi_f1_flow := scale_to_signed6.output_int;
  587. scale_to_signed7(input_uint := f2_flow);
  588. hmi_f2_flow := scale_to_signed7.output_int;
  589. scale_to_signed8(input_uint := purge_flow);
  590. hmi_purge_flow := scale_to_signed8.output_int;
  591. scale_to_signed9(input_uint := product_flow);
  592. hmi_product_flow := scale_to_signed9.output_int;
  593. ADD87_OUT := ADD(scan_count, 1);
  594. scan_count := ADD87_OUT;
  595. GE91_OUT := GE(scan_count, 32000);
  596. MOVE92_OUT := MOVE(EN := GE91_OUT, IN := 0, ENO => MOVE92_ENO);
  597. IF MOVE92_ENO THEN
  598. scan_count := MOVE92_OUT;
  599. END_IF;
  600. END_PROGRAM
  601.  
  602.  
  603. CONFIGURATION Config0
  604.  
  605. RESOURCE Res0 ON PLC
  606. VAR_GLOBAL
  607. run_bit : BOOL;
  608. END_VAR
  609. TASK MainTask(INTERVAL := T#50ms,PRIORITY := 0);
  610. PROGRAM instance0 WITH MainTask : main;
  611. END_RESOURCE
  612. END_CONFIGURATION
Buy Me A Coffee