kidi3
Full Member level 1
I at moment trying to combine a project consisting of 3 components. <ADC>, <LED>, Control (top-module), and <servo>.
the Idea is that the LED , start the ADC, and the ADC tells the Control unit when it can read from it , and based on the value the control unit reads, the servo moves.
Until now the connection between the ADC,LED and control seem to work. But when Instantiate the component Servo, and try to add it it simply breaks the looks...
I really don't have any idea on how this could occur, and would be very grateful if anyone could help me debugging this issue.
It interfers with my LED components output.
which I don't get. Servo should be running in the background, and not interfere with anything else..
Here is some code snippets of the process within each components.
counter.vhd
led.vhd
servo.vhd
I really don't get how this can become a problem to combine these within the top module , control. Can any of you see where i might affect some signals?
the Idea is that the LED , start the ADC, and the ADC tells the Control unit when it can read from it , and based on the value the control unit reads, the servo moves.
Until now the connection between the ADC,LED and control seem to work. But when Instantiate the component Servo, and try to add it it simply breaks the looks...
I really don't have any idea on how this could occur, and would be very grateful if anyone could help me debugging this issue.
It interfers with my LED components output.
which I don't get. Servo should be running in the background, and not interfere with anything else..
Here is some code snippets of the process within each components.
counter.vhd
Code:
readBlock: process(clk,read_adc_sig, adc_value_sig,led_on_sig,redCount,greenCount,blueCount)
variable iterations: integer range 0 to 40 :=0 ;
begin
if rising_edge(clk) then
if iterations < 30 then
led_on_sig <= '1';
elsif iterations >= 30 then
led_on_sig <= '0';
if redCount < greenCount then
if greenCount > blueCount then
MAX_LED_r <= '0';
MAX_LED_g <= '0';
MAX_LED_b <= '0';
--GreenCount max
--Måler forkert
--direc_sig <= "10";
end if;
elsif redCount < blueCount then
if blueCount > greenCount then
MAX_LED_r <= '1';
MAX_LED_g <= '0';
MAX_LED_b <= '1';
-- BlueCount max
--direc_sig <= "00";
end if;
elsif greenCount < redCount then
if redCount > blueCount then
MAX_LED_r <= '0';
MAX_LED_g <= '1';
MAX_LED_b <= '0';
-- redCount max
--direc_sig <= "11";
end if;
end if;
redCount <= 0;
blueCount <= 0;
greenCount <= 0;
iterations:=0;
end if;
if led_on_sig = '1' then
if read_adc_sig = '1' then
if adc_value_sig = "1111111111" then
redCount <= redCount +1;
adc_read_sig <= '1';
iterations := iterations + 1;
elsif adc_value_sig = "0000000000" then
blueCount <= blueCount +1;
adc_read_sig <= '1';
iterations := iterations + 1;
else
greenCount <= greenCount +1;
adc_read_sig <= '1';
iterations := iterations + 1;
end if;
-- delay to settle LED, so ADC turned off--
elsif read_adc_sig = '0' then
adc_read_sig <= '0';
end if;
if adc_read_sig = '1' then
next_state_sig <= '1'; -- Saying start next state => turn off start_adc...
else
next_state_sig <= '0';
end if;
else
next_state_sig <= '0'; -- Saying start next state => turn off start_adc...
end if;
end if;
end process;
led.vhd
Code:
LEDprocess: process(led_on, state)
begin
if led_on = '1' then
case state is
when red =>
led_red <= '1';
led_green<= '0';
led_blue <= '0';
stateS <= "10";
when green =>
led_red <= '0';
led_green<= '1';
led_blue <= '0';
stateS <= "01";
when blue =>
led_red <= '0';
led_green <= '0';
led_blue <= '1';
stateS <= "11";
end case;
elsif led_on = '0' then
led_blue <= '0';
led_red <= '0';
led_green <= '0';
stateS <= "00";
else
led_blue <= '0';
led_red <= '0';
led_green <= '0';
stateS <= "00";
end if;
end process;
state_changer: process(next_state,state, clk)
variable count: integer range 0 to 100000000 :=0;
begin
if next_state = '1' then
if count > 650 then
if state = red then
state <= green;
elsif state = green then
state <= blue;
elsif state = blue then
state <= red;
end if;
end if;
count:= 0;
elsif rising_edge(clk) then
if count > 650 then
start_adc <= '1';
--adc_on <= '1';
elsif count <650 then
start_adc <= '0';
--adc_on <= '1';
end if;
count := count +1 ;
end if;
end process;
servo.vhd
Code:
process (clk)
--variable to count the clock pulse
variable count : integer range 0 to 1000000;
begin
if (rising_edge(CLK)) then
count:= count+1;
if count = 1000000 then
count:= 0;
end if;
end if;
case direc is
--increasing the count for each clock cycle
when "11" =>
if count < 960000 then -- 900000, 950000 , 960000
PWM_motor <= '0';
else
PWM_motor <= '1';
end if;
when "00" =>
if count < 900000 then -- 900000, 950000 , 960000
PWM_motor <= '0';
else
PWM_motor <= '1';
end if;
when others =>
if count < 950000 then -- 900000, 950000 , 960000
PWM_motor <= '0';
else
PWM_motor <= '1';
end if;
end case;
end process;
I really don't get how this can become a problem to combine these within the top module , control. Can any of you see where i might affect some signals?