论坛风格切换切换到宽版
  • 3863阅读
  • 3回复

新搞的脉冲发生器 [复制链接]

上一主题 下一主题
离线XLDZZ
 
发帖
443
只看楼主 倒序阅读 0楼 发表于: 2010-08-13
新搞的可变主振
以下为vhdl和仿真波形,可用于电加工领域。或其他需要脉冲的地方。
本来打算用在打0.05mm小孔的机器上,但是机械设计延后。线路的设计
也有很多改善的地方,特别是高速的击穿检测和主轴的伺服刚性多是
需要改善的地方。因为他是一次加工的。没有余量。
另外我也准备把光洁度这个指标提高一个等级,至少要到1.0以下
最好是ra0.8以下。但是取决的因素太多,还没综合综合考虑。可能
根本做不到。
缺点就是用了16bit的数据线传输ton和toff的数据,准备简化为8bit
加上数据选择信号,刚试过不成功。正在烦恼找问题翻书和发帖,但是
好像没有人理我。大概我太菜,别人对我的初级为问题不感兴趣。

论坛内有没有学习dsp和cpld的兄弟 大家可以一起交流交流。

总觉得一个人学习挺艰难的,特别是dsp上的问题。大家一起学习起来
也快,也不寂寞了。





library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity mosc is
generic( duty:integer:=266  
      );  
port(clk:in std_logic;  
    plus :out std_logic;
    datah:in std_logic_vector(7 downto 0);
    datal:in std_logic_vector(7 downto 0);
    ld :in std_logic;
    ent :in std_logic
    );
end mosc;

architecture mosc1 of mosc is    
signal cunton :integer range 0 to duty-1;
signal cuntoff :integer range 0 to duty-1;
signal flg   :integer range 0 to 1;
signal on_temp :integer range 0 to duty-1;
signal off_temp:integer range 0 to duty-1;
signal ph     :integer range 0 to duty-1;
signal pl     :integer range 0 to duty-1;


 
begin
process(clk )
begin
  ph<=conv_integer(datah);
  pl<=conv_integer(datal);
 
  if rising_edge(clk) then
    if cunton<255 and flg=1 and ent=Ƈ' then
    plus<=Ƈ'
    flg<=1;
    cunton<=cunton+1;
  elsif cunton=255 and flg=1 and ent=Ƈ'then
    cunton<=ph;
    flg<=0;
    plus<=Ɔ'
    elsif cuntoff<255 and flg=0 and ent=Ƈ'then
    cuntoff<=cuntoff+1;
    plus<=Ɔ'
      else
    plus<=Ƈ'
    flg<=1;
    cuntoff<=pl;      
end if;
end if;
end process;





end mosc1;
离线XLDZZ
发帖
443
只看该作者 1楼 发表于: 2010-08-14
怪事 有可能是我超频太厉害了。把fsb超到了300以上。
所以计算机误码比较多,我现在把主频从3g以上降到2。45后
相同的程序就编译过了


以下是把16bit数据线变更为8bit 加了一个ld信号和数据选择dc信号。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity mosc is
generic( duty:integer:=266  
      );  
port(clk:in std_logic;  
    plus :out std_logic;
    data:in std_logic_vector(7 downto 0);
    dc   :in std_logic;
    ld :in std_logic;
    ent :in std_logic
    );
end mosc;

architecture mosc1 of mosc is    
signal cunton :integer range 0 to duty-1;
signal cuntoff :integer range 0 to duty-1;
signal flg   :integer range 0 to 1;
signal ph     :integer range 0 to duty-1;
signal pl     :integer range 0 to duty-1;


 
begin
process(clk )
begin
  if ld=Ƈ' and dc=Ƈ' then
  ph<=conv_integer(data);
  elsif ld=Ƈ' and dc=Ɔ' then
  pl<=conv_integer(data);
end if;
 
  if rising_edge(clk) then
    if cunton<255 and flg=1 and ent=Ƈ' then
    plus<=Ƈ'
    flg<=1;
    cunton<=cunton+1;
  elsif cunton=255 and flg=1 and ent=Ƈ'then
    cunton<=ph;
    flg<=0;
    plus<=Ɔ'
    elsif cuntoff<255 and flg=0 and ent=Ƈ'then
    cuntoff<=cuntoff+1;
    plus<=Ɔ'
      else
    plus<=Ƈ'
    flg<=1;
    cuntoff<=pl;      
end if;
end if;
end process;
end mosc1;

后续编辑(忘了上图了),增加了ld dc信号 数据线从16bit更改为8bit
离线honggun
发帖
483
只看该作者 2楼 发表于: 2010-08-15
真是高手。
离线digi01
发帖
82
只看该作者 3楼 发表于: 2010-08-17
高手,完全不懂楼主在说什么。

感觉我落伍啦