Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Integer convert to std_logic_vector ?

Status
Not open for further replies.

abimann

Member level 4
Joined
Jun 21, 2016
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
673
I want to do tachometer from 20k to 70k rpms, and get every 5mS and make some changes to pwm output, how to convert from integer to std_logic_vector ?


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
entity mmmm is
        Port ( clk100        : in  STD_LOGIC;   
               sensor         : in  STD_LOGIC;
               result          : out std_logic_vector);
   end mmmm;
architecture Behavioral of mmmm is
      constant period :integer:=2000000; --2000000 * 10 nano seconds
      constant strobe :integer:=500; --5 milliSeconds
        signal   counter:integer:=0;
             signal   cnt    :integer:=0;
         signal   inte   :integer:=0;
           signal   rp5ms  : std_logic_vector(16 downto 0);
            
begin
     process(clk100)
            begin             
         if rising_edge(clk100)
            then
                if cnt = strobe 
                   then   cnt <= 0;               
                   else   cnt <= cnt + 1;  
                   inte <= inte + to_integer(unsigned'('0' & sensor)); --inte <= inte + 1 when (sensor = '1') else 0;
                end if;
        end if;
     end process;
     result   <= std_logic_vector(unsigned(inte);

 
Last edited by a moderator:

vhdl-type-conversions-914x1024.png
Conversion list.
 
Hi,

I don't understand some statements:

...I want to do tachometer from 20k to 70k rpms, and get every 5mS and...
20.000 RPM are 333 Hz = 333 pulses per second.
1 or 2 pulses in 5ms

70.000 RPM are 1167 Hz = 1167 pulses per second.
5 or 6 pulses in 5ms
***
--2000000 * 10 nano seconds
= 20ms or 50Hz

constant strobe :integer:=500; --5 milliSeconds
...then you need an input rate of 100kHz or 10us or 10.000ns

Klaus
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top