Hallo,
jetzt möchte ich fragen und zwar , wie man Bits aus ADC mit
STD_LOGIC_VECTOR zu real bzw. integer umwandeln könnte.
ich hab einen code geschrieben aber kriegt immer fehlermeldung
<<Line 75. * can not have such operands in this context.
ERROR:HDLParsers:164 -
Line 77. parse error, unexpected INTEGER_LITERAL, expecting OPENPAR or
IDENTIFIER>>
1 | entity Calculation is
|
2 | Port ( --CLK : in STD_LOGIC;
|
3 | -- RESET : in STD_LOGIC;
|
4 | GET_DATA : in STD_LOGIC;
|
5 | Buffer_VAL : in STD_LOGIC_VECTOR (71 downto 0);
|
6 | -- CHANNEL : in STD_LOGIC_VECTOR (99 downto 0);
|
7 | READ_ENABLE : out STD_LOGIC := '0'; -- buffer
|
8 | DATA : out STD_LOGIC_VECTOR (7 downto 0));
|
9 | end Calculation;
|
10 |
|
11 | architecture Behavioral of Calculation is
|
12 |
|
13 | signal ADC_2 : STD_LOGIC_VECTOR (0 downto 19) := (others => '0');
|
14 | signal ADC_3 : STD_LOGIC_VECTOR (0 downto 13) := (others => '0');
|
15 |
|
16 | signal ADC_2_OUT : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
|
17 | signal ADC_3_OUT : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
|
18 |
|
19 | signal ADC_2_UN : unsigned (7 downto 0):= (others => '0');
|
20 | signal ADC_3_UN : unsigned (7 downto 0):= (others => '0');
|
21 |
|
22 | signal calc_1 : INTEGER := 0;
|
23 | signal result_1 : REAL := 0.000000;
|
24 |
|
25 | signal calc_2 : INTEGER := 0;
|
26 | signal result_2 : REAL := 0.00000;
|
27 |
|
28 | constant ADC_2_sub : INTEGER := 1048576;
|
29 | constant ADC_3_sub : INTEGER := 16384;
|
30 |
|
31 | constant ADC_2_div : INTEGER := 524288;
|
32 | constant ADC_3_div : INTEGER := 8192;
|
33 |
|
34 | begin
|
35 |
|
36 |
|
37 | Process (GET_DATA, Buffer_VAL)
|
38 | begin
|
39 |
|
40 | if (GET_DATA = '1') then
|
41 | READ_ENABLE <= '1';
|
42 |
|
43 | ADC_2 <= not Buffer_VAL (51 downto 32);
|
44 |
|
45 | calc_1 <= (to_integer(unsigned(ADC_2))) - ADC_2_sub;
|
46 | result_1 <= REAL(0.5 * calc_1)/ADC_2_div;
|
47 |
|
48 | ADC_2_UN <= to_unsigned(integer(result_1),ADC_2_UN'8);
|
49 |
|
50 | ADC_2_OUT <= STD_LOGIC_VECTOR(ADC_2_UN);
|
51 |
|
52 | end if;
|
53 | end Process;
|
danach müssen die Messwerte in 8 databits über rs232 übertragen werden.
was ist die beste Möglichkeit ? bit zu Ascii zu konvertieren
ich hab mir überlegt, erst HEXdez und dann Ascii bin aber nicht sicher