1 | -- PI Control Process
|
2 | PiCtrl_pro: PROCESS(clk, reset_n) IS
|
3 | BEGIN
|
4 | if reset_n = '0' then -- asyn reset_n
|
5 | yout_sat_reg <= (others=> '0');
|
6 | Ki_Mantise_reg <= (others=> '0');
|
7 | Kp_expopnet_reg <= (others=> '0');
|
8 | Ki_exp_reg <= (others=> '0');
|
9 | ysum_reg <= (others=> '0');
|
10 | yi_alt <= (others=> '0');
|
11 | start_delay <= (others=> '0');
|
12 | op1_reg <= (others=> '0');
|
13 | op2_reg <= (others=> '0');
|
14 | -- ...
|
15 | elsif rising_edge(clk) then
|
16 | -- start: los!
|
17 | if ( start = '1' ) then -- Uebernahme gueltige Daten
|
18 | start_delay(0) <= '1';
|
19 | op1_reg <= Kp_mantise_inp;
|
20 | Kp_exponent_reg <= Kp_exponent_inp;
|
21 | Ki_exponent_reg <= Ki_exponent_inp;
|
22 | Ki_mantise_reg <= Ki_mantise_inp;
|
23 | else
|
24 | start_delay(0) <= '0';
|
25 | end if;
|
26 |
|
27 | -- clock enable Vorbereiten
|
28 | if start_delay(1) = '1' then start_delay(2) <= '1'; else start_delay(2) <= '0';end if ;
|
29 | if start_delay(2) = '1' then start_delay(3) <= '1'; else start_delay(3) <= '0';end if ;
|
30 | if start_delay(3) = '1' then start_delay(4) <= '1'; else start_delay(4) <= '0';end if ;
|
31 | if start_delay(4) = '1' then start_delay(5) <= '1'; else start_delay(5) <= '0';end if ;
|
32 | if start_delay(5) = '1' then start_delay(6) <= '1'; else start_delay(6) <= '0';end if ;
|
33 | if start_delay(6) = '1' then start_delay(7) <= '1'; else start_delay(7) <= '0';end if ;
|
34 | if start_delay(7) = '1' then start_delay(8) <= '1'; else start_delay(8) <= '0';end if ;
|
35 | if start_delay(8) = '1' then start_delay(9) <= '1'; else start_delay(9) <= '0';end if ;
|
36 | if start_delay(9) = '1' then start_delay(10)<= '1'; else start_delay(10) <= '0';end if ;
|
37 |
|
38 | -- Delay 1 Clock nach "Start"
|
39 | if start_delay(0) = '1' then
|
40 | start_delay(1) <= '1';
|
41 | AbsKpExp_r <= AbsKpExp_s;
|
42 | AbsKiExp_r <= AbsKiExp_s;
|
43 | else
|
44 | start_delay(1) <= '0';
|
45 | end if ;
|
46 | -- Regelabweichung mit Überlauf check und Korrektur
|
47 | if start_delay(1) = '1' then op2_reg <= DeltaMitOVcheck_s; end if;
|
48 | -- (kp_mantise * delta)
|
49 | if start_delay(2) = '1' then yp1_reg <= i32Tmp_s; end if; -- yp1_reg = DeltaMitOVcheck_s * Kp_mantise_inp
|
50 | -- mux
|
51 | if start_delay(3) = '1' then op1_reg <= Ki_man_reg; end if;
|
52 | -- ...
|
53 | -- ...
|
54 | -- "done" nach 12 Clock
|
55 | if start_delay(10) = '1' then
|
56 | done <= '1';
|
57 | y_out <= y_sat_tmp;
|
58 | else
|
59 | done <= '0';
|
60 | end if;
|
61 | end process;
|
62 |
|
63 | -- Absolutwertsbildung
|
64 | AbsKpExp_s <= Kp_exponent_reg when Kp_exponent_reg(15) = '0' else - Kp_exponent_reg;
|
65 | AbsKiExp_s <= Ki_exponent_reg when Ki_exponent_reg(15) = '0' else - Ki_exponent_reg;
|
66 |
|
67 | -- gemeinsame Multiplikation: (delta * Kp_mantise) oder (delta * Ki_mantise)
|
68 | i32Tmp_s <= op1_reg * op2_reg;
|
69 |
|
70 | -- Regelabweichung mit Überlauf check und Korrektur
|
71 | DeltaMitOVcheck_s <= OV_SUB16(ref_inp, act_inp); -- (ref - act)
|
72 |
|
73 | -- ..
|
74 | -- ..
|
75 | -- ..
|