Frequency divider for infrared output

Status
Not open for further replies.

devsan

Newbie level 1
Joined
Nov 4, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,288
Hi I need to divide my frequency from 1MHz to 38kHz, will this code help me do that?

entity test is
port( clk:in bit; clkoutut bit);
end test;

architecture behavior of test is
begin
process(clk)
variable cnt : integer range 0 to 26;
begin
if(clk'event and clk='1') then
if(cnt=26)then
cnt:=0;
clkout<='1';
else
cnt := cnt+1;
clkout<='0';
end if;
end if;
end process;
end behavior;

This should give me a frequency of 38,5kHz will this work for an IR transmitter?
 

Look sharp, the divider factor is 27 rather than 26 in your code, but 26 would be better. Furthermore, you should provide a 50% duty cycle square wave.

Code:
begin 
if(clk'event and clk='1') then 
  if(cnt=12)then -- divide by 13
    cnt:=0; 
    clkout<=NOT clkout; -- divide by 2, generate square wave
  else 
    cnt := cnt+1; 
  end if; 
end if;
Usual RC receivers have about 10-15% relative bandwidth, 38.5 kHz would cause no relevant sensitivity drop.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…