关于一个步进电机的驱动程序

   2018-04-10 74
核心提示:[db:简介]

点击此处看仿真图形:http://img291.photo.163.com/yswhu/32190484/962972640.jpg

module module1(fin,wr,cs,din,fout,rst);

input fin,wr,cs,rst;
input [7:0] din;
output fout;

reg[9:0] count;
reg[7:0] step,step_temp;
reg fout;
//assign fout = count[SIZE-1];

always @(negedge wr or posedge fout or negedge rst)
begin 
 if(!rst)
 begin
  step = 1;
 end
 else if(!wr)
  begin
  if(!cs)
  step_temp = din;
  end
 else
 begin 
 if(step<step_temp)
  step = step+1b1;
 else if(step>step_temp)
  step = step-1b1;
 else step = step_temp;
 end
end 
  
  
always @(posedge fin)
begin
 count <= count+step;
 fout <= count[9];
end

endmodule

你可以通过这个链接引用该篇文章:http://yswhu.bokee.com/tb.b?diaryId=10560988

 

 
举报收藏 0打赏 0
 
更多>同类数控技术
推荐图文
推荐数控技术
点击排行
网站首页  |  关于我们  |  升级会员  |  联系客服  |  广告合作  |  广告位图  |  使用协议  |  隐私政策  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  RSS订阅  |  违规举报  |  蜀ICP备2021024440号