Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > analog to digital

Reply
Thread Tools

analog to digital

 
 
rotemkim2 rotemkim2 is offline
Junior Member
Join Date: Jan 2011
Posts: 1
 
      02-16-2011
hello
I am writing a code in vhdl for line tracker sensor and according to a design a made ( the pictures are attached)
I am sure this isnt the way to implement a a/d and I am looking for a better way to do that.
keeping in mind that the input from the sensor could change between 0 - 3.3 [volt] and let say that from 1.3 it's consider to be '1'
the code I wrote

Code:
library IEEE;
use ieee.std_logic_1164.all;

entity Line_tracker is
--		generic (	black: std_logic := 1;
--					white: std_logic := '0'
--				);
		port	(
					data_left: 	in std_logic;
					data_right: in std_logic;
					Clk:		in std_logic;
					Reset: 		in std_logic;
					Enable:		in std_logic;
					error_left:	out std_logic;
					error_right:out std_logic
				);
end entity Line_Tracker;

architecture arc_Line_Tracker of Line_Tracker is
signal l_dataout:	std_logic;
signal l_high_bit:	std_logic;
signal l_low_bit: 	std_logic;
signal l_reg: 		std_logic;
signal r_dataout:	std_logic;
signal r_high_bit:  std_logic;
signal r_low_bit: 	std_logic;
signal r_reg: 		std_logic;
begin

left_reg: 	process (Clk,Reset,Enable)
			begin
				if (Reset = '0') then
					l_dataout <= '0';
					l_high_bit <= '0';
					l_low_bit <= '0';
					error_left <= '0';
					l_reg <= '0';
				elsif rising_edge(Clk) and (Enable = '1') then
					l_dataout <= data_left;
					if (l_dataout = '1') then
						l_high_bit <= '1';
						l_low_bit <= '0';
					else
						l_high_bit <= '0';
						l_low_bit <= '1';
					end if;
					if ((l_high_bit and (not l_low_bit)) = '1' ) then
						l_reg <= '1';
					end if;
					error_left <= l_reg;
				end if;
			end process left_reg;
right_reg: 	process (Clk,Reset,Enable)
			begin
				if (Reset = '0') then
					r_dataout <= '0';
					r_high_bit <= '0';
					r_low_bit <= '0';
					error_right <= '0';
					r_reg <= '0';
				elsif rising_edge(Clk) and (Enable = '1') then
					r_dataout <= data_right;
					if (r_dataout = '1') then
						r_high_bit <= '1';
						r_low_bit <= '0';
					else
						r_high_bit <= '0';
						r_low_bit <= '1';
					end if;
					if ((r_high_bit and (not r_low_bit)) = '1') then
						r_reg <= '1';
					end if;
					error_right <= r_reg;
				end if;
			end process right_reg;
end architecture arc_Line_Tracker;
thanks in advance
Attached Images
File Type: png line1.png (34.9 KB, 0 views)
File Type: png line2.png (55.0 KB, 0 views)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Digital vs analog monitor feed rfdjr1@optonline.net Computer Support 6 07-07-2005 02:03 PM
analog to digital striker Computer Support 3 04-24-2005 01:17 PM
digital analog conversion Veronica Matthews VHDL 6 11-27-2004 10:38 PM
How to convert analog mc3810 to digital. Santiago Blanco Cisco 2 04-22-2004 05:24 PM
Switching Between Digital and Analog Sound Output Robert H. Risch Computer Support 0 01-10-2004 10:54 PM



Advertisments