jimmykk
Full Member level 3

Hi
I aM trying to get a short pulse of frequency 50khz with 5 cycles from MD1213. The problem i am getting is that i am able to get only a single output from OUTB while OUTA is at VH(5V) level and does not provide any pulse out of it. i am using Altera DE1 SOC board for logic and logic for INA, INB and OE (all are between 0 and 3.3v) are coming from this board + 5V supply voltage is PROVIDED TO VDD1, VDD2 and VH while VL, VSS1 and VSS2 are connected to ground. I am not sure whether it is a hardware problem or software. Anyways, i have attached my VHDL code for this. Please check and suggest some improvements.

I aM trying to get a short pulse of frequency 50khz with 5 cycles from MD1213. The problem i am getting is that i am able to get only a single output from OUTB while OUTA is at VH(5V) level and does not provide any pulse out of it. i am using Altera DE1 SOC board for logic and logic for INA, INB and OE (all are between 0 and 3.3v) are coming from this board + 5V supply voltage is PROVIDED TO VDD1, VDD2 and VH while VL, VSS1 and VSS2 are connected to ground. I am not sure whether it is a hardware problem or software. Anyways, i have attached my VHDL code for this. Please check and suggest some improvements.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity pulse_tx is port( clock_50 : in std_logic; GPIO_0 : inout std_logic_vector(35 downto 0) ); end pulse_tx; architecture arch of pulse_tx is type state_type is (init, write_state, idle_state); signal state : state_type := init; signal clock_5 : std_logic := '0'; signal clk_div : integer range 0 to 5 := 0; signal count : integer range 0 to 500000 := 0; begin -- GPIO_0(0) <= OE OF MD1213; -- GPIO_0(1) <= INA OF MD1213; -- GPIO_0(3) <= INB OF MD1213; GPIO_0(35 downto 4) <= (others => '0'); process(clock_50) -- CLOCK DIVISION PROCESS begin if(rising_edge(clock_50)) then if (clk_div = 4) then clock_5 <= clock_5 xor '1'; clk_div <= 0; else clk_div <= clk_div + 1; end if; end if; end process; process(clock_50) begin if(rising_edge(clock_5)) then if(clk_div= 4 and clock_5 = '1') then case state is when init => GPIO_0(0) <= '0'; GPIO_0(1) <= '0'; GPIO_0(3) <= '1'; if (count = 100) then count <= count + 1; state <= write_state; else count <= count + 1; state <= init; end if; when write_state => if (count > 100 and count < 250000) then count <= count + 1; if (count = 190000) then GPIO_0(0) <= '1'; state <= write_state; elsif(count = 200000) then GPIO_0(0) <= '1'; GPIO_0(1) <= '1'; state <= write_state; elsif(count = 200050) then GPIO_0(0) <= '1'; GPIO_0(1) <= '0'; GPIO_0(3) <= '0'; state <= write_state; elsif(count = 200100) then GPIO_0(0) <= '1'; GPIO_0(1) <= '1'; GPIO_0(3) <= '1'; state <= write_state; elsif(count = 200150) then GPIO_0(0) <= '1'; GPIO_0(1) <= '0'; GPIO_0(3) <= '0'; state <= write_state; elsif(count = 200200) then GPIO_0(0) <= '1'; GPIO_0(1) <= '1'; GPIO_0(3) <= '1'; state <= write_state; elsif(count = 200250) then GPIO_0(1) <= '0'; GPIO_0(0) <= '1'; GPIO_0(3) <= '0'; state <= write_state; elsif(count = 200300) then GPIO_0(1) <= '1'; GPIO_0(0) <= '1'; GPIO_0(3) <= '1'; state <= write_state; elsif(count = 200350) then GPIO_0(1) <= '0'; GPIO_0(0) <= '1'; GPIO_0(3) <= '0'; state <= write_state; elsif(count = 200400) then GPIO_0(1) <= '1'; GPIO_0(3) <= '1'; GPIO_0(0) <= '1'; state <= write_state; elsif(count = 200450) then GPIO_0(1) <= '0'; GPIO_0(0) <= '1'; GPIO_0(3) <= '0'; state <= write_state; elsif(count = 200500) then GPIO_0(0) <= '1'; GPIO_0(3) <= '1'; state <= write_state; else state <= write_state; end if; elsif(count = 250000) then count <= count + 1; state <= idle_state; end if; when idle_state => if(count > 250000 and count < 500000) then GPIO_0(0) <= '0'; if (count = 499999) then count <= 101; state <= write_state; else count <= count + 1; state <= idle_state; end if; end if; end case; end if; end if; end process; end arch;

Last edited by a moderator: