中自数字移动传媒

您的位置:首页 >> 产业动态 >> Verilog HDL语言的四相八拍步进西玛电机驱动

Verilog HDL语言的四相八拍步进西玛电机驱动

已有80884次阅读2015-03-24标签:
西玛西玛电机 if(!der) reg[3:0] out; case(current1) else current1 < =s7; end if(cnt < = 4000) cnt < = cnt+1'b1;//0.5MS 1MS 2MS 4MS 8MS 4000 8000 16000 32000 64000 current1 < =s4; begin out < =4'b0011; a=~a; else if(temp==3'd1) s0: else a=~a; out < =4'b1100; else end always @(posedge clk1) module step2 (clk1,a,adj);//分频module else reg[2:0] current; end begin current1 < =s2; begin current < =s7; begin current < =s0; end step2 l1 (clk,p,d);//clk系统时钟 end end s3: end begin end else end begin current1 < =s1; end endmodule begin cnt < =26'b0; end current < =s1; begin if(!der) begin begin if(!der) endmodule

主要思想,用状态机驱动步进西玛电机!!!

总体感觉,整个程序比较繁琐,看见别人实现相同的功能代码也才那么几十行,我的……呃 差距可想而知了。。。
current<=s5; end always@(current1 )//or clk0 current<=s0; temp=adj[5]+adj[4]+adj[3]+adj[2]+adj[1]+adj[0]; end output [3:0]out; if(!reset) end cnt <=26'b0; s2: endcase current1<=s7; begin s5: begin end current<=s5; current<=s4; cnt <=26'b0; begin end current1<=s4; end out<=4'b0110; begin output a; end end end end end else if(temp==3'd2) if(!der) end module step (clk,reset,out,der,d);//总体模块d[5:0]调速控制端口 用6个拨码开关表示 全1速度最慢 全0时速度最快 其中1(0)的个数能表示西玛电机速度的快慢 else if(temp==3'd0) current1<=s1; s3: reg[2:0] current1; end if(cnt <= 8000) cnt <= cnt+1'b1;//0.5MS 1MS 2MS 4MS 8MS 4000 8000 16000 32000 64000 current<=s6; begin out<=4'b0010; begin a=~a; end begin parameter s0=3'b000,s1=3'b001,s2=3'b010, input clk1; if(!der) s7: end reg[25:0] cnt; begin else step1 l2 (p,reset ,out,der);//reset停止转动 out[3:0]西玛电机控制输出端口 der正反方向控制端 begin current1<=s5; begin else begin s4: s2: end end s6:

这两天,学校做关于cpld的课程设计,本来应该用VHDL写的,但是由于我对这个比较白痴,所以就选用Verilog HDL写了,由于旁边有同学是学这个的这样,有什么问题也好解决一点。下面就先把我Verilog HDL的处女作给大家贴出来,虽然功能比较简单,但毕竟也是第一个程序嘛。。。 module step1 (clk0,reset,out,der,x);//状态机module out<=4'b0001; current<=s0; current1<=s3; begin end cnt <=26'b0; begin begin s1: else if(temp==3'd4) begin current<=s7; endcase begin begin current<=s3; else input clk ,reset,der,d; else if(temp==3'd5) current1<=s0; end begin begin begin end input clk0,reset,der,x; begin reg[2:0] temp; a=~a; current<=s4; begin end current1<=s6; out<=4'b1001; end reg a; current<=s2; a=~a; wire[5:0] adj; current1<=s3; begin if(!der) end wire p; a=~a; else begin current1<=s0; s1: begin else if(!der) out<=4'b0100; end begin else begin begin current<=s1; end begin end begin if(!der) end begin begin end if(temp==3'd6) if(cnt <= 32000) cnt <= cnt+1'b1;//0.5MS 1MS 2MS 4MS 8MS 4000 8000 16000 32000 64000 current<=s3; end end s6: reg[15:0] counter; begin cnt <=26'b0; case(current) endmodule current<=s6; begin if(cnt <= 16000) cnt <= cnt+1'b1;//0.5MS 1MS 2MS 4MS 8MS 4000 8000 16000 32000 64000 end else else if(temp==3'd3) current<=s2; begin end always@(posedge clk0 or negedge reset ) end s6=3'b110,s7=3'b111; cnt <=26'b0; input[5:0] adj; s3=3'b011,s4=3'b100,s5=3'b101, cnt <=26'b0; if(cnt <= 12000) cnt <= cnt+1'b1;//0.5MS 1MS 2MS 4MS 8MS 4000 8000 16000 32000 64000 current1<=s6; begin end s4: else a=~a; end end current1<=s5; wire[5:0] d; if(cnt <= 6000) cnt <= cnt+1'b1;//0.5MS 1MS 2MS 4MS 8MS 4000 8000 16000 32000 64000 out<=4'b1000; begin else begin begin s7: s5: end end end s0: begin output[3:0] out; if(cnt <= 10000) cnt <= cnt+1'b1;//0.5MS 1MS 2MS 4MS 8MS 4000 8000 16000 32000 64000 current1<=s2; else else 西玛西玛电机

分享到:

[ 新闻搜索 ]  [ ]  [ 告诉好友 ]  [ 打印本文 ]  [ 关闭窗口 ]  [ 返回顶部 ]

0条 [查看全部]  网友评论

移动互联

2010年,中国移动互联网用户规模达到3.03亿人2011年,中国移动互联网行业进入了更加快速发展的一年,无论是用户规模还是手机应用下载次数都有了快速的增长。在移动互联网发展的大的趋势下,中自传媒已经开始进行区别于传统互联网的运营模式探索,伴随着产业链和产业格局的变化提供创新的服务

更多>>推荐视频

工业转型升级-中国电器工业协会电力电子分会 秘书长 肖向锋

工业转型升级-中国电器工业协会

在本次2012北京国际工业自动化展上,我们将全面剖析在新...
中国高压变频器产业发展之路——走过十三年 李玉琢

中国高压变频器产业发展之路——

中国高压变频器产业发展之路走过十三年 李玉琢
从企业家角度 谈行业的未来发展——汇川技术股份有限公司

从企业家角度 谈行业的未来发展

从企业家角度 谈行业的未来发展汇川技术股份有限公司
现代能源变换的核心技术——电力电子 李崇坚

现代能源变换的核心技术——电力

中国电工技术学会常务理事---李崇坚,电力电子是先进能源...
打造专业电力电子元器件品牌 助力变频器产业发展

打造专业电力电子元器件品牌 助

联合主办单位深圳市智胜新电子有限公司领导嘉宾致辞 7月...