基于Verilog的FPGA步进电机控制

上传人:woxinch****an2018 文档编号:38969288 上传时间:2018-05-10 格式:DOCX 页数:5 大小:16.30KB
返回 下载 相关 举报
基于Verilog的FPGA步进电机控制_第1页
第1页 / 共5页
基于Verilog的FPGA步进电机控制_第2页
第2页 / 共5页
基于Verilog的FPGA步进电机控制_第3页
第3页 / 共5页
基于Verilog的FPGA步进电机控制_第4页
第4页 / 共5页
基于Verilog的FPGA步进电机控制_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《基于Verilog的FPGA步进电机控制》由会员分享,可在线阅读,更多相关《基于Verilog的FPGA步进电机控制(5页珍藏版)》请在金锄头文库上搜索。

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

2、大速度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=7b1111111; always(posedge clk or negedge rst)if(!rst)b

3、egincountup=4b1001)count1=countup-1;count=7b0;endif(countup=aver)countdn=aver;count=7b0;endendelse if(speed=dns)begincount1=4b1111;if(count2=0) count2=countdn;if(count2!=0) count2=count2-1;if(countdn=4b1110)count2=countdn+1;count=7b0;endif(countdn=4b1111)count=7b0;endendendelse if(speed=stop)begincountup=4b1111;countdn=aver;count1=4b1111;count=7b0;endalways(count1 or count2 or rst)if(!rst) out=4b1001;else if(count1=0)|(count2=0)beginif(speed=stop)out=out;else if(speed=ups)|(speed=dns)beginif(direct=1)out=out2:0,out3;else if(direct=0)out=out0,out3:1;endendendmodule

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 高中教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号