]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blobdiff - pmsm-control/rpi_pmsm_control.vhdl
Sending unique measured current value was replaced by current accumulator. Now multip...
[fpga/rpi-motor-control.git] / pmsm-control / rpi_pmsm_control.vhdl
index 104d2727aa7e5edb9fd20b70bb53517b4b04ae6a..47fd12c8615e667018b2249a3439c9b9a8efa31f 100644 (file)
@@ -149,14 +149,16 @@ architecture behavioral of rpi_mc_simple_dc is
                adc_channels: out std_logic_vector (35 downto 0);       --consistent data of 3 channels
                adc_sclk: out std_logic;                                --spi clk
                adc_scs: out std_logic;                                 --spi slave select
-               adc_mosi: out std_logic                                 --spi master out slave in
+               adc_mosi: out std_logic;                                --spi master out slave in
+               measur_count: out std_logic_vector(8 downto 0)          --number of accumulated measurments
        
        );
        end component;
        
        
        signal adc_reset : std_logic;
-       signal adc_channels: std_logic_vector(35 downto 0);
+       signal adc_channels: std_logic_vector(71 downto 0);
+       signal adc_m_count: std_logic_vector(8 downto 0);
        
        signal spiclk_old: std_logic_vector(1 downto 0); --pro detekci hrany SPI hodin
        --signal pwm_in, pwm_dir_in: std_logic;
@@ -176,6 +178,7 @@ architecture behavioral of rpi_mc_simple_dc is
        signal pwm_sync: std_logic;
        signal pwm_en_p: std_logic_vector(1 to 3);
        signal pwm_en_n: std_logic_vector(1 to 3);
+       signal pwm_sig: std_logic_vector(1 to 3);
        
        signal income_data_valid: std_logic;
        
@@ -232,7 +235,7 @@ begin
                        match => pwm_match(i),
                        count => pwm_count,
                        -- outputs
-                       out_p => open,--pwm(i),                         --positive signal
+                       out_p => pwm_sig(i),                            --positive signal
                        out_n => shdn(i)                                --reverse signal is in shutdown mode
                );
        end generate;
@@ -253,7 +256,8 @@ begin
                adc_channels => adc_channels,
                adc_sclk => adc_sclk,
                adc_scs => adc_scs,
-               adc_mosi => adc_mosi
+               adc_mosi => adc_mosi,
+               measur_count => adc_m_count
                
        );
 
@@ -291,13 +295,9 @@ begin
        rs485_dir <= '0';
 
 
-       --shdn(1) <= '0';
-       --shdn(2) <= '1';
-       --shdn(3) <= '0';
-
-       --pwm(1) <= '0';
-       --pwm(2) <= '0';
-       --pwm(3) <= '0';
+       pwm(1) <= pwm_sig(1) and dip_sw(1);
+       pwm(2) <= pwm_sig(2) and dip_sw(1);
+       pwm(3) <= pwm_sig(3) and dip_sw(1);
        
                
        
@@ -348,14 +348,8 @@ begin
                        dat_reg(92 downto 90) <= pwm_en_p(1 to 3); --enable positive
                        dat_reg(89 downto 87) <= pwm_en_n(1 to 3); --shutdown
                        dat_reg(86 downto 81) <= (others=>'0');--pwm_match(1)(10 downto 5); --6 MSb of PWM1
-                       dat_reg(80 downto 74) <= (others=>'0');--pwm_match(2)(10 downto 4); --7 MSb of PWM2
-                       dat_reg(73 downto 68) <= (others=>'0');--pwm_match(3)(10 downto 5); --6 MSb of PWM3
-                       dat_reg(71 downto 60)<=(others=>'0');
-                       dat_reg(59 downto 48) <= adc_channels(35 downto 24); --current mesurments
-                       dat_reg(47 downto 36)<=(others=>'0');
-                       dat_reg(35 downto 24) <= adc_channels(23 downto 12); --current mesurments
-                       dat_reg(23 downto 12)<=(others=>'0');
-                       dat_reg(11 downto 0) <= adc_channels(11 downto 0); --current mesurments
+                       dat_reg(80 downto 72) <=adc_m_count(8 downto 0);        --count of measurments
+                       dat_reg(71 downto 0) <= adc_channels(71 downto 0);      --current mesurments
                        adc_reset<='0'; --remove reset flag, and wait on its rising edge
                elsif (ce0_old = "01") then --rising edge of SS, we should read the data
                        adc_reset<='1';