基于Verilog的FPGA步进电机控制.docx

上传人:牧羊曲112 文档编号:3385017 上传时间:2023-03-12 格式:DOCX 页数:3 大小:36.97KB
返回 下载 相关 举报
基于Verilog的FPGA步进电机控制.docx_第1页
第1页 / 共3页
基于Verilog的FPGA步进电机控制.docx_第2页
第2页 / 共3页
基于Verilog的FPGA步进电机控制.docx_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《基于Verilog的FPGA步进电机控制.docx》由会员分享,可在线阅读,更多相关《基于Verilog的FPGA步进电机控制.docx(3页珍藏版)》请在三一办公上搜索。

1、基于Verilog的FPGA步进电机控制基于FPGA步进电机控制: 电机为四相步进电机,单四拍工作. Speed为电机运行状态输入; Direct 为电机转动方向输入; Out 为电机控制信号输出; 程序控制电机加速减速,采用计数原理,不同计数值控制电机旋转速度,再利用一个另外计数值控制特定速度运行时间,时间到则转到下一速度,设定有最大速度值,加速到最大速度自动进入匀速过程. module motor1(speed,rst,out,direct,clk, ); /运行状态输入 input 1:0 speed; /加速 parameter ups=2b01; /减速 parameter dns=

2、2b10; /停止 parameter stop=2b11; /最大速度 parameter aver=4b1000; /电机运行方向,复位,时钟输入 input direct,rst,clk; /控制电机信号输出 output 3:0 out; reg 3:0 out; /加速速度转换计数 reg 3:0count1; /减速速度转换计数 reg 3:0count2; /加速速度数字代表 reg 3:0countup; /减速速度数字代表 reg 3:0countdn; /特定速度运行时间计数 reg 6:0count; /特定速度运行时间到标志 parameter countmax=7b1

3、111111; always(posedge clk or negedge rst) if(!rst) begin countup=4b1111; count1=4b1111; count2=4b1000; countdn=4b1000; count=7b0; end else if(speed=ups)|(speed=dns) begin count=count+1; if(speed=ups) begin if(count1=0)count1=countup; if(count1!=0) count1=4b1001)&(count=countmax) begin countup=count

4、up-1; count1=countup-1; count=7b0; end if(countup=aver)&(count=countmax) begin count1=aver; countdn=aver; count=7b0; end end else if(speed=dns) begin count1=4b1111; if(count2=0) count2=countdn; if(count2!=0) count2=count2-1; if(countdn=4b1110)&(count=countmax) begin countdn=countdn+1; count2=countdn

5、+1; count=7b0; end if(countdn=4b1111)&(count=countmax) begin count2=4b1111; count=7b0; end end end else if(speed=stop) begin countup=4b1111; countdn=aver; count1=4b1111; count=7b0; end always(count1 or count2 or rst) if(!rst) out=4b1001; else if(count1=0)|(count2=0) begin if(speed=stop) out=out; else if(speed=ups)|(speed=dns) begin if(direct=1) out=out2:0,out3; else if(direct=0) out=out0,out3:1; end end endmodule

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号