Forum Discussion
8 Replies
- Altera_Forum
Honored Contributor
The problems I'm facing include:
-how do i interface d ldr(sensor) with the d de2 board -how do I convert d analog input from d sensor to digital form in other to generate my output from an external led -will I use d expansion header to connect d external ldr circuit - what pins will I assign in my code so the de2 board will be able to recognise my analog input and my output(external led)..pls help! - Altera_Forum
Honored Contributor
Any1 to help me out pls..I need sme1 to put me through .thankz
- Altera_Forum
Honored Contributor
Show us what you've done so far, and let us know what you're having problems with
- Altera_Forum
Honored Contributor
--- Quote Start --- Show us what you've done so far, and let us know what you're having problems with --- Quote End --- Thankz I have bn able to do smthng.I was able to turn on the led using switch 'swo' on the board using this code LIBRARY IEEE;USE IEEE.std_logic _1164.all;ENTITY streetlight IS PORT (D, resetn,clock: IN STD_LOGIC; Q :OUT STD_LOGIC);END flipflop;ARCHITECTURE Behaviour of streetlight IS BEGIN PROCESS (Clock,resetn)BEGINIF Clock 'EVENT AND CLOCK='1' THENIF resetn='0' THEN Q - Altera_Forum
Honored Contributor
LIBRARY IEEE;
USE IEEE.std_logic _1164.all; ENTITY streetlight IS PORT (D, resetn,clock: IN STD_LOGIC; Q :OUT STD_LOGIC); END flipflop; ARCHITECTURE Behaviour of streetlight IS BEGIN PROCESS (Clock,resetn) BEGIN IF Clock 'EVENT AND CLOCK='1' THEN IF resetn='0' THEN Q<='0'; ELSE Q<=D; END IF; END IF; END PROCESS; END BEHAVIOR; I have done this and I have assigned pin to produce d output on an led on d de2 board.when i push d switch down d led comes on when i push it up d led goes off.but now I want to use an external ldr to generate analog input that will b converted into digital form whose output will turn on an external led.that is when it is dark d ldr will generate input signal that will turn on d led and when if is day d ldr will generate signal to turn off d led. Pls put me through - Altera_Forum
Honored Contributor
you will need an external ADC as there is not one on the fpga.
- Altera_Forum
Honored Contributor
library IEEE;
use IEEE.STD_LOGIC_1164.all; ENTITY sirisha IS port ( temp :in std_logic_vector(6 downto 0); CLK :in std_logic; enable :in std_logic; day , night :out std_logic; disp :out std_logic_vector(2 downto 0) ); end sirisha; ARCHITECTURE structure of sirisha IS signal temp :std_logic_vector(6 downto 0); signal CLK :std_logic; signal enable :std_logic; signal day,night :std_logic; signal disp :std_logic_vector(2 downto 0); constant TCLKH_C :time:=5ns; constant TCLKL_C :time:=TCLKH_C; constant TCLKL_C :time:=(TCLKH_C + TCLKL_C); constant TRDELAY_C :time:=TCLKL_C; constant TRHOLD_C :time:=1ns; component sirisha port ( temp :in std_logic_vector(6 downto 0); CLK :in std_logic; enable :in std_logic; day , night :out std_logic; disp :out std_logic_vector(2 downto 0) ); end component; cur_st_process (CLK,enable) begin if (enable='0') then cur_st <= start; else if (CLK'event and CLK='1') then cur_st<=next_st; end if; end process cur_st_pr; nxt_st_process (cur_st,temp) --next state comb. circuit begin if(temp>"1000110")then nxt_st<= day; else if (temp<"0110010") then nxt_st<=night; else nxt_st<=cur_st; end if; end process nxt_st_pr; reg_pr : process (enable,CLK) begin if (enable='0') then day <='0'; night <='0'; disp <="000"; else day <='1'; night <='1'; disp< ="001"; end if; end process reg_pr; begin (temp=>temp,CLK=>CLK,enable=>enable,day=>day,night=>night,disp=>disp); end structure; thanks alot will i av to build one myself or buy one or does it come with the de2 board?.pls help me check d code it is still giving me errors.i want the leds to come on if the if statement of nxt_st_process (cur_st,temp) is satisfied but it still doesnt work - Altera_Forum
Honored Contributor
Im not familiar with the DE2, but the features dont seem to specify an ADC. You may need to connect one to one of the expansion headers.
What errors are you getting with the code? do you have a test bench?